Skip to content

fix(sessions): stabilize durable history reconciliation - #2372

Merged
bobleer merged 2 commits into
GCWing:mainfrom
bobleer:bob/sync-session-history-fixes
Aug 18, 2026
Merged

fix(sessions): stabilize durable history reconciliation#2372
bobleer merged 2 commits into
GCWing:mainfrom
bobleer:bob/sync-session-history-fixes

Conversation

@bobleer

@bobleer bobleer commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Port 1f29e82a1 and e666b6e62 from 1.0.0-explore onto the latest main.
  • Make Runtime completion authoritative for settled Turn content and emit a per-Turn durable history fence after persistence succeeds.
  • Repair Desktop, Peer Device, and Mobile projections from persisted history without dropping a newer live Turn.
  • Cache read-only snapshot managers and load large snapshot metadata indexes on bounded blocking workers to reduce restore stalls.

Type and Areas

Type: regression fix / performance fix

Areas: Rust core, event contracts, desktop/Tauri, Remote Connect, Web UI, Mobile Web, Peer Device Mode, architecture docs

Motivation / Impact

Terminal stream chunks can be missed while a window is suspended, a remote controller reconnects, or persistence races the frontend completion finalizer. A client could therefore keep a completed assistant response prefix, or a late history fence could erase the projection of a newer running Turn. Large snapshot indexes also made the repair path hold session coordination for seconds.

This change makes the persisted terminal Turn the repair authority, adds a backward-compatible settled-Turn fence, preserves newer live projections, and avoids repeatedly loading snapshot metadata.

Verification

  • cargo check -p bitfun-events — passed
  • cargo check -p bitfun-desktop — passed
  • cargo test -p bitfun-core --no-default-features --features agent-runtime --lib stale_projected_turn_saves_cannot_overwrite_runtime_recovery_state — passed
  • cargo test -p bitfun-core --no-default-features --features agent-runtime --lib completion_replaces_a_projected_text_prefix_with_runtime_generation_content — passed
  • cargo test -p bitfun-core --no-default-features --features agent-runtime --lib completed_persisted_turn_emits_a_durable_history_fence — passed
  • cargo test -p bitfun-core --no-default-features --features agent-runtime --lib view_manager_is_cached_and_superseded_by_a_later_writer — passed
  • cargo test -p bitfun-services-integrations --no-default-features --features remote-connect --lib remote_connect::tests:: — 9 passed
  • cargo test -p bitfun-services-integrations --no-default-features --features remote-connect --test remote_connect_contracts — 55 passed
  • pnpm --dir src/web-ui run gen:types && pnpm run type-check:web — passed
  • pnpm --dir src/web-ui run test:run src/flow_chat/services/flow-chat-manager/EventHandlerModule.test.ts src/flow_chat/store/FlowChatStore.test.ts — 172 passed
  • pnpm --dir src/mobile-web run type-check && pnpm run build:mobile-web — passed
  • git diff --check upstream/main...HEAD — passed

Remote scenario coverage:

  • Local/Desktop: Core unit coverage and Desktop compile check.
  • Remote control: Remote Connect unit/contract coverage and Mobile Web type/build checks.
  • Peer Device Mode: settled local/Peer projection regression coverage in FlowChatStore tests.
  • Remote workspace and Detached Dispatch: not manually exercised; the event field and poll replacement field are optional for cross-version compatibility.

No manual browser/device run was performed.

Reviewer Notes

  • settled_turn_id is optional and omitted when absent, so older event payloads continue to deserialize.
  • message_snapshot is optional; the additive delta remains populated for older Mobile Web clients.
  • The second commit is a follow-up to the first and should be reviewed/applied as a pair.
  • AI-assisted port; verification level is focused automated testing as listed above.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

@bobleer
bobleer merged commit 405c1c7 into GCWing:main Aug 18, 2026
8 checks passed
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