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
+18 -3
View File
@@ -8,8 +8,8 @@
* tool started bare on its default model, no prompt (a prompt, router or
* worktree is still the workspace home's prompt box) — plus a link to
* Settings → Agents. Four tabs is the server's limit (`MAX_PANE_SLOT`). The
* bar is the console's only header; `actions` (the workspace's Tools menu)
* sits at its right end. A click shows a tab in the focused pane, Ctrl/Cmd+click
* bar is the console's only header: Home (the workspace's home) at its left
* end, `actions` (the workspace's Tools menu) at its right end. A click shows a tab in the focused pane, Ctrl/Cmd+click
* (on a tab or a `+` item) opens it in a split to the right, and a tab drags
* onto the panes (`PaneGrid.tsx`); a tab another pane shows is marked.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
@@ -18,7 +18,7 @@
import { useEffect, useRef, useState, type ReactNode } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { Plus, Settings2, SquareTerminal, X } from "lucide-react";
import { House, Plus, Settings2, SquareTerminal, X } from "lucide-react";
import { api } from "../../lib/api";
import type { RunHandle } from "../../lib/api";
import type { Lane } from "../../lib/types";
@@ -34,6 +34,7 @@ export function ConsoleTabs({
shownRunIds = [],
onOpen,
onClosed,
onHome,
actions,
}: {
lane: Lane;
@@ -47,6 +48,8 @@ export function ConsoleTabs({
onOpen: (runId: string, split?: boolean) => void;
/** A tab's session was stopped. */
onClosed: (runId: string) => void;
/** The workspace's home (its prompt box, Recents, context). */
onHome?: () => void;
/** Right end of the bar (the workspace's Tools menu). */
actions?: ReactNode;
}) {
@@ -108,6 +111,18 @@ export function ConsoleTabs({
return (
<div className="flex h-10 shrink-0 items-stretch border-b border-border bg-surface-1">
{onHome && (
<button
type="button"
data-testid="console-home"
onClick={onHome}
title={t("tabs.home")}
aria-label={t("tabs.home")}
className="flex w-10 shrink-0 items-center justify-center border-r border-border text-fg-muted hover:bg-surface-4 hover:text-fg-primary"
>
<House className="h-4 w-4" />
</button>
)}
<div role="tablist" aria-label={t("tabs.label")} className="flex min-w-0 items-stretch">
{tabs.map((r) => {
const active = r.id === activeRunId;