Skip to content

Keep long runs' activity timeline within the 200-step limit - #649

Merged
sambitcreate merged 4 commits into
mainfrom
claude/project-thread-n3riys
Nov 1, 2026
Merged

sambitcreate merged 4 commits into
mainfrom
claude/project-thread-n3riys

Conversation

@sambitcreate

@sambitcreate sambitcreate commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Requested by sbt · project thread

Why

Every timeline reader accepts at most 200 steps: parseGenerationTimeline, iOS, Android, and the OpenAPI maxItems. But GenerationTimelineProjector had no cap. A run longer than that (about 100 tool calls with a thinking model) lost its timeline in two places:

  • chat-store-core appendMessage saved the reply with no timeline. The activity trail, question recaps, claim check and image placements were all gone.
  • Remote run-event-projection ignored every timeline event after step 200, so phone progress froze.

This came out of comparing the app against an upstream long-thread performance change.

What

  • The projector still keeps every step internally. Only snapshot() is bounded, through boundGenerationTimelineSteps (renderer/shared/generation-timeline.ts).

  • Fold order: the oldest settled tool steps drop first, in this order:

    1. routine read-only calls
    2. plain calls, which now include run_command
    3. calls with a recap, or that anchor an image or visual
    4. failed calls

    When a drop leaves two finished thoughts side by side, they merge. Reasoning stays fully covered and each thought stays where it happened.

  • Careful passes come first. They never join two reply text rows, never change the first step of a row that holds an image, visual or subagent (that would remount iframes), never fold subagent or recording steps, and keep the newest 40 steps.

  • If that is not enough, for example a run that writes a line before every call, later passes drop regardless. Moved text is better than losing the whole timeline.

  • Running steps never fold.

  • Folding is sticky: the projector remembers what it folded, so a step that settles later cannot bring back an earlier-dropped one.

  • order is renumbered. Step ids and public call-N ids are unchanged.

  • No protocol revision: the phones already accept up to 200 steps.

Trade-off: past 200 steps, the summary sentence counts only the kept steps. The screenshot shows "Explored 200 searches" for 210 calls.

Screenshots

A 210-call run in the Electron e2e harness.

  • Before (main): the saved reply has no activity trail at all.
  • After: the trail is kept.

Files (light, dark, and trail open) in the project folder upstream-two-changes/:

  • A-before-light.png
  • A-after-light.png
  • A-after-dark-trail-open.png

Tests

  • 5 long-run cases at the end of main/services/generation-timeline.test.ts:

    • thoughts and reads past 200, with reasoning intact and in order
    • tools only
    • a folded step never comes back
    • text and image rows don't move
    • a run that narrates every call

    The new and changed cases fail on the first version of this branch.

  • The generation-timeline, run-event-projection, chat-store-core and presentation suites pass, as do tsc and eslint.

Flaky tests

Reviews

Two review rounds. Fixed from them: dropped steps reappearing, row-key remounts, joined text rows, thoughts moving above tools, narrated runs losing the cap, and reopened merged thoughts.

Not fixed: if reconcileContentOffset later re-anchors offsets, a decision made earlier can join text rows. This only happens in turns over about 40 steps, and nothing breaks parsing.

Docs

docs/aiden-remote-api-v1.md (timeline bullet), docs/plans/long-thread-payload-upgrade-plan.md, docs/plans/README.md, and .memory/generation-timeline-step-bound.md.


Generated by Claude Code

The timeline projector had no step cap, but every reader (chat storage,
Aiden Remote, iOS, Android, the OpenAPI schema) rejects a timeline with
more than 200 steps. A run past that, about 100 tool calls with a
thinking model, was saved with no timeline at all, losing its activity
trail, question recaps, verification check and step-placed images, and
phones stopped getting progress at step 200.

The projector still records every step, but what it publishes is now
bounded: older finished thinking stretches merge into one whose
reasoning span covers theirs, then the oldest settled tool steps drop,
read-only calls first and failed calls last. Running steps and the
newest 40 are never folded, and public call ids are unchanged. No
protocol revision: phones already accept up to 200 steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018VA6RJCS8ZrZhCj6xAxhhS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018VA6RJCS8ZrZhCj6xAxhhS
Review follow-up. Drops no longer move reply text or an image row's
first step, thoughts merge only with a neighbour at the same offset so
they stay where they happened, subagent and recording steps never fold,
and the projector remembers what it folded so a step that settles later
cannot bring an earlier one back. The newest 40 steps fold only when
nothing older can.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018VA6RJCS8ZrZhCj6xAxhhS
Second review follow-up. When the careful passes cannot make room (a run
that writes a line before each call puts every call at its own offset),
later passes drop regardless, so the reply keeps a timeline with its text
joined rather than losing the timeline. Finished thoughts that sit side by
side now join whenever room is needed, and a merged thought that reopens
keeps an open reasoning span.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018VA6RJCS8ZrZhCj6xAxhhS
@sambitcreate sambitcreate self-assigned this Oct 29, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes across the projector, shared timeline folding, long-run regression tests, documentation, and downstream desktop/remote/native consumers.

  • Bounded snapshots: Keep the projector's complete internal history while publishing timelines within the existing 200-step reader limit.
  • Stable folding: Persist removal and thinking-merge decisions, preserve public call IDs, and renumber retained steps without disrupting internal reconciliation indexes.
  • Prioritized retention: Prefer routine settled calls for removal, preserve text boundaries and anchored activity rows where possible, and use documented relaxed fallback passes when necessary.
  • Behavioral coverage and docs: Exercise long reasoning/tool runs, sticky folding, visual-row stability, and narrated runs; document retention rules and summary-count tradeoffs.
  • Validation: All 177 focused desktop tests passed. Inspected both native validators and chronological projections. Android tests and an offline retry each timed out after 120000 ms; iOS tests could not run because xcodebuild is unavailable. Hosted CI was still pending when checked, so this review does not establish full CI or native acceptance.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

