Repository navigation
Description
Summary
An editor built on useFormEditor keeps a stale baseline after Discard loads a change made in another session. From then on, any refetch of the same data flags the person's next draft as changed elsewhere, even when nothing changed. Seen live on Settings › Governance › Models › Standard agent: after the person's own header switch saved, the editor said "These settings changed in another session. Discard your draft to load them, or save to replace them." The alert invites them to throw away a draft for no reason, and it stays until they discard or save.
Source and environment
- Source:
origin/mainat1842d09f4(2026-10-01), in a detached worktree with no local changes. - Stack: an isolated local stack started with
bun scripts/dev.tsandTALE_DEV_SKIP_DOCKER=1 TALE_E2E=1. Vite runs onlocalhost:3581, the backend on127.0.0.1:3586, and the occurrence has its own PostgreSQL cluster on127.0.0.1:55358. - Browser: headless Chromium 1208 through the repository's
playwright-core1.58.2, at 1280×900,en-US. - Data: a synthetic organization and its owner. The "other session" is that owner's own API write,
POST /api/app/governance/policies/standard_agent.
Reproduction
- Open Settings › Governance › Models with the standard agent on, and type a draft in its Instructions.
- From another session, save different instructions. Here:
POST /api/app/governance/policies/standard_agentwith{config: {enabled: true, instructions: "Remote k2"}}. The alert "These settings changed in another session…" appears, which is correct. - Select Discard in the settings header. The field now shows
Remote k2and the alert is gone, which is correct. - Type a new draft in Instructions.
- Switch Provide a standard agent off. This is the page's own instant save. Then switch it on again.
Observed
After step 5, the alert "These settings changed in another session. Discard your draft to load them, or save to replace them." is back, and it stays after switching on again. Nothing changed elsewhere: the only write was this page's own switch, which keeps the saved instructions (Remote k2).
Expected
No alert. The switch's own save changed nothing the form holds.
Control
Same page, no earlier remote update: type a draft, switch off, switch on. No alert, and the draft is kept. The alert after step 2 is also correct. Only the alert after a Discard that loaded a remote change is false.
Root cause
packages/ui/src/components/editor/use-form-editor.ts:
- The effect at
:145–163skips a refetch whenstructuralEqual(lastDataRef.current, data). Otherwise it flagshasRemoteUpdateif the form is dirty, or resets the form and adoptsdataaslastDataRefif not. - When a remote change arrives while the form is dirty, it only flags.
lastDataRefkeeps the old baseline. reset()(:256–262, what Discard calls) doesform.reset(dataRef.current)and clears the flag, but never moveslastDataRefto the data it just loaded.- The next refetch with the same values, here the governance policy re-read after the switch's write, is therefore compared against the stale baseline. It differs, the new draft makes the form dirty, and the editor raises
hasRemoteUpdateagain.
useFormEditor is the shared editor hook (@tale/ui/editor). Every editor that renders hasRemoteUpdate can show this false alert after a Discard that loaded a remote change. Any later refetch can trigger it: an own instant-save beside the form, a live-update hint, or a refetch on focus.
Acceptance checks
- After Discard loads remote data, a refetch that returns the same data doesn't flag a remote update while the person types a new draft. This is the reproduction above.
- A real change from another session after that Discard still flags.
- A unit test in
packages/uicovers it: remote change while dirty →reset()→ new edit → samedataagain →hasRemoteUpdate === false.
Retained evidence
Evidence is retained locally under /agent/workspace/.tale358/r20261001T1415/, and attached as a tarball to Tale task TALE-358:
evidence/p8-false-remote.log: the case (K2) and the control (K1);evidence/p6-editor.log(E5–E6): the first sighting;evidence/p6/K2-false-alert.png;scripts/p8-false-remote.ts: the probe.
Limits
- Driven on the standard agent editor only. The other
useFormEditoreditors share the code path by reading. - Whether typing during the refetch that follows a successful Save can raise the same false alert wasn't staged.
- Local stack only; production wasn't touched.
Activity
fix(ui): move the form editor's remote baseline on discard and save