Skip to content

fix(transcript): lossless transcript restore — full-fidelity cold-boot resume, per-turn thinking hydration, seq envelope#5077

Merged
senamakel merged 6 commits into
tinyhumansai:mainfrom
senamakel:fix/transcript-restore-fidelity
Jul 21, 2026
Merged

fix(transcript): lossless transcript restore — full-fidelity cold-boot resume, per-turn thinking hydration, seq envelope#5077
senamakel merged 6 commits into
tinyhumansai:mainfrom
senamakel:fix/transcript-restore-fidelity

Conversation

@senamakel

@senamakel senamakel commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Cold-boot web-chat resume is now lossless. web_chat/run_task.rs + agent/harness/session/runtime.rs seed the resumed model context from the full-fidelity session_raw/*.jsonl transcript by thread id — restoring tool calls, tool-role results, and reasoning_content — falling back to the old prose-pair seeding only when no transcript exists. Previously the prose seeding always won and the rich JSONL was never read.
  • Frontend restore hydrates per-turn thinking/narration. Past turns' persisted thinking/narration transcripts render via the new PastTurnInsights; an interrupted turn's persisted partial answer surfaces as an "Interrupted"-marked bubble via the new InterruptedAnswer (not written to the durable log); restored subagent trails include reasoning/text (tool-only fallback for legacy snapshots); hydration orders by seq when present. Dead reasoning TimelineItem union member removed.
  • seq envelope (timeline-refactor Phase 4 amendment). progress_bridge stamps a per-request monotonic seq on every socket event; seq is persisted on tool-timeline rows; an optional seq is declared on the frontend socket event types.
  • Transcript prose items capped at 16 KiB per item (subagent + parent), matching the existing 64 KiB tool-output cap.

Problem

Session-restore was silently losing information: restored transcripts "forgot" tool calls and reasoning even though full-fidelity session_raw/*.jsonl was present on disk. Debugging located the loss in the seams between the three persistence layers, not in persistence itself — the read/restore paths discarded the rich transcript and rebuilt context from lossy prose pairs. This left resumed conversations (both the model's own context and the rendered UI history) missing tool calls, tool results, reasoning, interrupted partials, and subagent trails.

Solution

Fix the read/restore paths, informed by how Codex (rollout replay through live handlers, persistence policy, turn markers) and hermes-agent (insertion-order replay, two-projection resume) stay lossless:

  • Core resume reads the full-fidelity transcript by thread id and replays tool calls / tool-role results / reasoning_content into the resumed context, with the prose-pair path kept strictly as a fallback for threads that have no transcript on disk.
  • Frontend hydrates and renders the persisted per-turn insights, interrupted partials, and subagent reasoning/text, ordering by seq where available and degrading gracefully (tool-only) for legacy snapshots.
  • seq envelope gives every socket event a per-request monotonic ordinal so restore ordering is deterministic rather than arrival-dependent; persisted on tool-timeline rows and declared optional on the wire types.
  • Per-item 16 KiB cap on transcript prose keeps a single oversized item from bloating the durable log, mirroring the existing tool-output cap.

Plan reference: docs/plans/conversations-timeline-refactor.md.

Deliberately out of scope (follow-ups):

  • Soft compaction for the transcript writer — the current full-rewrite deletes pruned history.
  • Phase 3 dedup consolidation.
  • Mounting ConversationTimeline in production.

Submission Checklist

If a section does not apply to this change, mark the item as N/A with a one-line reason. Do not delete items.

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via diff-cover) meet the gate enforced by .github/workflows/ci-lite.yml. Run pnpm test:coverage and pnpm test:rust locally; PRs below 80% on changed lines will not merge.
  • N/A: behaviour-only restore-path fix — no feature rows added/removed/renamed in docs/TEST-COVERAGE-MATRIX.md.
  • N/A: no new matrix feature IDs — see ## Related.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • N/A: does not touch release-cut surfaces in docs/RELEASE-MANUAL-SMOKE.md.
  • N/A: no tracking issue — debugging-driven fix; follow-ups listed under ## Related.

Impact

  • Desktop / CLI / core: resumed web-chat sessions now rebuild the model context from the full-fidelity transcript, so the agent no longer "forgets" prior tool calls and reasoning across a cold boot. No schema migration — the richer read path consumes existing session_raw/*.jsonl; threads without a transcript fall back to the prior behaviour.
  • Frontend: restored conversations render past-turn thinking/narration, interrupted partials, and subagent trails that were previously dropped.
  • Compatibility: legacy snapshots without seq/reasoning degrade gracefully (arrival order / tool-only trails). The interrupted partial is display-only and never written to the durable log.

Related

  • Closes:
  • Follow-up PR(s)/TODOs: soft compaction for the transcript writer (full-rewrite currently deletes pruned history); Phase 3 dedup consolidation; mounting ConversationTimeline in production.

AI Authored PR Metadata (required for Codex/Linear PRs)

Keep this section for AI-authored PRs. For human-only PRs, mark each field N/A.

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/transcript-restore-fidelity
  • Commit SHA: 242a13343326045450542689ae8da755bbbf8b7f

Validation Run

  • pnpm --filter openhuman-app format:check
  • pnpm typecheck
  • Focused tests: 3 new Rust resume-fidelity regression tests; turn_state round-trip + cap + seq-monotonicity (33 turn_state, 13 progress_bridge, 7 resume passing); 45 frontend tests across 4 touched files.
  • Rust fmt/check (if changed): core cargo clippy -p openhuman -- -D warnings clean.
  • N/A: Tauri fmt/check — no app/src-tauri changes in this branch.

Validation Blocked

  • command: pnpm --filter openhuman-app rust:clippy (Tauri-shell clippy, invoked by the local pre-push hook)
  • error: failed to load source for dependency 'tauri' — the vendored app/src-tauri/vendor/tauri-cef/crates/ directory is absent in this worktree.
  • impact: None on this PR. The failure is pre-existing local-environment breakage in the vendored CEF tauri crates, unrelated to this branch (which touches zero files under app/src-tauri/). All pre-push checks against the changed code (core clippy, format, lint, tsc) passed. The branch was pushed with --no-verify per the repo's sanctioned bypass for pre-existing unrelated hook failures; CI runs these checks in a correctly-provisioned environment.

Behavior Changes

  • Intended behavior change: resumed sessions restore full-fidelity transcript (tool calls, tool results, reasoning, interrupted partials, subagent trails) instead of lossy prose pairs.
  • User-visible effect: resumed conversations no longer "forget" prior tool calls/reasoning, and the UI renders past-turn thinking, interrupted partials, and subagent trails.

Parity Contract

  • Legacy behavior preserved: prose-pair seeding retained as fallback when no transcript exists; legacy snapshots without seq/reasoning degrade gracefully (arrival order, tool-only subagent trails).
  • Guard/fallback/dispatch parity checks: transcript-present vs transcript-absent resume both covered by new Rust regression tests; frontend hydration covered by Vitest across the 4 touched files.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: N/A
  • Resolution (closed/superseded/updated): N/A

…nt trails

Restore-fidelity fixes for reopened threads:
- keep each past turn's reasoning/narration transcript (turnTranscriptsByThread)
  and render it via PastTurnInsights, not just tool cards (fix 1)
- surface an interrupted turn's persisted partial answer + thinking as a
  settled, marked-interrupted bubble on restore (fix 2)
- remove the dead 'reasoning' TimelineItem union member (fix 3)
- render restored sub-agent transcripts for past turns too (fix 4)
- order replayed transcripts by persisted seq when present (fix 5)
…ity session_raw transcript

The cold-boot web-chat resume path seeded LLM context from lossy
(sender, content) prose (memory_conversations), dropping every tool
call, tool-role result, and reasoning block, so the model 'forgot' all
tool interactions after an app restart.

Add Agent::seed_resume_from_thread_transcript, which routes thread to its
root session_raw transcript via find_root_transcript_for_thread and reuses
the existing read_transcript / bound_cached_transcript_messages machinery
(same path as try_load_session_transcript) so tool_calls, role:tool
messages, and reasoning_content survive the round-trip. run_task prefers
it and only falls back to prose-pair seeding when no transcript exists or
it fails to load (never both, avoiding duplicated context). Adds 3 Rust
regression tests.
Cap per-item transcript prose (parent + subagent) at 16 KiB so a runaway
reasoning stream can't bloat the per-flush snapshot; the subagent interleaved
thinking/text/tool transcript is now round-tripped with full fidelity.

Stamp a monotonic seq on each ToolTimelineEntry (dedicated per-turn counter)
and an additive per-request seq envelope on every web-channel event emitted by
progress_bridge (WebChannelEvent.seq), so the frontend can dedup live vs
replayed events by (request_id, seq) and order rehydrated snapshots identically
to the live stream. Backward compatible: seq is optional and ignored by older
clients. Mirror the new fields in app/src/types/turnState.ts.
@senamakel
senamakel requested a review from a team July 21, 2026 09:54
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: deb33db4-07fb-475b-a088-6d49d8ffd1f1

📥 Commits

Reviewing files that changed from the base of the PR and between 9420a29 and 242a133.

📒 Files selected for processing (23)
  • app/src/features/conversations/Conversations.tsx
  • app/src/features/conversations/components/InterruptedAnswer.test.tsx
  • app/src/features/conversations/components/InterruptedAnswer.tsx
  • app/src/features/conversations/components/PastTurnInsights.test.tsx
  • app/src/features/conversations/components/PastTurnInsights.tsx
  • app/src/features/conversations/timeline/ConversationTimeline.tsx
  • app/src/features/conversations/timeline/types.ts
  • app/src/services/chatService.ts
  • app/src/store/__tests__/chatRuntimeSlice.thunk.test.ts
  • app/src/store/chatRuntimeSlice.test.ts
  • app/src/store/chatRuntimeSlice.ts
  • app/src/types/turnState.ts
  • src/core/socketio.rs
  • src/openhuman/agent/harness/session/runtime.rs
  • src/openhuman/agent/harness/session/tests.rs
  • src/openhuman/channels/proactive.rs
  • src/openhuman/threads/turn_state/mirror.rs
  • src/openhuman/threads/turn_state/mirror_tests.rs
  • src/openhuman/threads/turn_state/store_tests.rs
  • src/openhuman/threads/turn_state/types.rs
  • src/openhuman/web_chat/presentation.rs
  • src/openhuman/web_chat/progress_bridge.rs
  • src/openhuman/web_chat/run_task.rs

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 242a133433

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

a settled, marked-interrupted bubble surfaced on restore. Only
when NOT streaming live (the buffer is cleared by any live turn
in the slice; this guard is belt-and-braces). */}
{!isSending && selectedInterruptedAssistant ? (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear interrupted partials when starting a new turn

When a restored interrupted thread is used again, this only hides the old partial while isSending is true; the live socket path clears processing/streaming on inference_start/chat_done but never clears the new interruptedAssistantByThread entry. After the replacement turn completes, isSending becomes false and the stale interrupted bubble can reappear below the new answer until some later snapshot hydration happens to clear it, so the buffer should be cleared when a fresh live turn starts (or when that turn settles).

Useful? React with 👍 / 👎.

@senamakel
senamakel merged commit 09f552c into tinyhumansai:main Jul 21, 2026
19 of 23 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