Copy link
Copy Markdown
Owner Author

CI on f716caf failed in the Linux Electron e2e job, and the two Linux packaging jobs (x64, arm64) failed after it. All 242 tests passed and 1 was flaky. The job fails on any flaky test:

  • tests/e2e/inline-visuals.spec.ts:47 › a reply draws native and HTML visuals inline, and both get snapshots for phones (run)

This spec is already on the known-flaky list from #583 (run 39813515653, the Weekly total iframe timing out after relaunch). This PR's fold runs only past 200 steps; under that it returns the steps unchanged, and that spec's run is a few steps long. I re-ran the failed jobs once. If it fails again, I'll treat it as real and dig in.


Generated by Claude Code

@very-hermes-bot

Copy link
Copy Markdown
Collaborator

Hermes Review Bot

Confidence: 4

Engine: opencode/opencode-go/deepseek-v4.1-flash
Review mode: full
Head: f716cafcce9105acd669fe07798fe1bdf188f02d
Generated: 2026-10-31T05:40:50+00:00
Reviews: 1

Summary

The projector now publishes a bounded view of the timeline: snapshot() passes the full internal step list (plus a sticky GenerationTimelineFolds record) through boundGenerationTimelineSteps, which drops the oldest settled tool steps by rank, merges adjacent finished thoughts, renumbers order, and leaves the newest 40 steps untouched for the careful passes. The internal projector state is unchanged, so stepIndex, reasoning reconciliation, and public call-N ids keep working; only what is emitted/saved is capped at MAX_GENERATION_TIMELINE_STEPS (200). The five new tests cover the saved-path regression, drop ordering, sticky drops, text/image row stability, and the relaxed narrated-run fallback. The one thing to double-check is the acknowledged reconcileContentOffset case: a drop decision made before offsets are re-anchored can leave two text rows joined later in the turn.

Confidence Score: 4/5

I traced the projector through snapshot(), finish(), claim-check attachment, chat persistence, the Remote event projection, and the renderer presentation rows, and read all changed files in full; I did not execute the test suites.

📁 Important Files Changed
  • renderer/shared/generation-timeline.ts — adds MAX_GENERATION_TIMELINE_STEPS, uses it in parseGenerationTimeline, and adds the whole fold algorithm (foldRank, canDrop, mergeThinking, GenerationTimelineFolds, boundGenerationTimelineSteps).
  • main/services/generation-timeline.ts — owns the per-run folds state and routes every published snapshot() through the bound function; nothing else in the projector changed.
  • main/services/generation-timeline.test.ts — five long-run tests exercising saved replay, drop ordering, sticky folds, row/text stability, and narrated runs.
  • docs/aiden-remote-api-v1.md — documents the bounded timeline event behavior on the wire contract.
  • docs/plans/long-thread-payload-upgrade-plan.md, docs/plans/README.md, .memory/generation-timeline-step-bound.md — plan/status/memory records for the fix.

Findings

No findings.

📊 Sequence Diagram
sequenceDiagram
  participant P as GenerationTimelineProjector
  participant B as boundGenerationTimelineSteps
  participant S as chat-store appendMessage
  participant R as run-event-projection

  P->>B: snapshot() copies internal steps + sticky folds
  B->>B: drop/merge oldest ranks until <= 200, remember folds
  B-->>P: bounded, order-renumbered steps
  P->>S: finish() timeline on assistant save
  S->>S: parseGenerationTimeline(steps <= 200)
  P->>R: chat:timeline event
  R->>R: parseGenerationTimeline(payload.timeline)
Loading

Machine-Readable Findings

[]

Last reviewed commit: f716cafcce91
Reviews (1) · Comment /hermes review to trigger a new review · /hermes review full for full re-review

@sambitcreate
sambitcreate merged commit 7a39f72 into main Nov 1, 2026
47 of 50 checks passed
@sambitcreate
sambitcreate deleted the claude/project-thread-n3riys branch November 1, 2026 21:14
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.

3 participants