claude-bridge-cli 2.0.19 → 2.0.20

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/lib/bridge.js +24 -0
  2. package/package.json +1 -1
package/lib/bridge.js CHANGED
@@ -787,6 +787,7 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
787
787
  // anything INTO the Files drawer it's now told about.
788
788
  "--add-dir", path.join(dataDir(), "images")];
789
789
  let resumeCwd = null;
790
+ let divergedFrom = null; // set if the CLI answers under a different session
790
791
  if (session_id) {
791
792
  const existing = scanSessionFiles().find(s => s.id === session_id);
792
793
  if (existing) {
@@ -844,6 +845,14 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
844
845
  const bin = isCmdShim ? process.env.COMSPEC || "cmd.exe" : config.claudeBin;
845
846
  const fullArgs = isCmdShim ? ["/c", config.claudeBin, ...args] : args;
846
847
 
848
+ // Opt-in spawn tracing (CLAUDE_BRIDGE_DEBUG=1). Nothing recorded WHAT the
849
+ // bridge actually ran, so when a turn misbehaved there was no evidence to
850
+ // separate "we built the wrong command" from "the CLI ignored it" — a
851
+ // resume regression took hours to narrow with no way to see the argv.
852
+ if (process.env.CLAUDE_BRIDGE_DEBUG) {
853
+ console.error("[bridge] spawn bin=%s cwd=%s args=%s",
854
+ bin, effCwd, JSON.stringify(fullArgs));
855
+ }
847
856
  const proc = spawn(bin, fullArgs, {
848
857
  cwd: effCwd,
849
858
  timeout: config.timeout,
@@ -871,6 +880,17 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
871
880
  const finalText = result.result || result.assistantMessage || "";
872
881
  writeCompletionMarker(sid, finalText);
873
882
  if (session_id && session_id !== sid) writeCompletionMarker(session_id, finalText);
883
+ // The CLI answered under a DIFFERENT session than we asked to resume:
884
+ // the turn's history is not where the user is looking, and the session
885
+ // they see can never update again. This was handled silently, so the
886
+ // symptom reaching the user was "Claude keeps repeating its last reply"
887
+ // with nothing anywhere to explain it. Never swallow it again — log it,
888
+ // and hand it to the client so the UI can say so.
889
+ if (session_id && session_id !== sid) {
890
+ console.error("[bridge] WARNING resume diverged: asked=%s answered=%s "
891
+ + "(the turn was written to a different session)", session_id, sid);
892
+ divergedFrom = session_id;
893
+ }
874
894
  if (images && images.length && session_id === "pending" && sid !== "pending") {
875
895
  const oldDir = path.join(dataDir(), "images", "pending");
876
896
  const newDir = path.join(dataDir(), "images", sid);
@@ -892,6 +912,10 @@ function askClaude(config, { prompt, session_id, images, cwd, plan_mode, allow_t
892
912
  duration_ms: result.duration_ms || null,
893
913
  context: result.context || null,
894
914
  permission_denials,
915
+ // Non-null when the CLI answered under a different session than the
916
+ // one we asked to resume. The client shows the conversation it is
917
+ // displaying will not receive this turn, and where the turn went.
918
+ resume_diverged_from: divergedFrom,
895
919
  });
896
920
  } catch {
897
921
  if (stdout.trim()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-bridge-cli",
3
- "version": "2.0.19",
3
+ "version": "2.0.20",
4
4
  "description": "Use Claude Code from your browser. Runs a local server that connects your browser tools to the Claude CLI.",
5
5
  "main": "lib/bridge.js",
6
6
  "bin": {