Skip to content

fix(cloud): push live CLI session transcripts on share - #649

Open
Neonforge98 wants to merge 1 commit into
developfrom
fix/cliagent-share-hollow-events
Open

fix(cloud): push live CLI session transcripts on share#649
Neonforge98 wants to merge 1 commit into
developfrom
fix/cliagent-share-hollow-events

Conversation

@Neonforge98

Copy link
Copy Markdown
Collaborator

Problem

Sharing a live CLI session (cliagent-* — Claude Code, Codex CLI, … GUI sessions) publishes a permanently hollow cloud copy: the row is created with the right access_mode/visibility and metadata, but events_count stays 0, so the recipient forever sees "No activity yet — Session data may not have loaded" and Reload does nothing.

Root cause: loadPushEvents reads non-imported sessions from eventStoreProxy.getPersistedEvents (the SQLite events cache). Live CLI sessions never write that cache — their transcript of record is the CLI's native store (account-profile aware, e.g. ~/.orgii/claude-code-cli-profiles/<account>/projects/…jsonl). The engine reads 0 events with no cursor, silently upserts metadata only, and then stamps the event plane clean, so subsequent passes skip the session entirely. The owner's own replay hydrates from the native transcript, which is why this is invisible on the sharing side and only the recipient breaks.

Solution

When the persisted events cache is empty for a CLI session, load the full native transcript through cli_agent_chunks — the same profile-home-aware command the session-resume path uses — and convert with processChunksRust, mirroring the imported-history branch. A populated events cache still wins, so sessions that do persist (forks, cloud replays) keep their existing path, and non-CLI sessions are untouched.

Verification

  • Unit: two new tests in org2CloudSyncEngine.sessions.test.ts pin both directions (empty cache → native transcript chunks; populated cache → no chunks call). Full src/features/Org2Cloud suite: 1043 passed. pnpm typecheck clean.
  • Live dual-instance, real reproduction: a live Claude Code session (3 rounds) shared from instance-1 sat at events_count: 0 across restarts and new activity on the unfixed build. With this fix installed, the first sync pass pushed 7 events (events_epoch: 1), and the second instance (different cloud account) rendered the full replay — all three rounds navigable via the round switcher, correct owner attribution, no synthetic-round pollution.

Risks

The fallback only fires when the events cache is empty AND the session id is cliagent-*. Chunk→event conversion is the same deterministic pipeline the imported-history push already relies on, so freeze-line/epoch/hash behavior is unchanged. Mid-turn reads produce a prefix snapshot; the next pass appends, as with imported sources. Rollback is a revert.

🤖 Generated with Claude Code

Pre-commit hook ran. Total eslint: 0, total circular: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant