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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +23 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-remote",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Remote control bridge for Claude Code REPL - drive from phone/WebUI",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -203,28 +203,32 @@ function maybeAttachHookSession(data, source) {
203
203
  return;
204
204
  }
205
205
 
206
- // Switching to a different session — apply source-specific guards.
207
- if (currentSessionId && currentSessionId !== target.sessionId && !expectingSwitch) {
208
- const targetHasContent = fileLooksLikeTranscript(target.full);
209
-
210
- if (source === 'session-start') {
211
- // --resume triggers two session-start hooks in unpredictable order.
212
- // Don't switch away from a transcript with conversation content to an
213
- // empty one the one with content is the real resumed session.
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 (currentHasContent && !targetHasContent) {
216
- log(`Ignored hook session from ${source}: ${target.sessionId} (current has content, target empty)`);
216
+ if (!targetHasContent || currentHasContent) {
217
+ log(`Ignored session-start: ${target.sessionId} (current=${currentSessionId} currentHasContent=${currentHasContent} targetHasContent=${targetHasContent})`);
217
218
  return;
218
219
  }
219
- } else if (source === 'pre-tool-use') {
220
- // pre-tool-use is the most reliable signal — it comes from the actually
221
- // running Claude process. Accept it if the transcript has content.
222
- if (!targetHasContent) {
223
- log(`Ignored hook session from ${source}: ${target.sessionId} (no conversation content)`);
224
- return;
225
- }
226
- } else {
227
- // Unknown source — block unexpected switches
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
  }