Refactor web store access to granular Zustand selectors - #141
Merged
Merged
MacroscopeApp / Macroscope - Correctness Check
succeeded
Mar 2, 2026 in 8m 25s
No issues identified (66 code objects reviewed).
• Merge Base:
5c09614
• Head:ae56cd1
Details
| ✅ | File Path | Comments Posted |
|---|---|---|
| ✅ | apps/web/src/types.ts |
0 |
| ✅ | apps/web/src/terminalStateStore.ts |
0 |
| ➖ | apps/web/src/terminalStateStore.test.ts |
|
| ➖ | apps/web/src/worktreeCleanup.test.ts |
|
| ✅ | apps/web/src/components/ThreadTerminalDrawer.tsx |
0 |
| ✅ | apps/web/src/components/ui/combobox.tsx |
0 |
| ✅ | apps/web/src/components/ui/toggle-group.tsx |
0 |
| ➖ | apps/web/src/store.test.ts |
|
| ✅ | apps/web/src/routes/_chat.$threadId.tsx |
0 |
| ✅ | apps/web/src/routes/__root.tsx |
0 |
| ✅ | apps/web/src/components/BranchToolbar.tsx |
0 |
| ✅ | apps/web/src/components/DiffPanel.tsx |
0 |
| ✅ | apps/web/src/routes/_chat.settings.tsx |
0 |
| ✅ | apps/web/src/store.ts |
0 |
| ✅ | apps/web/src/components/Sidebar.tsx |
0 |
| ✅ | apps/web/src/components/ChatView.tsx |
0 |
Filtered Issues Details
apps/web/src/components/ChatView.tsx
- line 147: The function
selectThreadTerminalStateinapps/web/src/terminalStateStore.tscallsgetDefaultThreadTerminalState(), but no such function is defined or imported in the module. The provided code definescreateDefaultThreadTerminalStateinstead. This will cause aReferenceError(runtime crash) immediately whenChatViewrenders, asChatViewunconditionally callsselectThreadTerminalStatevia theuseTerminalStateStorehook. [ Already posted ]
apps/web/src/components/ThreadTerminalDrawer.tsx
- line 292: The
openTerminalfunction creates a closure over theautoFocusvariable. By explicitly excludingautoFocusfrom theuseEffectdependency array (via the addedeslint-disablecomment), the effect does not re-run when this prop changes. SinceopenTerminalperforms an asynchronous operation (api.terminal.open), it reads the stale value ofautoFocusfrom the time the effect began, not when the operation completes. [ Already posted ]
apps/web/src/terminalStateStore.ts
- line 118: In
terminalGroupsEqual, the code iterates usingleft.lengthas the bound but accesses bothleft[index]andright[index]. Ifrightis shorter thanleft,right[index]will be undefined. Although the very first line checksleft.length !== right.length, the iteration is safe. However, inside the loop, the code accessesleftGroup.idandrightGroup.id. The checkif (!leftGroup || !rightGroup)handles the undefined case, returningfalse. [ Already posted ] - line 431: The function
updateTerminalStateByThreadIdis vulnerable to a prototype property collision that causes a runtime crash. It callsselectThreadTerminalState(line 430) withterminalStateByThreadId(a plain object) andthreadId. IfthreadIdis a built-in property name like"toString"or"constructor",selectThreadTerminalStatereturns the corresponding function fromObject.prototypeinstead of aThreadTerminalStateobject. This function reference is then passed ascurrentto theupdatercallback (line 431). Theupdater(e.g.,setThreadTerminalOpen) passes this value tonormalizeThreadTerminalState, which attempts to accessstate.terminalIds(line 179). Since(function).terminalIdsisundefined, the subsequent call tonormalizeTerminalIdsattempts to accessundefined.map(line 31), throwing aTypeError. [ Already posted ]
Loading