fix: stop resetting an emptied custom agent id mid-typing - #362
Conversation
The per-keystroke onChange regenerated the default id and wrote it back into the field the moment it went empty, so retyping an id required select-all. Empty is now a transient state: nothing commits while empty, and blur restores the last valid id if the field is abandoned.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughCustom agent ID editing now treats empty input as a transient state, preserving the committed ID until a non-empty value is entered and restoring it when the field loses focus. ChangesCustom agent ID editing
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Retyping a custom agent's ID was nearly impossible: the moment the field went empty (deleting the last character), the per-keystroke
onChangeregenerated the default id (custom-agent) and wrote it straight back into the input. Deletingcustom-agentcharacter by character snapped back tocustom-agenton the last backspace — the only workaround was select-all-and-overwrite.The repair logic itself is legitimate (ids are keys — section open-state,
defaultAgentIdretargeting, and every keystroke persists viaflushSettings()— so settings must never hold an empty id), but it ran at the wrong time. The same field already established the right timing for exactly this reason: the preset-collision check validates on blur, with a comment noting that per-keystroke validation misfires because onChange commits every intermediate value.This PR moves the empty handling to the same model:
The Display name field is deliberately left unchanged: its blank-means-fallback model suits a derived cosmetic value, while an identity key that is referenced elsewhere (fence
agent:pins, saved sessions, per-agent last-used maps) should conservatively restore rather than silently swap to a generated default.Related issue
None (reported during manual testing).
Type of change
Checklist
npm run lintpasses ("Use sentence case for UI text" errors are acceptable for brand names)npm run buildpassesTesting environment
Screenshots
N/A
Summary by CodeRabbit