fix(desktop): unfreeze UI state that React Compiler cached on stable handles
Links
- Before/after page with films and compiler output for every fix: https://app.superset.sh/page/react-compiler-sweep-what-froze-and-the-fixes-b6edt4
- Follows #9726 (same bug class, workspace shortcuts)
Summary
- Fixes 13 places where the desktop UI kept its first value after React Compiler (#9582) was turned on.
- Worst two: the Tasks list stayed on "No tasks found", and file panes never showed the "changed on disk" / "deleted on disk" banners.
- Migrates the tasks table from TanStack Table 8.21.3 to 9.3.1, the first version built for the compiler.
Why / Context
The compiler caches a value until one of its inputs changes identity. Several hooks return one stable object or function and re-render through a side subscription (router history, TanStack table, Tiptap editor, our file document handle, a zustand getter, a TanStack DB collection). Reads off them were cached forever. Three more patterns showed up in a sweep of compiled output for 5,752 files:
- a "version" listed in a
useMemoarray only to force a recompute is dropped, because the body never reads it; useMemoused as a snapshot (a value left out of the array on purpose) is removed;- a helper that reads the clock inside, such as
formatRelativeTime(date), is cached ondate.
Unit tests run uncompiled source, so none of this is visible to them.
How It Works
| Surface | Fix |
|---|---|
| Tasks list | TanStack Table v9: useTable returns a new table when data or state changes. Features are declared in tasksTableFeatures.ts. |
| File panes (tab dot, banners, save error) | useSharedFileDocument returns an immutable snapshot from getDocumentSnapshot, read with useSyncExternalStore. |
| Back button | Router's useCanGoBack(). |
| Rich-text bubble toolbar | Tiptap useEditorState. |
| Changes filter picker | useLiveQuery instead of collection.get(). |
| Dock badge count | useSyncExternalStore over the query cache. |
| GitHub hold notice, pinned-section drag, page thumbnail retry | Value kept in state. |
| Sidebar toggle | Store selector. |
| Relative times in 22 long-lived views | now from useNow (one tick per minute); three helpers gained an optional now. ui's useNow moved to packages/ui/src/hooks/use-now.ts. |
| Channel date picker | Function matcher for "today". |
| Terminal WebSocket URL | "use no memo" (see Known Limitations). |
One behaviour change: file auto-save on focus change now takes the document id and looks up the live document, because a snapshot held in an old closure would report stale dirty state. Dirty documents stay in the store after their pane closes, so the lookup finds them.
Manual QA Checklist
Each scene below was driven in the dev app over CDP with real clicks and keys, recorded on the unfixed build and again on this branch. Films are on the page linked above.
- Tasks list: before "No tasks found" at every step; after 76 rows load, search narrows to 49, checkbox selects
- File pane: type, change the file on disk, delete it on disk. Before no banners; after both banners with Compare and Discard
- File pane: edit and Cmd+S writes once, Save control goes away
- Back button: disabled at the first history entry, enabled again after navigating (before: always enabled)
- Bubble toolbar: Bold and List highlights follow the selection (before: never highlighted)
- Changes picker: label changes to "Uncommitted" (before: stayed on "Commits 0 | main")
- Dock badge count with a staged permission request: 1 → 2 → 1 (before: 1 → 1 → 1)
- PR list relative times advance on their own (before: one minute behind, only on refetch)
- No React errors in the console in any run
Testing
bun test src/rendererinapps/desktop: 7757 pass, 0 failbun testinpackages/ui: 106 passbunx tsc --noEmitfor desktop,ui,workspace-clientbun run check:i18n,bunx sherif, Biome on changed files- New test: a document snapshot is a new object only after the document changes
- The full local
apps/desktoprun has 39 failures, all in main-process git/shell tests this PR does not touch; relying on CI for those
Known Limitations
useWorkspaceWsUrlkeeps"use no memo". Its token is plain module state in the auth client with nothing to subscribe to. Making it reactive is an auth-client change.TasksTableViewis skipped by the compiler because it usesuseVirtualizer. If that skip goes away, its per-row reads such asrow.getIsSelected()need v9'stable.Subscribe.- Not exercised in the running app: GitHub hold notice (a staged hold cleared on time on both builds), page thumbnail retry, pinned-section drag, the date-picker limit, WebSocket token refresh. Evidence for these is the compiled output.
- The sidebar toggle bug did not reproduce in the app (the toggle remounts on collapse). The compiled read was still wrong, so the selector fix is included.
- The tasks scene ran with the organization's task tracker rewritten in the API response, because the dev account is set to Linear.
Risks / Rollout
- Risk: the file document snapshot changes what every file pane reader receives. Covered by the edit/save and banner scenes above.
- Risk: TanStack Table v9 is a major version. Tasks is its only user in the repo.
- Rollback: revert this commit; it has no data or API changes.
Summary by cubic
Fixes 13 places where the desktop UI froze to its first rendered value after React Compiler was enabled, including the Tasks list staying on "No tasks found" and file panes never showing the changed-on-disk or deleted-on-disk banners.
The compiler caches a value until one of its inputs changes identity. Several hooks return one stable object or function and re-render through a side subscription (router history, TanStack table, Tiptap editor, file document handle, zustand getter, TanStack DB collection), so reads off them were cached forever. A sweep of compiled output also found three patterns: a version in a useMemo array that only forces a recompute is dropped, a useMemo used as a snapshot is removed, and a helper reading the clock inside, such as formatRelativeTime(date), is cached on date. Unit tests run uncompiled source, so none of this was visible to them.
Key changes
- Migrates the Tasks table from
@tanstack/react-table8.21.3 to 9.3.1, the first version built for the compiler; features are declared in a newtasksTableFeatures.ts. - File panes read an immutable document snapshot through
useSyncExternalStore, so the unsaved dot and the changed/deleted-on-disk banners update. - Relative times in 22 long-lived views take
nowfromuseNow(one tick per minute); three formatting helpers gained an optionalnowparameter. - Back button, bubble toolbar, changes filter, dock badge, and sidebar toggle now read through the subscription or selector the library provides.
- GitHub hold notice, pinned-section drag snapshot, and page thumbnail retry keep their value in state instead of in a memo dependency or module map.
useWorkspaceWsUrlopts out of the compiler with"use no memo"; its token is plain module state with nothing to subscribe to.
Behavior change
- File auto-save on focus change now looks up the live document by id, because a snapshot held in an old closure reports stale
dirtystate; dirty documents stay in the store after their pane closes, so the lookup finds them.
Summary by CodeRabbit
- Bug Fixes
- Relative-time labels across activity, comments, pages, workspaces, and settings now refresh about once a minute.
- Formatting toolbar states update to reflect the current selection.
- Sidebar drop zones remain stable during a drag, and focus-triggered saves use the current document.
- Attention counts and workspace change filters stay synchronized with current data.
- The calendar continues to prevent selecting future dates.
- Improvements
- Task tables support filtering, grouping, expanding rows, and selection.