From e1eedfbb7589d0a7e477e1b590e11b0a153906ca Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 19 Oct 2026 00:30:03 +0000 Subject: [PATCH] Tags: saving an edit no longer redraws the step, so typing keeps its focus and place Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01MpnF7GwNGMbngU11wjym7P --- app/ui/features/training/state.js | 3 ++- app/ui/features/training/training.test.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/ui/features/training/state.js b/app/ui/features/training/state.js index e6d5a625..a6f50ae1 100644 --- a/app/ui/features/training/state.js +++ b/app/ui/features/training/state.js @@ -33,10 +33,11 @@ export function makeSession(api) { if (!queued) return; const { name, doc } = queued; queued = null; + const was = s.error; s.saving = true; try { await api.trainSaveSet(name, doc); s.error = ""; } catch (err) { s.error = `Could not save the set: ${err.message}`; } s.saving = false; - emit(); + if (s.error !== was) emit(); // a saved edit changes nothing on screen; redrawing would take the cursor out of the box being typed in } s.flush = async () => { clearTimeout(timer); timer = null; await push(); }; /** Change the open set in place and save it soon. Does not redraw: the controls on screen already show the edit. */ diff --git a/app/ui/features/training/training.test.js b/app/ui/features/training/training.test.js index 95011c3c..6650adb0 100644 --- a/app/ui/features/training/training.test.js +++ b/app/ui/features/training/training.test.js @@ -104,6 +104,7 @@ test("Tags step: a text box per item under its picture; typing saves the set and await wait(700); const saved = f.calls.filter((c) => c[0] === "save").pop(); assert.equal(saved[2].items[0].caption, "A cat\nsits, calmly"); + assert.ok(box.isConnected && document.querySelector(".cx-captioned textarea") === box, "saving does not redraw the step: the box being typed in stays"); off(); });