GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): paste guard also catches a new terminal attach stream · pingdotgg/t3code@c74644d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components
    • ThreadTerminalDrawer.test.ts
    • ThreadTerminalDrawer.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/ThreadTerminalDrawer.test.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ThreadTerminalDrawer.test.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
shouldHandleTerminalExit,
1212
synchronizeTerminalOutput,
1313
synchronizeTerminalSession,
14+
terminalInputLifecycle,
1415
} from "./ThreadTerminalDrawer";
1516

1617
describe("terminal selection actions", () => {
@@ -65,6 +66,9 @@ it("retains visible output and selection until a replacement subscription receiv
6566
type: "snapshot",
6667
snapshot: { ...snapshot, history: "host output\nobserved output" },
6768
});
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));
6872
const observedCursor = synchronizeTerminalOutput(terminal, observed, cursor);
6973
expect(terminal.resetAndWrite).toHaveBeenLastCalledWith("host output\nobserved output");
7074

Collapse file

‎apps/web/src/components/ThreadTerminalDrawer.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/ThreadTerminalDrawer.tsx
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ function writableSessionGeneration(
468468
: null;
469469
}
470470

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+
471478
export function shouldHandleTerminalExit(
472479
current: TerminalSessionState["status"],
473480
synchronized: TerminalSessionState["status"],
@@ -770,7 +777,7 @@ function TerminalSessionViewport({
770777
? { text, ...(fallback === undefined ? {} : { fallback }) }
771778
: null,
772779
),
773-
inputLifecycle: () => readTerminalSession().lifecycleVersion,
780+
inputLifecycle: () => terminalInputLifecycle(readTerminalSession()),
774781
// Surface listeners start before WASM loading finishes and the terminal handler exists.
775782
onContextMenu: (event) => {
776783
if (terminalRef.current) void showTerminalContextMenu(event);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.