Cortex icon indicating copy to clipboard operation
Cortex copied to clipboard

Medium: Settings navigation guard ignores unsaved Permanent Memory edits and removals

Open dovvnloading opened this issue 3 weeks ago • 1 comments

Severity

Medium — unsaved edits/removals in the Permanent Memory editor are silently discarded when navigating away from Settings, even though the Settings page has a “Save your changes?” navigation guard. The guard only knows about the parent settings form, not the memory editor's separate draft.

Evidence

Deterministic reproduction

  1. In Settings → Memory, ensure one saved fact exists.
  2. Edit that fact or mark it for removal, without clicking Save changes. The local editor correctly displays “Unsaved changes.”
  3. Click Close settings, New thread, or a chat in the sidebar.
  4. Actual: if no separate settings field was changed, SettingsPanel.dirty remains false, so navigation proceeds without the save/discard/keep-editing dialog. MemoryPanel unmounts and the unsaved memory edit is lost.
  5. Expected: any unsaved memory draft should block/confirm route navigation and window reload just like unsaved settings fields, or preserve drafts across the route transition.

Fix/tests

Lift memory dirty state into SettingsPanel (e.g. onDirtyChange and a scoped draft manager) and include it in both the navigation and beforeunload guards. A Save and close must persist the changed memories, not only settings, and handle 409 conflicts correctly; Discard must explicitly discard both drafts. Add tests for edited and removed memory rows, each navigation entry point and reload, plus a failed/409 memory save.

Reviewed revision: e824fe2dcba0d1be127c9fff165f776186dc37e9. Deterministic state ownership and navigation-guard mismatch; UI test not executed. Distinct from #424, which covers native history bypassing a guard even when the parent settings state is dirty.

dovvnloading avatar Nov 09 '26 15:11 dovvnloading

Additional immediate reproduction: changing Settings tabs also discards the unsaved memory draft, without navigating away from Settings. SettingsPanel.tsx:433–439 renders MemoryPanel only when section === "memory"; clicking “General,” “AI Model,” etc. unmounts it. MemoryPanel.tsx:34–38 initializes local draft state from the saved memos prop on remount. Repro: edit an existing memory without Save changes → click AI Model → click Memory again → the edit is gone. This is stronger than the route-guard scenario because it occurs within a single Settings session; it should be covered by the same lifted/persisted draft state solution and regression tests.

dovvnloading avatar Nov 09 '26 15:11 dovvnloading