Repository navigation
fix(settings): ask before leaving a page with unsaved changes - #6683
Conversation
Only Connections asked before dropping an edit, and only on Back. The
General, MCP server and plugin editors dropped typed changes on Back,
and a section switch or Close either dropped them (MCP) or kept them
without saying so.
Settings pages may now hold the dialog's exits behind a prompt: Back,
Escape, a section switch in the rail and Close each ask once ("Keep
editing" / "Discard changes") while a page has unsaved changes, and
leave only after Discard. General, MCP servers, Plugins, Network and
Connections share one prompt state and the existing confirmation copy.
Footer Cancel and Discard buttons still drop a draft without asking,
and an untouched missing global AGENTS.md does not count as a change.
Restore the DESIGN.md rule that apache#6670 held back until this existed.
Generated-by: Claude Code
There was a problem hiding this comment.
I reviewed all 20 changed files at 555ea55. The change holds a requested navigation action while an edited page asks whether to keep editing or discard; confirmation rechecks the current page, target availability, busy state and disposal before leaving. General, Connections, MCP, Network and plugin-field editors share this behavior, while explicit Cancel remains an immediate discard. I found no confirmed P0–P2 issue in this revision.
I ran the nine settings-discard tests and 16 connection-login tests unchanged: all 25 passed. I also exercised the actual ModelSettings initialization/navigation handlers together with the actual discard controller in 11 additional controlled checks covering clean navigation, Keep, Discard, Close, Escape, replacement of the pending exit, removed targets, changed pages, busy state, disposal and stale callbacks. Replacing those navigation handlers with the previous base version makes the new assertions fail. These checks use controlled NSH/contribution adapters and omit the JSX render body; they are not native UI acceptance tests.
The current-head tooling job 128264273057 also passes (266 passed, one skipped). Its logged checkout 3074f3c merges this revision into current rust-preview c0eb7b3. Desktop build job 128264273051 succeeds. CI 42326859362 has completed with failure. Job 128269415526 failed: the client request-custody test withheld_opening_cancellation_does_not_substitute_for_the_original_anchor_ack times out after 30.016 s (230 other tests passed). The same case passes in 0.373 s on current-base job 128267752070, and the client source directory and manifest are identical between that base and this merged tree. I have not established the cause or attributed it to this settings change; this is not an all-green CI result. My actual merge into c0eb7b3 has no textual conflicts; I have not built that merge locally.
The protection is limited to navigation inside the settings panel. App-level shortcuts or opening a conversation can still close the panel outside this guard, as the PR documents; the Skills Add field is also outside the edited forms covered here. I viewed the five author-provided before/after captures, but did not produce those captures or independently test native terminal/GUI keyboard behavior, macOS/Windows interactions, or a real configuration write/restart. Those limits remain relevant to end-to-end acceptance.
Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.
Summary
Leaving a settings page with unsaved changes now asks once: "Discard unsaved changes?" with Keep editing and Discard changes. The page leaves only after Discard; a page with no changes leaves at once.
SettingsPageNavigationgains an optionalleave(next).ModelSettings.tsxroutes rail switches and Close through it, and checks the request again when the held exit finally runs.createSettingsDiscard, and one confirmation,SettingsDiscard, built on the existingSettingsConfirm. The copy is the existing Connections strings, which already exist in en, zh-CN and zh-TW, so no new strings.AGENTS.mdstill enables Save, but leaving it does not ask.DESIGN.mdrule "Leaving with unsaved changes asks first.", which feat(workbench): redesign the settings dialog on one row-and-group system #6670 held back until this existed.Fixes #6672
Behavior change
Before this change, General, Network and Connections kept a dirty draft without saying so across a rail switch or Close, and the MCP editor dropped it. All of them now ask; Discard drops the draft and Keep editing stays on the page.
Two cases are out of scope:
App.tsx; I can follow up if wanted.Screenshots
These are the terminal workbench, rendered from cell captures of the real-host test. The steps are the same on both sides: add an MCP server, type a name, click Skills in the rail, return to MCP servers, then click Close.
rust-preview9c67d19)Verification
node --test products/maka/workbench/tests/*.test.mjs: 132 passed.settings-discard.test.mjs(9 tests) covers General (including the missingAGENTS.mdcase), MCP, Plugins and Network: a clean leave doesn't ask; Back andleaveask after an edit; Keep editing keeps the draft; Discard drops it and only then runs the exit; Cancel doesn't ask.connection-login.test.mjsadds a Connectionsleavetest.just typecheckpasses.node scripts/ci.mjs check formatpasses.cargo nextest run --locked -p maka-cli --test integration -E 'test(terminal::configuration_management::)'passes. The test now switches sections with an MCP draft and chooses Keep editing; the later save assertions confirm the draft survived. Near the end it closes settings with a draft and chooses Discard changes.desktop_model_settings_keeps_successful_sign_in_and_retries_modelsanddesktop_provider_picker_searches_real_catalog_and_preserves_selectionpass (--features desktop-tests); they cover the editedmodel_settings_preview.tsx.Not run: the full
just check, the Windows suites, and a manual pass in the GPUI desktop window.AI use
Select exactly one:
Tool(s) and scope: Claude Code mapped the settings exits, implemented the change and its tests, ran the checks above and produced the screenshots. The commit carries
Generated-by: Claude Code.Checklist
Does this PR entail a change in behavior?