@devries-cameron20 / t3code Mirror · read-only / commits / 6615d3d70b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 24, 09:00 UTC

refactor(web): test live Ghostty link resolution directly (#10041)

Julius Marminge committed Sep 5, 2026 at 01:29 UTC 6615d3d70ba399c4b274d17f19487d94afac17ed
2 files changed +15 -27
apps/web/src/terminal/ghostty/surface.test.ts
+15 -15
@@ -23,8 +23,6 @@ import {
23 terminalGridCellAt,
24 terminalScrollbarGeometry,
25 terminalScrollbarOffsetAtPointer,
26 - terminalLinkAtColumn,
27 - terminalLinkAtPosition,
26 terminalLinkAtPositionWithRange,
27 terminalContentOriginY,
28 terminalFontFamily,
@@ -433,7 +431,7 @@ describe("shouldBlinkTerminalCursor", () => {
431 });
432 });
433
436 -describe("terminalLinkAtColumn", () => {
434 +describe("terminalLinkAtPositionWithRange", () => {
435 it("maps terminal cells to UTF-16 offsets after a wide emoji", () => {
436 const cells = [
437 cell("🙂"),
@@ -450,9 +448,11 @@ describe("terminalLinkAtColumn", () => {
448 wrapsToNext: false,
449 };
450
453 - expect(terminalLinkAtColumn(row, 2)).toBe("https://t3.codes");
454 - expect(terminalLinkAtColumn(row, cells.length - 1)).toBe("https://t3.codes");
455 - expect(terminalLinkAtColumn(row, 0)).toBeNull();
451 + expect(terminalLinkAtPositionWithRange([row], 0, 2)?.text).toBe("https://t3.codes");
452 + expect(terminalLinkAtPositionWithRange([row], 0, cells.length - 1)?.text).toBe(
453 + "https://t3.codes",
454 + );
455 + expect(terminalLinkAtPositionWithRange([row], 0, 0)).toBeNull();
456 expect(terminalLinkAtPositionWithRange([row], 0, 8)?.range).toEqual({
457 start: { x: 2, y: 0 },
458 end: { x: cells.length - 1, y: 0 },
@@ -473,10 +473,10 @@ describe("terminalLinkAtColumn", () => {
473 row("C:\\repo\\file.ts", false),
474 ];
475
476 - expect(terminalLinkAtPosition(rows, 0, 8)).toBe("https://example.com/reference");
477 - expect(terminalLinkAtPosition(rows, 1, 4)).toBe("https://example.com/reference");
478 - expect(terminalLinkAtPosition(rows, 2, 2)).toBe("~/project/file");
479 - expect(terminalLinkAtPosition(rows, 3, 4)).toBe("C:\\repo\\file.ts");
476 + expect(terminalLinkAtPositionWithRange(rows, 0, 8)?.text).toBe("https://example.com/reference");
477 + expect(terminalLinkAtPositionWithRange(rows, 1, 4)?.text).toBe("https://example.com/reference");
478 + expect(terminalLinkAtPositionWithRange(rows, 2, 2)?.text).toBe("~/project/file");
479 + expect(terminalLinkAtPositionWithRange(rows, 3, 4)?.text).toBe("C:\\repo\\file.ts");
480 expect(terminalLinkAtPositionWithRange(rows, 1, 4)).toEqual({
481 text: "https://example.com/reference",
482 range: {
@@ -495,13 +495,13 @@ describe("terminalLinkAtColumn", () => {
495 });
496 // The head of the wrapped line scrolled above the viewport.
497 const headCut = [row("ple.com/missing", true), row("head", true)];
498 - expect(terminalLinkAtPosition(headCut, 0, 4)).toBeNull();
498 + expect(terminalLinkAtPositionWithRange(headCut, 0, 4)).toBeNull();
499 // The bottom row soft-wraps on below the viewport.
500 const tailCut = [row("https://t3.codes", false, true)];
501 - expect(terminalLinkAtPosition(tailCut, 0, 8)).toBeNull();
501 + expect(terminalLinkAtPositionWithRange(tailCut, 0, 8)).toBeNull();
502 // A partial bottom row is provably complete and still resolves.
503 const complete = [row("https://t3.codes", false), row("", false)];
504 - expect(terminalLinkAtPosition(complete, 0, 8)).toBe("https://t3.codes");
504 + expect(terminalLinkAtPositionWithRange(complete, 0, 8)?.text).toBe("https://t3.codes");
505 // A wide grapheme earlier in the row must not break truncation detection:
506 // the soft-wrap flag decides, not string-length-versus-cell-count.
507 const wideFull: GhosttyRow = {
@@ -514,7 +514,7 @@ describe("terminalLinkAtColumn", () => {
514 isWrapContinuation: false,
515 wrapsToNext: true,
516 };
517 - expect(terminalLinkAtPosition([wideFull], 0, 8)).toBeNull();
517 + expect(terminalLinkAtPositionWithRange([wideFull], 0, 8)).toBeNull();
518 // Unwritten trailing cells prove the bottom row is complete.
519 const unwrittenTail: GhosttyRow = {
520 cells: [
@@ -526,7 +526,7 @@ describe("terminalLinkAtColumn", () => {
526 isWrapContinuation: false,
527 wrapsToNext: false,
528 };
529 - expect(terminalLinkAtPosition([unwrittenTail], 0, 8)).toBe("https://t3.codes");
529 + expect(terminalLinkAtPositionWithRange([unwrittenTail], 0, 8)?.text).toBe("https://t3.codes");
530 });
531 });
532
apps/web/src/terminal/ghostty/surface.ts
-12
@@ -244,14 +244,6 @@ function terminalColumnOffset(row: GhosttySnapshot["rowData"][number], column: n
244 return offset;
245 }
246
247 -export function terminalLinkAtPosition(
248 - rows: GhosttySnapshot["rowData"],
249 - rowIndex: number,
250 - column: number,
251 -): string | null {
252 - return terminalLinkAtPositionWithRange(rows, rowIndex, column)?.text ?? null;
253 -}
254 -
247 export interface TerminalLinkWithRange {
248 readonly text: string;
249 readonly range: GhosttyCellRange;
@@ -325,10 +317,6 @@ export function terminalLinkAtPositionWithRange(
317 return null;
318 }
319
328 -export function terminalLinkAtColumn(row: GhosttySnapshot["rowData"][number], column: number) {
329 - return terminalLinkAtPosition([row], 0, column);
330 -}
331 -
320 export function isTerminalCopyShortcut(
321 event: Pick<KeyboardEvent, "ctrlKey" | "key" | "metaKey" | "shiftKey">,
322 platform = navigator.platform,