Skip to content

Fix Activity thread options trigger ref loop - #7096

Merged
nwparker merged 1 commit into
mainfrom
nwparker/crash-activity-thread-options-radix-ref-loop
Jul 2, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/crash-activity-thread-options-radix-ref-loop

Conversation

@nwparker

@nwparker nwparker commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes crash report fb583dd8-8c87-4cc7-9ea1-167b1d291f3d from Linux/WSL2 Activity view.

The crash stack was React error #185 with setRef -> Array.map -> setRef under TooltipTrigger, which points at Radix composed refs recursively updating. The Activity thread-list overflow button had TooltipTrigger asChild wrapped directly around DropdownMenuTrigger asChild, so both Radix triggers composed refs onto the same button.

This PR extracts the thread options menu and inserts a real wrapper span as the tooltip target. The dropdown trigger still owns the button, but Tooltip no longer composes its ref onto the same DOM node.

Reproduction / Fix Evidence

  • Crash evidence: report fb583dd8-8c87-4cc7-9ea1-167b1d291f3d, boundary app.workspace-shell, active view activity, stack includes setRef, Array.map, TooltipTrigger.
  • Repro guard before fix: the new ActivityThreadOptionsMenu test failed because the button had no wrapper target, preserving the same same-node Radix ref composition from the report.
  • Fix evidence after patch:
    • pnpm vitest run --config config/vitest.config.ts src/renderer/src/components/activity/ActivityThreadOptionsMenu.test.tsx src/renderer/src/components/activity/ActivityPrototypePage.test.ts -> 2 files / 25 tests passed.
    • pnpm exec oxlint src/renderer/src/components/activity/ActivityPrototypePage.tsx src/renderer/src/components/activity/ActivityThreadOptionsMenu.test.tsx -> passed.
    • pnpm exec tsgo --noEmit -p config/tsconfig.tc.web.json -> passed.
    • git diff --check -> passed.

ELI5

The same button was wearing two different “I need to hold onto this element” hats. In some Activity sessions, those two hats could keep handing the button back and forth until React hit its safety limit and crashed the Activity page. Now the tooltip holds a tiny wrapper, and the menu holds the button, so they stop fighting over the same thing.

Trade-offs

  • Adds one inline wrapper span around the menu button. Layout is unchanged because it uses the same inline-flex/shrink behavior already used in similar toolbar menus.
  • The regression test locks the DOM structure because happy-dom did not deterministically reproduce the full packaged Electron/Linux update-depth loop. The structure is the risky condition shown by the production stack.

@nwparker
nwparker merged commit e59c041 into main Jul 2, 2026
1 of 2 checks passed
@nwparker
nwparker deleted the nwparker/crash-activity-thread-options-radix-ref-loop branch July 2, 2026 09:17
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change extracts the inline "Thread list options" dropdown menu from ActivityPrototypePage.tsx into a new exported component, ActivityThreadOptionsMenu, which handles the overflow tooltip button, a compact-mode checkbox, and a mark-all-read action disabled when there are no unread threads. The main page render now uses this component, passing through compactMode, hasUnreadThreads, setCompactMode, and markAllThreadsRead. A new test file adds coverage for the extracted component's rendering and keyboard interaction.

Changes

Cohort / File(s) Summary
Menu extraction – ActivityPrototypePage.tsx Adds exported ActivityThreadOptionsMenu component; replaces inline dropdown markup with the new component in the page render
Test coverage – ActivityThreadOptionsMenu.test.tsx New test file with harness setup, teardown, and a keyboard-interaction test verifying menu content

Sequence Diagram(s)

sequenceDiagram
  participant ActivityPrototypePage
  participant ActivityThreadOptionsMenu
  ActivityPrototypePage->>ActivityThreadOptionsMenu: pass compactMode, hasUnreadThreads
  ActivityPrototypePage->>ActivityThreadOptionsMenu: pass setCompactMode, markAllThreadsRead
  ActivityThreadOptionsMenu->>ActivityPrototypePage: onCompactModeChange callback
  ActivityThreadOptionsMenu->>ActivityPrototypePage: onMarkAllThreadsRead callback
