Skip to content

Skip persisted tool_progress entries during session replay#3909

Open
silvaitamar wants to merge 1 commit into
Automattic:trunkfrom
silvaitamar:fix/cli-skip-tool-progress-replay
Open

Skip persisted tool_progress entries during session replay#3909
silvaitamar wants to merge 1 commit into
Automattic:trunkfrom
silvaitamar:fix/cli-skip-tool-progress-replay

Conversation

@silvaitamar

Copy link
Copy Markdown

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interactive session resume hangs when JSONL accumulates studio.tool_progress entries

1 participant