Files
AgentHub/server/__tests__/dashboard-runs.test.js
T
nntrivi2001 a6bd33bcff 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).
2026-10-02 13:19:50 +07:00

53 lines
2.2 KiB
JavaScript

/**
* @file Tests for the persisted run history (`server/lib/dashboard-runs.js`).
* A run's id is its tmux pane name, which every Start in that pane reuses, so
* a new run must ARCHIVE the previous row under its own id instead of
* overwriting it; and a row is flagged dead only when its tmux session is
* really gone — panes outlive a server restart.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
const { describe, it, before, after } = require("node:test");
const assert = require("node:assert/strict");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
const ROOT = fs.mkdtempSync(path.join(os.tmpdir(), "dashboard-runs-"));
process.env.DASHBOARD_DB_PATH = path.join(ROOT, "t.db");
let runs;
before(() => {
runs = require("../lib/dashboard-runs");
});
after(() => fs.rmSync(ROOT, { recursive: true, force: true }));
const start = (id, extra = {}) =>
runs.recordRun({ id, mode: "interactive", cwd: "/r", status: "running", laneId: 4, ...extra });
describe("dashboard-runs", () => {
it("keeps the previous run of a pane as history when the pane starts again", () => {
start("agenthub-lane-4", { startedAt: Date.parse("2026-10-01T10:00:00Z"), sessionId: "s-old" });
start("agenthub-lane-4", { startedAt: Date.parse("2026-10-02T10:00:00Z"), sessionId: "s-new" });
const current = runs.getRun("agenthub-lane-4");
assert.equal(current.session_id, "s-new");
const history = runs.listRuns({ laneId: 4 });
assert.equal(history.length, 2);
const old = history.find((r) => r.session_id === "s-old");
assert.notEqual(old.id, "agenthub-lane-4");
assert.ok(old.id.startsWith("agenthub-lane-4@"), old.id);
// A pane that is being replaced is not running any more.
assert.equal(old.status, "abandoned");
assert.ok(old.ended_at);
});
it("flags as abandoned only the running rows whose pane is gone", () => {
start("agenthub-lane-5", { laneId: 5 });
start("agenthub-lane-6", { laneId: 6 });
const n = runs.reconcileOrphans((id) => id !== "agenthub-lane-6");
assert.equal(n, 1);
assert.equal(runs.getRun("agenthub-lane-5").status, "running");
assert.equal(runs.getRun("agenthub-lane-6").status, "abandoned");
});
});