Open History to see the last commit
1export function resolveTerminalRouteBootstrap(input: {
2 readonly hasThread: boolean;
3 readonly hasWorkspaceRoot: boolean;
4 readonly hasOpened: boolean;
5 readonly requestedTerminalId: string | null;
6 readonly currentTerminalId: string;
7 readonly runningTerminalId: string | null;
8 readonly currentTerminalStatus: "starting" | "running" | "exited" | "error" | "closed";
9 /** True once the attach stream has populated scrollback (`buffer` non-empty), not merely metadata. */
10 readonly hasCurrentTerminalHydration: boolean;
11}):
12 | { readonly kind: "idle" }
13 | { readonly kind: "redirect"; readonly terminalId: string }
14 | { readonly kind: "open" } {
15 if (!input.hasThread || !input.hasWorkspaceRoot || input.hasOpened) {
16 return { kind: "idle" };
17 }
18
19 if (
20 input.requestedTerminalId === null &&
21 input.runningTerminalId !== null &&
22 input.runningTerminalId !== input.currentTerminalId
23 ) {
24 return { kind: "redirect", terminalId: input.runningTerminalId };
25 }
26
27 if (
28 (input.currentTerminalStatus === "running" || input.currentTerminalStatus === "starting") &&
29 input.hasCurrentTerminalHydration
30 ) {
31 return { kind: "idle" };
32 }
33
34 return { kind: "open" };
35}