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
+59 -1
View File
@@ -3,7 +3,9 @@
* is started with `AGENTHUB_RUN_ID` in its tmux env, and a hook carrying that
* `run_id` binds the hook's session to the run (`dashboard_runs.session_id`),
* following `/clear` to a new session; a `run_id` that is not a dashboard pane
* name, or names no run, changes nothing.
* name, or names no run, changes nothing. A session a lane's pane holds is
* stamped with that lane (`sessions.lane_id`) — the workspace owns it — and a
* nested CLI's session, or one another lane already owns, is not.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
@@ -22,6 +24,7 @@ process.env.DASHBOARD_REMOTE_SYNC_MS = "0";
process.env.DASHBOARD_LIVENESS_PROBE = "0";
const { createApp } = require("../index");
const { db } = require("../db");
const dashboardRuns = require("../lib/dashboard-runs");
const tmux = require("../lib/tmux");
const pty = require("../lib/pty-run");
@@ -140,4 +143,59 @@ describe("run ↔ session binding", () => {
assert.equal(dashboardRuns.getRun("agenthub-lane-999"), null);
assert.equal(dashboardRuns.getRun("agenthub-lane-5-1").session_id, "sess-bbbb-2222");
});
it("stamps the session a lane's pane holds with that lane, once", async () => {
dashboardRuns.recordRun({
id: "agenthub-lane-8",
laneId: 8,
mode: "interactive",
cwd: ROOT,
status: "running",
startedAt: Date.now(),
});
const laneOf = (id) => db.prepare("SELECT lane_id FROM sessions WHERE id = ?").get(id)?.lane_id;
await postHook({
hook_type: "SessionStart",
data: { session_id: "own-aaaa-0001", cwd: ROOT, source: "startup" },
run_id: "agenthub-lane-8",
});
assert.equal(laneOf("own-aaaa-0001"), 8);
// A nested `claude -p` in that pane is not the pane's session.
await postHook({
hook_type: "SessionStart",
data: { session_id: "own-nest-0002", cwd: ROOT, source: "startup" },
run_id: "agenthub-lane-8",
});
assert.equal(laneOf("own-nest-0002"), null);
// A session another lane owns keeps its owner when resumed elsewhere.
db.prepare("UPDATE sessions SET lane_id = 3 WHERE id = ?").run("own-nest-0002");
await postHook({
hook_type: "SessionStart",
data: { session_id: "own-nest-0002", cwd: ROOT, source: "resume" },
run_id: "agenthub-lane-8",
});
assert.equal(dashboardRuns.getRun("agenthub-lane-8").session_id, "own-nest-0002");
assert.equal(laneOf("own-nest-0002"), 3);
});
it("stamps a resumed session the run was started with", async () => {
dashboardRuns.recordRun({
id: "agenthub-lane-9",
laneId: 9,
sessionId: "own-resu-0003",
mode: "interactive",
cwd: ROOT,
status: "running",
startedAt: Date.now(),
});
await postHook({
hook_type: "SessionStart",
data: { session_id: "own-resu-0003", cwd: ROOT, source: "resume" },
run_id: "agenthub-lane-9",
});
assert.equal(
db.prepare("SELECT lane_id FROM sessions WHERE id = ?").get("own-resu-0003").lane_id,
9
);
});
});