@volter/supercode-terminal 0.2.40 → 0.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +15 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFile, spawn, spawnSync } from 'node:child_process';
|
|
2
2
|
import { randomBytes, randomUUID } from 'node:crypto';
|
|
3
|
-
import { cpSync, existsSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { appendFileSync, cpSync, existsSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
4
5
|
import { dirname, join } from 'node:path';
|
|
5
6
|
import { connect as netConnect } from 'node:net';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
@@ -509,6 +510,18 @@ for (const event of ['end', 'close', 'error']) process.stdin.on(event, sweep);
|
|
|
509
510
|
* disposing), so every pane here is this host's own. As with tmux's `remain-on-exit failed`, a pane whose program
|
|
510
511
|
* fails stays listed and capturable, marked dead, until it is closed; one that exits cleanly leaves at once.
|
|
511
512
|
*/
|
|
513
|
+
/**
|
|
514
|
+
* A pane's end in the pane-exit log, as the tmux lane's hooks write it (`<time> <pane> closed`, or `died status=…
|
|
515
|
+
* signal=…` when it failed), under SUPERCODE_HOME or ~/.config/supercode: the machine daemon tells a clean finish from
|
|
516
|
+
* a failure by it, and a ConPTY pane that ended cleanly is otherwise gone without a trace.
|
|
517
|
+
*/
|
|
518
|
+
function recordPaneExit(contextKey, exitCode, signal) {
|
|
519
|
+
if (!contextKey) return;
|
|
520
|
+
const at = new Date().toISOString().slice(0, 19);
|
|
521
|
+
const line = exitCode === 0 && !signal ? `${at} ${contextKey} closed\n` : `${at} ${contextKey} died status=${exitCode ?? ''} signal=${signal || ''}\n`;
|
|
522
|
+
try { appendFileSync(join(process.env.SUPERCODE_HOME || join(homedir(), '.config', 'supercode'), 'pane-exits.log'), line); } catch { /* no log is no worse than before */ }
|
|
523
|
+
}
|
|
524
|
+
|
|
512
525
|
export class PtyTerminalHost {
|
|
513
526
|
#attachments = new Map();
|
|
514
527
|
#liveAttachments = new Set();
|
|
@@ -585,6 +598,7 @@ export class PtyTerminalHost {
|
|
|
585
598
|
// server) outlives it, as it outlives a tmux pane. What stayed in the pane's console ends with the console.
|
|
586
599
|
// Only closing a pane, or its daemon dying, ends a whole tree.
|
|
587
600
|
releasePane(child);
|
|
601
|
+
recordPaneExit(entry.contextKey, exitCode, signal);
|
|
588
602
|
this.#tellExit(entry);
|
|
589
603
|
this.#writeWatchList();
|
|
590
604
|
if (exitCode === 0) this.#forget(entry);
|