feat: v2.6.0 — Chat UI composer (+ menu, project files, activity panel, permission mode, Stop), git on a workspace's extra folders (#70), long paste as a file (#68), S3 server mode (experimental)
Chat UI: - Each Claude/Codex session keeps its own chat/terminal view; Settings only sets how new sessions open. - Composer + menu: upload, project files and folders (#54, also dragged from the Files/Changes tree), context files, recent uploads, skills, plugins. - Activity side panel (progress, outputs, files read, uploads, memory, skills, connectors) with a file preview; edited-file counts per turn. - Permission-mode chip (Shift+Tab steps, read back from the pane: server/lib/pane-mode.js, GET|POST /api/run/:id/permission-mode). - Stop (Esc) while the main agent works; the status is checked per agent (with session_id /api/agents ignores its status filter) and re-read every 5 s while Stop shows. - Dropped images shown in the conversation (GET /api/run/drop/:name, the requester's own drop dir), full-size viewer. - A plain-text paste over 5,000 characters is attached as pasted-text.txt, so no prompt reaches tmux/argv limits (#68). Changes panel: every /api/lanes/:id/git* route takes ?source=<lane_sources id> (sourceFolder; ENOSOURCE otherwise) and a folder picker switches the whole panel to a workspace's extra folder (#70). Server mode S3 (one Linux user per account) — experimental, verified with fake sudo plus a P6 managed-settings spike on a test account: - member tmux listing runs in the background (cached, 15 s => unknown); - transcript snapshot copy is async, chunked, temp file + rename; - Express Layer patch only on Express 4; - tmux capturePane/sendKey go to the member's own server. Docs: the multi-user design moved in as docs/plans/server-mode/README.md (the AgentHub-Server repo is gone); S3-PLAN P6 result; LANES/API/openapi.
This commit is contained in:
@@ -106,6 +106,28 @@ function addFolder(laneId, input, { allowed = () => true } = {}) {
|
||||
return insertSource(laneId, "folder", resolved, path.basename(resolved) || resolved, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* An extra folder's directory for the git routes (`?source=<id>`): only a
|
||||
* `folder` row of THIS workspace that is still a directory — the request names
|
||||
* a row id, never a path.
|
||||
* @throws ENOSOURCE otherwise.
|
||||
*/
|
||||
function sourceFolder(laneId, sourceId) {
|
||||
const row = /^\d+$/.test(String(sourceId))
|
||||
? db
|
||||
.prepare("SELECT path FROM lane_sources WHERE id = ? AND lane_id = ? AND kind = 'folder'")
|
||||
.get(Number(sourceId), laneId)
|
||||
: null;
|
||||
let dir = null;
|
||||
try {
|
||||
dir = row && fs.statSync(row.path).isDirectory() ? fs.realpathSync(row.path) : null;
|
||||
} catch {
|
||||
/* gone since it was added */
|
||||
}
|
||||
if (!dir) throw fail("ENOSOURCE", "that folder is not one of this workspace's folders");
|
||||
return dir;
|
||||
}
|
||||
|
||||
/** A file name AgentHub can store: no directory part, no control or path characters. */
|
||||
function safeName(raw) {
|
||||
const base = path.basename(String(raw || "")).replace(/[^\p{L}\p{N}._ -]/gu, "_");
|
||||
@@ -338,6 +360,7 @@ module.exports = {
|
||||
contextDir,
|
||||
listSources,
|
||||
addFolder,
|
||||
sourceFolder,
|
||||
addFile,
|
||||
removeSource,
|
||||
removeLaneContext,
|
||||
|
||||
@@ -736,6 +736,12 @@ function inferredDisplayStage(lane) {
|
||||
return lane.detected_stage;
|
||||
}
|
||||
|
||||
/** The owner's username — the staff sidebar groups workspaces by it. */
|
||||
function ownerName(id) {
|
||||
if (id == null) return null;
|
||||
return db.prepare("SELECT username FROM users WHERE id = ?").get(id)?.username ?? null;
|
||||
}
|
||||
|
||||
function lanePayload(lane, ageSec = null) {
|
||||
const pipeline = getPipeline(lane.pipeline);
|
||||
const since = lane.stage_since ? Date.parse(lane.stage_since) : NaN;
|
||||
@@ -749,6 +755,7 @@ function lanePayload(lane, ageSec = null) {
|
||||
delete row.instructions;
|
||||
return {
|
||||
...row,
|
||||
owner_name: ownerName(lane.owner_id),
|
||||
pipeline_name: pipeline.name,
|
||||
pipeline_skill: pipeline.skill || "",
|
||||
pipeline_nodes:
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @file pane-mode.js
|
||||
* @description A live `claude` pane's permission mode, read off the pane and
|
||||
* changed the only way Claude Code offers to a running session: Shift+Tab,
|
||||
* which steps through its cycle (Manual → Accept edits → Plan → Auto, Bypass
|
||||
* too when the session was allowed it). Every step is VERIFIED on the mode
|
||||
* line Claude Code prints under its prompt before the next key goes in, so it
|
||||
* stops on exactly the mode asked for — and presses nothing at all while that
|
||||
* line cannot be read (a menu or dialog is open, where Shift+Tab means
|
||||
* something else). A mode not in this session's cycle brings it back to where
|
||||
* it began. One change at a time per pane. Only this pane is touched: the
|
||||
* mode belongs to the session, not to an account.
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
const tmux = require("./tmux");
|
||||
|
||||
// Claude Code 2.1.x: "⏸ manual mode on · ← for agents",
|
||||
// "⏵⏵ accept edits on (shift+tab to cycle)". The marker keeps a sentence in
|
||||
// the conversation that merely mentions a mode from counting.
|
||||
const LINE =
|
||||
/(?:⏸|⏵⏵)\s+(manual mode|accept edits|plan mode|auto mode|bypass permissions|don't ask) on\b/;
|
||||
const MODES = {
|
||||
"manual mode": "default",
|
||||
"accept edits": "acceptEdits",
|
||||
"plan mode": "plan",
|
||||
"auto mode": "auto",
|
||||
"bypass permissions": "bypassPermissions",
|
||||
"don't ask": "dontAsk",
|
||||
};
|
||||
const SETTABLE = new Set(["default", "acceptEdits", "plan", "auto", "bypassPermissions"]);
|
||||
// Longest cycle Claude Code has: its six modes.
|
||||
const MAX_PRESSES = 6;
|
||||
|
||||
/** The mode on the pane's bottom lines, or null when none is shown. */
|
||||
function parseMode(screen) {
|
||||
const lines = String(screen)
|
||||
.split("\n")
|
||||
.filter((l) => l.trim())
|
||||
.slice(-4)
|
||||
.reverse();
|
||||
for (const l of lines) {
|
||||
const m = LINE.exec(l);
|
||||
if (m) return MODES[m[1]];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function readMode(runId) {
|
||||
try {
|
||||
return parseMode(tmux.capturePane(runId));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const fail = (code, message) => Object.assign(new Error(message), { code });
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
// The mode once it differs from `from` — or what the pane shows at the deadline.
|
||||
async function nextMode(runId, from, waitMs) {
|
||||
const until = Date.now() + waitMs;
|
||||
for (;;) {
|
||||
const now = readMode(runId);
|
||||
if ((now && now !== from) || Date.now() >= until) return now;
|
||||
await sleep(50);
|
||||
}
|
||||
}
|
||||
|
||||
const busy = new Set();
|
||||
|
||||
/** Steps `runId`'s mode to `target`; resolves with the mode now shown. */
|
||||
async function setMode(runId, target, { waitMs = 2000 } = {}) {
|
||||
if (!SETTABLE.has(target))
|
||||
throw fail("EBADMODE", `mode must be one of: ${[...SETTABLE].join(", ")}`);
|
||||
if (busy.has(runId)) throw fail("EBUSY", "the mode is already being changed");
|
||||
busy.add(runId);
|
||||
try {
|
||||
const start = readMode(runId);
|
||||
if (!start) throw fail("EMODEUNKNOWN", "the pane shows no mode line — close its menu first");
|
||||
let cur = start;
|
||||
for (let i = 0; i < MAX_PRESSES && cur !== target; i++) {
|
||||
tmux.sendKey(runId, "BTab");
|
||||
const next = await nextMode(runId, cur, waitMs);
|
||||
if (!next || next === cur) throw fail("EMODEUNKNOWN", "the mode did not change as expected");
|
||||
cur = next;
|
||||
if (cur === start) break;
|
||||
}
|
||||
if (cur !== target)
|
||||
throw fail("EMODEUNAVAILABLE", `${target} is not available in this session`);
|
||||
return cur;
|
||||
} finally {
|
||||
busy.delete(runId);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { parseMode, readMode, setMode };
|
||||
+15
-2
@@ -11,8 +11,9 @@
|
||||
* takes over an idle pane with `respawn-pane -- <argv>` rather than typing a
|
||||
* quoted line into that pane's shell, which keeps an API key passed in `env`
|
||||
* out of the pane's rendered text, its scrollback and the user's shell history.
|
||||
* `sendText` is the one primitive that does send keystrokes — a pane running an
|
||||
* interactive chat program that reads stdin as a message, not a shell.
|
||||
* `sendText` is the one primitive that sends typed text — a pane running an
|
||||
* interactive chat program that reads stdin as a message, not a shell — and
|
||||
* `sendKey` presses one named key (Shift+Tab for `pane-mode.js`), never text.
|
||||
*
|
||||
* Server mode, one Linux user per account (S3): a member's panes live on THAT
|
||||
* member's tmux server, socket `<home>/.agenthub/tmux/sock` (`run-as.js`), so
|
||||
@@ -547,6 +548,16 @@ function pasteText(name, text) {
|
||||
onServerOf(name, ["send-keys", "-t", pane(name), "Enter"]);
|
||||
}
|
||||
|
||||
/** The pane's visible screen as plain text (no escape sequences). */
|
||||
function capturePane(name) {
|
||||
return String(onServerOf(name, ["capture-pane", "-p", "-t", pane(name)]));
|
||||
}
|
||||
|
||||
/** Press ONE named key (`BTab`, `Escape`) in the pane — a key name, never text. */
|
||||
function sendKey(name, key) {
|
||||
onServerOf(name, ["send-keys", "-t", pane(name), key]);
|
||||
}
|
||||
|
||||
/** Idempotent — a session that's already gone is not an error. */
|
||||
function killSession(name) {
|
||||
try {
|
||||
@@ -657,6 +668,8 @@ module.exports = {
|
||||
sendCommand,
|
||||
sendText,
|
||||
pasteText,
|
||||
capturePane,
|
||||
sendKey,
|
||||
killSession,
|
||||
listSessions,
|
||||
liveSessions,
|
||||
|
||||
Reference in New Issue
Block a user