Skip to content

refactor(web): split ThreadChip into composable primitives#271

Merged
pedroscosta merged 2 commits into
mainfrom
refactor/thread-chip-composition
May 13, 2026
Merged

refactor(web): split ThreadChip into composable primitives#271
pedroscosta merged 2 commits into
mainfrom
refactor/thread-chip-composition

Conversation

@pedroscosta
Copy link
Copy Markdown
Collaborator

@pedroscosta pedroscosta commented May 12, 2026

Summary

  • Replace BaseThreadChip / ThreadChip pair with three primitives: ThreadChip (chip-only), ThreadSummaryCard (panel content), ThreadSummaryHoverCard (hover-card wrapper around any trigger element)
  • Add ThreadChipWithSummary as a thin convenience composing the above
  • Drop the unstyled chip variant; the signals action rows now render their inline thread reference directly (avatar + name + #shortId in a Link) and wrap it with ThreadSummaryHoverCard for the summary preview
  • Widen the duplicateThread include in threads/updates.tsx so the new summary card can render the assignee avatar

Test plan

  • bun run --filter web typecheck
  • Hover the thread mention chip inside a markdown message — summary card appears with status / priority / assignee
  • Signals action rows — inline thread refs hover-preview correctly and the link still navigates
  • "Marked as duplicate" thread update entry — hover preview works
  • Thread toolbar duplicate-suggestion chips (quick-actions + support-intelligence) — shared hover card with action buttons still opens; chip styling unchanged

🤖 Generated with Claude Code


Summary by cubic

Split the thread mention UI into three composable primitives—ThreadChip, ThreadSummaryCard, and ThreadSummaryHoverCard—to make hover previews reusable across the app. Also fixed the assignee avatar in the summary card to use the author image.

  • Refactors

    • Added ThreadChip (chip-only), ThreadSummaryCard (panel content), ThreadSummaryHoverCard (wrap any trigger), and ThreadChipWithSummary (convenience).
    • Replaced markdown mentions with ThreadChipWithSummary; signals action rows now inline render (avatar + name + #shortId) wrapped in ThreadSummaryHoverCard.
    • Quick actions and support intelligence now use ThreadChip for chip-only use.
    • Broadened duplicate thread query to include assignedUser.user so the summary can show the assignee details.
  • Migration

    • Use ThreadChip for chip-only rendering.
    • Wrap any element with ThreadSummaryHoverCard to add a summary preview.
    • Use ThreadChipWithSummary when you want a chip with a preview.
    • Remove any variant="unstyled" usage and inline the content where needed.

Written for commit d2e2b96. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Hover cards now show full thread summaries (status, priority, assignee/unassigned, creation time) when hovering thread references.
  • Refactor

    • Thread references simplified to compact chips showing thread name and author avatar.
    • Thread mention, signal action rows, duplicate suggestions, and thread updates now use the new summary hover behavior for consistent presentation.

Review Change Stack

Replace BaseThreadChip/ThreadChip pair with ThreadChip, ThreadSummaryCard, and
ThreadSummaryHoverCard primitives plus a ThreadChipWithSummary convenience.
Drops the "unstyled" variant in favor of inline rendering composed with the
new hover card.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94a3c2ee-2324-47dc-8cbb-74b55489fff2

📥 Commits

Reviewing files that changed from the base of the PR and between 3958cb8 and d2e2b96.

📒 Files selected for processing (1)
  • apps/web/src/components/chips.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/components/chips.tsx

📝 Walkthrough

Walkthrough

ThreadChip is refactored from a hover-card-backed component into a plain button chip; hover and summary UI moved into ThreadSummaryCard/ThreadSummaryHoverCard/ThreadChipWithSummary. Callers across markdown, signals, and thread-toolbar were updated to the new APIs.

Changes

ThreadChip Refactor to Modular Summary Components

Layer / File(s) Summary
ThreadChip core simplification
apps/web/src/components/chips.tsx
threadChipVariants simplified to only disabled styling; ThreadChip converted from hover-card-backed component to plain button chip and narrowed to require only author data.
ThreadSummary composition components
apps/web/src/components/chips.tsx
ThreadSummaryCard, ThreadSummaryHoverCard, and ThreadChipWithSummary are exported to provide the previous "chip with hover summary" behavior as separate composable units.
Markdown ThreadMention update
apps/web/src/components/markdown/rich-markdown.tsx
ThreadMention now renders ThreadChipWithSummary instead of plain ThreadChip; import updated accordingly.
Signal action rows ThreadRef refactor
apps/web/src/components/signals/action-row/rows.tsx
ThreadRef refactored to render thread link inside ThreadSummaryHoverCard with Avatar and thread name/shortId; multiple action row headers updated to use the new ThreadRef without variant="unstyled".
Quick-actions duplicate suggestion
apps/web/src/components/threads/thread-toolbar/quick-actions.tsx
Duplicate-thread suggestion UI updated from BaseThreadChip to ThreadChip with the same props wiring.
Support-intelligence duplicate suggestion
apps/web/src/components/threads/thread-toolbar/support-intelligence.tsx
Duplicate-thread suggestion rendering switched from BaseThreadChip to ThreadChip in the "Duplicate of" hover-card trigger.
Thread updates duplicate rendering
apps/web/src/components/threads/updates.tsx
Duplicate-thread UI switched from ThreadChip to ThreadChipWithSummary; duplicateThread live query updated to include nested author and assignedUser data with related user records.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • danielmoural

Poem

🐰 I hopped in code where chips did hide,
Split the card from the button with pride,
Now summaries live where they belong,
Chips stay small and chase bugs gone,
A tidy patch—hooray, carrot-fueled stride!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 summarizes the main refactoring: ThreadChip is split into composable primitives (ThreadChip, ThreadSummaryCard, ThreadSummaryHoverCard, ThreadChipWithSummary), which is the primary change across all modified files.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/thread-chip-composition

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/web/src/components/threads/thread-toolbar/support-intelligence.tsx (1)

670-778: ⚡ Quick win

Consider reusing ThreadSummaryCard to reduce duplication.

Similar to quick-actions.tsx, this hover card content duplicates the thread summary layout from ThreadSummaryCard. Consider refactoring to reuse the shared component and reduce maintenance burden.

🤖 Prompt for 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.

In `@apps/web/src/components/threads/thread-toolbar/support-intelligence.tsx`
around lines 670 - 778, This hover card duplicates the thread summary UI;
replace the inline markup with the existing ThreadSummaryCard component to avoid
duplication: remove the manual layout that reads duplicateSuggestion.thread and
render <ThreadSummaryCard thread={duplicateSuggestion.thread} /> (or pass the
specific props ThreadSummaryCard expects) from support-intelligence.tsx, making
sure to surface the same fields (name, author, createdAt, status, priority,
assignedUserId/assignedUser) and any small-variant/display props used in
quick-actions.tsx so status/priority/assignee and avatar fallback behavior
remain identical.
apps/web/src/components/threads/thread-toolbar/quick-actions.tsx (1)

540-653: ⚡ Quick win

Consider reusing ThreadSummaryCard to reduce duplication.

The hover card content (lines 540-653) duplicates much of the layout logic from ThreadSummaryCard. While the custom layout with action buttons may justify this, consider extracting the shared thread details section (name, author, date, status, priority, assignee) into ThreadSummaryCard and rendering it here to reduce maintenance burden.

🤖 Prompt for 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.

In `@apps/web/src/components/threads/thread-toolbar/quick-actions.tsx` around
lines 540 - 653, The hover-card duplicates the thread-detail UI already
implemented in ThreadSummaryCard; extract the shared section (name,
author/avatar, createdAt formatting, status via StatusIndicator/StatusText,
priority via PriorityIndicator/PriorityText, and assignee/avatar) into a
reusable ThreadSummaryCard prop API that accepts the thread object (e.g.,
thread: duplicateSuggestion.thread) and flags to hide or show action buttons;
then replace the duplicated JSX block in quick-actions.tsx with a call to
ThreadSummaryCard (passing buildThreadParam where needed and preserving
formatRelativeTime behavior) so the hover card composes the card and only adds
its custom action buttons.
🤖 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/chips.tsx`:
- Around line 135-143: The avatar source is using the wrong property: change
references of thread.assignedUser?.image to the nested user image
thread.assignedUser?.user?.image (and similarly use
thread.assignedUser?.user?.name for fallback/display if appropriate) in the
Avatar and span rendering inside the conditional block that checks
thread.assignedUserId and thread.assignedUser?.name; update the Avatar prop src
and any fallback/name usage so it mirrors how the author avatar is retrieved
(i.e., use the nested user relation).

---

Nitpick comments:
In `@apps/web/src/components/threads/thread-toolbar/quick-actions.tsx`:
- Around line 540-653: The hover-card duplicates the thread-detail UI already
implemented in ThreadSummaryCard; extract the shared section (name,
author/avatar, createdAt formatting, status via StatusIndicator/StatusText,
priority via PriorityIndicator/PriorityText, and assignee/avatar) into a
reusable ThreadSummaryCard prop API that accepts the thread object (e.g.,
thread: duplicateSuggestion.thread) and flags to hide or show action buttons;
then replace the duplicated JSX block in quick-actions.tsx with a call to
ThreadSummaryCard (passing buildThreadParam where needed and preserving
formatRelativeTime behavior) so the hover card composes the card and only adds
its custom action buttons.

In `@apps/web/src/components/threads/thread-toolbar/support-intelligence.tsx`:
- Around line 670-778: This hover card duplicates the thread summary UI; replace
the inline markup with the existing ThreadSummaryCard component to avoid
duplication: remove the manual layout that reads duplicateSuggestion.thread and
render <ThreadSummaryCard thread={duplicateSuggestion.thread} /> (or pass the
specific props ThreadSummaryCard expects) from support-intelligence.tsx, making
sure to surface the same fields (name, author, createdAt, status, priority,
assignedUserId/assignedUser) and any small-variant/display props used in
quick-actions.tsx so status/priority/assignee and avatar fallback behavior
remain identical.
🪄 Autofix (Beta)

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

Run ID: e0731fe2-51d6-48ae-8838-e829772641cf

📥 Commits

Reviewing files that changed from the base of the PR and between 1e2baf8 and 3958cb8.

📒 Files selected for processing (6)
  • apps/web/src/components/chips.tsx
  • apps/web/src/components/markdown/rich-markdown.tsx
  • apps/web/src/components/signals/action-row/rows.tsx
  • apps/web/src/components/threads/thread-toolbar/quick-actions.tsx
  • apps/web/src/components/threads/thread-toolbar/support-intelligence.tsx
  • apps/web/src/components/threads/updates.tsx

Comment thread apps/web/src/components/chips.tsx
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: This is a well-structured refactor that splits ThreadChip into composable primitives (ThreadChip, ThreadSummaryCard, ThreadSummaryHoverCard) without changing behavior, and the AI review found no issues.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/web/src/components/chips.tsx">

<violation number="1" location="apps/web/src/components/chips.tsx:140">
P2: The assignee row now shows the author's avatar instead of the assignee's avatar, causing incorrect user identity in the summary card.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread apps/web/src/components/chips.tsx
@pedroscosta pedroscosta merged commit d77fd94 into main May 13, 2026
4 checks passed
@pedroscosta pedroscosta deleted the refactor/thread-chip-composition branch May 13, 2026 01:16
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