The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type { ScopedThreadRef } from "@t3tools/contracts"; |
| 2 | |
| 3 | import { selectThreadRightPanelState, useRightPanelStore } from "../rightPanelStore"; |
| 4 | import { useTerminalUiStateStore } from "../terminalUiStateStore"; |
| 5 | import { focusTerminalOnNavigation } from "./terminalFocus"; |
| 6 | |
| 7 | export function revealThreadTerminal(threadRef: ScopedThreadRef, terminalId: string) { |
| 8 | const panels = useRightPanelStore.getState(); |
| 9 | const surface = selectThreadRightPanelState(panels.byThreadKey, threadRef).surfaces.find( |
| 10 | (surface) => surface.kind === "terminal" && surface.terminalIds.includes(terminalId), |
| 11 | ); |
| 12 | if (surface) { |
| 13 | panels.activateTerminal(threadRef, surface.id, terminalId); |
| 14 | panels.activateSurface(threadRef, surface.id); |
| 15 | focusTerminalOnNavigation(threadRef, terminalId); |
| 16 | return; |
| 17 | } |
| 18 | useTerminalUiStateStore.getState().ensureTerminal(threadRef, terminalId, { |
| 19 | open: true, |
| 20 | active: true, |
| 21 | }); |
| 22 | focusTerminalOnNavigation(threadRef, terminalId); |
| 23 | } |