GeezerVison is showing github.com — fix(web): paste guard also catches a new terminal attach stream · pingdotgg/t3code@c74644d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/ThreadTerminalDrawer.test.ts +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import { | 11 | 11 | shouldHandleTerminalExit, | 12 | 12 | synchronizeTerminalOutput, | 13 | 13 | synchronizeTerminalSession, | | 14 | + terminalInputLifecycle, | 14 | 15 | } from "./ThreadTerminalDrawer"; | 15 | 16 |
| 16 | 17 | describe("terminal selection actions", () => { | @@ -65,6 +66,9 @@ it("retains visible output and selection until a replacement subscription receiv | 65 | 66 | type: "snapshot", | 66 | 67 | snapshot: { ...snapshot, history: "host output\nobserved output" }, | 67 | 68 | }); | | 69 | + // Each attach stream restarts lifecycleVersion, so a pending paste must also see the stream change. | | 70 | + expect(observed.lifecycleVersion).toBe(attached.lifecycleVersion); | | 71 | + expect(terminalInputLifecycle(observed)).not.toBe(terminalInputLifecycle(attached)); | 68 | 72 | const observedCursor = synchronizeTerminalOutput(terminal, observed, cursor); | 69 | 73 | expect(terminal.resetAndWrite).toHaveBeenLastCalledWith("host output\nobserved output"); | 70 | 74 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/ThreadTerminalDrawer.tsx +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -468,6 +468,13 @@ function writableSessionGeneration( | 468 | 468 | : null; | 469 | 469 | } | 470 | 470 |
| | 471 | +/** Changes on a restart and on a new attach stream, which restarts lifecycleVersion at zero. */ | | 472 | +export function terminalInputLifecycle( | | 473 | + session: Pick<TerminalSessionState, "lifecycleVersion" | "output">, | | 474 | +): string { | | 475 | + return `${session.output.generation}:${session.lifecycleVersion}`; | | 476 | +} | | 477 | + | 471 | 478 | export function shouldHandleTerminalExit( | 472 | 479 | current: TerminalSessionState["status"], | 473 | 480 | synchronized: TerminalSessionState["status"], | @@ -770,7 +777,7 @@ function TerminalSessionViewport({ | 770 | 777 | ? { text, ...(fallback === undefined ? {} : { fallback }) } | 771 | 778 | : null, | 772 | 779 | ), | 773 | | - inputLifecycle: () => readTerminalSession().lifecycleVersion, | | 780 | + inputLifecycle: () => terminalInputLifecycle(readTerminalSession()), | 774 | 781 | // Surface listeners start before WASM loading finishes and the terminal handler exists. | 775 | 782 | onContextMenu: (event) => { | 776 | 783 | if (terminalRef.current) void showTerminalContextMenu(event); | |
|