@devries-cameron20 / t3code-1 / commits / b92ebce0ad
Fork 0

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

fix(terminal): keep project script commands out of shell history (#13903)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Otavio Salvador committed Oct 19, 2026 at 02:26 UTC b92ebce0ad8ebbaaf09da09180fb67b6e9ad889e
5 files changed +27 -7
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+2 -1
@@ -25,6 +25,7 @@ import {
25 import {
26 projectScriptCwd,
27 projectScriptRuntimeEnv,
28 + projectScriptTerminalInput,
29 resolveProjectScripts,
30 } from "@t3tools/shared/projectScripts";
31 import { Platform, ScrollView, View } from "react-native";
@@ -667,7 +668,7 @@ function ThreadRouteContent(
668 cwd,
669 worktreePath: preferredWorktreePath,
670 env,
670 - initialInput: `${script.command}\r`,
671 + initialInput: projectScriptTerminalInput(script.command),
672 },
673 });
674 terminalDebugLog("project-script:staged", {
apps/server/src/project/ProjectSetupScriptRunner.test.ts
+4 -2
@@ -106,7 +106,7 @@ it.effect("resolves setup scripts through the standalone project service", () =>
106 NO_COLOR: "1",
107 FORCE_COLOR: "0",
108 });
109 - assert.equal(write.mock.calls[0]?.[0].data, "vp install\r");
109 + assert.equal(write.mock.calls[0]?.[0].data, " vp install\r");
110 const lines: string[] = [];
111 const observed = yield* runner.runForThread({
112 threadId: "thread-1",
@@ -120,6 +120,7 @@ it.effect("resolves setup scripts through the standalone project service", () =>
120 },
121 });
122 assert.equal(observed.status, "started");
123 + assert.match(write.mock.calls[1]?.[0].data ?? "", /^ \S/);
124 const listener = listeners[0]!;
125 yield* listener({
126 type: "output",
@@ -138,7 +139,7 @@ it.effect("resolves setup scripts through the standalone project service", () =>
139 });
140 const settleTerminalId = settle.status === "started" ? settle.terminalId : "";
141 assert.match(settleTerminalId, /^settle-clean-/);
141 - assert.equal(write.mock.calls.at(-1)?.[0].data, "cargo clean\r");
142 + assert.equal(write.mock.calls.at(-1)?.[0].data, " cargo clean\r");
143
144 const observedSettle = yield* runner.runForThread({
145 threadId: "thread-1",
@@ -149,6 +150,7 @@ it.effect("resolves setup scripts through the standalone project service", () =>
150 });
151 const observedTerminalId = observedSettle.status === "started" ? observedSettle.terminalId : "";
152 assert.notEqual(observedTerminalId, settleTerminalId);
153 + assert.match(write.mock.calls.at(-1)?.[0].data ?? "", /^ \S/);
154 const token = /__T3_SETUP_DONE___(\w+):/.exec(write.mock.calls.at(-1)?.[0].data ?? "")?.[1];
155 const settleListener = listeners.at(-1)!;
156 const completion = yield* Effect.forkChild(
apps/server/src/project/ProjectSetupScriptRunner.ts
+2 -1
@@ -2,6 +2,7 @@ import { ProjectId, type ProjectScript } from "@t3tools/contracts";
2 import * as HostProcess from "@t3tools/shared/HostProcess";
3 import {
4 projectScriptRuntimeEnv,
5 + projectScriptTerminalInput,
6 resolveProjectScripts,
7 settleProjectScript,
8 setupProjectScript,
@@ -410,7 +411,7 @@ export const make = Effect.gen(function* () {
411 .write({
412 threadId: input.threadId,
413 terminalId,
413 - data: `${commandLine}\r`,
414 + data: projectScriptTerminalInput(commandLine),
415 })
416 .pipe(
417 Effect.mapError(
apps/web/src/components/ChatView.tsx
+10 -3
@@ -129,7 +129,11 @@ import {
129 resolvePromptInjectedEffort,
130 resolveSelectableModel,
131 } from "@t3tools/shared/model";
132 -import { projectScriptCwd, resolveProjectScripts } from "@t3tools/shared/projectScripts";
132 +import {
133 + projectScriptCwd,
134 + projectScriptTerminalInput,
135 + resolveProjectScripts,
136 +} from "@t3tools/shared/projectScripts";
137 import { CHAT_LIST_ANCHOR_OFFSET } from "@t3tools/shared/chatList";
138 import { derivePendingBackgroundWork } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
139 import {
@@ -3436,6 +3440,7 @@ export default function ChatView(props: ChatViewProps) {
3440 worktreePath?: string | null;
3441 preferNewTerminal?: boolean;
3442 rememberAsLastInvoked?: boolean;
3443 + shellHistory?: "preserve" | "suppress";
3444 },
3445 ) => {
3446 if (!hasTerminalWriteAccess() || !activeThreadId || !activeProject || !activeThread) return;
@@ -3502,7 +3507,9 @@ export default function ChatView(props: ChatViewProps) {
3507
3508 const writeResult = await terminalActions.writeToTerminal(
3509 targetTerminalId,
3505 - `${script.command}\r`,
3510 + options?.shellHistory === "preserve"
3511 + ? `${script.command}\r`
3512 + : projectScriptTerminalInput(script.command),
3513 );
3514 if (!writeResult) return;
3515 if (writeResult._tag === "Failure") {
@@ -3548,7 +3555,7 @@ export default function ChatView(props: ChatViewProps) {
3555 icon: "play",
3556 runOnWorktreeCreate: false,
3557 },
3551 - { rememberAsLastInvoked: false },
3558 + { rememberAsLastInvoked: false, shellHistory: "preserve" },
3559 );
3560 };
3561 const runShellCommandStable = useStableCallback(runShellCommand);
packages/shared/src/projectScripts.ts
+9
@@ -79,3 +79,12 @@ export function projectScriptMenuLabel(script: ProjectScript): string {
79 export function settleProjectScript(scripts: readonly ProjectScript[]): ProjectScript | null {
80 return scripts.find((script) => script.runOnSettle === true) ?? null;
81 }
82 +
83 +/**
84 + * Leading spaces omit scripts from Bash history with ignorespace/ignoreboth,
85 + * zsh with HIST_IGNORE_SPACE, and fish. Only the first line is prefixed, so later
86 + * entries from multiline input may still enter history. PowerShell/PSReadLine history is not suppressed.
87 + */
88 +export function projectScriptTerminalInput(command: string): string {
89 + return ` ${command}\r`;
90 +}