The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(dashboard): avoid duplicate IME fallback input
Denis H3d9fdb2e2b07
diff --git a/web/src/lib/pty-composition.test.ts b/web/src/lib/pty-composition.test.tsindex 45fb275b906..d60761857e0 100644--- a/web/src/lib/pty-composition.test.ts+++ b/web/src/lib/pty-composition.test.ts@@ -28,7 +28,7 @@ describe("createPtyCompositionForwarder", () => {expect(send).not.toHaveBeenCalled();});- it("keeps the fallback pending when xterm emits unrelated input", () => {+ it("prefers xterm input in the grace window over the fallback", () => {vi.useFakeTimers();const send = vi.fn();const forwarder = createPtyCompositionForwarder(send);@@ -37,7 +37,21 @@ describe("createPtyCompositionForwarder", () => {forwarder.noteTerminalData("x");vi.runAllTimers();- expect(send).toHaveBeenCalledExactlyOnceWith("ä");+ expect(send).not.toHaveBeenCalled();+ });++ it("forwards a second composition after the first fallback completes", () => {+ vi.useFakeTimers();+ const send = vi.fn();+ const forwarder = createPtyCompositionForwarder(send);++ forwarder.onCompositionEnd("ä");+ vi.runAllTimers();+ forwarder.onCompositionEnd("ö");+ vi.runAllTimers();++ expect(send).toHaveBeenNthCalledWith(1, "ä");+ expect(send).toHaveBeenNthCalledWith(2, "ö");});it("supersedes an earlier composition and cancels it on disposal", () => {diff --git a/web/src/lib/pty-composition.ts b/web/src/lib/pty-composition.tsindex 329cb4c173e..7944b8cb556 100644--- a/web/src/lib/pty-composition.ts+++ b/web/src/lib/pty-composition.ts@@ -25,12 +25,13 @@ export function createPtyCompositionForwarder(send: (data: string) => void) {const committed = pending;clearPending();if (committed) send(committed);- }, 0);+ }, 16);},- noteTerminalData(data: string) {- if (pending && data.startsWith(pending)) {- clearPending();- }+ noteTerminalData(_data: string) {+ // Any xterm input in the short grace window is its own composition+ // delivery (possibly chunked or normalization-different), so prefer it+ // over the fallback to avoid duplicate text.+ if (pending) clearPending();},dispose: clearPending,};diff --git a/web/src/pages/ChatPage.tsx b/web/src/pages/ChatPage.tsxindex b53f4086d62..a67525234a8 100644--- a/web/src/pages/ChatPage.tsx+++ b/web/src/pages/ChatPage.tsx@@ -1313,7 +1313,10 @@ export default function ChatPage({ isActive = true }: { isActive?: boolean }) {// The deferred composition fallback is already committed text, so it// must not consume the mobile replacement window intended for xterm's// normal onData path.- sendComposedText = (data) => forwardPtyData(data, false);+ sendComposedText = (data) => {+ forwardPtyData(data, false);+ mobileReplacementInputUntilRef.current = 0;+ };onDataDisposable = term.onData((data) => {compositionForwarder.noteTerminalData(data);forwardPtyData(data);