Skip to content
TypeScript

fix(web): terminal controls no longer cover the first line (#23373)

Julius Marminge296b089ab679
diff --git a/apps/web/src/components/ThreadTerminalDrawer.tsx b/apps/web/src/components/ThreadTerminalDrawer.tsx
index 88a945becc9..59e8f237abf 100644
--- a/apps/web/src/components/ThreadTerminalDrawer.tsx
+++ b/apps/web/src/components/ThreadTerminalDrawer.tsx
@@ -1777,6 +1777,53 @@ export default function ThreadTerminalDrawer({
);
}
+ // The single-terminal row and the split sidebar header share these controls,
+ // so neither layout floats them over terminal text.
+ const terminalActions = (
+ <div className="inline-flex h-full items-stretch">
+ <TerminalActionButton
+ disabled={!canOperateTerminal}
+ className={`inline-flex h-full items-center px-1 text-foreground/90 transition-colors ${
+ hasReachedSplitLimit
+ ? "cursor-not-allowed opacity-64 hover:bg-transparent"
+ : "hover:bg-accent/70"
+ }`}
+ onClick={onSplitTerminalAction}
+ label={splitTerminalActionLabel}
+ >
+ <SquareSplitHorizontal className="size-3.25" />
+ </TerminalActionButton>
+ <TerminalActionButton
+ disabled={!canOperateTerminal}
+ className={`inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors ${
+ hasReachedSplitLimit
+ ? "cursor-not-allowed opacity-64 hover:bg-transparent"
+ : "hover:bg-accent/70"
+ }`}
+ onClick={onSplitTerminalVerticalAction}
+ label={splitTerminalVerticalActionLabel}
+ >
+ <SquareSplitVertical className="size-3.25" />
+ </TerminalActionButton>
+ <TerminalActionButton
+ disabled={!canOperateTerminal}
+ className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
+ onClick={onNewTerminalAction}
+ label={newTerminalActionLabel}
+ >
+ <Plus className="size-3.25" />
+ </TerminalActionButton>
+ <TerminalActionButton
+ disabled={!canOperateTerminal}
+ className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
+ onClick={() => confirmCloseTerminal(resolvedActiveTerminalId)}
+ label={closeTerminalActionLabel}
+ >
+ <Trash2 className="size-3.25" />
+ </TerminalActionButton>
+ </div>
+ );
+
return (
<aside
ref={drawerRef}
@@ -1801,52 +1848,14 @@ export default function ThreadTerminalDrawer({
) : null}
{!hasTerminalSidebar && (
- <div className="pointer-events-none absolute right-2 top-2 z-20">
- <div className="pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background shadow-xs">
- <TerminalActionButton
- disabled={!canOperateTerminal}
- className={`p-1 text-foreground/90 transition-colors ${
- hasReachedSplitLimit
- ? "cursor-not-allowed opacity-64 hover:bg-transparent"
- : "hover:bg-accent"
- }`}
- onClick={onSplitTerminalAction}
- label={splitTerminalActionLabel}
- >
- <SquareSplitHorizontal className="size-3.25" />
- </TerminalActionButton>
- <div className="h-4 w-px bg-border/80" />
- <TerminalActionButton
- disabled={!canOperateTerminal}
- className={`p-1 text-foreground/90 transition-colors ${
- hasReachedSplitLimit
- ? "cursor-not-allowed opacity-64 hover:bg-transparent"
- : "hover:bg-accent"
- }`}
- onClick={onSplitTerminalVerticalAction}
- label={splitTerminalVerticalActionLabel}
- >
- <SquareSplitVertical className="size-3.25" />
- </TerminalActionButton>
- <div className="h-4 w-px bg-border/80" />
- <TerminalActionButton
- disabled={!canOperateTerminal}
- className="p-1 text-foreground/90 transition-colors hover:bg-accent"
- onClick={onNewTerminalAction}
- label={newTerminalActionLabel}
- >
- <Plus className="size-3.25" />
- </TerminalActionButton>
- <div className="h-4 w-px bg-border/80" />
- <TerminalActionButton
- disabled={!canOperateTerminal}
- className="p-1 text-foreground/90 transition-colors hover:bg-accent"
- onClick={() => confirmCloseTerminal(resolvedActiveTerminalId)}
- label={closeTerminalActionLabel}
- >
- <Trash2 className="size-3.25" />
- </TerminalActionButton>
- </div>
+ <div
+ className={cn(
+ "flex shrink-0 items-stretch justify-end border-b border-border/70",
+ // The drawer's resize strip covers its top 6px; keep the buttons below it.
+ isPanel ? "h-[22px]" : "h-7 pt-1.5",
+ )}
+ >
+ {terminalActions}
</div>
)}
@@ -1878,48 +1887,7 @@ export default function ThreadTerminalDrawer({
{hasTerminalSidebar && (
<aside className="flex w-36 min-w-36 flex-col border border-border/70 bg-muted/10">
<div className="flex h-[22px] items-stretch justify-end border-b border-border/70">
- <div className="inline-flex h-full items-stretch">
- <TerminalActionButton
- disabled={!canOperateTerminal}
- className={`inline-flex h-full items-center px-1 text-foreground/90 transition-colors ${
- hasReachedSplitLimit
- ? "cursor-not-allowed opacity-64 hover:bg-transparent"
- : "hover:bg-accent/70"
- }`}
- onClick={onSplitTerminalAction}
- label={splitTerminalActionLabel}
- >
- <SquareSplitHorizontal className="size-3.25" />
- </TerminalActionButton>
- <TerminalActionButton
- disabled={!canOperateTerminal}
- className={`inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors ${
- hasReachedSplitLimit
- ? "cursor-not-allowed opacity-64 hover:bg-transparent"
- : "hover:bg-accent/70"
- }`}
- onClick={onSplitTerminalVerticalAction}
- label={splitTerminalVerticalActionLabel}
- >
- <SquareSplitVertical className="size-3.25" />
- </TerminalActionButton>
- <TerminalActionButton
- disabled={!canOperateTerminal}
- className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
- onClick={onNewTerminalAction}
- label={newTerminalActionLabel}
- >
- <Plus className="size-3.25" />
- </TerminalActionButton>
- <TerminalActionButton
- disabled={!canOperateTerminal}
- className="inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
- onClick={() => confirmCloseTerminal(resolvedActiveTerminalId)}
- label={closeTerminalActionLabel}
- >
- <Trash2 className="size-3.25" />
- </TerminalActionButton>
- </div>
+ {terminalActions}
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-1 py-1">
diff --git a/apps/web/test/fixtures/terminal-layout/capture.mjs b/apps/web/test/fixtures/terminal-layout/capture.mjs
new file mode 100644
index 00000000000..b1afa18051a
--- /dev/null
+++ b/apps/web/test/fixtures/terminal-layout/capture.mjs
@@ -0,0 +1,52 @@
+export const frozenTime = Date.UTC(2026, 9, 21, 22, 30);
+
+// Freeze wall-clock labels without changing animation or recording timing.
+export function freezeClock() {
+ const RealDate = globalThis.__evidenceRealDate ?? Date;
+ globalThis.__evidenceRealDate = RealDate;
+ globalThis.Date = class extends RealDate {
+ constructor(...args) {
+ super(...(args.length ? args : [frozenTime]));
+ }
+ static now() {
+ return frozenTime;
+ }
+ };
+}
+
+export async function metadata(provenance) {
+ await document.fonts.ready;
+ const box = (selector) =>
+ [...document.querySelectorAll(selector)].map((el) => {
+ const r = el.getBoundingClientRect();
+ return { x: r.x, y: r.y, width: r.width, height: r.height };
+ });
+ return {
+ ...provenance,
+ userAgent: navigator.userAgent,
+ platform: navigator.platform,
+ locale: navigator.language,
+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
+ frozenTime: new Date().toISOString(),
+ devicePixelRatio,
+ viewport: { width: innerWidth, height: innerHeight },
+ visualViewportScale: visualViewport.scale,
+ rootFontSize: getComputedStyle(document.documentElement).fontSize,
+ rootClass: document.documentElement.className,
+ fonts: [...document.fonts]
+ .filter((f) => f.status === "loaded")
+ .map((f) => ({ family: f.family, style: f.style, weight: f.weight })),
+ terminal: box("[data-thread-terminal-drawer]"),
+ canvases: box("canvas"),
+ composer: box('[role="textbox"][contenteditable="true"]'),
+ scroll: [...document.querySelectorAll("*")]
+ .filter((e) => e.scrollTop || e.scrollLeft)
+ .map((e) => ({
+ tag: e.tagName,
+ className: e.className,
+ top: e.scrollTop,
+ left: e.scrollLeft,
+ })),
+ reducedMotion: matchMedia("(prefers-reduced-motion: reduce)").matches,
+ };
+}
diff --git a/apps/web/test/fixtures/terminal-layout/driver.mjs b/apps/web/test/fixtures/terminal-layout/driver.mjs
new file mode 100644
index 00000000000..04b93e1a07c
--- /dev/null
+++ b/apps/web/test/fixtures/terminal-layout/driver.mjs
@@ -0,0 +1,85 @@
+import * as NodeChildProcess from "node:child_process";
+import * as NodeFSP from "node:fs/promises";
+import * as NodePath from "node:path";
+
+// The caller supplies the harness's T3 preview tool dispatcher, not Playwright.
+export async function createDriver(
+ callPreview,
+ { tabId, outputDir, repoDir, run, phase, sourceTreeSha },
+) {
+ await NodeFSP.mkdir(outputDir, { recursive: true });
+ await NodeFSP.mkdir("/tmp/t3-terminal-evidence", { recursive: true });
+ const events = [];
+ const captures = [];
+ const started = Date.now();
+ const git = (...args) =>
+ NodeChildProcess.execFileSync("git", args, { cwd: repoDir, encoding: "utf8" }).trim();
+ const provenance = {
+ headSha: git("rev-parse", "HEAD"),
+ sourceTreeSha,
+ terminalBlob: git("hash-object", "apps/web/src/components/ThreadTerminalDrawer.tsx"),
+ workingTreeStatus: git("status", "--short"),
+ phase,
+ };
+ let milestones;
+ let pendingMilestones;
+ const decode = (result) =>
+ result.structuredContent ??
+ JSON.parse(result.content.find((item) => item.type === "text").text);
+ // Watch before the action that starts a shell, so fast prompts cannot race the watcher.
+ const arm = async () => {
+ await milestones?.return();
+ milestones = NodeFSP.watch("/tmp/t3-terminal-evidence");
+ pendingMilestones = milestones.next();
+ };
+ const call = async (name, args = {}) => {
+ if (name === "press" && args.key === "Enter") await arm();
+ const result = await callPreview(name, { ...args, tabId });
+ events.push({ run, ms: Date.now() - started, op: name, args, isError: !!result.isError });
+ if (result.isError) throw new Error(JSON.stringify(result));
+ return decode(result);
+ };
+ const evaluate = async (expression) => (await call("evaluate", { expression })).value;
+ const driver = {
+ call,
+ evaluate,
+ arm,
+ ready: async (pane) => {
+ if (!milestones) throw new Error(`Terminal readiness for ${pane} was not armed`);
+ for (;;) {
+ const event = await pendingMilestones;
+ if (event.done) throw new Error("Terminal readiness watcher ended");
+ if (event.value.filename === `ready-${pane}`) break;
+ pendingMilestones = milestones.next();
+ }
+ await milestones.return();
+ milestones = undefined;
+ pendingMilestones = undefined;
+ },
+ columns: async () =>
+ Number(
+ (await NodeFSP.readFile("/tmp/t3-terminal-evidence/input-size", "utf8"))
+ .trim()
+ .split(/\s+/)[1],
+ ),
+ note: async (note, data) => events.push({ run, ms: Date.now() - started, note, data }),
+ checkpoint: async (checkpoint) => {
+ const meta = await evaluate(
+ `(async()=>{const m=await import('/test/fixtures/terminal-layout/capture.mjs');return m.metadata(${JSON.stringify(provenance)})})()`,
+ );
+ const snapshot = await call("snapshot", { save: true });
+ const target = NodePath.join(outputDir, `${run}-${checkpoint}.png`);
+ await NodeFSP.copyFile(snapshot.screenshotPath, target);
+ captures.push({ run, checkpoint, path: target, meta });
+ events.push({ run, ms: Date.now() - started, checkpoint, path: target });
+ },
+ finish: async () => {
+ await milestones?.return();
+ await NodeFSP.writeFile(
+ NodePath.join(outputDir, `${run}.json`),
+ JSON.stringify({ provenance, events, captures }, null, 2),
+ );
+ },
+ };
+ return driver;
+}
diff --git a/apps/web/test/fixtures/terminal-layout/manifest.json b/apps/web/test/fixtures/terminal-layout/manifest.json
new file mode 100644
index 00000000000..bc45d580779
--- /dev/null
+++ b/apps/web/test/fixtures/terminal-layout/manifest.json
@@ -0,0 +1,38 @@
+{
+ "frozenUtc": "2026-10-21T22:30:00.000Z",
+ "viewports": {
+ "W": [1440, 900],
+ "N": [390, 900]
+ },
+ "themes": ["light", "dark"],
+ "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"],
+ "recordings": ["RP-W-D", "RP-N-L", "RD-W-D", "RD-N-L"],
+ "permissionUnavailable": ["Q1-N-L", "Q2-W-D"],
+ "shellCommand": "bash <checkout>/apps/web/test/fixtures/terminal-layout/shell.sh A",
+ "drawerHeight": 280,
+ "diff": {
+ "zero": {
+ "threshold": 0,
+ "gain": 8
+ },
+ "thresholded": {
+ "threshold": 8,
+ "gain": 8
+ },
+ "raw": {
+ "threshold": 0,
+ "gain": 1
+ }
+ },
+ "historical": {
+ "baselineApp": "70e5e384dab96a1d1e4a253ee5a9415ed5d8ce30",
+ "afterApp": "ec679087f9029cc9be36fc76e1f95e2ffb692dce"
+ },
+ "baselineApp": "b5a226e49c52ecab4ddc2d678a7012d97e651a6a",
+ "afterApp": "Resolve HEAD at capture time; includes finalized fixtures",
+ "terminalBlobs": {
+ "before": "0a12a6535c2d56325ef3193068b44c5ef08eb4b2",
+ "after": "9626c2640b7d20fc38c972ed6fd3af250a434c16"
+ },
+ "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."
+}
diff --git a/apps/web/test/fixtures/terminal-layout/replay.mjs b/apps/web/test/fixtures/terminal-layout/replay.mjs
new file mode 100644
index 00000000000..752a06a7ab3
--- /dev/null
+++ b/apps/web/test/fixtures/terminal-layout/replay.mjs
@@ -0,0 +1,196 @@
+// The driver invokes only T3 preview tools. Each checkpoint saves the whole viewport.
+export async function replay(driver, { mode, width, shellPath, threadRef, threadKey }) {
+ const owner = mode === "RP" ? "right-panel" : "drawer";
+ const surface = `[data-terminal-owner="${owner}"]`;
+ const action = (name) => `${surface} button[aria-label^="${name}"]`;
+ const call = driver.call;
+ const read = driver.evaluate;
+ const checkpoint = driver.checkpoint;
+ await read(
+ `globalThis.driverThreadRef = ${JSON.stringify(threadRef)}; globalThis.driverThreadKey = ${JSON.stringify(threadKey)}`,
+ );
+ const press = (key, modifiers) => call("press", { key, modifiers });
+ const click = (locator) => call("click", { locator });
+ const quotedShellPath = `'${shellPath.replaceAll("'", "'\\''")}'`;
+ const command = async (text) => {
+ await press("c", ["Control"]);
+ await call("type", { locator: `${surface} textarea:focus`, text });
+ await press("Enter");
+ };
+ const seed = async (pane, index) => {
+ await click(`${surface} canvas >> nth=${index}`);
+ await command(`bash ${quotedShellPath} ${pane}`);
+ await driver.ready(pane);
+ };
+ const reset = async () => {
+ const n = await read(`document.querySelectorAll('${surface} canvas').length`);
+ for (let i = 0; i < n; i++) {
+ await click(`${surface} canvas >> nth=${i}`);
+ await command("fixture_reset");
+ await driver.ready(String.fromCharCode(65 + i));
+ }
+ };
+ const close = async () => {
+ await click(action("Close Terminal ("));
+ await call("wait_for", { locator: '[role="alertdialog"]' });
+ await click('role=button[name="Confirm"]');
+ await call("wait_for", { locator: `${surface} canvas` });
+ };
+ await reset();
+ await checkpoint("single");
+ for (const name of [
+ "Split Terminal Horizontally",
+ "Split Terminal Vertically",
+ "New Terminal",
+ "Close Terminal (",
+ ]) {
+ await call("hover", { locator: action(name) });
+ await call("wait_for", { locator: '[role="dialog"]' });
+ }
+ await checkpoint("tooltip");
+ const hit = await read(
+ `(()=>{const b=document.querySelector('${action("Split Terminal Horizontally")}');const r=b.getBoundingClientRect();return {x:r.x+r.width/2,y:r.y+2,label:b.getAttribute('aria-label'),hit:document.elementFromPoint(r.x+r.width/2,r.y+2)?.closest('button')?.getAttribute('aria-label')}})()`,
+ );
+ await driver.note("top2px horizontal split hit test", hit);
+ await call("click", { x: hit.x, y: hit.y });
+ await seed("B", 1);
+ await reset();
+ await checkpoint("S-H");
+ for (const [pane, index] of [
+ ["C", 2],
+ ["D", 3],
+ ]) {
+ await click(action("Split Terminal Horizontally"));
+ await seed(pane, index);
+ }
+ await reset();
+ await call("hover", { locator: action("Split Terminal Horizontally") });
+ await call("wait_for", { text: "max 4 per group" });
+ try {
+ await click(action("Split Terminal Horizontally"));
+ } catch (error) {
+ await driver.note("Limit control rejected the pointer attempt", { error: String(error) });
+ }
+ const count = await read(`document.querySelectorAll('${surface} canvas').length`);
+ if (count !== 4) throw Error(`Expected four panes, received ${count}`);
+ await checkpoint("L");
+ for (let i = 0; i < 3; i++) await close();
+ await reset();
+ await checkpoint("single-after-horizontal");
+ await click(action("Split Terminal Vertically"));
+ await seed("B", 1);
+ await reset();
+ await checkpoint("S-V");
+ await close();
+ await reset();
+ await click(action("New Terminal"));
+ await seed("B", 0);
+ await checkpoint(mode === "RP" ? "new-tab" : "G");
+ if (mode === "RP") {
+ const tab = (index) =>
+ `[data-right-panel-tab-list] [data-active-tab] button:not([aria-label]):visible >> nth=${index}`;
+ await click(tab(0));
+ await reset();
+ await click(tab(1));
+ await close();
+ if (width > 980) {
+ await call("drag", {
+ source: '[role="separator"].cursor-col-resize:visible',
+ target: '[role="textbox"][contenteditable="true"]',
+ });
+ await checkpoint("width-drag");
+ await click('button[aria-label="Maximize panel"]:visible');
+ await checkpoint("maximized");
+ await click('button[aria-label="Restore panel size"]:visible');
+ await call("drag", {
+ source: '[role="separator"].cursor-col-resize:visible',
+ target: 'button[aria-label="Toggle right panel"]:visible',
+ });
+ }
+ await click('button[aria-label="Toggle right panel"]:visible');
+ await checkpoint("hidden");
+ await click('button[aria-label="Toggle right panel"]:visible');
+ } else {
+ const session = (index) =>
+ `${surface} [class~="group/tab"] > button:not([aria-label]) >> nth=${index}`;
+ await click(session(0));
+ await reset();
+ await click(session(1));
+ await close();
+ await click('button[aria-label="Toggle thread details panel"]:visible');
+ await driver.arm();
+ await click(
+ 'button[aria-label="Run Evidence deterministic terminal with deliberately long label"]',
+ );
+ await call("wait_for", { locator: `${surface} canvas` });
+ await click('button[aria-label="Toggle thread details panel"]:visible');
+ await driver.ready("G");
+ await checkpoint("G-long-label");
+ await close();
+ await click(`${surface} canvas`);
+ await press("d", ["Control"]);
+ await seed("B", 1);
+ await checkpoint("shortcut-split");
+ await close();
+ await call("drag", { source: `${surface} > .cursor-row-resize`, target: `${surface} canvas` });
+ await reset();
+ await checkpoint("minimum-height");
+ await read(
+ `(async()=>{const m=await import('/src/terminalUiStateStore.ts');m.useTerminalUiStateStore.getState().setTerminalHeight(driverThreadRef,280)})()`,
+ );
+ await click('button[aria-label="Toggle terminal drawer"]:visible');
+ await click('button[aria-label="Toggle terminal drawer"]:visible');
+ await call("wait_for", { locator: `${surface} canvas` });
+ await driver.note("restore preferred height through existing store action", { height: 280 });
+ await call("type", {
+ locator: '[role="textbox"][contenteditable="true"]',
+ text: Array.from({ length: 12 }, (_, i) => "Composer fixture line " + (i + 1)).join("\n"),
+ });
+ await read(
+ `(async()=>{const m=await import('/src/hooks/useSettings.ts');await m.updateClientSettings({fontSizeTerminal:18})})()`,
+ );
+ await reset();
+ await checkpoint("constrained-font18");
+ await call("type", {
+ locator: '[role="textbox"][contenteditable="true"]',
+ text: "",
+ clear: true,
+ });
+ await read(
+ `(async()=>{const m=await import('/src/hooks/useSettings.ts');await m.updateClientSettings({fontSizeTerminal:12})})()`,
+ );
+ await click(`${surface} canvas`);
+ await command("fixture_scrollback");
+ await driver.ready("A");
+ await read(
+ `document.querySelector('${surface} canvas').dispatchEvent(new WheelEvent('wheel',{deltaY:-1000,bubbles:true,cancelable:true}))`,
+ );
+ await checkpoint("scroll-up");
+ await read(
+ `document.querySelector('${surface} canvas').dispatchEvent(new WheelEvent('wheel',{deltaY:1000,bubbles:true,cancelable:true}))`,
+ );
+ await checkpoint("scroll-down");
+ await click('button[aria-label="Toggle terminal drawer"]:visible');
+ await checkpoint("hidden");
+ await click('button[aria-label="Toggle terminal drawer"]:visible');
+ }
+ await reset();
+ await checkpoint("reopened");
+ await click(action("Close Terminal ("));
+ await click('role=button[name="Cancel"]');
+ await checkpoint("close-cancel");
+ await click(action("Close Terminal ("));
+ await click('role=button[name="Confirm"]');
+ await checkpoint("E-last-close");
+ if (mode === "RP") {
+ const open = await read(
+ `JSON.parse(localStorage.getItem('t3code:right-panel-state:v2')).state.byThreadKey[driverThreadKey]?.isOpen === true`,
+ );
+ if (!open) await click('button[aria-label="Toggle right panel"]:visible');
+ await click('role=button[name="Terminal T"]');
+ } else {
+ await click('button[aria-label="Toggle terminal drawer"]:visible');
+ }
+ await seed("A", 0);
+ await checkpoint("new-usable-single");
+}
diff --git a/apps/web/test/fixtures/terminal-layout/seed.mjs b/apps/web/test/fixtures/terminal-layout/seed.mjs
new file mode 100644
index 00000000000..37978c0a889
--- /dev/null
+++ b/apps/web/test/fixtures/terminal-layout/seed.mjs
@@ -0,0 +1,36 @@
+import * as NodeFSP from "node:fs/promises";
+import * as NodeOS from "node:os";
+import * as NodePath from "node:path";
+import * as NodeURL from "node:url";
+
+// Run with the isolated server stopped: node seed.mjs <T3-home> <project-id>.
+// The app creates projects/drafts normally; this adds only the named script.
+const [home, projectId] = process.argv.slice(2);
+if (!home || !projectId) throw new Error("Usage: node seed.mjs <isolated-T3-home> <project-id>");
+const resolvedHome = await NodeFSP.realpath(home);
+const liveHome = await NodeFSP.realpath(NodePath.join(NodeOS.homedir(), ".t3"));
+if (resolvedHome === liveHome || resolvedHome.startsWith(liveHome + NodePath.sep)) {
+ throw new Error("Refusing to write live T3 state");
+}
+const target = NodePath.join(resolvedHome, "userdata/settings.json");
+const settings = JSON.parse(
+ await NodeFSP.readFile(target, "utf8").catch((error) => {
+ if (error.code === "ENOENT") return "{}";
+ throw error;
+ }),
+);
+const shellPath = NodeURL.fileURLToPath(new URL("./shell.sh", import.meta.url));
+const script = {
+ id: "evidence-deterministic-t",
+ name: "Evidence deterministic terminal with deliberately long label",
+ command: `bash '${shellPath.replaceAll("'", "'\\''")}' G`,
+ icon: "play",
+ runOnWorktreeCreate: false,
+};
+settings.projectScriptOverrides ??= {};
+const previous = settings.projectScriptOverrides[projectId] ?? [];
+settings.projectScriptOverrides[projectId] = [
+ ...previous.filter((item) => item.id !== script.id),
+ script,
+];
+await NodeFSP.writeFile(target, JSON.stringify(settings, null, 2) + "\n");
diff --git a/apps/web/test/fixtures/terminal-layout/setup.mjs b/apps/web/test/fixtures/terminal-layout/setup.mjs
new file mode 100644
index 00000000000..521bbf146e4
--- /dev/null
+++ b/apps/web/test/fixtures/terminal-layout/setup.mjs
@@ -0,0 +1,62 @@
+// Start an isolated dev server and pair its Browser panel before calling this.
+// callPreview dispatches names to T3 preview_* tools; it must keep one owned tab.
+export async function setup(driver, { width, theme, mode, shellPath, projectName = "server" }) {
+ const { call, evaluate } = driver;
+ await call("resize", { mode: "freeform", width, height: 900 });
+ await call("set_appearance", { colorScheme: theme });
+ await evaluate(`(async()=>{
+ const capture=await import('/test/fixtures/terminal-layout/capture.mjs');
+ capture.freezeClock();
+ const settings=await import('/src/hooks/useSettings.ts');
+ await settings.updateClientSettings({fontSizeTerminal:12});
+ localStorage.setItem('t3code:theme',${JSON.stringify(theme)});
+ window.dispatchEvent(new StorageEvent('storage',{key:'t3code:theme',newValue:${JSON.stringify(theme)}}));
+ })()`);
+ await call("click", {
+ locator: `button[aria-label=${JSON.stringify(`New thread in ${projectName}`)}]`,
+ });
+ await call("wait_for", { locator: '[role="textbox"][contenteditable="true"]' });
+ const context = await evaluate(`(()=>{
+ const draftId=location.pathname.split('/').at(-1);
+ const draft=JSON.parse(localStorage['t3code:composer-drafts:v1']).state.draftThreadsByThreadKey[draftId];
+ if(!draft) throw Error('Expected a newly created draft');
+ const threadRef={environmentId:draft.environmentId,threadId:draft.threadId};
+ return {route:location.pathname,threadRef,threadKey:draft.environmentId+':'+draft.threadId};
+ })()`);
+ const sidebarOpen = await evaluate(
+ `document.querySelector('button[aria-label="Toggle main sidebar"]')?.getAttribute('aria-pressed')==='true'`,
+ );
+ if (sidebarOpen) await call("click", { locator: 'button[aria-label="Toggle main sidebar"]' });
+ if (mode === "RP") {
+ await call("click", { locator: 'button[aria-label="Toggle right panel"]' });
+ await call("click", { locator: 'role=button[name="Terminal T"]' });
+ } else {
+ await call("click", { locator: 'button[aria-label="Toggle terminal drawer"]' });
+ }
+ const surface = `[data-terminal-owner="${mode === "RP" ? "right-panel" : "drawer"}"]`;
+ await call("wait_for", { locator: `${surface} canvas` });
+ await call("click", { locator: `${surface} canvas` });
+ await call("press", { key: "c", modifiers: ["Control"] });
+ const quotedPath = `'${shellPath.replaceAll("'", "'\\''")}'`;
+ await call("type", { locator: `${surface} textarea:focus`, text: `bash ${quotedPath} A` });
+ await call("press", { key: "Enter" });
+ await driver.ready("A");
+ return context;
+}
+
+// This leaves real unexecuted shell input and its cursor on the first row.
+export async function typeFirstLine(driver, { mode, columns }) {
+ const surface = `[data-terminal-owner="${mode === "RP" ? "right-panel" : "drawer"}"]`;
+ await driver.call("click", { locator: `${surface} canvas` });
+ await driver.call("press", { key: "c", modifiers: ["Control"] });
+ await driver.call("type", { locator: `${surface} textarea:focus`, text: "fixture_input" });
+ await driver.call("press", { key: "Enter" });
+ await driver.ready("input");
+ const terminalColumns = columns ?? (await driver.columns());
+ const prefix = "printf '%s\\n' '";
+ const suffix = "RIGHT'";
+ const text =
+ prefix + "typed-".padEnd(terminalColumns - 2 - prefix.length - suffix.length, "x") + suffix;
+ await driver.call("type", { locator: `${surface} textarea:focus`, text });
+ return text;
+}
diff --git a/apps/web/test/fixtures/terminal-layout/shell.sh b/apps/web/test/fixtures/terminal-layout/shell.sh
new file mode 100644
index 00000000000..833fe434b71
--- /dev/null
+++ b/apps/web/test/fixtures/terminal-layout/shell.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
+ set -eu
+ mkdir -p /tmp/t3-terminal-evidence
+ exec env -i HOME=/tmp/t3-terminal-evidence PATH=/usr/bin:/bin TERM=xterm-256color LANG=C.UTF-8 LC_ALL=C.UTF-8 EVIDENCE_PANE="${1:-A}" bash --noprofile --rcfile "$0" -i
+fi
+cd /tmp/t3-terminal-evidence
+HISTFILE=/dev/null
+set +o history
+fixture_prompt() {
+ local width fill
+ width=$(stty size); width=${width##* }
+ printf -v fill '%*s' "$((width > 12 ? width - 12 : 1))" ''
+ PS1="\[\e[36m\]LEFT-${fill// /-}-RIGHT\[\e[0m\]\n\[\e[32m\]pane ${EVIDENCE_PANE} READY\[\e[0m\] ANSI blue: \[\e[34m\]0123456789\[\e[0m\]\nevidence:/fixture $ "
+ printf '\033[?25l'
+ stty size > /tmp/t3-terminal-evidence/input-size
+ printf '%s\n' "$EVIDENCE_PANE" > "/tmp/t3-terminal-evidence/ready-${EVIDENCE_PANE}"
+}
+fixture_reset() { printf '\033[3J\033[H\033[2J'; }
+fixture_scrollback() {
+ local n
+ for ((n=1;n<=80;n++)); do printf 'SCROLL %03d | deterministic terminal output | RIGHT\n' "$n"; done
+}
+PROMPT_COMMAND=fixture_prompt
+fixture_reset
+
+# Leave the next command on the first physical line with a steady visible cursor.
+fixture_input() {
+ PROMPT_COMMAND=
+ PS1=
+ printf '\033[3J\033[H\033[2J\033[?25h\033[2 q'
+ stty size > /tmp/t3-terminal-evidence/input-size
+ printf 'input\n' > /tmp/t3-terminal-evidence/ready-input
+}