Skip to content
TypeScript

feat(server): stop opted-in project actions when threads settle (#31857)

Yash Singhdd059b40bcf0
diff --git a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
index 9b3db1e3525..7569c22ad3e 100644
--- a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
+++ b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx
@@ -487,6 +487,7 @@ function ThreadTerminal(props: {
cols: initialAttachGridSize.cols,
rows: initialAttachGridSize.rows,
...(pendingLaunch?.env ? { env: pendingLaunch.env } : {}),
+ ...(pendingLaunch ? { stopOnSettle: pendingLaunch.stopOnSettle ?? false } : {}),
...(pendingLaunch ? { restartIfNotRunning: true } : {}),
}
: null,
diff --git a/apps/mobile/src/features/terminal/terminalLaunchContext.ts b/apps/mobile/src/features/terminal/terminalLaunchContext.ts
index 1ee18cd2006..62eec0835f2 100644
--- a/apps/mobile/src/features/terminal/terminalLaunchContext.ts
+++ b/apps/mobile/src/features/terminal/terminalLaunchContext.ts
@@ -17,6 +17,7 @@ export interface PendingTerminalLaunch {
readonly worktreePath: string | null;
readonly env?: Record<string, string>;
readonly initialInput?: string;
+ readonly stopOnSettle?: boolean;
}
const pendingTerminalLaunches = new Map<string, PendingTerminalLaunch>();
@@ -34,6 +35,7 @@ export function stagePendingTerminalLaunch(input: {
worktreePath: input.launch.worktreePath,
env: input.launch.env ? { ...input.launch.env } : undefined,
initialInput: input.launch.initialInput,
+ stopOnSettle: input.launch.stopOnSettle,
});
}
diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
index 4aecde3be74..80a3e8643a5 100644
--- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx
@@ -767,6 +767,7 @@ function ThreadRouteContent(
worktreePath: preferredWorktreePath,
env,
initialInput: projectScriptTerminalInput(script.command),
+ stopOnSettle: script.stopOnSettle ?? false,
},
});
diff --git a/apps/server/src/orchestration-v2/ThreadSettlementService.test.ts b/apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
index ff5caf6a591..f3c83eca706 100644
--- a/apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
+++ b/apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
@@ -682,7 +682,7 @@ const makeHarness = Effect.fn("makeThreadSettlementHarness")(function* (options:
dispatch,
}),
Layer.mock(TerminalManager.TerminalManager)({
- closeIdle: (input) =>
+ closeOnSettle: (input) =>
Queue.offer(closedIdle, input).pipe(Effect.andThen(options.onCloseIdle?.() ?? Effect.void)),
}),
Layer.mock(ProjectSetupScriptRunner.ProjectSetupScriptRunner)({
diff --git a/apps/server/src/orchestration-v2/ThreadSettlementService.ts b/apps/server/src/orchestration-v2/ThreadSettlementService.ts
index 40c6bf7d057..aedbb73fc55 100644
--- a/apps/server/src/orchestration-v2/ThreadSettlementService.ts
+++ b/apps/server/src/orchestration-v2/ThreadSettlementService.ts
@@ -599,7 +599,7 @@ export const make = Effect.gen(function* () {
function* (threadId: ThreadId) {
const settled = yield* projections.getThread(threadId);
if (settled.settledOverride !== "settled") return;
- yield* terminals.closeIdle({ threadId });
+ yield* terminals.closeOnSettle({ threadId });
const worktreePath = settled.worktreePath;
if (worktreePath === null || !(yield* fileSystem.exists(worktreePath))) return;
// Recheck after closing and worktree I/O; re-engaged threads must not be cleaned up.
diff --git a/apps/server/src/project/ProjectSetupScriptRunner.test.ts b/apps/server/src/project/ProjectSetupScriptRunner.test.ts
index f383436cdb4..4eb466200bc 100644
--- a/apps/server/src/project/ProjectSetupScriptRunner.test.ts
+++ b/apps/server/src/project/ProjectSetupScriptRunner.test.ts
@@ -62,6 +62,7 @@ const makeHarness = Effect.fn(function* (options: {
}),
write: (input) => Queue.offer(writes, input.data).pipe(Effect.asVoid),
closeIdle: () => Effect.void,
+ closeOnSettle: () => Effect.void,
});
const runner = yield* ProjectSetupScriptRunner.make.pipe(
Effect.provide(
diff --git a/apps/server/src/project/ProjectSetupScriptRunner.ts b/apps/server/src/project/ProjectSetupScriptRunner.ts
index 96b574f2f89..8e7c3105b36 100644
--- a/apps/server/src/project/ProjectSetupScriptRunner.ts
+++ b/apps/server/src/project/ProjectSetupScriptRunner.ts
@@ -466,6 +466,7 @@ export const make = Effect.gen(function* () {
.open({
threadId: input.threadId,
terminalId,
+ stopOnSettle: script.stopOnSettle ?? false,
cwd,
worktreePath: input.worktreePath,
env: { ...env, NO_COLOR: "1", FORCE_COLOR: "0" },
diff --git a/apps/server/src/provider/agentContextBudget.json b/apps/server/src/provider/agentContextBudget.json
index c94f48a61b5..0d9f26d44c4 100644
--- a/apps/server/src/provider/agentContextBudget.json
+++ b/apps/server/src/provider/agentContextBudget.json
@@ -1,5 +1,5 @@
{
"claudeSystemAppendBytes": 5366,
"codexAdditionalContextBytes": 7096,
- "mcpToolListJsonBytes": 48051
+ "mcpToolListJsonBytes": 48119
}
diff --git a/apps/server/src/terminal/Manager.test.ts b/apps/server/src/terminal/Manager.test.ts
index 7accdb95837..d89316cc749 100644
--- a/apps/server/src/terminal/Manager.test.ts
+++ b/apps/server/src/terminal/Manager.test.ts
@@ -740,34 +740,52 @@ it.layer(
}),
);
- it.effect("closes only a thread's idle shells, ignoring a helper forked from the shell", () =>
- Effect.gen(function* () {
- const { manager, ptyAdapter } = yield* createManager(5, {
- processTable: Effect.succeed([
- { pid: 9000, ppid: 1, name: "zsh" },
- { pid: 100, ppid: 9000, name: "zsh" },
- { pid: 9001, ppid: 1, name: "zsh" },
- { pid: 200, ppid: 9001, name: "node" },
- { pid: 9002, ppid: 1, name: "zsh" },
- { pid: 300, ppid: 9002, name: "zsh" },
- { pid: 301, ppid: 300, name: "sleep" },
- { pid: 9003, ppid: 1, name: "zsh" },
- ]),
- }).pipe(Effect.provide(layerWithHostPlatform("linux")));
- yield* manager.open(openInput({ terminalId: "idle" }));
- yield* manager.open(openInput({ terminalId: "dev-server" }));
- yield* manager.open(openInput({ terminalId: "subshell" }));
- yield* manager.open(openInput({ threadId: "thread-2" }));
-
- yield* manager.closeIdle({ threadId: "thread-1" });
-
- expect(ptyAdapter.processes.map((process) => process.killed)).toEqual([
- true,
- false,
- false,
- false,
- ]);
- }),
+ it.effect(
+ "closes idle shells and opted-in actions on settlement without stopping other commands",
+ () =>
+ Effect.gen(function* () {
+ const { manager, ptyAdapter } = yield* createManager(5, {
+ processTable: Effect.succeed([
+ { pid: 9000, ppid: 1, name: "zsh" },
+ { pid: 100, ppid: 9000, name: "zsh" },
+ { pid: 9001, ppid: 1, name: "zsh" },
+ { pid: 200, ppid: 9001, name: "node" },
+ { pid: 9002, ppid: 1, name: "zsh" },
+ { pid: 300, ppid: 9002, name: "zsh" },
+ { pid: 301, ppid: 300, name: "sleep" },
+ { pid: 9003, ppid: 1, name: "zsh" },
+ { pid: 9004, ppid: 1, name: "zsh" },
+ { pid: 400, ppid: 9004, name: "node" },
+ ]),
+ }).pipe(Effect.provide(layerWithHostPlatform("linux")));
+ yield* manager.open(openInput({ terminalId: "idle" }));
+ yield* manager.open(openInput({ terminalId: "dev-server" }));
+ yield* manager.open(openInput({ terminalId: "subshell" }));
+ yield* manager.open(openInput({ threadId: "thread-2", stopOnSettle: true }));
+ yield* manager.open(openInput({ terminalId: "managed-dev", stopOnSettle: true }));
+
+ yield* manager.closeIdle({ threadId: "thread-1" });
+
+ expect(ptyAdapter.processes.map((process) => process.killed)).toEqual([
+ true,
+ false,
+ false,
+ false,
+ false,
+ ]);
+ yield* manager.open(openInput({ terminalId: "managed-dev", stopOnSettle: false }));
+ yield* manager.closeOnSettle({ threadId: "thread-1" });
+ expect(ptyAdapter.processes[4]?.killed).toBe(false);
+ yield* manager.open(openInput({ terminalId: "managed-dev", stopOnSettle: true }));
+ yield* manager.closeOnSettle({ threadId: "thread-1" });
+ expect(ptyAdapter.processes.map((process) => process.killed)).toEqual([
+ true,
+ false,
+ false,
+ false,
+ true,
+ ]);
+ }),
);
it.effect("labels a running command by its whole process name, spaces included", () =>
diff --git a/apps/server/src/terminal/Manager.ts b/apps/server/src/terminal/Manager.ts
index 6a661db4e09..3ee43635f45 100644
--- a/apps/server/src/terminal/Manager.ts
+++ b/apps/server/src/terminal/Manager.ts
@@ -219,6 +219,8 @@ export class TerminalManager extends Context.Service<
/** Omit terminalId to close all sessions for the thread. */
readonly close: (input: TerminalCloseInput) => Effect.Effect<void, TerminalError>;
+ readonly closeOnSettle: (input: { readonly threadId: string }) => Effect.Effect<void>;
+
readonly closeIdle: (input: {
readonly threadId: string;
readonly terminalId?: string;
@@ -304,6 +306,7 @@ interface TerminalSessionState {
hasRunningSubprocess: boolean;
childCommandLabel: string | null;
runtimeEnv: Record<string, string> | null;
+ stopOnSettle: boolean;
}
interface TerminalGrid {
@@ -2871,6 +2874,7 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
hasRunningSubprocess: false,
childCommandLabel: null,
runtimeEnv: normalizedRuntimeEnv(input.env),
+ stopOnSettle: input.stopOnSettle ?? false,
};
const createdSession = session;
@@ -2896,6 +2900,7 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
}
const liveSession = existing.value;
+ if (input.stopOnSettle !== undefined) liveSession.stopOnSettle = input.stopOnSettle;
const nextRuntimeEnv = normalizedRuntimeEnv(input.env);
const currentRuntimeEnv = liveSession.runtimeEnv;
const targetCols = input.cols ?? liveSession.cols;
@@ -3453,6 +3458,23 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
),
);
+ const closeOnSettle = Effect.fn("terminal.closeOnSettle")(function* (input: {
+ readonly threadId: string;
+ }) {
+ yield* withThreadLock(
+ input.threadId,
+ Effect.gen(function* () {
+ const sessions = yield* sessionsForThread(input.threadId);
+ yield* Effect.forEach(
+ sessions.filter((session) => session.stopOnSettle),
+ (session) => closeSession(input.threadId, session.terminalId, false),
+ { discard: true },
+ );
+ }),
+ );
+ yield* closeIdle(input);
+ });
+
return TerminalManager.of({
open,
getShell,
@@ -3465,6 +3487,7 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
clear,
close,
closeIdle,
+ closeOnSettle,
subscribe,
subscribeMetadata,
});
diff --git a/apps/web/src/components/ProjectScriptsControl.tsx b/apps/web/src/components/ProjectScriptsControl.tsx
index 165f57fc6dd..29eaab6adf7 100644
--- a/apps/web/src/components/ProjectScriptsControl.tsx
+++ b/apps/web/src/components/ProjectScriptsControl.tsx
@@ -137,6 +137,7 @@ export default function ProjectScriptsControl({
runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false,
waitForSetup: fileScript.runOnWorktreeCreate === true && fileScript.async === false,
runOnSettle: fileScript.runOnSettle ?? false,
+ stopOnSettle: fileScript.stopOnSettle ?? false,
...(readEnvironmentScope(environmentId, AuthSettingsWriteScope) ? { keybinding: null } : {}),
previewUrl: fileScript.previewUrl ?? null,
autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false,
diff --git a/apps/web/src/components/chat/useChatTerminalActions.ts b/apps/web/src/components/chat/useChatTerminalActions.ts
index 55c2a8380da..5108b72f1af 100644
--- a/apps/web/src/components/chat/useChatTerminalActions.ts
+++ b/apps/web/src/components/chat/useChatTerminalActions.ts
@@ -218,6 +218,7 @@ export function useChatTerminalActions(input: ChatTerminalActionsInput) {
}
const targetCwd = options?.cwd ?? gitCwd ?? activeProject.workspaceRoot;
const reusableTerminalId =
+ script.stopOnSettle ||
options?.preferNewTerminal ||
!canReuseTerminal ||
!readEnvironmentScope(environmentId, AuthTerminalReadScope)
@@ -254,6 +255,7 @@ export function useChatTerminalActions(input: ChatTerminalActionsInput) {
? { size: { cols: SCRIPT_TERMINAL_COLS, rows: SCRIPT_TERMINAL_ROWS } }
: { terminalId: reusableTerminalId }),
location: { cwd: targetCwd, worktreePath: targetWorktreePath },
+ stopOnSettle: script.stopOnSettle ?? false,
...(options?.env ? { extraEnv: options.env } : {}),
});
if (!launched) return;
diff --git a/apps/web/src/components/projectScriptEditor.tsx b/apps/web/src/components/projectScriptEditor.tsx
index 8bb765ff5f7..ca3bac76a9a 100644
--- a/apps/web/src/components/projectScriptEditor.tsx
+++ b/apps/web/src/components/projectScriptEditor.tsx
@@ -85,6 +85,7 @@ export interface NewProjectScriptInput {
runOnWorktreeCreate: boolean;
waitForSetup: boolean;
runOnSettle: boolean;
+ stopOnSettle?: boolean;
/** Omit to preserve the current shortcut when the form did not edit it. */
keybinding?: string | null;
previewUrl: string | null;
@@ -100,6 +101,7 @@ export const EMPTY_PROJECT_SCRIPT_INPUT: NewProjectScriptInput = {
runOnWorktreeCreate: false,
waitForSetup: false,
runOnSettle: false,
+ stopOnSettle: false,
keybinding: null,
previewUrl: null,
autoOpenPreview: false,
@@ -124,6 +126,7 @@ export function editorRequestForScript(
runOnWorktreeCreate: script.runOnWorktreeCreate,
waitForSetup: script.runOnWorktreeCreate && script.async === false,
runOnSettle: script.runOnSettle ?? false,
+ stopOnSettle: script.stopOnSettle ?? false,
keybinding: keybindingValueForCommand(keybindings, commandForProjectScript(script.id)),
previewUrl: script.previewUrl ?? null,
autoOpenPreview: script.autoOpenPreview ?? false,
@@ -275,6 +278,7 @@ function ProjectScriptEditorForm({
);
const [waitForSetup, setWaitForSetup] = useState(request.initial.waitForSetup);
const [runOnSettle, setRunOnSettle] = useState(request.initial.runOnSettle);
+ const [stopOnSettle, setStopOnSettle] = useState(request.initial.stopOnSettle ?? false);
const [keybinding, setKeybinding] = useState(request.initial.keybinding ?? "");
const [previewUrl, setPreviewUrl] = useState(request.initial.previewUrl ?? "");
const [autoOpenPreview, setAutoOpenPreview] = useState(request.initial.autoOpenPreview);
@@ -359,6 +363,7 @@ function ProjectScriptEditorForm({
runOnWorktreeCreate,
waitForSetup: runOnWorktreeCreate && waitForSetup,
runOnSettle,
+ stopOnSettle,
...((request.scriptId === null && canChangeKeybinding) || changesKeybinding
? { keybinding: keybindingRule?.key ?? null }
: {}),
@@ -521,6 +526,13 @@ function ProjectScriptEditorForm({
onCheckedChange={(checked) => setRunOnSettle(Boolean(checked))}
/>
</label>
+ <label className="flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035]">
+ <span>Stop this action when the thread settles</span>
+ <Switch
+ checked={stopOnSettle}
+ onCheckedChange={(checked) => setStopOnSettle(Boolean(checked))}
+ />
+ </label>
<label
className={`flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035] ${
previewUrl.trim().length === 0 ? "opacity-60" : ""
diff --git a/apps/web/src/components/settings/ProjectActionsSettings.tsx b/apps/web/src/components/settings/ProjectActionsSettings.tsx
index dd2d75f0c72..b0d10d9df38 100644
--- a/apps/web/src/components/settings/ProjectActionsSettings.tsx
+++ b/apps/web/src/components/settings/ProjectActionsSettings.tsx
@@ -91,6 +91,7 @@ export function ProjectActionsSettings() {
runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false,
waitForSetup: fileScript.runOnWorktreeCreate === true && fileScript.async === false,
runOnSettle: fileScript.runOnSettle ?? false,
+ stopOnSettle: fileScript.stopOnSettle ?? false,
keybinding: null,
previewUrl: fileScript.previewUrl ?? null,
autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false,
diff --git a/apps/web/src/components/terminal/useThreadTerminalActions.ts b/apps/web/src/components/terminal/useThreadTerminalActions.ts
index 6fb18cc6208..9112f415197 100644
--- a/apps/web/src/components/terminal/useThreadTerminalActions.ts
+++ b/apps/web/src/components/terminal/useThreadTerminalActions.ts
@@ -87,6 +87,7 @@ export function useThreadTerminalActions(threadRef: ScopedThreadRef | null) {
readonly terminalId?: string;
readonly location?: TerminalLaunchLocation | null;
readonly extraEnv?: Record<string, string>;
+ readonly stopOnSettle?: boolean;
readonly size?: { readonly cols: number; readonly rows: number };
}) => {
if (!threadRef || !canWrite() || !project) return null;
@@ -107,6 +108,7 @@ export function useThreadTerminalActions(threadRef: ScopedThreadRef | null) {
...(input.extraEnv ? { extraEnv: input.extraEnv } : {}),
}),
...input.size,
+ ...(input.stopOnSettle !== undefined ? { stopOnSettle: input.stopOnSettle } : {}),
},
});
return { terminalId, result };
diff --git a/apps/web/src/projectScripts.ts b/apps/web/src/projectScripts.ts
index dffdb0337d5..516692f6290 100644
--- a/apps/web/src/projectScripts.ts
+++ b/apps/web/src/projectScripts.ts
@@ -14,6 +14,7 @@ export interface ProjectScriptInput {
readonly runOnWorktreeCreate: ProjectScript["runOnWorktreeCreate"];
readonly waitForSetup: boolean;
readonly runOnSettle: boolean;
+ readonly stopOnSettle?: boolean;
readonly previewUrl: Exclude<ProjectScript["previewUrl"], undefined> | null;
readonly autoOpenPreview: boolean;
}
@@ -27,6 +28,7 @@ export function buildProjectScript(id: string, input: ProjectScriptInput): Proje
runOnWorktreeCreate: input.runOnWorktreeCreate,
...(input.runOnWorktreeCreate && input.waitForSetup ? { async: false } : {}),
...(input.runOnSettle ? { runOnSettle: true } : {}),
+ ...(input.stopOnSettle ? { stopOnSettle: true } : {}),
...(input.previewUrl === null
? {}
: {
diff --git a/docs/operations/development.md b/docs/operations/development.md
index 0d6db641b16..74ac4b50fc3 100644
--- a/docs/operations/development.md
+++ b/docs/operations/development.md
@@ -57,6 +57,11 @@ See the [mobile README](../../apps/mobile/README.md) for native builds and Metro
Flags go directly after the task name, for example `vp run dev --home-dir /tmp/t3code-dev`.
Add `--browser` to open a browser automatically.
+To stop a worktree's dev stack when its thread settles, import the **Dev** action from
+`t3.json` in Settings > Projects > Actions and start it through the action menu or its
+keybinding. Its `stopOnSettle` option lets T3 stop the terminal and its child processes.
+Running `vp run dev` through an agent's own shell tool does not attach it to this lifecycle.
+
### State and ports
Linked worktrees default to their own `.t3/userdata`, even when `T3CODE_HOME` is set.
diff --git a/docs/user/thread-sidebar.md b/docs/user/thread-sidebar.md
index 4829fa3c6b7..25095b70f1c 100644
--- a/docs/user/thread-sidebar.md
+++ b/docs/user/thread-sidebar.md
@@ -167,7 +167,11 @@ and prevents automatic settlement until new activity resumes the usual rules.
Manually settling an idle thread dismisses unanswered async questions without
sending an answer or restarting the agent. Settling also closes the thread's
terminals that wait at an idle prompt, and keeps their output. A terminal that
-runs a command, such as a dev server, stays open.
+runs a command, such as a dev server, stays open unless its action has **Stop this action
+when the thread settles** enabled in Settings > Projects > Actions. You can also set
+`"stopOnSettle": true` on a `t3.json` action and import it there. Start the command through
+that action so T3 can stop its terminal and child processes. Commands started through an
+agent's own shell tools are managed by the provider.
To reclaim disk space from settled work, turn on **Run in the thread's worktree when the
thread settles** for one of the project's actions, or set `"runOnSettle": true` on a
diff --git a/packages/contracts/src/project.ts b/packages/contracts/src/project.ts
index 39696c62e4c..b987d073cdf 100644
--- a/packages/contracts/src/project.ts
+++ b/packages/contracts/src/project.ts
@@ -38,6 +38,7 @@ export const ProjectScript = Schema.Struct({
icon: ProjectScriptIcon,
runOnWorktreeCreate: Schema.Boolean,
runOnSettle: Schema.optional(Schema.Boolean),
+ stopOnSettle: Schema.optional(Schema.Boolean),
async: Schema.optional(Schema.Boolean),
previewUrl: Schema.optional(TrimmedNonEmptyString),
autoOpenPreview: Schema.optional(Schema.Boolean),
diff --git a/packages/contracts/src/t3ProjectFile.ts b/packages/contracts/src/t3ProjectFile.ts
index e89db9db958..2bed72cc5a2 100644
--- a/packages/contracts/src/t3ProjectFile.ts
+++ b/packages/contracts/src/t3ProjectFile.ts
@@ -46,6 +46,12 @@ export const T3ProjectFileScript = Schema.Struct({
"When true, the script runs in the thread's worktree each time the thread settles, for example to delete build output. Threads without their own worktree skip it.",
}),
),
+ stopOnSettle: Schema.optionalKey(
+ Schema.Boolean.annotate({
+ description:
+ "When true, T3 stops this action's terminal and child processes when its thread settles.",
+ }),
+ ),
async: Schema.optionalKey(
Schema.Boolean.annotate({
description:
diff --git a/packages/contracts/src/terminal.ts b/packages/contracts/src/terminal.ts
index 717727d8932..8731d6ec25c 100644
--- a/packages/contracts/src/terminal.ts
+++ b/packages/contracts/src/terminal.ts
@@ -41,6 +41,7 @@ export const TerminalOpenInput = Schema.Struct({
rows: Schema.optional(TerminalRowsSchema),
env: Schema.optional(TerminalEnvSchema),
providerInstanceId: Schema.optional(ProviderInstanceId),
+ stopOnSettle: Schema.optional(Schema.Boolean),
});
export type TerminalOpenInput = typeof TerminalOpenInput.Type;
@@ -52,6 +53,7 @@ export const TerminalAttachInput = Schema.Struct({
rows: Schema.optional(TerminalRowsSchema),
env: Schema.optional(TerminalEnvSchema),
providerInstanceId: Schema.optional(ProviderInstanceId),
+ stopOnSettle: Schema.optional(Schema.Boolean),
restartIfNotRunning: Schema.optional(Schema.Boolean),
// Resubscriptions preserve stopped terminals; unknown IDs recover after a server restart.
resume: Schema.optional(Schema.Boolean),
diff --git a/packages/shared/src/t3ProjectFile.test.ts b/packages/shared/src/t3ProjectFile.test.ts
index d2f3a70e94b..d75f94e1049 100644
--- a/packages/shared/src/t3ProjectFile.test.ts
+++ b/packages/shared/src/t3ProjectFile.test.ts
@@ -11,12 +11,12 @@ describe("T3ProjectFileFromJson", () => {
// team scripts
"iconPath": "assets/logo.svg",
"scripts": [
- { "name": "Dev", "command": "pnpm dev", },
+ { "name": "Dev", "command": "pnpm dev", "stopOnSettle": true, },
],
}`);
expect(decoded.iconPath).toBe("assets/logo.svg");
- expect(decoded.scripts?.[0]).toEqual({ name: "Dev", command: "pnpm dev" });
+ expect(decoded.scripts?.[0]).toEqual({ name: "Dev", command: "pnpm dev", stopOnSettle: true });
});
});
diff --git a/t3.json b/t3.json
index d2c55e05077..959600ea27e 100644
--- a/t3.json
+++ b/t3.json
@@ -2,6 +2,12 @@
"$schema": "https://t3.codes/schema/t3.json",
"iconPath": "assets/dev/blueprint-web-apple-touch-180.png",
"scripts": [
+ {
+ "name": "Dev",
+ "command": "vp run dev",
+ "icon": "play",
+ "stopOnSettle": true
+ },
{
"name": "Setup Worktree",
"command": "node scripts/setup-worktree.ts",