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:
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file panePaste.test.ts
|
||||
* @description Pins where a pasted diff comment lands: the workspace's pane
|
||||
* focused last, else any of its panes, never another workspace's (lane 1 is
|
||||
* not lane 12), and nowhere once the pane unmounted.
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { notePaneFocus, pasteToLane, registerPane } from "../panePaste";
|
||||
|
||||
describe("panePaste", () => {
|
||||
it("pastes into the workspace's last-focused pane, and only its own", () => {
|
||||
const got: Record<string, string[]> = {};
|
||||
const reg = (id: string) => registerPane(id, (t) => (got[id] ??= []).push(t));
|
||||
const off12 = reg("agenthub-lane-12");
|
||||
const off0 = reg("agenthub-lane-1");
|
||||
const off2 = reg("agenthub-lane-1-2");
|
||||
expect(pasteToLane(1, "a")).toBe(true);
|
||||
expect(got["agenthub-lane-1"]).toEqual(["a"]);
|
||||
notePaneFocus("agenthub-lane-1-2");
|
||||
pasteToLane(1, "b");
|
||||
expect(got["agenthub-lane-1-2"]).toEqual(["b"]);
|
||||
// Focus on another workspace's pane does not pull lane 1's text there.
|
||||
notePaneFocus("agenthub-lane-12");
|
||||
pasteToLane(1, "c");
|
||||
expect(got["agenthub-lane-12"]).toBeUndefined();
|
||||
off0();
|
||||
off2();
|
||||
expect(pasteToLane(1, "d")).toBe(false);
|
||||
off12();
|
||||
});
|
||||
});
|
||||
@@ -681,6 +681,10 @@ export const api = {
|
||||
cwd?: string;
|
||||
/** One CLI's sessions only (`claude`, `codex`, `antigravity`). */
|
||||
tool?: string;
|
||||
/** The sessions this workspace owns (`sessions.lane_id`). */
|
||||
lane?: number;
|
||||
/** `false` = not archived, `true` = archived only; omitted = both. */
|
||||
archived?: boolean;
|
||||
sort_by?: string;
|
||||
sort_desc?: boolean;
|
||||
limit?: number;
|
||||
@@ -692,6 +696,8 @@ export const api = {
|
||||
if (params?.q) qs.set("q", params.q);
|
||||
if (params?.cwd) qs.set("cwd", params.cwd);
|
||||
if (params?.tool) qs.set("tool", params.tool);
|
||||
if (params?.lane !== undefined) qs.set("lane", String(params.lane));
|
||||
if (params?.archived !== undefined) qs.set("archived", params.archived ? "1" : "0");
|
||||
if (params?.sort_by) qs.set("sort_by", params.sort_by);
|
||||
// `!== undefined` (not truthiness) so an explicit `sort_desc: false` is preserved.
|
||||
if (params?.sort_desc !== undefined) qs.set("sort_desc", String(params.sort_desc));
|
||||
@@ -733,6 +739,13 @@ export const api = {
|
||||
* @returns {@link SessionStats} for that one session.
|
||||
*/
|
||||
stats: (id: string) => request<SessionStats>(`/sessions/${encodeURIComponent(id)}/stats`),
|
||||
/** PATCH /api/sessions/:id — rename, or archive (hides it from its
|
||||
* workspace, deletes nothing). */
|
||||
patch: (id: string, body: { name?: string; archived?: boolean }) =>
|
||||
request<{ session: Session }>(`/sessions/${encodeURIComponent(id)}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(body),
|
||||
}),
|
||||
/**
|
||||
* GET /api/sessions/:id/transcripts - the picker list of available
|
||||
* transcripts (main agent, subagents, compaction markers) for this session.
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file panePaste.ts — lets another part of the Workspace page paste text into
|
||||
* a workspace's terminal (a diff-line comment from the Changes panel). Every
|
||||
* mounted TerminalView registers its run id; the text goes to the pane of that
|
||||
* workspace the user focused last, else any of its panes. It is a paste —
|
||||
* bracketed, so `claude` takes it as one block in its composer — and never an
|
||||
* Enter: the user reads it and sends it.
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
const panes = new Map<string, (text: string) => void>();
|
||||
let lastFocused: string | null = null;
|
||||
|
||||
/** Registers a mounted terminal; returns its unregister. */
|
||||
export function registerPane(runId: string, paste: (text: string) => void): () => void {
|
||||
panes.set(runId, paste);
|
||||
return () => {
|
||||
if (panes.get(runId) === paste) panes.delete(runId);
|
||||
if (lastFocused === runId) lastFocused = null;
|
||||
};
|
||||
}
|
||||
|
||||
export function notePaneFocus(runId: string): void {
|
||||
lastFocused = runId;
|
||||
}
|
||||
|
||||
/** The tmux names of workspace `laneId`'s panes: `agenthub-lane-<id>[-slot]`. */
|
||||
function ofLane(runId: string, laneId: number): boolean {
|
||||
const base = `agenthub-lane-${laneId}`;
|
||||
return runId === base || runId.startsWith(`${base}-`);
|
||||
}
|
||||
|
||||
/** Pastes `text` into one of the workspace's mounted panes; false when none is. */
|
||||
export function pasteToLane(laneId: number, text: string): boolean {
|
||||
const id =
|
||||
lastFocused && panes.has(lastFocused) && ofLane(lastFocused, laneId)
|
||||
? lastFocused
|
||||
: [...panes.keys()].find((k) => ofLane(k, laneId));
|
||||
if (!id) return false;
|
||||
panes.get(id)!(text);
|
||||
return true;
|
||||
}
|
||||
@@ -25,6 +25,11 @@ export const SETTINGS_INDEX: {
|
||||
descKey?: string;
|
||||
keywords?: string[];
|
||||
}[] = [
|
||||
{
|
||||
section: "general",
|
||||
titleKey: "language.title",
|
||||
keywords: ["english", "tiếng việt", "vietnamese", "ngôn ngữ"],
|
||||
},
|
||||
{ section: "general", titleKey: "lanesSection.title", descKey: "lanesSection.description" },
|
||||
{ section: "general", titleKey: "lanesSection.runHousekeeping" },
|
||||
{ section: "general", titleKey: "import.title", keywords: ["history", "transcripts"] },
|
||||
|
||||
@@ -734,6 +734,13 @@ export interface Session {
|
||||
* journals and hooks) or `"antigravity"` (agy's conversation files and
|
||||
* hooks). Attach/resume offer `claude` rows only. Maps to `sessions.tool`. */
|
||||
tool?: string;
|
||||
/** The workspace (lane id) that owns the session — the one whose pane held
|
||||
* it; null for a session no workspace started.
|
||||
* Maps to `sessions.lane_id`. */
|
||||
lane_id?: number | null;
|
||||
/** ISO time the user archived the session out of its workspace's lists;
|
||||
* null when not archived. Hides only. Maps to `sessions.archived_at`. */
|
||||
archived_at?: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user