@radnine/claude-session-daemon 0.6.5 → 0.6.6
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/package.json +1 -1
- package/src/daemon.js +4 -2
- package/src/git-reset.js +16 -9
package/package.json
CHANGED
package/src/daemon.js
CHANGED
|
@@ -156,11 +156,13 @@ class Daemon extends EventEmitter {
|
|
|
156
156
|
const shouldResume = !!claudeSessionId;
|
|
157
157
|
this._cancelledSessionIds.delete(sessionId);
|
|
158
158
|
|
|
159
|
-
// Reset git state to clean main when requested (scheduled sessions)
|
|
159
|
+
// Reset git state to clean main when requested (scheduled sessions).
|
|
160
|
+
// Awaited so spawn waits for a clean tree, but async under the hood so the
|
|
161
|
+
// event loop keeps servicing ActionCable pings during the git commands.
|
|
160
162
|
if (options.resetGit) {
|
|
161
163
|
const cwd = options.workingDir || this._config.workingDir;
|
|
162
164
|
this._logger.info('Resetting git state before activation', { sessionId, cwd });
|
|
163
|
-
resetGitState(cwd, this._logger);
|
|
165
|
+
await resetGitState(cwd, this._logger);
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
// Create new process
|
package/src/git-reset.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { execFile } = require('node:child_process');
|
|
4
|
+
const { promisify } = require('node:util');
|
|
5
|
+
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
4
7
|
|
|
5
8
|
const EXEC_TIMEOUT = 15000; // 15 seconds per git command
|
|
6
9
|
|
|
@@ -11,48 +14,52 @@ const EXEC_TIMEOUT = 15000; // 15 seconds per git command
|
|
|
11
14
|
* Each step logs its result. Failures are logged but never thrown —
|
|
12
15
|
* session activation must not be blocked by git problems.
|
|
13
16
|
*
|
|
17
|
+
* Uses async execFile (not execFileSync) so the Node.js event loop stays
|
|
18
|
+
* responsive to ActionCable pings while git commands are running. A blocked
|
|
19
|
+
* event loop causes the ping watchdog to fire and force a WebSocket reconnect.
|
|
20
|
+
*
|
|
14
21
|
* @param {string} workingDir - The repo directory to reset
|
|
15
22
|
* @param {object} logger - Logger with .info() and .warn() methods
|
|
16
|
-
* @returns {{ stash: boolean, checkout: boolean, pull: boolean }} step results
|
|
23
|
+
* @returns {Promise<{ stash: boolean, checkout: boolean, pull: boolean }>} step results
|
|
17
24
|
*/
|
|
18
|
-
function resetGitState(workingDir, logger) {
|
|
25
|
+
async function resetGitState(workingDir, logger) {
|
|
19
26
|
const results = { stash: false, checkout: false, pull: false };
|
|
20
27
|
|
|
21
28
|
// Step 1: stash uncommitted changes
|
|
22
29
|
try {
|
|
23
|
-
const
|
|
30
|
+
const { stdout } = await execFileAsync('git', ['stash', '--include-untracked'], {
|
|
24
31
|
cwd: workingDir,
|
|
25
32
|
timeout: EXEC_TIMEOUT,
|
|
26
33
|
encoding: 'utf8',
|
|
27
34
|
});
|
|
28
35
|
results.stash = true;
|
|
29
|
-
logger.info('git stash completed', { output:
|
|
36
|
+
logger.info('git stash completed', { output: stdout.trim() });
|
|
30
37
|
} catch (err) {
|
|
31
38
|
logger.warn('git stash failed (continuing)', { error: err.message });
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
// Step 2: checkout main
|
|
35
42
|
try {
|
|
36
|
-
const
|
|
43
|
+
const { stdout } = await execFileAsync('git', ['checkout', 'main'], {
|
|
37
44
|
cwd: workingDir,
|
|
38
45
|
timeout: EXEC_TIMEOUT,
|
|
39
46
|
encoding: 'utf8',
|
|
40
47
|
});
|
|
41
48
|
results.checkout = true;
|
|
42
|
-
logger.info('git checkout main completed', { output:
|
|
49
|
+
logger.info('git checkout main completed', { output: stdout.trim() });
|
|
43
50
|
} catch (err) {
|
|
44
51
|
logger.warn('git checkout main failed (continuing)', { error: err.message });
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
// Step 3: pull latest
|
|
48
55
|
try {
|
|
49
|
-
const
|
|
56
|
+
const { stdout } = await execFileAsync('git', ['pull', 'origin', 'main'], {
|
|
50
57
|
cwd: workingDir,
|
|
51
58
|
timeout: EXEC_TIMEOUT,
|
|
52
59
|
encoding: 'utf8',
|
|
53
60
|
});
|
|
54
61
|
results.pull = true;
|
|
55
|
-
logger.info('git pull completed', { output:
|
|
62
|
+
logger.info('git pull completed', { output: stdout.trim() });
|
|
56
63
|
} catch (err) {
|
|
57
64
|
logger.warn('git pull failed (continuing)', { error: err.message });
|
|
58
65
|
}
|