fix: sidebar highlight out of sync after notification click#6
Open
Teamingzooper wants to merge 1 commit into
Open
fix: sidebar highlight out of sync after notification click#6Teamingzooper wants to merge 1 commit into
Teamingzooper wants to merge 1 commit into
Conversation
… an instance When the user clicked a native OS notification, NotificationService.onclick correctly called both views.activate() and profiles.setActive(), and ViewService emitted 'instance:activated' on the main-process eventBus. But nothing forwarded that bus event to the renderer, so the renderer's state.activeInstanceId stayed stale and the sidebar's "active" highlight pointed at the wrong instance until the user clicked something manually. Sidebar clicks were unaffected because that path round-trips through the renderer's activateInstance action which calls refreshComposite() and overwrites the Zustand state directly. Fix: wire a main→renderer bridge for the bus event. - New IPC channel: nexus:instance:activated (push-event, main→renderer). - IpcService subscribes to bus 'instance:activated' on init, forwards to the main window via webContents.send. Tracks the subscription in a new teardowns array so dispose unhooks it. - preload.ts exposes window.nexus.onInstanceActivated(cb). - renderer's store.init() subscribes and updates state.activeInstanceId in place — no full refreshComposite needed since only that one field changes, and the sidebar-click path still does the round-trip refresh for everything else. No automated test added — the bug is purely renderer↔main wiring and the existing test infra doesn't cover IPC integration. Verified manually that typecheck, full 178-test suite, and renderer/main builds all stay green.
This was referenced May 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a stale-highlight bug: clicking a native OS notification opened the right webview but left the sidebar's "active" highlight on the previous instance.
Root cause
When the user clicks a native notification, `NotificationService.onclick` correctly calls both `views.activate(id)` and `profiles.setActive(id)`, and `ViewService` emits `instance:activated` on the main-process eventBus. But nothing was forwarding that bus event to the renderer — so the renderer's `state.activeInstanceId` stayed stale.
Sidebar clicks worked because they round-trip through the renderer's own `activateInstance` action, which calls `refreshComposite()` and overwrites the Zustand state from scratch.
Fix
Wire a main → renderer bridge for the bus event so the renderer hears about activations no matter what triggered them.
Audit
Checked all other `bus.emit` callsites to make sure this wasn't a wider class of bug. `instance:activated` was the only orphan event — every other emit is either renderer-initiated (round-trips through IPC) or already has a forwarding path (`unread:update`, etc.).
Test plan
No automated test added — the bug is purely renderer↔main IPC wiring and the project doesn't yet have an integration-test harness for that surface. The four edits are small enough that the manual smoke test is the right level of validation.
🤖 Generated with Claude Code