fix(renderer): use snapshot.currentCompanyId as single source of truth (D-03)

CompanySlice's standalone currentCompanyId field + setCurrentCompanyId action
were never written by any caller, so useDesktopEvents.ts read null and fell
through to full refresh for every entity event -- the granular patch
machinery was dead code.

- Remove currentCompanyId field + setCurrentCompanyId from CompanySlice
- refreshBadges reads from snapshot.currentCompanyId
- useDesktopEvents reads companyId from snapshot.currentCompanyId
- Update store unit test to seed snapshot instead of calling removed action
This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 21:56:40 -04:00
1 parent a130dc29f5
commit 0119872db6
3 files changed
+4 -11

No files matched your search

+2 -2
View File
@@ -495,8 +495,8 @@ describe("CompanySlice patch methods", () => {
const mockBadges = { tasks: 5, approvals: 2, runs: 0, messages: 3 };
mockGetSidebarBadges.mockResolvedValue({ ok: true, data: mockBadges });
// Set current company ID first
useAppStore.getState().setCurrentCompanyId("company-1");
// Seed snapshot with currentCompanyId -- refreshBadges reads from snapshot
useAppStore.getState().setSnapshot(makeSnapshot());
await useAppStore.getState().refreshBadges();