The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(dashboard): place the deactivation ref reset after the callbacks that also write those refs
teknium187cc4de43027
diff --git a/web/src/lib/pty-mobile-input.test.ts b/web/src/lib/pty-mobile-input.test.tsindex 5245a2e3186..a6c7ba22e86 100644--- a/web/src/lib/pty-mobile-input.test.ts+++ b/web/src/lib/pty-mobile-input.test.ts@@ -70,6 +70,26 @@ describe("normalizePtyMobileInput", () => {});});+describe("normalizePtyMobileInput with a stale tracked line", () => {+ it("emits deletes sized to the stale tracker unless the tracker was reset", () => {+ // #106403: the tracked line survives a dashboard tab switch while the+ // TUI composer moves on. A re-emitted word inside the replacement+ // window is then rewritten against the stale snapshot — the DELETE+ // count is the tracker's length, not the composer's, so the composer+ // ends up with repeated characters ("hel" + 3×DEL + "hello" over a+ // composer holding "hello" leaves "hehello"). Clearing the tracker on+ // deactivation makes the same input pass through untouched.+ const stale = normalizePtyMobileInput("hello", "hel", true);+ expect(stale.normalized).toBe(true);+ expect(stale.data).toBe("\x7f".repeat("hel".length) + "hello");++ const reset = normalizePtyMobileInput("hello", "", true);+ expect(reset.normalized).toBe(false);+ expect(reset.data).toBe("hello");+ expect(reset.nextLine).toBe("hello");+ });+});+describe("updatePtyInputLine", () => {it("tracks printable text, delete, and submit", () => {expect(updatePtyInputLine("", "abc")).toBe("abc");diff --git a/web/src/pages/ChatPage.tsx b/web/src/pages/ChatPage.tsxindex a152d9c3319..3d3c89185a4 100644--- a/web/src/pages/ChatPage.tsx+++ b/web/src/pages/ChatPage.tsx@@ -205,16 +205,6 @@ export default function ChatPage({ isActive = true }: { isActive?: boolean }) {useEffect(() => {setHasActivated((prev) => latchChatActivation(prev, isActive));}, [isActive]);-- // Clear mobile-input tracking refs when the tab is hidden so stale state- // from a previous /chat visit doesn't cause the mobile-replacement logic- // to misfire on the next activation (#106403: repeated last character).- useEffect(() => {- if (!isActive) {- ptyInputLineRef.current = "";- mobileReplacementInputUntilRef.current = 0;- }- }, [isActive]);const [searchParams, setSearchParams] = useSearchParams();// Lazy-init: the missing-token check happens at construction so the effect// body doesn't have to setState (React 19's set-state-in-effect rule).@@ -307,6 +297,15 @@ export default function ChatPage({ isActive = true }: { isActive?: boolean }) {setPtyState("connecting");setReconnectNonce((n) => n + 1);}, [clearReconnectTimer, searchParams, setSearchParams]);+ // Clear mobile-input tracking refs when the tab is hidden so stale state+ // from a previous /chat visit doesn't cause the mobile-replacement logic+ // to misfire on the next activation (#106403: repeated last character).+ useEffect(() => {+ if (!isActive) {+ ptyInputLineRef.current = "";+ mobileReplacementInputUntilRef.current = 0;+ }+ }, [isActive]);// Raw state for the mobile side-sheet + a derived value that force-// closes whenever the chat tab isn't active. The *derived* value is// what side-effects (body-scroll lock, keydown listener, portal render)