Skip to content

Refactor conversation folding/thread-feed and thread event bus - #140

Merged
soorya-u merged 2 commits into
mainfrom
conversation-fold-and-bus-refactor
Aug 5, 2026
Merged

soorya-u merged 2 commits into
mainfrom
conversation-fold-and-bus-refactor

Conversation

@soorya-u

@soorya-u soorya-u commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Simplify fold/thread-feed conversation logic in shared/utils, with new/expanded test coverage
  • Add ephemeral-vs-persisted chunk stamping to the CLI thread event bus (apps/cli/src/queue/bus.ts), with new tests
  • Reorganize auth UI components and move show.tsx into components/helpers

Test plan

  • turbo check:types passes
  • knip passes
  • syncpack lint passes
  • vitest run and bun test:unit pass (104 tests passed, 1 skipped)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved live conversation updates with more reliable ordering, replay, and incremental loading.
    • Tool activity now displays associated file changes as expandable diff details.
    • Added clearer sequencing for streamed messages, thoughts, approvals, and other conversation events.
  • Bug Fixes

    • Improved handling of optimistic updates and reconnects to reduce duplicated or misplaced conversation entries.
    • Preserved streamed content more reliably while updates are received.
  • Refactor

    • Standardized conditional rendering across authentication and chat interfaces without changing their behavior.

…auth UI

Simplifies fold/thread-feed logic with test coverage, adds ephemeral vs
persisted chunk stamping to the CLI event bus, and reorganizes auth
component internals (moves show.tsx into components/helpers).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cyrus Ready Ready Preview Aug 5, 2026 12:22pm

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@soorya-u, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7eae17d2-4f34-4f81-a150-1d1c3215fd13

📥 Commits

Reviewing files that changed from the base of the PR and between 524e83d and e262d32.

📒 Files selected for processing (4)
  • apps/web/src/components/chat/work-log/diff-row.tsx
  • apps/web/src/components/chat/work-log/tool-row.test.tsx
  • shared/utils/src/conversations/fold.test.ts
  • shared/utils/src/conversations/fold.ts
📝 Walkthrough

Walkthrough

Conversation processing now uses seq and sub metadata for streaming, caching, folding, replay, and feed ordering. Tool diffs are nested in tool calls. Web components use a shared Show helper for conditional rendering.

Changes

Conversation sequencing and feed pipeline

Layer / File(s) Summary
Sequence and view contracts
shared/schemas/src/rtc/*, shared/schemas/src/view/index.ts
Schemas add optional subsequences and required sequence fields. Tool-call views now contain nested diffs.
Entry ordering and merging
shared/utils/src/conversations/entries.ts, shared/utils/src/conversations/entries.test.ts
Entries classify persistence by sub, sort by (seq, sub, createdAt), calculate persisted sequence values, and merge cached entries with fetched entries.
Conversation folding and feed construction
shared/utils/src/conversations/fold.ts, shared/utils/src/conversations/thread-feed.ts, shared/utils/src/conversations/*test.ts
Folding stores sequence metadata, derives tool-call diffs, preserves sorted input order, and builds feeds with sequence-based ordering.
Streaming cache and event-bus replay
apps/cli/src/queue/*, shared/hooks/src/conversation/*, shared/hooks/package.json
The event bus stamps ephemeral chunks. Conversation caching uses Throttler, subsequence-aware pruning, optimistic sequence values, and incremental fetching.
Conditional UI and tool-diff rendering
apps/web/src/components/helpers/show.tsx, apps/web/src/components/auth/*, apps/web/src/components/chat/*
The shared Show helper replaces inline conditional JSX. Tool rows render nested diffs, and standalone diff feed entries are removed.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.77% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary changes to conversation folding, thread-feed logic, and the thread event bus.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch conversation-fold-and-bus-refactor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/src/components/chat/work-log/tool-row.tsx`:
- Around line 56-57: Prevent nested DiffRow controls from triggering the parent
ToolRow expansion handlers: either move the parent expand/collapse role and
handlers to the tool header, or stop click and keyboard event propagation in
DiffRow while preserving both toggle behaviors. Add a regression test verifying
that opening a diff leaves its parent tool row open.

In `@shared/utils/src/conversations/fold.ts`:
- Around line 463-467: Update latestTurnIdFromEntries() to determine the latest
user turn from canonical (seq, sub) entry order rather than createdAt, scanning
sorted entries in reverse or comparing sequence keys directly. Preserve the
active-turn streaming and turn-state behavior, and add coverage with reversed
timestamps where a later running turn remains identified as latest.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4d311f50-05ef-4124-b10b-8bb6fb979942

📥 Commits

Reviewing files that changed from the base of the PR and between ad69ef8 and 524e83d.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (29)
  • apps/cli/package.json
  • apps/cli/src/queue/bus.test.ts
  • apps/cli/src/queue/bus.ts
  • apps/web/src/components/auth/login-form.tsx
  • apps/web/src/components/auth/magic-link-sent.tsx
  • apps/web/src/components/auth/provider-button.tsx
  • apps/web/src/components/auth/security/active-session.tsx
  • apps/web/src/components/auth/security/active-sessions.tsx
  • apps/web/src/components/auth/security/linked-accounts.tsx
  • apps/web/src/components/chat/composer/agent-model-picker.tsx
  • apps/web/src/components/chat/composer/compact-composer-controls.tsx
  • apps/web/src/components/chat/composer/footer-controls.tsx
  • apps/web/src/components/chat/feed/feed-entry-view.tsx
  • apps/web/src/components/chat/work-log/diff-row.tsx
  • apps/web/src/components/chat/work-log/tool-row.tsx
  • apps/web/src/components/helpers/show.tsx
  • shared/hooks/package.json
  • shared/hooks/src/conversation/conversation-cache.ts
  • shared/hooks/src/conversation/use-interactive-respond.ts
  • shared/hooks/src/conversation/use-thread-conversation.ts
  • shared/schemas/src/rtc/chat.ts
  • shared/schemas/src/rtc/threads.ts
  • shared/schemas/src/view/index.ts
  • shared/utils/src/conversations/entries.test.ts
  • shared/utils/src/conversations/entries.ts
  • shared/utils/src/conversations/fold.test.ts
  • shared/utils/src/conversations/fold.ts
  • shared/utils/src/conversations/thread-feed.test.ts
  • shared/utils/src/conversations/thread-feed.ts
💤 Files with no reviewable changes (1)
  • apps/web/src/components/chat/feed/feed-entry-view.tsx

Comment thread apps/web/src/components/chat/work-log/tool-row.tsx
Comment thread shared/utils/src/conversations/fold.ts Outdated
…urn lookup

DiffRow's toggle button click bubbled up into ToolRow's own click handler,
closing the parent row (and unmounting the diff) whenever a diff was opened.
Stop propagation in DiffRow.

latestTurnIdFromEntries still compared createdAt strings after fold.ts moved
to trusting entry array position (seq, sub) as the canonical order; reversed
or skewed timestamps could pick the wrong turn as latest. Take the last
user_message in iteration order instead.

Addresses CodeRabbit review comments on PR #140.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@soorya-u
soorya-u merged commit 8897efb into main Aug 5, 2026
9 checks passed
@soorya-u
soorya-u deleted the conversation-fold-and-bus-refactor branch August 5, 2026 12:24

This branch was successfully deployed

1 active deployment
Preview — e262d327 Deployed Aug 5, 2026 by vercel[bot]
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.

1 participant