Expand description
Backfill the registry record session_id from each agent’s provider
transcript, so a cross-channel open --resumes the original conversation
instead of starting a fresh session.
Background: the registry session_id is read on launch (surfaced to the
picker, which passes it as --resume <sid> on the first turn of a reattached
block — agent_handlers.rs) but was never written by production code, so
it was always null. A fresh-build / cross-channel open therefore had no sid
to resume and spawned a brand-new session, which then shadowed the original.
See docs/retro/retro-cross-channel-conversation-continuity-regression-2026-06-16.md.
Once populated, --resume keeps the same session id across turns, so a single
idempotent startup pass keeps continuity solid without per-turn wiring.
Functions§
- backfill_
session_ ids - Populate
session_idfor registry records that lack one, from the agent’s largest provider session. Idempotent (skips records that already carry a non-empty id). Returns the number populated. Best-effort per record — a record with nosource_agents_baseor no transcript is skipped, never fatal. - encode_
project_ slug - Encode an absolute workspace path to a Claude project-dir slug. Claude Code
replaces each of
/ \ : .with-(lossy — a literal-inside a segment is indistinguishable from a separator; this matches the CLI’s own scheme and thedecode_project_pathdirection inhistory::claude_adapter). - largest_
session_ id - The provider session id (jsonl stem) of the agent’s largest session across
the candidate project roots (the account-wide default and, for identity-bound
agents, the identity bundle). We pick the largest, not the newest, on purpose:
an accidental fresh session (one started when a blank cross-channel open failed
to resume) must never win over the real conversation.
Nonewhen there are no session files under any root. - largest_
with_ 🔒size - The largest
(size, session-id)directly underprojects_dir/<slug>, orNoneif the dir doesn’t exist / has no session files.