Skip to content

Skip persisted tool_progress entries during session replay - #3909

Merged
youknowriad merged 2 commits into
Automattic:trunkfrom
silvaitamar:fix/cli-skip-tool-progress-replay
Jun 29, 2026
Merged

Skip persisted tool_progress entries during session replay#3909
youknowriad merged 2 commits into
Automattic:trunkfrom
silvaitamar:fix/cli-skip-tool-progress-replay

Conversation

@silvaitamar

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Used Cursor to locate the affected code path (replaySessionHistory) and to
draft the change and its unit test. I reviewed the diff myself and validated it
locally (see Testing Instructions). The change is intentionally minimal and
scoped to the resume hang.

Proposed Changes

Interactive studio code sessions resume could hang on "Resuming session…"
because session replay re-emitted every persisted studio.tool_progress entry
to the loader. On sessions that accumulated tens of thousands of progress ticks,
this is an O(n) UI redraw before the session becomes usable.

Tool progress is ephemeral UI state with no value when rehydrating history
(finishReplay() clears the loader at the end anyway), so this skips those
entries during replay. Conversation context — messages, tool results, site
selection, and agent questions — is unchanged, and live progress during a run is
not affected.

Out of scope (tracked in #3865): progress is still persisted to the JSONL, and
studio code sessions list still parses full session files. Those are separate
concerns better addressed in follow-up PRs.

Testing Instructions

  1. Resume a session that contains many studio.tool_progress entries (a real
    bloated session, or one crafted with thousands of such lines).
  2. Run studio code sessions resume <id> (interactive TUI).
    • Before: stays on "Resuming session…" for a long time / appears frozen.
    • After: resumes promptly, with full conversation context restored.
  3. Confirm a normal session still replays messages, tool results, and the
    selected site correctly.

Unit test: npm run test -- apps/cli/ai/sessions/tests/replay.test.ts

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
Interactive `studio code sessions resume` could hang on "Resuming
session..." because replaySessionHistory re-emitted every persisted
studio.tool_progress entry to the loader. On sessions with tens of
thousands of progress ticks this is an O(n) UI redraw before the
session becomes usable.

Tool progress is ephemeral UI state with no value when rehydrating
history (finishReplay clears the loader anyway), so skip it during
replay. Conversation context (messages, tool results, site selection,
agent questions) is unchanged.

Adds a unit test covering that progress entries are not replayed while
the surrounding conversation still is.

Co-authored-by: Cursor <cursoragent@cursor.com>

@youknowriad youknowriad 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.

Not entirely convinced these tests add value but I appreciate the fix. Thanks

@youknowriad
youknowriad enabled auto-merge (squash) June 29, 2026 14:47
@youknowriad
youknowriad disabled auto-merge June 29, 2026 15:42
@youknowriad
youknowriad merged commit 0890a32 into Automattic:trunk Jun 29, 2026
2 checks passed
@silvaitamar

Copy link
Copy Markdown
Contributor Author

Thanks for the review and for merging this, @youknowriad .

Happy to adjust the test coverage if the team prefers a different approach
later. Glad the replay fix helps.

silvaitamar added a commit to silvaitamar/wp-studio-session-cleaner that referenced this pull request Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants