Skip to content

fix(settings): ask before leaving a page with unsaved changes - #6683

Merged
M4n5ter merged 1 commit into
apache:rust-previewfrom
YongGoose:fix/settings-unsaved-changes
Nov 9, 2026
Merged

M4n5ter merged 1 commit into
apache:rust-previewfrom
YongGoose:fix/settings-unsaved-changes

Conversation

@YongGoose

@YongGoose YongGoose commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

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.

  • Exits: Back, Escape, a section switch in the rail and the Close button. SettingsPageNavigation gains an optional leave(next). ModelSettings.tsx routes rail switches and Close through it, and checks the request again when the held exit finally runs.
  • Pages:
    • General: personalization, Bash tool shell, global instructions, compaction prompt and message predictions.
    • The MCP server editor and a plugin setting editor.
    • Network.
    • Connections, which already asked on Back and now also asks on a rail switch or Close.
  • Shared parts: the pages share one small prompt state, createSettingsDiscard, and one confirmation, SettingsDiscard, built on the existing SettingsConfirm. The copy is the existing Connections strings, which already exist in en, zh-CN and zh-TW, so no new strings.
  • Unchanged: the footer Cancel and Discard buttons still drop a draft without asking, since they already are the explicit discard. An untouched missing global AGENTS.md still enables Save, but leaving it does not ask.
  • Restores the DESIGN.md rule "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:

  • Closes from outside the dialog, such as opening a conversation or a global shortcut, still close settings without asking. Guarding them needs a settings handle in App.tsx; I can follow up if wanted.
  • The Skills Add skills source field. It is an install flow without Save, and the issue does not list it.

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.

Step Before (rust-preview 9c67d19) After (this PR)
Click Skills in the rail with an unsaved MCP server before: Skills opens at once after: the prompt asks first
Return to MCP servers (after: Keep editing) before: the draft is gone after: the draft is kept
Click Close with the draft Settings close and the draft is lost after: the prompt asks first

Verification

  • node --test products/maka/workbench/tests/*.test.mjs: 132 passed.
    • New settings-discard.test.mjs (9 tests) covers General (including the missing AGENTS.md case), MCP, Plugins and Network: a clean leave doesn't ask; Back and leave ask after an edit; Keep editing keeps the draft; Discard drops it and only then runs the exit; Cancel doesn't ask.
    • connection-login.test.mjs adds a Connections leave test.
  • just typecheck passes.
  • node scripts/ci.mjs check format passes.
  • 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_models and desktop_provider_picker_searches_real_catalog_and_preserves_selection pass (--features desktop-tests); they cover the edited model_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:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

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

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

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

@Astro-Han Astro-Han left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Nov 7, 2026
@M4n5ter
M4n5ter merged commit 75fe3d0 into apache:rust-preview Nov 9, 2026
34 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants