Files
kandev/apps/web/components/task/terminal-panel.tsx
T
José Almeida 9d275d3009 refactor: route user terminals by environment (#758)
* refactor: route user terminals by environment

* refactor: remove terminal compatibility shims

* fix: address terminal PR review feedback

* fix: wait for remote shell readiness

* fix: require agent mode for session terminals
2026-05-01 13:27:25 +01:00

53 lines
1.8 KiB
TypeScript

"use client";
import { memo } from "react";
import { PanelRoot, PanelBody } from "./panel-primitives";
import { PassthroughTerminal } from "./passthrough-terminal";
import { ShellTerminal } from "./shell-terminal";
import { useAppStore } from "@/components/state-provider";
import { useIsTaskArchived, ArchivedPanelPlaceholder } from "./task-archived-context";
import { useEnvironmentId } from "@/hooks/use-environment-session-id";
type TerminalPanelProps = {
panelId: string;
params: Record<string, unknown>;
};
export const TerminalPanel = memo(function TerminalPanel({ params }: TerminalPanelProps) {
const terminalId = params.terminalId as string;
const type = (params.type as string) ?? "shell";
const processId = params.processId as string | undefined;
const environmentId = useEnvironmentId();
const devOutput = useAppStore((state) =>
processId ? (state.processes.outputsByProcessId[processId] ?? "") : "",
);
const devProcess = useAppStore((state) =>
processId ? state.processes.processesById[processId] : undefined,
);
const isStopping = devProcess?.status === "stopping";
const isArchived = useIsTaskArchived();
if (isArchived)
return <ArchivedPanelPlaceholder message="Terminal not available — this task is archived" />;
if (type === "dev-server" && processId) {
return (
<PanelRoot data-testid="terminal-panel">
<PanelBody padding={false} scroll={false}>
<ShellTerminal processOutput={devOutput} processId={processId} isStopping={isStopping} />
</PanelBody>
</PanelRoot>
);
}
return (
<PanelRoot data-testid="terminal-panel">
<PanelBody padding={false} scroll={false}>
<PassthroughTerminal mode="shell" environmentId={environmentId} terminalId={terminalId} />
</PanelBody>
</PanelRoot>
);
});