Loading

Estimated code review effort: 2 (Medium)

Related issues: None found in the provided context.

Related PRs: None found in the provided context.

Suggested labels: frontend, tests, refactor

Suggested reviewers: None specified.

Poem:
A rabbit hopped through dropdown code,
Extracted menus, lightened the load.
Compact mode checked, unread threads clear,
Tests now hop in, keyboard-tap cheer.
A tidy component, tucked in its den—
Thread options menu, born again. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: fixing the Activity thread options trigger ref loop.
Description check ✅ Passed The description is mostly complete and follows the template, with clear summary, testing, review, security, and notes sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3b849b8a-e574-45df-a5ca-e81f2b50d343

📥 Commits

Reviewing files that changed from the base of the PR and between b51dd80 and bcc697f.

📒 Files selected for processing (2)
  • src/renderer/src/components/activity/ActivityPrototypePage.tsx
  • src/renderer/src/components/activity/ActivityThreadOptionsMenu.test.tsx

Comment on lines +887 to +913
return (
<DropdownMenu>
<Tooltip>
<TooltipTrigger asChild>
{/* Why: keep Tooltip and Dropdown from composing refs onto the same
button; the crash report's stack loops through Radix setRef. */}
<span className="inline-flex shrink-0">
<DropdownMenuTrigger asChild>
<Button
type="button"
variant="outline"
size="sm"
className="size-8 shrink-0 border-input bg-transparent p-0 text-muted-foreground shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-transparent dark:hover:bg-accent dark:hover:text-accent-foreground"
aria-label={translate(
'auto.components.activity.ActivityPrototypePage.db8a1878b5',
'Thread list options'
)}
>
<MoreVertical className="size-3.5" />
</Button>
</DropdownMenuTrigger>
</span>
</TooltipTrigger>
<TooltipContent side="bottom">
{translate('auto.components.activity.ActivityPrototypePage.a472a14700', 'More options')}
</TooltipContent>
</Tooltip>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the target component around the reported lines.
file="src/renderer/src/components/activity/ActivityPrototypePage.tsx"
wc -l "$file"
sed -n '860,930p' "$file"

# Map nearby structure to understand the trigger composition.
ast-grep outline "$file" --view expanded | sed -n '1,220p'

# Find similar composed trigger patterns in the renderer codebase.
rg -n "TooltipTrigger asChild|DropdownMenuTrigger asChild" src/renderer/src -g '*.{ts,tsx}' -A 6 -B 6

# Locate Radix tooltip/menu packages or docs references in repo metadata.
rg -n '"`@radix-ui/react-tooltip`"|"`@radix-ui/react-dropdown-menu`"|radix' package.json pnpm-lock.yaml yarn.lock package-lock.json -A 3 -B 3

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the exact target region with line numbers.
file="src/renderer/src/components/activity/ActivityPrototypePage.tsx"
sed -n '880,920p' "$file" | cat -n

# Search for local Radix tooltip implementation or docs references.
rg -n "aria-describedby|TooltipTrigger|asChild" . -g '*.{ts,tsx,js,jsx,md,mjs,cjs}' \
  -g '!**/dist/**' -g '!**/build/**' -g '!**/node_modules/**' \
  -A 3 -B 3 | sed -n '1,240p'

# If package metadata is present, identify the Radix version used.
rg -n '"`@radix-ui/react-tooltip`"|`@radix-ui/react-tooltip`' package.json pnpm-lock.yaml yarn.lock package-lock.json -A 4 -B 2

Repository: stablyai/orca

Length of output: 22111


Keep TooltipTrigger on the focusable button
A plain <span> as the trigger moves aria-describedby off the button, so keyboard focus won’t pick up the tooltip text. Forward the tooltip props to the actual button instead of the wrapper.

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