Skip to content

Commit 296b089

Browse files
fix(web): terminal controls no longer cover the first line (pingdotgg#23373)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 6e58094 commit 296b089

8 files changed

Lines changed: 559 additions & 88 deletions

File tree

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

Lines changed: 56 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,53 @@ export default function ThreadTerminalDrawer({
17771777
);
17781778
}
17791779

1780+
// The single-terminal row and the split sidebar header share these controls,
1781+
// so neither layout floats them over terminal text.
1782+
const terminalActions = (
1783+
<div className="inline-flex h-full items-stretch">
1784+
<TerminalActionButton
1785+
disabled={!canOperateTerminal}
1786+
className={`inline-flex h-full items-center px-1 text-foreground/90 transition-colors ${
1787+
hasReachedSplitLimit
1788+
? "cursor-not-allowed opacity-64 hover:bg-transparent"
1789+
: "hover:bg-accent/70"
1790+
}`}
1791+
onClick={onSplitTerminalAction}
1792+
label={splitTerminalActionLabel}
1793+
>
1794+
<SquareSplitHorizontal className="size-3.25" />
1795+
</TerminalActionButton>
1796+
<TerminalActionButton
1797+
disabled={!canOperateTerminal}
1798+
className={`inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors ${
1799+
hasReachedSplitLimit
1800+
? "cursor-not-allowed opacity-64 hover:bg-transparent"
1801+
: "hover:bg-accent/70"
1802+
}`}
1803+
onClick={onSplitTerminalVerticalAction}
1804+
label={splitTerminalVerticalActionLabel}
1805+
>
1806+
<SquareSplitVertical className="size-3.25" />
1807+
</TerminalActionButton>
1808+
<TerminalActionButton
1809+
disabled={!canOperateTerminal}
1810+
className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
1811+
onClick={onNewTerminalAction}
1812+
label={newTerminalActionLabel}
1813+
>
1814+
<Plus className="size-3.25" />
1815+
</TerminalActionButton>
1816+
<TerminalActionButton
1817+
disabled={!canOperateTerminal}
1818+
className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
1819+
onClick={() => confirmCloseTerminal(resolvedActiveTerminalId)}
1820+
label={closeTerminalActionLabel}
1821+
>
1822+
<Trash2 className="size-3.25" />
1823+
</TerminalActionButton>
1824+
</div>
1825+
);
1826+
17801827
return (
17811828
<aside
17821829
ref={drawerRef}
@@ -1801,52 +1848,14 @@ export default function ThreadTerminalDrawer({
18011848
) : null}
18021849

18031850
{!hasTerminalSidebar && (
1804-
<div className="pointer-events-none absolute right-2 top-2 z-20">
1805-
<div className="pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs">
1806-
<TerminalActionButton
1807-
disabled={!canOperateTerminal}
1808-
className={`p-1 text-foreground/90 transition-colors ${
1809-
hasReachedSplitLimit
1810-
? "cursor-not-allowed opacity-64 hover:bg-transparent"
1811-
: "hover:bg-accent"
1812-
}`}
1813-
onClick={onSplitTerminalAction}
1814-
label={splitTerminalActionLabel}
1815-
>
1816-
<SquareSplitHorizontal className="size-3.25" />
1817-
</TerminalActionButton>
1818-
<div className="h-4 w-px bg-border/80" />
1819-
<TerminalActionButton
1820-
disabled={!canOperateTerminal}
1821-
className={`p-1 text-foreground/90 transition-colors ${
1822-
hasReachedSplitLimit
1823-
? "cursor-not-allowed opacity-64 hover:bg-transparent"
1824-
: "hover:bg-accent"
1825-
}`}
1826-
onClick={onSplitTerminalVerticalAction}
1827-
label={splitTerminalVerticalActionLabel}
1828-
>
1829-
<SquareSplitVertical className="size-3.25" />
1830-
</TerminalActionButton>
1831-
<div className="h-4 w-px bg-border/80" />
1832-
<TerminalActionButton
1833-
disabled={!canOperateTerminal}
1834-
className="p-1 text-foreground/90 transition-colors hover:bg-accent"
1835-
onClick={onNewTerminalAction}
1836-
label={newTerminalActionLabel}
1837-
>
1838-
<Plus className="size-3.25" />
1839-
</TerminalActionButton>
1840-
<div className="h-4 w-px bg-border/80" />
1841-
<TerminalActionButton
1842-
disabled={!canOperateTerminal}
1843-
className="p-1 text-foreground/90 transition-colors hover:bg-accent"
1844-
onClick={() => confirmCloseTerminal(resolvedActiveTerminalId)}
1845-
label={closeTerminalActionLabel}
1846-
>
1847-
<Trash2 className="size-3.25" />
1848-
</TerminalActionButton>
1849-
</div>
1851+
<div
1852+
className={cn(
1853+
"flex shrink-0 items-stretch justify-end border-b border-border/70",
1854+
// The drawer's resize strip covers its top 6px; keep the buttons below it.
1855+
isPanel ? "h-[22px]" : "h-7 pt-1.5",
1856+
)}
1857+
>
1858+
{terminalActions}
18501859
</div>
18511860
)}
18521861

@@ -1878,48 +1887,7 @@ export default function ThreadTerminalDrawer({
18781887
{hasTerminalSidebar && (
18791888
<aside className="flex w-36 min-w-36 flex-col border border-border/70 bg-muted/10">
18801889
<div className="flex h-[22px] items-stretch justify-end border-b border-border/70">
1881-
<div className="inline-flex h-full items-stretch">
1882-
<TerminalActionButton
1883-
disabled={!canOperateTerminal}
1884-
className={`inline-flex h-full items-center px-1 text-foreground/90 transition-colors ${
1885-
hasReachedSplitLimit
1886-
? "cursor-not-allowed opacity-64 hover:bg-transparent"
1887-
: "hover:bg-accent/70"
1888-
}`}
1889-
onClick={onSplitTerminalAction}
1890-
label={splitTerminalActionLabel}
1891-
>
1892-
<SquareSplitHorizontal className="size-3.25" />
1893-
</TerminalActionButton>
1894-
<TerminalActionButton
1895-
disabled={!canOperateTerminal}
1896-
className={`inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors ${
1897-
hasReachedSplitLimit
1898-
? "cursor-not-allowed opacity-64 hover:bg-transparent"
1899-
: "hover:bg-accent/70"
1900-
}`}
1901-
onClick={onSplitTerminalVerticalAction}
1902-
label={splitTerminalVerticalActionLabel}
1903-
>
1904-
<SquareSplitVertical className="size-3.25" />
1905-
</TerminalActionButton>
1906-
<TerminalActionButton
1907-
disabled={!canOperateTerminal}
1908-
className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
1909-
onClick={onNewTerminalAction}
1910-
label={newTerminalActionLabel}
1911-
>
1912-
<Plus className="size-3.25" />
1913-
</TerminalActionButton>
1914-
<TerminalActionButton
1915-
disabled={!canOperateTerminal}
1916-
className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
1917-
onClick={() => confirmCloseTerminal(resolvedActiveTerminalId)}
1918-
label={closeTerminalActionLabel}
1919-
>
1920-
<Trash2 className="size-3.25" />
1921-
</TerminalActionButton>
1922-
</div>
1890+
{terminalActions}
19231891
</div>
19241892

19251893
<div className="min-h-0 flex-1 overflow-y-auto px-1 py-1">
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
export const frozenTime = Date.UTC(2026, 9, 21, 22, 30);
2+
3+
// Freeze wall-clock labels without changing animation or recording timing.
4+
export function freezeClock() {
5+
const RealDate = globalThis.__evidenceRealDate ?? Date;
6+
globalThis.__evidenceRealDate = RealDate;
7+
globalThis.Date = class extends RealDate {
8+
constructor(...args) {
9+
super(...(args.length ? args : [frozenTime]));
10+
}
11+
static now() {
12+
return frozenTime;
13+
}
14+
};
15+
}
16+
17+
export async function metadata(provenance) {
18+
await document.fonts.ready;
19+
const box = (selector) =>
20+
[...document.querySelectorAll(selector)].map((el) => {
21+
const r = el.getBoundingClientRect();
22+
return { x: r.x, y: r.y, width: r.width, height: r.height };
23+
});
24+
return {
25+
...provenance,
26+
userAgent: navigator.userAgent,
27+
platform: navigator.platform,
28+
locale: navigator.language,
29+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
30+
frozenTime: new Date().toISOString(),
31+
devicePixelRatio,
32+
viewport: { width: innerWidth, height: innerHeight },
33+
visualViewportScale: visualViewport.scale,
34+
rootFontSize: getComputedStyle(document.documentElement).fontSize,
35+
rootClass: document.documentElement.className,
36+
fonts: [...document.fonts]
37+
.filter((f) => f.status === "loaded")
38+
.map((f) => ({ family: f.family, style: f.style, weight: f.weight })),
39+
terminal: box("[data-thread-terminal-drawer]"),
40+
canvases: box("canvas"),
41+
composer: box('[role="textbox"][contenteditable="true"]'),
42+
scroll: [...document.querySelectorAll("*")]
43+
.filter((e) => e.scrollTop || e.scrollLeft)
44+
.map((e) => ({
45+
tag: e.tagName,
46+
className: e.className,
47+
top: e.scrollTop,
48+
left: e.scrollLeft,
49+
})),
50+
reducedMotion: matchMedia("(prefers-reduced-motion: reduce)").matches,
51+
};
52+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import * as NodeChildProcess from "node:child_process";
2+
import * as NodeFSP from "node:fs/promises";
3+
import * as NodePath from "node:path";
4+
5+
// The caller supplies the harness's T3 preview tool dispatcher, not Playwright.
6+
export async function createDriver(
7+
callPreview,
8+
{ tabId, outputDir, repoDir, run, phase, sourceTreeSha },
9+
) {
10+
await NodeFSP.mkdir(outputDir, { recursive: true });
11+
await NodeFSP.mkdir("/tmp/t3-terminal-evidence", { recursive: true });
12+
const events = [];
13+
const captures = [];
14+
const started = Date.now();
15+
const git = (...args) =>
16+
NodeChildProcess.execFileSync("git", args, { cwd: repoDir, encoding: "utf8" }).trim();
17+
const provenance = {
18+
headSha: git("rev-parse", "HEAD"),
19+
sourceTreeSha,
20+
terminalBlob: git("hash-object", "apps/web/src/components/ThreadTerminalDrawer.tsx"),
21+
workingTreeStatus: git("status", "--short"),
22+
phase,
23+
};
24+
let milestones;
25+
let pendingMilestones;
26+
const decode = (result) =>
27+
result.structuredContent ??
28+
JSON.parse(result.content.find((item) => item.type === "text").text);
29+
// Watch before the action that starts a shell, so fast prompts cannot race the watcher.
30+
const arm = async () => {
31+
await milestones?.return();
32+
milestones = NodeFSP.watch("/tmp/t3-terminal-evidence");
33+
pendingMilestones = milestones.next();
34+
};
35+
const call = async (name, args = {}) => {
36+
if (name === "press" && args.key === "Enter") await arm();
37+
const result = await callPreview(name, { ...args, tabId });
38+
events.push({ run, ms: Date.now() - started, op: name, args, isError: !!result.isError });
39+
if (result.isError) throw new Error(JSON.stringify(result));
40+
return decode(result);
41+
};
42+
const evaluate = async (expression) => (await call("evaluate", { expression })).value;
43+
const driver = {
44+
call,
45+
evaluate,
46+
arm,
47+
ready: async (pane) => {
48+
if (!milestones) throw new Error(`Terminal readiness for ${pane} was not armed`);
49+
for (;;) {
50+
const event = await pendingMilestones;
51+
if (event.done) throw new Error("Terminal readiness watcher ended");
52+
if (event.value.filename === `ready-${pane}`) break;
53+
pendingMilestones = milestones.next();
54+
}
55+
await milestones.return();
56+
milestones = undefined;
57+
pendingMilestones = undefined;
58+
},
59+
columns: async () =>
60+
Number(
61+
(await NodeFSP.readFile("/tmp/t3-terminal-evidence/input-size", "utf8"))
62+
.trim()
63+
.split(/\s+/)[1],
64+
),
65+
note: async (note, data) => events.push({ run, ms: Date.now() - started, note, data }),
66+
checkpoint: async (checkpoint) => {
67+
const meta = await evaluate(
68+
`(async()=>{const m=await import('/test/fixtures/terminal-layout/capture.mjs');return m.metadata(${JSON.stringify(provenance)})})()`,
69+
);
70+
const snapshot = await call("snapshot", { save: true });
71+
const target = NodePath.join(outputDir, `${run}-${checkpoint}.png`);
72+
await NodeFSP.copyFile(snapshot.screenshotPath, target);
73+
captures.push({ run, checkpoint, path: target, meta });
74+
events.push({ run, ms: Date.now() - started, checkpoint, path: target });
75+
},
76+
finish: async () => {
77+
await milestones?.return();
78+
await NodeFSP.writeFile(
79+
NodePath.join(outputDir, `${run}.json`),
80+
JSON.stringify({ provenance, events, captures }, null, 2),
81+
);
82+
},
83+
};
84+
return driver;
85+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"frozenUtc": "2026-10-21T22:30:00.000Z",
3+
"viewports": {
4+
"W": [1440, 900],
5+
"N": [390, 900]
6+
},
7+
"themes": ["light", "dark"],
8+
"static": ["P1-W-L", "P1-W-D", "P1-N-L", "P1-N-D", "D1-W-L", "D1-W-D", "D1-N-L", "D1-N-D"],
9+
"recordings": ["RP-W-D", "RP-N-L", "RD-W-D", "RD-N-L"],
10+
"permissionUnavailable": ["Q1-N-L", "Q2-W-D"],
11+
"shellCommand": "bash <checkout>/apps/web/test/fixtures/terminal-layout/shell.sh A",
12+
"drawerHeight": 280,
13+
"diff": {
14+
"zero": {
15+
"threshold": 0,
16+
"gain": 8
17+
},
18+
"thresholded": {
19+
"threshold": 8,
20+
"gain": 8
21+
},
22+
"raw": {
23+
"threshold": 0,
24+
"gain": 1
25+
}
26+
},
27+
"historical": {
28+
"baselineApp": "70e5e384dab96a1d1e4a253ee5a9415ed5d8ce30",
29+
"afterApp": "ec679087f9029cc9be36fc76e1f95e2ffb692dce"
30+
},
31+
"baselineApp": "b5a226e49c52ecab4ddc2d678a7012d97e651a6a",
32+
"afterApp": "Resolve HEAD at capture time; includes finalized fixtures",
33+
"terminalBlobs": {
34+
"before": "0a12a6535c2d56325ef3193068b44c5ef08eb4b2",
35+
"after": "9626c2640b7d20fc38c972ed6fd3af250a434c16"
36+
},
37+
"setup": "Pair an isolated dev server; createDriver dispatches T3 preview tools for one owned tab; setup creates a fresh draft and shell. Call replay with the returned threadRef/threadKey. Use typeFirstLine for pending-input captures. Stop the server before seed.mjs."
38+
}

0 commit comments

Comments
 (0)