fix: event-loop freezes, plugin-install boot crash, tmux attach/scrollbar, Codex transcripts
- GET /api/workflows: one LEAD() window pass in a read worker (read-pool.js, workflow-stats.js); idx_events_session restored, idx_events_tool added - compat-sqlite gains function/pluck/readonly so a plugin install without a better-sqlite3 build boots again; antigravity-usage uses db.js's Database - install-hooks adds no checkout hooks while the agenthub plugin is enabled (events were doubled) - terminal attach runs the live tmux server's own binary; the pane scrollbar gets a visible 2-column style, and claude panes start with CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1 so tmux keeps history to scroll - Codex sessions' conversation in GET /api/sessions/:id/transcript - Codex/Antigravity sessions claimed by their workspace without hooks - UI-audit follow-ups, docs and OpenAPI
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
/**
|
||||
* @file pty-attach.js
|
||||
* @description Bridges one WebSocket connection to an `@lydell/node-pty`-backed
|
||||
* `tmux attach-session` process. Binary WS frames carry raw PTY bytes in
|
||||
* `tmux attach-session` process, run with the live tmux server's own binary
|
||||
* (`attachBinary`). Binary WS frames carry raw PTY bytes in
|
||||
* both directions; text WS frames carry small JSON control messages
|
||||
* (`resize`, and an outbound `exit` sent once when the pane process/tmux
|
||||
* session ends). Multiple browser tabs each get their own PTY attach
|
||||
@@ -10,6 +11,7 @@
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
const fs = require("fs");
|
||||
const tmux = require("./tmux");
|
||||
|
||||
const RUN_ID_RE = /^agenthub-lane-\d+(?:-[1-3])?$/;
|
||||
@@ -34,6 +36,26 @@ function __setSpawnImpl(fn) {
|
||||
spawnImpl = fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* The binary to run `tmux attach` with: the RUNNING server's own executable
|
||||
* (`/proc/<pid>/exe`, which still works after a package upgrade replaced the
|
||||
* file), else `tmux` on PATH. A client must match its server — tmux installed
|
||||
* in a newer version while the server runs makes PATH's client fail every
|
||||
* attach with "open terminal failed: not a terminal", though every other tmux
|
||||
* command still works. Linux only; elsewhere PATH's tmux as before.
|
||||
*/
|
||||
function attachBinary() {
|
||||
const pid = tmux.serverPid();
|
||||
if (!pid) return "tmux";
|
||||
const exe = `/proc/${pid}/exe`;
|
||||
try {
|
||||
fs.accessSync(exe, fs.constants.X_OK);
|
||||
return exe;
|
||||
} catch {
|
||||
return "tmux";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach `ws` to the tmux session `runId`. Spawns one PTY-backed
|
||||
* `tmux attach-session -t <runId>` per call.
|
||||
@@ -48,7 +70,7 @@ function attach(ws, runId, { cols, rows }) {
|
||||
} catch {
|
||||
/* session gone or tmux unavailable — attach below will surface that */
|
||||
}
|
||||
const pty = spawnImpl("tmux", ["attach-session", "-t", `=${runId}`], {
|
||||
const pty = spawnImpl(attachBinary(), ["attach-session", "-t", `=${runId}`], {
|
||||
name: "xterm-256color",
|
||||
cols: cols || 80,
|
||||
rows: rows || 24,
|
||||
|
||||
Reference in New Issue
Block a user