22 lines
894 B
TypeScript
22 lines
894 B
TypeScript
import type { ScopedThreadRef } from "@t3tools/contracts";
|
|
|
|
import { selectThreadRightPanelState, useRightPanelStore } from "../rightPanelStore";
|
|
import { useTerminalUiStateStore } from "../terminalUiStateStore";
|
|
|
|
/** Reveal an existing terminal in the panel that owns it, without opening another PTY. */
|
|
export function revealThreadTerminal(threadRef: ScopedThreadRef, terminalId: string) {
|
|
const panels = useRightPanelStore.getState();
|
|
const surface = selectThreadRightPanelState(panels.byThreadKey, threadRef).surfaces.find(
|
|
(surface) => surface.kind === "terminal" && surface.terminalIds.includes(terminalId),
|
|
);
|
|
if (surface) {
|
|
panels.activateTerminal(threadRef, surface.id, terminalId);
|
|
panels.activateSurface(threadRef, surface.id);
|
|
return;
|
|
}
|
|
useTerminalUiStateStore.getState().ensureTerminal(threadRef, terminalId, {
|
|
open: true,
|
|
active: true,
|
|
});
|
|
}
|