Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

revealThreadTerminal.ts

20 lines803 Bytes

1import type { ScopedThreadRef } from "@t3tools/contracts";
2​
3import { selectThreadRightPanelState, useRightPanelStore } from "../rightPanelStore";
4import { useTerminalUiStateStore } from "../terminalUiStateStore";
5​
6export function revealThreadTerminal(threadRef: ScopedThreadRef, terminalId: string) {
7 const panels = useRightPanelStore.getState();
8 const surface = selectThreadRightPanelState(panels.byThreadKey, threadRef).surfaces.find(
9 (surface) => surface.kind === "terminal" && surface.terminalIds.includes(terminalId),
10 );
11 if (surface) {
12 panels.activateTerminal(threadRef, surface.id, terminalId);
13 panels.activateSurface(threadRef, surface.id);
14 return;
15 }
16 useTerminalUiStateStore.getState().ensureTerminal(threadRef, terminalId, {
17 open: true,
18 active: true,
19 });