Skip to main content

Module bridge_pointer

Module bridge_pointer 

Source
Expand description

Bridge pointer for crash-recovery.

Translated from openclaudecode/openclaudecode/src/bridge/bridgePointer.ts

Crash-recovery pointer for Remote Control sessions.

Written immediately after a bridge session is created, periodically refreshed during the session, and cleared on clean shutdown. If the process dies unclean (crash, kill -9, terminal closed), the pointer persists. On next startup, claude remote-control detects it and offers to resume via the –session-id flow.

Staleness is checked against the file’s mtime (not an embedded timestamp) so that a periodic re-write with the same content serves as a refresh.

Scoped per working directory (alongside transcript JSONL files) so two concurrent bridges in different repos don’t clobber each other.

Structs§

BridgePointer
Bridge pointer data
BridgePointerWithAge
Bridge pointer with age information

Enums§

BridgePointerSource
Bridge pointer source

Constants§

BRIDGE_POINTER_TTL_MS
Crash-recovery pointer TTL in milliseconds (4 hours)

Functions§

clear_bridge_pointer
Delete the pointer. Idempotent — ENOENT is expected when the process shut down clean previously.
get_bridge_pointer_path
Get the bridge pointer path for a directory
read_bridge_pointer
Read the pointer and its age (ms since last write). Operates directly and handles errors — no existence check. Returns None on any failure: missing file, corrupted JSON, schema mismatch, or stale (mtime > 4h ago). Stale/invalid pointers are deleted so they don’t keep re-prompting after the backend has already GC’d the env.
read_bridge_pointer_across_worktrees
Worktree-aware read for --continue. The REPL bridge writes its pointer to the original CWD which EnterWorktreeTool/activeWorktreeSession can mutate to a worktree path — but claude remote-control --continue runs with resolve(‘.’) = shell CWD. This fans out across git worktree siblings to find the freshest pointer, matching /resume’s semantics.
write_bridge_pointer
Write the pointer. Also used to refresh mtime during long sessions — calling with the same IDs is a cheap no-content-change write that bumps the staleness clock. Best-effort — a crash-recovery file must never itself cause a crash. Logs and swallows on error.