Skip to content

fix(orgtrack): add reply preview + end time to Claude placeholders - #849

Merged
Neonforge98 merged 1 commit into
developfrom
fix/claude-window-turn-previews
Aug 21, 2026
Merged

fix(orgtrack): add reply preview + end time to Claude placeholders#849
Neonforge98 merged 1 commit into
developfrom
fix/claude-window-turn-previews

Conversation

@Harry19081

Copy link
Copy Markdown
Member

Summary

Claude Code replays open through the reduced user-row index, and every round except the newest collapses into an unloadedTurn placeholder. Unlike every full-stream provider, those placeholders carried no final-reply preview and no end timestamp — so collapsed rounds rendered an empty "Agent worked for <1min" bar with nothing under it. This PR makes the Claude fast path emit the same placeholder metadata the generic imported-history window builder produces.

Problem

load_claude_code_initial_window_for_session pushes only the user header chunk for rounds outside the recent window. Downstream, build_initial_window_from_turns derives a collapsed round's last-reply preview (turnPreviewOnly) and endedAt from the round's body chunks — which the Claude path never supplies. The result in the Chat Pane:

  • No closing agent message under the collapse bar (every other provider shows one).
  • endedAt == startedAt, so the bar reads <1min with no HH:MM – HH:MM range regardless of the round's real duration.

Solution

  • The byte-offset index scan (index_claude_user_turns) now records, per round, the byte range of the newest line that raw-scans as an assistant message with a text item (last_assistant_text_line). The scan stays raw-prefilter only — no extra JSON parsing.
  • For unloaded rounds, the initial-window loader seeks and parses just that one line and feeds the resulting assistant chunk to the shared window builder, which consumes it into the placeholder's preview text and (via turn projection) a real endedAt. The chunk itself never crosses the wire.
  • overlay_indexed_body_counts takes the loaded-turn boundary so reduced rounds keep the honest line-count surrogate as bodyEventCount even though they now project one preview chunk.

Potential risks

  • The raw prefilter can false-positive (e.g. \"type\":\"text\" inside a tool input) — the canonical parser then finds no assistant text and the round simply stays preview-less, the previous behavior. It can also pick a text line followed only by tool activity, making endedAt the last reply time rather than the last event time; that is an approximation, but strictly better than startedAt.
  • One extra seek + single-line parse per unloaded round on first open (bounded by round count, not transcript size). Recent rounds are unaffected.
  • Rounds whose reply line prefilters but parses empty keep no preview; expansion via the existing turn-window loader is unchanged.

Validation / Test plan

  • claude_initial_window_placeholders_advertise_fetchable_bodies now runs the real path-based loader end to end and additionally asserts each placeholder carries turnPreviewOnly, the round's closing reply text, and endedAt > startedAt, while the loaded round keeps its exact projected counts.
  • New claude_initial_window_previews_skip_tool_use_only_assistant_lines covers tool_use-only assistant lines not displacing the text candidate, and that no stray body chunks leak next to an unloaded round.
  • cargo test -p orgtrack_core: 550 passed. cargo clippy -p orgtrack_core --all-targets clean; full src-tauri workspace cargo check clean.

Pre-commit hook ran. Total eslint: 5, total circular: 0
@Neonforge98
Neonforge98 merged commit 7b8f532 into develop Aug 21, 2026
3 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.

2 participants