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:
+11
-4
@@ -1306,15 +1306,22 @@ const HOOK_TOOLS = { codex: codexHookInput, antigravity: antigravityHookInput };
|
||||
* AGENTHUB_RUN_ID too, and its hooks must not take the pane over. That rule
|
||||
* is Claude's only: for Codex and agy it is not verified that a new session in
|
||||
* the pane and a nested one can be told apart, so their panes follow every one.
|
||||
*
|
||||
* The session the pane holds is also stamped with the pane's lane
|
||||
* (`sessions.lane_id`, first writer wins) — that is what makes it the
|
||||
* workspace's own session rather than one that merely ran in the same folder.
|
||||
*/
|
||||
function bindRunSession(runId, sessionId, hookType, source, tool) {
|
||||
if (typeof runId !== "string" || !/^agenthub-lane-\d+(-[1-3])?$/.test(runId)) return;
|
||||
if (typeof sessionId !== "string" || !sessionId) return;
|
||||
const row = dashboardRuns.getRun(runId);
|
||||
if (!row || row.session_id === sessionId) return;
|
||||
const reopened = hookType === "SessionStart" && source !== "startup";
|
||||
if (tool === "claude" && row.session_id && !reopened) return;
|
||||
dashboardRuns.patchRun({ id: runId, sessionId });
|
||||
if (!row) return;
|
||||
if (row.session_id !== sessionId) {
|
||||
const reopened = hookType === "SessionStart" && source !== "startup";
|
||||
if (tool === "claude" && row.session_id && !reopened) return;
|
||||
dashboardRuns.patchRun({ id: runId, sessionId });
|
||||
}
|
||||
if (row.lane_id != null) stmts.claimSessionLane.run(row.lane_id, sessionId);
|
||||
}
|
||||
|
||||
router.post("/event", (req, res) => {
|
||||
|
||||
@@ -1790,6 +1790,7 @@ router.post("/:id/:action", sameOriginGuard, async (req, res) => {
|
||||
resumeLast: body.resumeLast === true,
|
||||
bypass: body.bypass === true,
|
||||
resumeSessionId: body.resumeSessionId || (body.resume ? current.session_id : undefined),
|
||||
forkSession: body.forkSession === true,
|
||||
});
|
||||
startedRunId = handle.id;
|
||||
// An extra pane's session is not the lane's run: `run_id` stays the
|
||||
@@ -1843,8 +1844,9 @@ router.post("/:id/:action", sameOriginGuard, async (req, res) => {
|
||||
if (err.code === "ETMUXMISSING") {
|
||||
return res.status(503).json({ error: { code: err.code, message: err.message } });
|
||||
}
|
||||
// A refused field (EBADMODEL, EBADEFFORT, …) is the request's fault.
|
||||
const status = /^EBAD/.test(err.code || "") ? 400 : 500;
|
||||
// A refused field (EBADMODEL, EBADEFFORT, …) or a thing the lane's tool
|
||||
// cannot do (EUNSUPPORTED: a fork on a non-Claude lane) is the request's fault.
|
||||
const status = /^(EBAD|EUNSUPPORTED$)/.test(err.code || "") ? 400 : 500;
|
||||
return res.status(status).json({ error: { code: err.code, message: err.message } });
|
||||
}
|
||||
|
||||
|
||||
@@ -130,6 +130,13 @@ router.get("/", (req, res) => {
|
||||
// Which CLI's sessions (claude / codex / antigravity). Applied here, before
|
||||
// the limit, so a busy Codex lane cannot push Claude rows out of a page.
|
||||
const tool = typeof req.query.tool === "string" ? req.query.tool : "";
|
||||
// `lane` = the sessions a workspace owns (`sessions.lane_id`).
|
||||
const lane = req.query.lane;
|
||||
if (lane !== undefined && !/^\d+$/.test(String(lane))) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: { code: "INVALID_INPUT", message: "lane must be a lane id" } });
|
||||
}
|
||||
const sortBy = req.query.sort_by || "time"; // "time", "duration", "price"
|
||||
const sortDesc = req.query.sort_desc !== "false";
|
||||
|
||||
@@ -153,6 +160,13 @@ router.get("/", (req, res) => {
|
||||
where.push("s.tool = ?");
|
||||
params.push(tool);
|
||||
}
|
||||
if (lane !== undefined) {
|
||||
where.push("s.lane_id = ?");
|
||||
params.push(Number(lane));
|
||||
}
|
||||
// `archived=0|1` = only live / only archived; absent = both, as before.
|
||||
if (req.query.archived === "0") where.push("s.archived_at IS NULL");
|
||||
if (req.query.archived === "1") where.push("s.archived_at IS NOT NULL");
|
||||
// Data-scope filter: restrict to sessions collected from a chosen set of
|
||||
// machines (local + any configured remote sources). Absent = all sources.
|
||||
const sourceFilter = sourceColumnClause(parseSources(req));
|
||||
@@ -397,6 +411,16 @@ router.patch("/:id", (req, res) => {
|
||||
if (!existing) {
|
||||
return res.status(404).json({ error: { code: "NOT_FOUND", message: "Session not found" } });
|
||||
}
|
||||
if (Object.hasOwn(req.body, "archived")) {
|
||||
if (typeof req.body.archived !== "boolean") {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: { code: "INVALID_INPUT", message: "archived must be a boolean" } });
|
||||
}
|
||||
db.prepare(
|
||||
"UPDATE sessions SET archived_at = CASE WHEN ? THEN COALESCE(archived_at, strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) END WHERE id = ?"
|
||||
).run(req.body.archived ? 1 : 0, req.params.id);
|
||||
}
|
||||
|
||||
stmts.updateSession.run(
|
||||
name || null,
|
||||
|
||||
Reference in New Issue
Block a user