Skip to content

Keep an answer visible when the turn continues without work - #1033

Open
Piyushrathoree wants to merge 1 commit into
hardbeat920:mainfrom
Piyushrathoree:fix/claude-stop-hook-fold-hides-answer
Open

Piyushrathoree wants to merge 1 commit into
hardbeat920:mainfrom
Piyushrathoree:fix/claude-stop-hook-fold-hides-answer

Conversation

@Piyushrathoree

@Piyushrathoree Piyushrathoree commented Oct 16, 2026 •

Copy link
Copy Markdown

What changed

foldableWork() no longer ends the fold at a run of reasoning alone. An activity group can anchor the fold only when it holds actual tool calls, so a turn the agent continued after answering — a Stop hook feeding its message back — keeps the message it interrupted visible, with the continuation below it.

Why

Fixes #952. A Stop hook exits 2 to continue the turn, so the transcript ends up prompt → answer → thinking → one more line. The fold treated the thinking as work the answer narrated, demoted the answer into the trail ("thought process"), and showed only the continuation as the reply. The CLI shows both messages in order.

Mid-turn commentary still folds — every run there holds tools; only reasoning-only trails change.

UI

No chrome change. The fold line no longer swallows the first message: both appear in order, and the setup that folded nothing at all now shows no "Show the work" toggle. (Repro needs a Stop hook, so the before state isn't screenshot-able here.)

Checklist

  • I ran npm run check (npm run check:web: vitest 483 files / 5366 tests passed; tsc --noEmit clean; no Rust touched)
  • This PR is small and focused
  • I did not mix unrelated changes

Summary by CodeRabbit

  • Bug Fixes
    • Transcript work is now folded only when it includes tool activity. Assistant messages followed by reasoning or notes without tool activity remain visible without a “Show the work” toggle.
    • When work is folded, the continuation’s reasoning and tool activity are included, while its final answer remains visible.

A Stop hook that continues a turn (exit 2) fed the answer it interrupted into the work trail: foldableWork() ended the fold at any activity group below a prose message, including reasoning-only runs, then extended the fold over the prose. Only the continuation's text stayed visible as the reply.

An activity run can carry the fold now only when it holds actual tool calls, so a continuation with nothing but thinking leaves both messages in the order the CLI shows them. Commentary on real work still folds as before. Fixes hardbeat920#952.
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a47e9bca-4cdf-43a0-bfb1-bf16d8f60e76
📥 Commits

Reviewing files that changed from the base of the PR and between e49a5ae and 1116022.

📒 Files selected for processing: 3
  • src/features/sessions/model/transcriptActivity.test.ts
  • src/features/sessions/model/transcriptActivity.ts
  • src/features/sessions/ui/AgentTranscript.foldProse.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

Transcript folding now requires an eligible activity group to contain a tool call. Added tests check that assistant messages remain visible when a continuation has no tools and that folding includes tool-running continuation work.

Changes: Assistant transcript folding

Layer / File(s) Summary
Require tools for foldable work
src/features/sessions/model/transcriptActivity.ts, src/features/sessions/model/transcriptActivity.test.ts, src/features/sessions/ui/AgentTranscript.foldProse.test.ts
foldableWork now requires an eligible activity group to contain a tool block. Tests cover continuations with and without tool calls, including which content the fold contains.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: hardbeat920

Merge Risk: ⚪ Minimal · up to 11160

Assistant answers stay visible when a turn continues without tool work, while tool-related commentary still folds. No merge-blocking risk remains.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: preserving an answer when the turn continues without tool work.
Description check Passed The description includes all required sections, explains the change and reason, addresses UI impact, and completes the checklist with test results.
Linked Issues check Passed Issue #952 requires the earlier assistant answer to remain visible when a Stop hook continues the turn. The change makes foldableWork() select a fold only when an eligible activity group contains a …
Out of Scope Changes check Passed The changed files are limited to foldableWork() and focused model and transcript rendering tests. The implementation preserves folding for activity groups that contain tool calls. The tests verify b…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files.
Full details: Linked Issues check

Explanation

Issue #952 requires the earlier assistant answer to remain visible when a Stop hook continues the turn. The change makes foldableWork() select a fold only when an eligible activity group contains a tool block. Reasoning-only continuation groups therefore do not absorb the earlier answer. The added model and UI tests cover the no-tool continuation and verify that both assistant messages render without a Show the work toggle. The reported check run also passed.

Full details: Out of Scope Changes check

Explanation

The changed files are limited to foldableWork() and focused model and transcript rendering tests. The implementation preserves folding for activity groups that contain tool calls. The tests verify both the issue case and the existing tool-work behavior. No unrelated production or test changes are shown.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

[Bug]: A Stop hook that continues the turn hides the real answer under "thought process"

1 participant