Skip to content

Deepen conversation fold/feed/bus modules from architecture review - #141

Merged
soorya-u merged 2 commits into
mainfrom
arch-review/fold-feed-bus-deepening
Aug 5, 2026
Merged

Deepen conversation fold/feed/bus modules from architecture review#141
soorya-u merged 2 commits into
mainfrom
arch-review/fold-feed-bus-deepening

Conversation

@soorya-u

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

Copy link
Copy Markdown
Owner

Summary

Follow-up to #140, from an /improve-codebase-architecture review of the conversation-folding / thread-feed / thread-event-bus layer.

  • ToolRow click-target seam — scope the clickable row to just the header instead of the whole row+children. The PR's own follow-up fix stopped propagation at DiffRow's header button, but the open diff body (PatchDiff) had no such guard — any interactive element inside it still bubbled up and collapsed the tool row. Scoping the click target removes the need for any descendant to remember stopPropagation at all (and DiffRow's is now removed as dead defensive code).
  • Consolidate seq/sub orderingentries.ts and thread-feed.ts each implemented their own seq/sub comparator; extracted into a shared order-key.ts. Also fixes getTurnStartedAt, which still ordered a turn's first activity by createdAt string comparison — the same bug class this PR's own follow-up fixed in fold.ts's latestTurnIdFromEntries, just one file over and unfixed.
  • Consolidate turn-terminal tracking — "is this turn over" was decided independently in three places (turn-waiters.ts, conversation-cache.ts, use-worker-conversation-sync.ts), each with its own copy of the same predicate, and settled via two independent trackers (turnWaiters Map, completedTurnKeys Set) kept in sync only by convention across multiple call sites. Now one shared isTerminalEvent predicate, and commitChunk settles any pending waitForTurnEnd() waiter automatically whenever a terminal chunk is committed, instead of relying on callers to remember a second manual step.
  • Wire snapshotHighWaterMark into a staleness checkwatchThread returns a watermark for exactly this purpose (ADR-0008), but no client ever read it. Entries persisted just before a peer starts watching a thread could be silently missed. Now useThreadConversation compares the watermark against the cached snapshot on watch and invalidates to catch up if needed.
  • Lock in ThreadEventBus eviction behavior with a test — investigated as a candidate "delta-first eviction isn't implemented" (ADR-0008), but found the property already holds by construction: ephemeral deltas never enter the bounded per-turn replay log in the first place, so there was nothing to fix. Added the missing eviction test and a comment documenting the invariant.

Test plan

  • bun run test:unit — 220 tests pass (vitest + bun test), including new regression tests for each fix
  • bun run check:types — clean across all 17 packages
  • ultracite check on all touched files — clean

Summary by CodeRabbit

  • Bug Fixes
    • Prevented clicking within an expanded diff from collapsing its parent tool entry.
    • Improved conversation synchronization so stale thread views refresh automatically.
    • Fixed interrupted turns so pending activity completes with the correct status.
    • Improved timeline ordering and turn start times for more accurate conversation history.
    • Limited replayed queue content to the newest three chunks after overflow.

Scope click-target on ToolRow to its header instead of the whole row,
so future interactive children (like DiffRow's open diff body) don't
need to remember stopPropagation. Consolidate the seq/sub ordering
comparator used by entries.ts and thread-feed.ts into one order-key
module, and fix getTurnStartedAt to order by seq/sub instead of a
skewed createdAt — the same bug class just fixed in fold.ts one file
over. Consolidate turn-terminal tracking behind one shared predicate
and settle pending waitForTurnEnd() waiters from the single cache
commit chokepoint, instead of two independent trackers kept in sync by
convention across three call sites. Wire watchThread's
snapshotHighWaterMark into a cache-invalidation check so entries
persisted just before a peer starts watching are no longer silently
missed. Lock in ThreadEventBus's replay-log eviction behavior with a
test (deltas already never enter the log, so eviction is delta-first
by construction).

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 1:57pm

@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: 53 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: 4b5233a5-f6bb-4909-8285-6e0432ca884b

📥 Commits

Reviewing files that changed from the base of the PR and between df50aed and 93c4be5.

📒 Files selected for processing (1)
  • apps/web/src/components/chat/work-log/tool-row.tsx
📝 Walkthrough

Walkthrough

The change centralizes conversation ordering and terminal-event handling, adds snapshot watermark recovery, updates work-log expansion behavior, and tests per-turn queue replay limits.

Changes

Conversation synchronization and ordering

Layer / File(s) Summary
Sequence ordering and turn start selection
shared/utils/src/conversations/order-key.ts, shared/utils/src/conversations/entries.ts, shared/utils/src/conversations/thread-feed.ts, shared/utils/src/conversations/*test.ts
Shared utilities compare entries by seq and sub. getTurnStartedAt now uses this ordering instead of createdAt.
Snapshot watermark recovery
shared/utils/src/conversations/entries.ts, shared/hooks/src/conversation/use-thread-conversation.ts, shared/utils/src/conversations/entries.test.ts
Thread watching invalidates the thread query when the cached snapshot is behind snapshotHighWaterMark.
Terminal event settlement
shared/utils/src/conversations/turn-waiters.ts, shared/hooks/src/conversation/conversation-cache.ts, shared/hooks/src/conversation/use-thread-turns.ts, shared/hooks/src/conversation/use-worker-conversation-sync.ts, shared/hooks/src/conversation/conversation-cache.test.ts
Terminal-event detection is shared. Committed chunks settle turn waiters, including interrupted turns. Duplicate settlement paths were removed.

Work-log expansion interaction

Layer / File(s) Summary
Expandable row interaction boundaries
apps/web/src/components/chat/work-log/tool-row.tsx, apps/web/src/components/chat/work-log/diff-row.tsx, apps/web/src/components/chat/work-log/tool-row.test.tsx
The tool-row header owns expansion and keyboard behavior. Open nested diff content no longer collapses the parent row.

Queue replay retention coverage

Layer / File(s) Summary
Per-turn replay retention test
apps/cli/src/queue/bus.test.ts
The test verifies that replay after overflow returns only the newest three persisted chunks per turn.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • soorya-u/cyrus#23: Overlaps the conversation cache, turn-waiter, thread-watching, and ordering flows.
  • soorya-u/cyrus#56: Overlaps worker conversation synchronization and terminal-event settlement.
  • soorya-u/cyrus#140: Overlaps conversation sequencing, cache logic, queue tests, and work-log components.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.76% 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 accurately identifies the main conversation folding, feed, and event bus changes from the architecture review.
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 arch-review/fold-feed-bus-deepening

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: 1

🤖 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 71-83: Add aria-expanded={open} to the same header div props
guarded by canExpand, alongside role, tabIndex, onClick, and onKeyDown, so the
disclosure exposes its current expansion state.
🪄 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: a0175440-f3e7-47f5-b8bf-d31cf12eb28b

📥 Commits

Reviewing files that changed from the base of the PR and between 365e5cf and df50aed.

📒 Files selected for processing (16)
  • apps/cli/src/queue/bus.test.ts
  • apps/web/src/components/chat/work-log/diff-row.tsx
  • apps/web/src/components/chat/work-log/tool-row.test.tsx
  • apps/web/src/components/chat/work-log/tool-row.tsx
  • shared/hooks/src/conversation/conversation-cache.test.ts
  • shared/hooks/src/conversation/conversation-cache.ts
  • shared/hooks/src/conversation/use-thread-conversation.ts
  • shared/hooks/src/conversation/use-thread-turns.ts
  • shared/hooks/src/conversation/use-worker-conversation-sync.ts
  • shared/utils/src/conversations/entries.test.ts
  • shared/utils/src/conversations/entries.ts
  • shared/utils/src/conversations/order-key.test.ts
  • shared/utils/src/conversations/order-key.ts
  • shared/utils/src/conversations/thread-feed.test.ts
  • shared/utils/src/conversations/thread-feed.ts
  • shared/utils/src/conversations/turn-waiters.ts

Comment thread apps/web/src/components/chat/work-log/tool-row.tsx
Addresses CodeRabbit review comment on PR #141: the expandable header
div sets role="button" but never exposed its open/closed state to
assistive tech.
@soorya-u

soorya-u commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

Addressed in 93c4be5: added aria-expanded={open} to the header div alongside role="button", tabIndex, onClick, and onKeyDown.

@soorya-u
soorya-u merged commit aaa2093 into main Aug 5, 2026
9 checks passed
@soorya-u
soorya-u deleted the arch-review/fold-feed-bus-deepening branch August 5, 2026 13:58
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