claude-remote 0.1.6 → 0.1.7
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/server.js +23 -19
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -203,28 +203,32 @@ function maybeAttachHookSession(data, source) {
|
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
206
|
+
const targetHasContent = fileLooksLikeTranscript(target.full);
|
|
207
|
+
|
|
208
|
+
if (source === 'session-start') {
|
|
209
|
+
// session-start is unreliable for --resume (fires twice, one is a
|
|
210
|
+
// snapshot-only session). Only accept when:
|
|
211
|
+
// 1. No session bound yet (first attach), OR
|
|
212
|
+
// 2. Expecting a switch (/clear), OR
|
|
213
|
+
// 3. Target has conversation content and current doesn't
|
|
214
|
+
if (currentSessionId && !expectingSwitch) {
|
|
214
215
|
const currentHasContent = transcriptPath && fileLooksLikeTranscript(transcriptPath);
|
|
215
|
-
if (
|
|
216
|
-
log(`Ignored
|
|
216
|
+
if (!targetHasContent || currentHasContent) {
|
|
217
|
+
log(`Ignored session-start: ${target.sessionId} (current=${currentSessionId} currentHasContent=${currentHasContent} targetHasContent=${targetHasContent})`);
|
|
217
218
|
return;
|
|
218
219
|
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
220
|
+
}
|
|
221
|
+
} else if (source === 'pre-tool-use') {
|
|
222
|
+
// pre-tool-use is the authoritative source — comes from the actually
|
|
223
|
+
// running Claude process. Always allow it to correct the session,
|
|
224
|
+
// as long as the target transcript has conversation content.
|
|
225
|
+
if (currentSessionId && currentSessionId !== target.sessionId && !targetHasContent) {
|
|
226
|
+
log(`Ignored pre-tool-use: ${target.sessionId} (no conversation content)`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
// Other sources (e.g. stop) — only accept if matching current or no session
|
|
231
|
+
if (currentSessionId && currentSessionId !== target.sessionId && !expectingSwitch) {
|
|
228
232
|
log(`Ignored hook session from ${source}: ${target.sessionId} (current=${currentSessionId})`);
|
|
229
233
|
return;
|
|
230
234
|
}
|