Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor(web): open and close thread terminals through one hook #20289

Mergedjuliusmarmingemerged 1 commit intochatview-split/terminal-components fromrefs/pull/20289/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 162 additions and 0 deletions (loading 2).

x
0 of 3 viewed, 3 left
162 additions and 0 deletionsapps/web/src/components/terminal/useThreadTerminalActions.tsAdded
View file
@@ -0,0 +1,162 @@
+import {
+ AuthTerminalOperateScope,
+ AuthTerminalReadScope,
+ type ScopedThreadRef,
+} from "@t3tools/contracts";
+import { scopeProjectRef } from "@t3tools/client-runtime/environment";
+import { isAtomCommandInterrupted } from "@t3tools/client-runtime/state/runtime";
+import { projectScriptCwd, projectScriptRuntimeEnv } from "@t3tools/shared/projectScripts";
+import { nextTerminalId } from "@t3tools/shared/terminalLabels";
+import { useComposerDraftStore } from "../../composerDraftStore";
+import { useStableCallback } from "../../hooks/useStableCallback";
+import { randomUUID } from "~/lib/utils";
+import { selectThreadRightPanelState, useRightPanelStore } from "../../rightPanelStore";
+import { useProject, useThreadShell } from "../../state/entities";
+import { readEnvironmentScope } from "../../state/session";
+import { terminalEnvironment } from "../../state/terminal";
+import { useKnownTerminalSessions } from "../../state/terminalSessions";
+import { useAtomCommand } from "../../state/use-atom-command";
+import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../../terminalUiStateStore";
+​
+/** Where a new terminal starts. Omitted fields fall back to the thread's project and worktree. */
+export interface TerminalLaunchLocation {
+ readonly cwd: string;
+ readonly worktreePath: string | null;
+}
+​
+/**
+ * Opens and closes a thread's terminal sessions. Every surface that hosts a
+ * terminal (the drawer, a right panel tab, the setup flow, script runs) goes
+ * through here, so ids are allocated from one view of the thread's terminals