fix(client): clean up leftover pre-TerminalView dead code and type errors in Workspace.tsx
`npm run test:client` (Vitest/esbuild) doesn't type-check, so several tasks' incomplete cleanup of the old RunConsole-era code in Workspace.tsx (SlashCommand/BUILTIN_SLASH_COMMANDS references, old RunStatus values, a stray `mode` field, a wrong `prompt` vs `initialPrompt` key) went unnoticed through every review until `tsc --noEmit` was run directly. Also fixes a stale `RunStatusPayload.exitCode` read in Tabby's brain.ts and dangling RunStreamPayload/RunInputAckPayload references left in types.ts.
This commit is contained in:
@@ -167,26 +167,11 @@ describe("reduceTabby counts and pulses", () => {
|
||||
expect(ok.state.worriedUntil).toBe(0);
|
||||
});
|
||||
|
||||
it("run_status completed exit 0 is happy, nonzero/error/killed is worried", () => {
|
||||
const good = reduceTabby(
|
||||
initialTabbyState(T0),
|
||||
runStatusMsg({ status: "completed", exitCode: 0 }),
|
||||
T0
|
||||
);
|
||||
expect(good.pulse).toBe("run_done");
|
||||
expect(deriveMood(good.state, T0)).toBe("happy");
|
||||
const bad = reduceTabby(
|
||||
initialTabbyState(T0),
|
||||
runStatusMsg({ status: "completed", exitCode: 1 }),
|
||||
T0
|
||||
);
|
||||
expect(bad.pulse).toBe("error");
|
||||
const err = reduceTabby(initialTabbyState(T0), runStatusMsg({ status: "error" }), T0);
|
||||
expect(err.pulse).toBe("error");
|
||||
const killed = reduceTabby(initialTabbyState(T0), runStatusMsg({ status: "killed" }), T0);
|
||||
expect(killed.pulse).toBe("error");
|
||||
it("run_status updates activity timestamp only (no exit code available)", () => {
|
||||
const running = reduceTabby(initialTabbyState(T0), runStatusMsg({ status: "running" }), T0);
|
||||
expect(running.pulse).toBe(null);
|
||||
const gone = reduceTabby(initialTabbyState(T0), runStatusMsg({ status: "gone" }), T0);
|
||||
expect(gone.pulse).toBe(null);
|
||||
});
|
||||
|
||||
it("any handled message refreshes lastActivityAt", () => {
|
||||
|
||||
@@ -340,25 +340,7 @@ export function reduceTabby(
|
||||
case "run_status": {
|
||||
const r = msg.data as RunStatusPayload;
|
||||
if (!r) return { state, pulse: null };
|
||||
// A run that finished cleanly (exit 0, or no exit code reported) → happy.
|
||||
if (r.status === "completed" && (r.exitCode == null || r.exitCode === 0)) {
|
||||
return {
|
||||
state: { ...state, happyUntil: now + HAPPY_MS, lastActivityAt: now },
|
||||
pulse: "run_done",
|
||||
};
|
||||
}
|
||||
// Errored, killed, or completed with a nonzero exit code → worried.
|
||||
if (
|
||||
r.status === "error" ||
|
||||
r.status === "killed" ||
|
||||
(r.status === "completed" && r.exitCode != null && r.exitCode !== 0)
|
||||
) {
|
||||
return {
|
||||
state: { ...state, worriedUntil: now + WORRIED_MS, lastActivityAt: now },
|
||||
pulse: "error",
|
||||
};
|
||||
}
|
||||
// spawning / running → activity only.
|
||||
// running / gone → activity only (no exit code to distinguish success/failure).
|
||||
return { state: { ...state, lastActivityAt: now }, pulse: null };
|
||||
}
|
||||
|
||||
|
||||
@@ -64,12 +64,12 @@ describe("TerminalView", () => {
|
||||
it("opens a WS connection to the run's ws-pty path", () => {
|
||||
render(<TerminalView runId="ccam-lane-1" wsBaseUrl="ws://localhost:4820" />);
|
||||
expect(MockWebSocket.instances).toHaveLength(1);
|
||||
expect(MockWebSocket.instances[0].url).toBe("ws://localhost:4820/ws-pty/ccam-lane-1");
|
||||
expect(MockWebSocket.instances[0]!.url).toBe("ws://localhost:4820/ws-pty/ccam-lane-1");
|
||||
});
|
||||
|
||||
it("writes incoming WS data to the terminal", () => {
|
||||
render(<TerminalView runId="ccam-lane-1" wsBaseUrl="ws://localhost:4820" />);
|
||||
const ws = MockWebSocket.instances[0];
|
||||
const ws = MockWebSocket.instances[0]!;
|
||||
ws.onopen?.();
|
||||
ws.onmessage?.({ data: "hello" });
|
||||
expect(writeMock).toHaveBeenCalledWith("hello");
|
||||
@@ -77,8 +77,8 @@ describe("TerminalView", () => {
|
||||
|
||||
it("forwards terminal keystrokes as outgoing WS sends", () => {
|
||||
render(<TerminalView runId="ccam-lane-1" wsBaseUrl="ws://localhost:4820" />);
|
||||
const ws = MockWebSocket.instances[0];
|
||||
onDataHandlers[0]("ls -la\r");
|
||||
const ws = MockWebSocket.instances[0]!;
|
||||
onDataHandlers[0]!("ls -la\r");
|
||||
expect(ws.sent).toEqual(["ls -la\r"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user