feat: workspaces own their sessions; desktop parity; sidebar and settings cleanup

Workspace sessions (docs/plans/desktop-parity, phases 1-5 and 7):
- sessions.lane_id: a workspace lists only the sessions its panes held,
  stamped by bindRunSession (first writer wins, nested `claude -p`
  excluded); GET /api/sessions?lane=&archived=
- session row state dot, double-click rename, archive (sessions.archived_at,
  hides only); the activity bar's duplicate Sessions tab removed
- Fork beside Resume (--fork-session, Claude only), Ctrl/Cmd+click a live
  session opens it in a second pane, a diff line's comment is pasted into
  the workspace's last-focused pane (lib/panePaste.ts)

dashboard_runs stability:
- a pane's previous run is archived as <pane>@<started_at> instead of being
  overwritten by INSERT OR REPLACE
- a run is flagged abandoned only once its tmux session is gone, at boot and
  on the run-heal beat (panes outlive a server restart)

UI:
- sidebar: no footer, language or theme block; small collapse button in the
  brand corner; version + update check in the connection details modal, a
  status-bar dot while a release is out; language in Settings -> General
- one Switch component for every switch, the themed Checkbox for every
  checkbox (no native checkboxes)

Also: AI Tools catalog trimmed to 10 built-ins (custom-file prompt modes
tested through fixtures), and the workspace plans under docs/plans/ (the
multi-user server plan lives in the AgentHub-Server repo).
This commit is contained in:
2026-10-02 12:05:00 +07:00
parent 5b269698f6
commit a6bd33bcff
121 changed files with 2699 additions and 1552 deletions
@@ -86,10 +86,6 @@ export interface LaneConsolePaneProps {
hiddenRunIds?: string[];
/** Reports the run this pane shows (null on the setup form). */
onHandleChange?: (runId: string | null) => void;
/** A session to resume in this pane, from the Workspace's Sessions tab. A new
* `nonce` is a new request; it goes through the same path as a resume from
* the run history, live-run fallback included. */
resumeRequest?: { sessionId: string; model: string | null; nonce: number } | null;
/** A live run to show in this pane (a session picked in the sidebar). It
* attaches to that tmux session only — nothing is started or resumed. */
attachRequest?: { runId: string; nonce: string } | null;
@@ -116,7 +112,6 @@ export function LaneConsolePane({
slot = 0,
hiddenRunIds,
onHandleChange,
resumeRequest,
attachRequest,
}: LaneConsolePaneProps) {
const { t } = useTranslation("run");
@@ -492,23 +487,6 @@ export function LaneConsolePane({
[busy, refreshList, t, lanes, slot, onLaneCreated, onLaneIdChange, attachToRun]
);
const resumeRef = useRef(onResumeFromHistory);
resumeRef.current = onResumeFromHistory;
useEffect(() => {
const lane = latest.current.lanes.find((l) => l.id === laneId);
if (!resumeRequest || !lane) return;
void resumeRef.current({
session_id: resumeRequest.sessionId,
cwd: lane.cwd,
tool: lane.tool,
model: resumeRequest.model,
permission_mode: null,
effort: null,
} as DashboardRunHistoryItem);
// Only a new request (nonce) resumes; a lane switch never replays one.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [resumeRequest?.nonce]);
const onViewFromHistory = useCallback(
(item: DashboardRunHistoryItem) => {
if (item.session_id) void onResumeFromHistory(item);
+8 -9
View File
@@ -26,6 +26,7 @@
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
import { Checkbox } from "../Checkbox";
import { useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import {
@@ -577,15 +578,13 @@ export function RunSetup(props: RunSetupProps) {
{canBypass && (
<div className="px-4 pb-3">
<label className="inline-flex items-center gap-2 text-[11.5px] text-status-danger cursor-pointer">
<input
type="checkbox"
checked={bypass}
onChange={(e) => setBypass(e.target.checked)}
className="accent-[rgb(var(--status-danger))]"
/>
{t("fields.bypass")}
</label>
<Checkbox
tone="danger"
checked={bypass}
onChange={setBypass}
label={t("fields.bypass")}
labelClassName="text-[11.5px] text-status-danger"
/>
{bypass && (
<div className="mt-2 rounded-md border border-status-danger/40 bg-status-danger/10 px-3 py-2 text-[11px] text-status-danger flex items-start gap-2">
<ShieldAlert className="w-3.5 h-3.5 flex-shrink-0 mt-0.5" />
+15 -1
View File
@@ -13,7 +13,9 @@
* (`lib/terminalTheme.ts`), recoloured live without re-attaching.
* An image dropped on it is saved on the server (`POST /api/run/drop-image`)
* and its PATH pasted into the pane — what a local terminal does on a drop,
* and how `claude` attaches an image.
* and how `claude` attaches an image. The pane also registers with
* `lib/panePaste.ts`, so a diff-line comment from the Changes panel can be
* pasted into whichever of the workspace's panes was focused last.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
import { useEffect, useMemo, useRef, useState, type DragEvent } from "react";
@@ -25,6 +27,7 @@ import "@xterm/xterm/css/xterm.css";
import { useTheme } from "../../hooks/useTheme";
import { terminalThemeFor } from "../../lib/terminalTheme";
import { api } from "../../lib/api";
import { notePaneFocus, registerPane } from "../../lib/panePaste";
type DropState = "hint" | "uploading" | "failed" | "imagesOnly";
const hasFiles = (e: DragEvent) => Array.from(e.dataTransfer.types).includes("Files");
@@ -291,6 +294,16 @@ export function TerminalView({ runId, wsBaseUrl, onExit }: TerminalViewProps) {
if (termRef.current) termRef.current.options.theme = palette;
}, [palette]);
// Other parts of the page (a diff-line comment) paste into this pane.
useEffect(
() =>
registerPane(runId, (text) => {
termRef.current?.paste(text);
termRef.current?.focus();
}),
[runId]
);
return (
<div
className="relative h-full w-full"
@@ -311,6 +324,7 @@ export function TerminalView({ runId, wsBaseUrl, onExit }: TerminalViewProps) {
if (dragDepth.current === 0) setDrop((d) => (d === "hint" ? null : d));
}}
onDrop={(e) => void onDrop(e)}
onFocus={() => notePaneFocus(runId)}
>
<div
ref={containerRef}
@@ -484,49 +484,6 @@ describe("LaneConsolePane", () => {
});
});
it("resumes a session handed over by the Sessions tab, once per request", async () => {
(api.lanes.action as ReturnType<typeof vi.fn>).mockResolvedValue({ run_id: "agenthub-lane-1" });
(api.run.get as ReturnType<typeof vi.fn>).mockResolvedValue({
id: "agenthub-lane-1",
laneId: 1,
status: "running",
cwd: "/workspace/a",
model: null,
permissionMode: null,
effort: null,
resumeSessionId: "s-1",
sessionId: null,
startedAt: null,
promptPreview: null,
});
const request = { sessionId: "s-1", model: "claude-opus-5-5", nonce: 1 };
const { rerender } = render(
<MemoryRouter>
<LaneConsolePane {...baseProps()} resumeRequest={request} />
</MemoryRouter>
);
await waitFor(() =>
expect(api.lanes.action).toHaveBeenCalledWith(
1,
"start",
expect.objectContaining({
slot: 0,
prompt: "",
resumeSessionId: "s-1",
model: "claude-opus-5-5",
})
)
);
// A re-render with the same request is not a second resume.
rerender(
<MemoryRouter>
<LaneConsolePane {...baseProps()} resumeRequest={{ ...request }} />
</MemoryRouter>
);
await screen.findByTestId("terminal-view");
expect(api.lanes.action).toHaveBeenCalledTimes(1);
});
it("attaches to a run picked in the sidebar without starting or resuming anything", async () => {
vi.mocked(api.run.get).mockResolvedValue({
id: "agenthub-lane-1-2",