Repository navigation
fix(settings): keep agent environment values with spaces when the field loses focus - #31772
Merged
Merged
Conversation
Values with spaces were shown unquoted and re-split on blur, cutting A="two words" to A=two.
The localization audit reads an `error` property as UI copy; these are codes.
AmoabaKelvin
marked this pull request as ready for review
October 22, 2026 22:00
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 22 minutes. View limit details
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
The Environment box in Settings → Agents showed
A="two words"asA=two words. Clicking into the box and back out read that text back and savedA=two, so part of a saved value was lost without any edit. The box now shows quotes where a value needs them, reads them back the same way, and does not save at all when you only click in and out.What Changed
stringifyAgentDefaultEnvDraftquotes a name or value when it is empty or contains whitespace or a quote (A='two words' B=keep). Plain values stay bare.parseAgentDefaultEnvDraftnow uses the shared tokenizer that custom commands already use (tokenizeCustomCommandTemplate,'literal'backslash mode), in place of its own whitespace splitter. Quotes group words, and backslashes stay literal, soTOOL=C:\tools\bintyped without quotes still saves as typed.Inputalready stylesaria-invalid.Why
The owner of the bug is the format/parse pair in
agent-default-env-draft.ts. The formatter dropped quoting that the parser never understood, so the two were not inverses and every blur re-saved a cut value. With one grammar on both sides, any saved record survives format → parse unchanged. Skipping unchanged blurs also stops a settings write on every click through the field.I chose literal backslashes over POSIX escapes because unquoted Windows paths are the common case in this field, and the parser already accepted them that way. The quoting reuses
quotePosixShellDoubleQuotedApostrophe(no backslashes needed). Only the settings text changes; the storedagentDefaultEnvrecord and the wire format stay the same, so mixed client/server versions and remote hosts are unaffected. The remote host editor uses one field per variable and mobile never edits this text.Linked Issue
No GitHub issue. Linear: STA-11496 (found in review of #31315).
Visual Proof
Saved env
{"A":"two words","B":"keep"}. Click into Environment, click out without editing. The caption shows the saved record read from the settings store.BEFORE (main): saved value becomes
{"A":"two","B":"keep"}.agent-env-before.mp4
AFTER (this branch): the field shows
A='two words' B=keepand the saved value is unchanged.agent-env-after.mp4
AFTER, unclosed quote: not saved, inline error.
Testing
agent-default-env-draft.test.ts: format → parse returns the same record for spaces, apostrophes, double quotes, both quotes,=, empty strings, tabs and Windows paths. It fails on main. Also covers bare backslashes and the unclosed-quote error.Hidden dev builds of main and this branch on macOS, driven over CDP with real clicks, as in the videos.
pnpm run check:code-quality:changed,pnpm run check:react-doctor:changed, i18n tests,verify:localization-catalogs,verify:localization-extraction,verify:localization-coverage.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Agent skill upstream boundary
Notes
Brennan's #31315 also edits
AgentDefaultEnvInput. The overlap here is the error-state rename and the skip-unchanged guard, so the conflict should be small.