Bug: Overview menu-card row clicks are dropped — `NSClickGestureRecognizer` inside NSMenu tracking, same failure class as #867
Affected version: v0.42.1 (build 103); behavior present since the clickable overview rows were introduced
Component: merged-menu overview rows (Sources/CodexBar/StatusItemController+MenuPresentation.swift)
Type: intermittent UI input loss
Prior art: issue #867 and its fix 9907f749 ("fix(menu): route switcher clicks through parent view") — the same failure mode, fixed for the provider switcher but not for menu-card rows
Summary
Clickable hosted-SwiftUI menu rows (MenuCardItemHostingView) deliver their onClick through an NSClickGestureRecognizer installed on the hosting view (StatusItemController+MenuPresentation.swift:194-199 at v0.42.1). Gesture recognizers on custom views inside a tracking NSMenu are subject to the same event-delivery loss that upstream already diagnosed and fixed for the provider switcher's NSButtons in 9907f749:
"NSMenu's tracking run loop occasionally drops NSButton target-action dispatch when the menu is rebuilt under the cursor (e.g. after switching back from a provider tab to Overview)." — comment added by
9907f749inStatusItemController+SwitcherViews.swift
The switcher fix routes clicks through the parent view's hitTest + mouseDown/mouseUp so the click "never has to round-trip through NSButton's tracking loop." MenuCardItemHostingView still uses the pre-#867 pattern — a recognizer that needs the tracking loop to deliver and complete a gesture — so overview row clicks (which select that provider's tab, StatusItemController+Menu.swift:580-583) can intermittently do nothing.
Symptom
With merged icons / the overview menu: clicking a provider's card row sometimes has no effect — the menu stays on the overview and no selection happens. It is timing-dependent and most likely when menu content is being rebuilt or refreshed while the menu is open under the cursor (the same trigger described in #867). A second click usually works, which makes it easy to dismiss as a mis-click.
Why the recognizer path is fragile here
NSMenuruns its own tracking loop; custom-view event delivery inside it is not the normal window responder chain.MenuCardItemHostingViewinstances are reused and re-wired while the menu is open:prepareForReuse(rootView:allowsMenuHighlight:onClick:)swapsrootViewandonClickin place on refresh (StatusItemController+MenuPresentation.swift:169-176). A gesture that began before a rebuild can complete against a view whose recognizer state was disturbed by the in-place SwiftUI diff.- A gesture recognizer requires the full begin→end state machine to run inside the tracking loop; parent-view
mouseDown/mouseUprouting does not.
Upstream's own #867 analysis covers this class of failure; the menu-card rows are the remaining user of the fragile pattern. (A grep at v0.42.1 shows NSClickGestureRecognizer in MenuCardItemHostingView is the only recognizer-based click path left inside menu content.)
Reproduction
Intermittent by nature — this is a race with the menu tracking loop, so there is no deterministic step list; #867 was the same kind of report. Best-known trigger sequence:
- Enable merged icons so the overview menu with per-provider card rows is shown.
- Open the menu and leave the cursor over a provider row while a background refresh rebuilds/reuses menu content (easiest during active provider refresh cycles; switching to a provider tab and back to Overview increases churn, mirroring #867).
- Click the row. Occasionally the click is swallowed: no provider tab opens.
Suggested fix — apply the #867 technique to MenuCardItemHostingView
Mirror 9907f749: remove the NSClickGestureRecognizer and route clicks through the hosting view itself —
hitTest(_:): whenonClick != nil, returnselffor hits on descendants, so child SwiftUI content never owns the click;mouseDown(with:): record pressed state if the click began inside bounds;mouseUp(with:): fireonClickonly if the press began and ended inside bounds (preserves click-cancel-by-drag-out semantics).
Applied to v0.42.1, this change passes the full test suite (634 test selections, 0 failures). Note the accessibility path is unaffected: accessibilityPerformPress() already invokes onClick directly and keeps working.
A regression test in the same shape as #867's StatusMenuSwitcherClickTests is straightforward: expose a DEBUG-only _test_simulateRuntimeClick() on MenuCardItemHostingView that drives the production click path without a recognizer, and assert onClick fires:
@Test
func `routes runtime click without gesture recognizer`() {
var clicked = false
let view = MenuCardItemHostingView(
rootView: Text("Overview row"),
highlightState: MenuCardHighlightState(),
allowsMenuHighlight: true,
onClick: { clicked = true })
#expect(view._test_simulateRuntimeClick())
#expect(clicked)
}
Evidence index (at tag v0.42.1)
- Recognizer installation:
Sources/CodexBar/StatusItemController+MenuPresentation.swift:194-199(installClickRecognizer), invoked frominit(:159-161) andprepareForReuse(:172-174) - Click handler requiring gesture completion:
:218-221(handlePrimaryClick,guard recognizer.state == .ended) - User-visible consumer: overview provider rows,
Sources/CodexBar/StatusItemController+Menu.swift:580-583(onClick→selectOverviewProvider) - Upstream precedent: commit
9907f749("fix(menu): route switcher clicks through parent view", fixes #867) — addshitTest/mouseDown/mouseUprouting plusStatusMenuSwitcherClickTeststoProviderSwitcherView, with in-code rationale describing the dropped-dispatch failure mode
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 12, 2026, 8:25 AM ET / 12:25 UTC.
Summary Current main still uses the fragile recognizer-based click path for overview menu-card rows, while the repository already uses parent-view mouse routing for the same NSMenu event-loss class in the provider switcher. No open pull request owns this repair, so the issue remains necessary and is a strong candidate for one focused fix.
Reproducibility: no. live failing run was performed in this environment, but current main retains the implicated recognizer path and the repository documents the same NSMenu event-loss mechanism in the prior switcher fix. This provides a credible source-level reproduction with medium confidence.
Root-cause cluster
Relationship: canonical
Canonical: https://github.com/steipete/codexbar/issues/2090
Summary: This issue is the canonical remaining report for overview menu-card rows; the older closed issue covers the same event-loss mechanism in the provider switcher.
Members:
same_root_cause: https://github.com/steipete/codexbar/issues/867 - Its fix replaced fragile menu-tracking dispatch with parent-view mouse routing for another control, while current overview cards still depend on recognizer completion.
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Ways to help us reproduce this
- Add a screenshot or short recording showing the behavior.
- Add expected vs actual behavior.
Next step The defect mechanism, established repair pattern, likely files, and validation boundary are concrete enough for one focused autonomous fix PR.
Review details
Best possible solution:
Use the existing parent-view mouse-routing model for clickable menu-card hosting views, preserving accessibility activation, non-clickable rows, reuse rewiring, highlighting, and drag-out cancellation, then verify it with focused tests and a fresh native app run.
Do we have a high-confidence way to reproduce the issue?
No live failing run was performed in this environment, but current main retains the implicated recognizer path and the repository documents the same NSMenu event-loss mechanism in the prior switcher fix. This provides a credible source-level reproduction with medium confidence.
Is this the best way to solve the issue?
Yes. Extending the repository's existing parent-view routing pattern is the narrowest maintainable repair and avoids creating a competing input-dispatch mechanism.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
- The reported loss is timing-dependent, so deterministic source-level regression tests should be supplemented with after-fix native macOS proof from a freshly built bundle before merging.
Codex review notes: model internal, reasoning high; reviewed against d57fb5d08696.
Label changes
Label changes:
- add
P2: The issue is a bounded intermittent provider-navigation failure with limited blast radius and a second-click workaround. - add
impact:ux-friction: A swallowed first click leaves users on Overview and makes provider-row navigation appear unreliable. - add
issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label. - add
clawsweeper:needs-live-repro: Current issue advisory state selects this label. - add
clawsweeper:queueable-fix: Current issue advisory state selects this label. - add
clawsweeper:fix-shape-clear: Current issue advisory state selects this label.
Label justifications:
P2: The issue is a bounded intermittent provider-navigation failure with limited blast radius and a second-click workaround.impact:ux-friction: A swallowed first click leaves users on Overview and makes provider-row navigation appear unreliable.
Evidence reviewed
Acceptance criteria:
- swift test --filter MenuCardViewRecyclingTests
- swift test --filter StatusMenuSwitcherClickTests
- make test
- make check
What I checked:
- Current-main click path: MenuCardItemHostingView installs an NSClickGestureRecognizer during initialization or reuse and invokes onClick only after the recognizer reaches its ended state. (
Sources/CodexBar/StatusItemController+MenuPresentation.swift:193, d57fb5d08696) - User-visible consumer: Overview provider rows pass an onClick closure that calls selectOverviewProvider, making the recognizer path responsible for the reported provider navigation. (
Sources/CodexBar/StatusItemController+Menu.swift:580, d57fb5d08696) - Established same-class repair: ProviderSwitcherView documents that NSMenu tracking can drop child-control dispatch during rebuilds and instead intercepts descendant hits and handles selection through parent mouseDown and mouseUp. (
Sources/CodexBar/StatusItemController+SwitcherViews.swift:265, d57fb5d08696) - Prior-fix provenance: Commit 9907f7496a8ec83961281a28917e3611fb62fb90 introduced the parent-view click routing and its runtime-click regression test for the related provider-switcher failure. (
Tests/CodexBarTests/StatusMenuSwitcherClickTests.swift:31, 9907f7496a8e) - Affected release confirmed: Tag v0.42.1 contains the same recognizer installation, reuse wiring, and ended-state handler described by the report; current main has not replaced them. (
Sources/CodexBar/StatusItemController+MenuPresentation.swift:193, 3e05988f5c5f) - Reuse history: Commit f927e8ad90ae7fd07c0f5708c062915309ecc0f0 introduced in-place menu-card hosting-view recycling and prepareForReuse, which is directly relevant to safe closure rewiring and click-state handling. (
Sources/CodexBar/StatusItemController+MenuPresentation.swift:164, f927e8ad90ae)
Likely related people:
- bcssewl: Commit f927e8ad and merged pull request https://github.com/steipete/CodexBar/pull/1394 introduced the affected hosting-view recycling and in-place reuse behavior. (role: feature contributor; confidence: high; commits: f927e8ad90ae; files:
Sources/CodexBar/StatusItemController+MenuPresentation.swift,Tests/CodexBarTests/MenuCardViewRecyclingTests.swift) - Karl-Dai: Commit 9907f749 authored the established parent-view routing and regression coverage for the same NSMenu click-loss mechanism in the provider switcher. (role: adjacent fix contributor; confidence: high; commits: 9907f7496a8e; files:
Sources/CodexBar/StatusItemController+SwitcherViews.swift,Tests/CodexBarTests/StatusMenuSwitcherClickTests.swift) - hhh2210: Commit 627b1fb2 and related overview-row work substantially changed rendering in the affected menu-card surface. (role: recent overview-row contributor; confidence: medium; commits: 627b1fb251c9; files:
Sources/CodexBar/StatusItemController+MenuPresentation.swift)
How this review workflow works
- ClawSweeper keeps one durable marker-backed review comment per issue or PR.
- Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
- A fresh review can be triggered by eligible
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch. - PR/issue authors and users with repository write access can comment
@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto request a fresh review only. - Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
- Maintainer-only repair and merge flows require explicit commands such as
@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review. - Maintainers can comment
@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.