claude-tmux 1.0.2 → 1.0.4
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/dist/index.js +24 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,6 +35,11 @@ function isBusy(output) {
|
|
|
35
35
|
}
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
|
+
function isDone(output) {
|
|
39
|
+
// Claude shows "✻ [verb] for [duration]" when task completes
|
|
40
|
+
// e.g., "✻ Baked for 1m 35s", "✻ Cogitated for 2m 10s"
|
|
41
|
+
return /✻\s+\w+\s+for\s+\d+[ms]/.test(output);
|
|
42
|
+
}
|
|
38
43
|
function filterUIChrome(output) {
|
|
39
44
|
const lines = output.split('\n');
|
|
40
45
|
const filtered = lines.filter(line => {
|
|
@@ -55,22 +60,35 @@ function filterUIChrome(output) {
|
|
|
55
60
|
}
|
|
56
61
|
async function waitForIdle(session) {
|
|
57
62
|
const timeout = 600000; // 10 minutes
|
|
58
|
-
const lines =
|
|
63
|
+
const lines = 100; // Capture more lines to catch done signal
|
|
59
64
|
const startTime = Date.now();
|
|
60
65
|
let lastOutput = "";
|
|
61
|
-
let
|
|
66
|
+
let idleCount = 0;
|
|
67
|
+
let sawBusy = false; // Must see Claude working before we consider it idle
|
|
62
68
|
while (Date.now() - startTime < timeout) {
|
|
63
69
|
await sleep(2000);
|
|
64
70
|
try {
|
|
65
71
|
const output = runTmux(`capture-pane -t "${session}" -p -S -${lines}`);
|
|
66
|
-
// If busy,
|
|
72
|
+
// If busy, mark that we've seen Claude working and reset idle count
|
|
67
73
|
if (isBusy(output)) {
|
|
74
|
+
sawBusy = true;
|
|
68
75
|
lastOutput = output;
|
|
69
|
-
|
|
76
|
+
idleCount = 0;
|
|
70
77
|
continue;
|
|
71
78
|
}
|
|
72
|
-
//
|
|
73
|
-
|
|
79
|
+
// Check for positive done signal (only trust if we saw busy first)
|
|
80
|
+
if (isDone(output) && sawBusy) {
|
|
81
|
+
return filterUIChrome(output);
|
|
82
|
+
}
|
|
83
|
+
// Not busy but no done signal - use settling delay
|
|
84
|
+
// Only start counting idle after we've seen Claude working
|
|
85
|
+
if (sawBusy) {
|
|
86
|
+
idleCount++;
|
|
87
|
+
if (idleCount >= 2) {
|
|
88
|
+
return filterUIChrome(output);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
lastOutput = output;
|
|
74
92
|
}
|
|
75
93
|
catch (e) {
|
|
76
94
|
return `Error: ${e.message}`;
|