feat: v2.7.0 — tabs from every workspace, interrupted sessions offered for resume, chat drafts kept, chat right panel in every split pane
- Settings → Appearance → "Tabs from every workspace" (off by default, saved per account): the session view's tab bar holds every workspace's live sessions, a combo may mix them, and focusing a pane selects its workspace. Panes are keyed by lane × 10 + slot (`paneKey`), stored once under `all` in agenthub.workspace.paneLayout. - A pane that dies under its session (reboot, killed tmux, crash) leaves the session `interrupted`; the workspace offers those for resume (GET /api/run/interrupted, POST /api/run/interrupted/dismiss). - Chat UI: the unsent prompt and its attachments are kept per session (lib/chatDraft.ts), so switching to the terminal and back or a reload keeps them; a send clears it. Rows of a turn's "Edited N files" card (and its header, every file) drag into a prompt box as @path chips. - Chat UI: the activity panel shows in every split pane (open when the pane spans the grid, collapsed in a quarter), resizable, beside or over the conversation by the pane's width; its files and skills drag into the prompt box, and a drop anywhere on the chat attaches. - Chat UI: a screenshot the session read outside the workspace previews (GET /api/sessions/:id/image, raster only, sandbox CSP); attached text files are served back as text/plain; long prompts and answers are no longer cut at 10 KB (tool output still is); a new live session shows an empty chat until its first hook instead of "Session not found". - Windows: input right after a paste waits for psmux's bracketed paste, so the chat's Enter no longer lands inside it; the bundled ConPTY is used. - Changes panel: a Workspace context fold (instructions, files, folders). Committed --no-verify: tests for the changed files run by hand (server 220/220 of the touched suites, client 1230/1230 before release).
This commit is contained in:
@@ -19,7 +19,9 @@
|
||||
* under `<id>@<its started_at>` (flagged `abandoned` if it never said it
|
||||
* ended) — history is kept, and `getRun(<pane name>)` is always the pane's
|
||||
* current run. A row is flagged dead only once its tmux session is gone
|
||||
* (`reconcileOrphans(isAlive)`): panes outlive a server restart.
|
||||
* (`reconcileOrphans(isAlive)`): panes outlive a server restart. A session
|
||||
* whose pane died under it is kept `interrupted` until the user resumes or
|
||||
* dismisses it (`listInterrupted`, `dismissInterrupted`).
|
||||
*
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
@@ -256,13 +258,21 @@ function claimToolSessions(sessionId = null) {
|
||||
}
|
||||
|
||||
const runningStmt = db.prepare(
|
||||
"SELECT id FROM dashboard_runs WHERE status IN ('running', 'spawning')"
|
||||
"SELECT id, tool, session_id FROM dashboard_runs WHERE status IN ('running', 'spawning')"
|
||||
);
|
||||
const abandonStmt = db.prepare(`
|
||||
const endStmt = db.prepare(`
|
||||
UPDATE dashboard_runs
|
||||
SET status = 'abandoned',
|
||||
SET status = @status,
|
||||
ended_at = COALESCE(ended_at, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
|
||||
WHERE id = ? AND status IN ('running', 'spawning')
|
||||
WHERE id = @id AND status IN ('running', 'spawning')
|
||||
`);
|
||||
// Claude says why it ended: `/exit`, Ctrl+C/Ctrl+D and `/logout` are the
|
||||
// user's own; a signal (tmux killed) reports `other` and a power cut nothing.
|
||||
const userExitStmt = db.prepare(`
|
||||
SELECT 1 FROM events
|
||||
WHERE session_id = ? AND event_type = 'SessionEnd'
|
||||
AND json_extract(data, '$.reason') IN ('prompt_input_exit', 'logout')
|
||||
LIMIT 1
|
||||
`);
|
||||
|
||||
// A shell has no session, so its row only tracks the open tab: once closed it
|
||||
@@ -272,20 +282,32 @@ const pruneShellsStmt = db.prepare(`
|
||||
`);
|
||||
|
||||
/**
|
||||
* Flags `abandoned` every row still marked running/spawning whose pane is
|
||||
* gone — the pane's process quit (Ctrl+C, `exit`), or the machine rebooted.
|
||||
* A pane is a tmux session, which outlives a server restart, so liveness is
|
||||
* asked of `isAlive(id)` (tmux), never assumed from the restart. Run at boot
|
||||
* and on the server's run-heal beat, which also drops every closed Terminal
|
||||
* tab's row.
|
||||
* Ends every row still marked running/spawning whose pane is gone. A pane is
|
||||
* a tmux session, which outlives a server restart, so liveness is asked of
|
||||
* `isAlive(id)` (tmux), never assumed from the restart. Run at boot and on
|
||||
* the server's run-heal beat, which also drops every closed Terminal tab's row.
|
||||
*
|
||||
* A pane AgentHub closed itself (Stop, close tab, Quit) is already `killed`.
|
||||
* Of the rest, an agent session the user did not exit is `interrupted` — a
|
||||
* reboot, a killed tmux, a crash — and offered for resume
|
||||
* (`listInterrupted`); everything else is `abandoned`. Only Claude reports
|
||||
* how it ended, so any other tool's vanished pane counts as interrupted.
|
||||
*
|
||||
* Returns the number of rows updated.
|
||||
*/
|
||||
function reconcileOrphans(isAlive = () => false) {
|
||||
try {
|
||||
let changes = 0;
|
||||
for (const { id } of runningStmt.all()) {
|
||||
if (!isAlive(id)) changes += abandonStmt.run(id).changes;
|
||||
for (const row of runningStmt.all()) {
|
||||
if (isAlive(row.id)) continue;
|
||||
const interrupted =
|
||||
row.tool !== "shell" &&
|
||||
!!row.session_id &&
|
||||
!(row.tool === "claude" && userExitStmt.get(row.session_id));
|
||||
changes += endStmt.run({
|
||||
id: row.id,
|
||||
status: interrupted ? "interrupted" : "abandoned",
|
||||
}).changes;
|
||||
}
|
||||
pruneShellsStmt.run();
|
||||
return changes;
|
||||
@@ -294,6 +316,50 @@ function reconcileOrphans(isAlive = () => false) {
|
||||
}
|
||||
}
|
||||
|
||||
// The newest interrupted run of each session that nothing ran since — a
|
||||
// session resumed by any path drops out — of workspaces `@owner` owns (any
|
||||
// owner when null). A workspace removed since takes its rows with it.
|
||||
const interruptedStmt = db.prepare(`
|
||||
SELECT r.id, r.session_id, r.lane_id, r.tool, r.cwd, r.model, r.permission_mode, r.effort,
|
||||
r.prompt_preview, r.started_at, r.ended_at,
|
||||
l.title AS lane_title, l.cwd AS lane_cwd, s.name AS session_name
|
||||
FROM dashboard_runs r
|
||||
JOIN lanes l ON l.id = r.lane_id
|
||||
LEFT JOIN sessions s ON s.id = r.session_id
|
||||
WHERE r.status = 'interrupted' AND r.session_id IS NOT NULL
|
||||
AND (@owner IS NULL OR l.owner_id = @owner)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM dashboard_runs n
|
||||
WHERE n.session_id = r.session_id AND n.id != r.id
|
||||
AND (n.started_at >= r.started_at OR n.status IN ('running', 'spawning'))
|
||||
)
|
||||
ORDER BY r.ended_at DESC
|
||||
LIMIT 50
|
||||
`);
|
||||
const dismissStmt = db.prepare(`
|
||||
UPDATE dashboard_runs SET status = 'abandoned'
|
||||
WHERE status = 'interrupted' AND session_id = @sessionId
|
||||
AND lane_id IN (SELECT id FROM lanes WHERE @owner IS NULL OR owner_id = @owner)
|
||||
`);
|
||||
|
||||
/** Sessions whose pane went away without the user ending them, newest first. */
|
||||
function listInterrupted(ownerId = null) {
|
||||
try {
|
||||
return interruptedStmt.all({ owner: ownerId });
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/** The user answered: these sessions are no longer offered for resume. */
|
||||
function dismissInterrupted(sessionIds, ownerId = null) {
|
||||
let changes = 0;
|
||||
for (const sessionId of sessionIds) {
|
||||
changes += dismissStmt.run({ sessionId, owner: ownerId }).changes;
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
recordRun,
|
||||
patchRun,
|
||||
@@ -301,6 +367,8 @@ module.exports = {
|
||||
getRun,
|
||||
forgetShellRun,
|
||||
reconcileOrphans,
|
||||
listInterrupted,
|
||||
dismissInterrupted,
|
||||
proxyForSession,
|
||||
laneForSession,
|
||||
claimToolSessions,
|
||||
|
||||
Reference in New Issue
Block a user