fix(workspace): a new tab shows in its workspace; a row opens its tabs

A tab opened bare from + had no session row until its first hook, and
the sidebar re-read its live panes only when a workspace's status or
session moved, which a tab in slots 1-3 never does: the new tab showed
nowhere. The sidebar now lists a live AI tab whose session has no row
yet as "New session" straight from the run (its session id is known
from the start) and follows the Workspace page's own run-list poll
(LIVE_RUNS_EVENT).

A sidebar workspace row now opens the workspace's live tabs on the pane
it last focused, and its home only when it has none; a Home button at
the left end of the tab bar reaches the home of a workspace whose tabs
keep running.
This commit is contained in:
2026-10-03 16:05:15 +07:00
parent 326dfa9d19
commit 8098f446b6
10 changed files with 205 additions and 21 deletions
+9
View File
@@ -75,6 +75,7 @@ import {
} from "../lib/paneLayout";
import { useAiTools } from "../hooks/useAiTools";
import { freeSlot } from "../components/lanes/WorkspaceHome";
import { LIVE_RUNS_EVENT } from "../components/WorkspaceTree";
import PipelineMap from "../components/lanes/PipelineMap";
import LaneCard, { since, LaneToolsMenu } from "../components/lanes/LaneCard";
import { AddLaneModal } from "../components/lanes/AddLaneModal";
@@ -325,6 +326,7 @@ function ConsoleArea({
onOpenRun(runId, { split });
}}
onClosed={(runId) => ended(slotOf(runId))}
onHome={onNewSession}
// Per-workspace actions (mcp sync, sync-base check, readme).
actions={<LaneToolsMenu lane={lane} />}
/>
@@ -558,6 +560,13 @@ export function Workspace() {
.catch(() => undefined);
}, []);
// The sidebar's live panes follow this page's poll: a tab in slots 1–3
// moves no lane column, so the sidebar would not re-read on its own.
useEffect(() => {
if (activeRuns)
window.dispatchEvent(new CustomEvent(LIVE_RUNS_EVENT, { detail: activeRuns.items }));
}, [activeRuns]);
// Background poll so the run list and history reflect external changes
// (server-boot reconciliation, sibling tabs, direct DB edits) even when
// no WS event fires. Lighter than typical WS gaps; aggressive enough that
@@ -856,6 +856,16 @@ describe("split panes", () => {
expect(screen.getByTestId("pane-split-new-right-1")).toBeDisabled();
});
it("the tab bar's Home button opens the workspace home, keeping the tabs", async () => {
withRuns([live(0), live(1)]);
await open("/workspace?lane=1&run=agenthub-lane-1");
await userEvent.setup().click(screen.getByTestId("console-home"));
await settle();
expect(screen.getByTestId("run-param").textContent).toBe("");
expect(screen.getByTestId("workspace-home")).toBeInTheDocument();
expect(api.run.kill).not.toHaveBeenCalled();
});
it("a divider resizes by keyboard", async () => {
withRuns([live(0), live(1)]);
await open("/workspace?lane=1&run=agenthub-lane-1");