Skip to content

fix: sidebar highlight out of sync after notification click#6

Open
Teamingzooper wants to merge 1 commit into
mainfrom
fix/notification-sidebar-sync
Open

fix: sidebar highlight out of sync after notification click#6
Teamingzooper wants to merge 1 commit into
mainfrom
fix/notification-sidebar-sync

Conversation

@Teamingzooper

Copy link
Copy Markdown
Owner

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.

  • New IPC channel `nexus:instance:activated` (push, 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 cleanly.
  • `preload.ts` exposes `window.nexus.onInstanceActivated(cb)`.
  • Renderer `store.init()` subscribes and updates `state.activeInstanceId` in place. No full `refreshComposite` needed — only that one field changes — and the sidebar-click path still does a full refresh for everything else.

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

  • `npm run typecheck` — clean
  • `npm run test` — 178/178 passing
  • `npm run build` — renderer + main both clean
  • Manual smoke: open Nexus, add at least 2 instances, switch to Telegram, trigger a WhatsApp notification, click it → sidebar highlight should jump to WhatsApp (not stay on Telegram)

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

… 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.
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.

2 participants