Repository navigation
perf(dashboard): stop re-sending repo icon data URLs on every republish - #11089
Conversation
#11012 put repo icons on the dashboard snapshot keyed by repoId. Image icons are data URLs capped at MAX_REPO_ICON_DATA_URL_LENGTH (400KB) and every repo contributing a card ships one, while the snapshot republishes up to 4x/sec (PUBLISH_THROTTLE_MS = 250) for as long as the pop-out is open. Icons change about never, so that structured-clones megabytes per second across the window boundary for bytes the pop-out already has. Publish the map only when it actually changed, comparing by reference since icons come off immutable store repo records. The two paths where the pop-out could be starting from nothing — it opened, or it mounted and asked — still force a full send, so the retained copy can never be the only one. The pop-out keeps the last map it was given when a republish omits the field. An explicitly empty map still clears, so removing an icon works. repoIconsByRepoId was already optional on DashboardSnapshot and isDashboardRepoIcons already returns true for undefined, so the main-process validator needed no change.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe dashboard popout bridge compares repository icon maps by reference, omits unchanged maps from throttled republishes, and forces icons into opening and requested snapshots. The IPC cache and snapshot hook retain omitted maps, while new or empty maps replace retained values. Tests cover publishing, replay, comparison, replacement, and clearing behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts (1)
12-22: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCondense the new renderer comments.
Keep the non-obvious performance/retention rationale, but reduce these multi-line explanations to concise one-line comments; test names and assertions already convey the rest.
src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts#L12-L22: shorten the helper documentation.src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts#L105-L107: reduce thewithIconsexplanation.src/renderer/src/components/dashboard/useDashboardPopoutBridge.test.tsx#L165-L166: remove or shorten the assertion walkthrough.src/renderer/src/components/dashboard-popout/useDashboardSnapshot.ts#L42-L45: retain only the omission/retention rationale.src/renderer/src/components/dashboard-popout/useDashboardSnapshot.test.tsx#L100-L102: let the test name describe this behavior.As per coding guidelines, “Comments must be concise, limited to non-obvious information, and preferably one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1b2fadd8-bc01-4ef7-ab4b-c934489b09e4
📒 Files selected for processing (4)
src/renderer/src/components/dashboard-popout/useDashboardSnapshot.test.tsxsrc/renderer/src/components/dashboard-popout/useDashboardSnapshot.tssrc/renderer/src/components/dashboard/useDashboardPopoutBridge.test.tsxsrc/renderer/src/components/dashboard/useDashboardPopoutBridge.ts
The bridge now omits an unchanged repoIconsByRepoId from republishes, so the cached snapshot main replays to a mounting pop-out could be icon-less, blanking the board's repo glyphs until the forced publish landed. Carry the last map into the cache; the forwarded payload is unchanged. Also covers the forced full sends (open, reopen, snapshot request) that no test exercised.
The changed-code quality gate reports react-doctor findings that overlap added lines, and effect-needs-cleanup spans the whole publish effect — so this PR's edits inside it turned a pre-existing false positive into a red static-analysis check. Hoisting the store subscriber leaves the effect owning one disposable; behaviour is unchanged.
The effect owns four disposables (offOpenChanged, offRequested, the store unsubscribe, and the trailing timer), not one. State the real reason the subscribe is hoisted so nobody inlines it back and re-reds the gate.
…t is open The lazy wiring exists so an enabled-but-closed pop-out costs nothing — a live subscriber would rebuild a cross-worktree snapshot on unrelated store writes. Nothing pinned the unsubscribe on close.
…sh (stablyai#11089) * perf(dashboard): stop re-sending repo icon data URLs on every republish stablyai#11012 put repo icons on the dashboard snapshot keyed by repoId. Image icons are data URLs capped at MAX_REPO_ICON_DATA_URL_LENGTH (400KB) and every repo contributing a card ships one, while the snapshot republishes up to 4x/sec (PUBLISH_THROTTLE_MS = 250) for as long as the pop-out is open. Icons change about never, so that structured-clones megabytes per second across the window boundary for bytes the pop-out already has. Publish the map only when it actually changed, comparing by reference since icons come off immutable store repo records. The two paths where the pop-out could be starting from nothing — it opened, or it mounted and asked — still force a full send, so the retained copy can never be the only one. The pop-out keeps the last map it was given when a republish omits the field. An explicitly empty map still clears, so removing an icon works. repoIconsByRepoId was already optional on DashboardSnapshot and isDashboardRepoIcons already returns true for undefined, so the main-process validator needed no change. * fix(dashboard): keep repo icons in the main-process snapshot cache The bridge now omits an unchanged repoIconsByRepoId from republishes, so the cached snapshot main replays to a mounting pop-out could be icon-less, blanking the board's repo glyphs until the forced publish landed. Carry the last map into the cache; the forwarded payload is unchanged. Also covers the forced full sends (open, reopen, snapshot request) that no test exercised. * test(dashboard): pin the icon omit on the throttled trailing republish * fix(dashboard): keep the popout bridge effect off the react-doctor gate The changed-code quality gate reports react-doctor findings that overlap added lines, and effect-needs-cleanup spans the whole publish effect — so this PR's edits inside it turned a pre-existing false positive into a red static-analysis check. Hoisting the store subscriber leaves the effect owning one disposable; behaviour is unchanged. * docs(dashboard): correct why watchSnapshotInputs sits outside the effect The effect owns four disposables (offOpenChanged, offRequested, the store unsubscribe, and the trailing timer), not one. State the real reason the subscribe is hoisted so nobody inlines it back and re-reds the gate. * test(dashboard): pin that the bridge subscribes only while the pop-out is open The lazy wiring exists so an enabled-but-closed pop-out costs nothing — a live subscriber would rebuild a cross-worktree snapshot on unrelated store writes. Nothing pinned the unsubscribe on close.
…sh (stablyai#11089) * perf(dashboard): stop re-sending repo icon data URLs on every republish stablyai#11012 put repo icons on the dashboard snapshot keyed by repoId. Image icons are data URLs capped at MAX_REPO_ICON_DATA_URL_LENGTH (400KB) and every repo contributing a card ships one, while the snapshot republishes up to 4x/sec (PUBLISH_THROTTLE_MS = 250) for as long as the pop-out is open. Icons change about never, so that structured-clones megabytes per second across the window boundary for bytes the pop-out already has. Publish the map only when it actually changed, comparing by reference since icons come off immutable store repo records. The two paths where the pop-out could be starting from nothing — it opened, or it mounted and asked — still force a full send, so the retained copy can never be the only one. The pop-out keeps the last map it was given when a republish omits the field. An explicitly empty map still clears, so removing an icon works. repoIconsByRepoId was already optional on DashboardSnapshot and isDashboardRepoIcons already returns true for undefined, so the main-process validator needed no change. * fix(dashboard): keep repo icons in the main-process snapshot cache The bridge now omits an unchanged repoIconsByRepoId from republishes, so the cached snapshot main replays to a mounting pop-out could be icon-less, blanking the board's repo glyphs until the forced publish landed. Carry the last map into the cache; the forwarded payload is unchanged. Also covers the forced full sends (open, reopen, snapshot request) that no test exercised. * test(dashboard): pin the icon omit on the throttled trailing republish * fix(dashboard): keep the popout bridge effect off the react-doctor gate The changed-code quality gate reports react-doctor findings that overlap added lines, and effect-needs-cleanup spans the whole publish effect — so this PR's edits inside it turned a pre-existing false positive into a red static-analysis check. Hoisting the store subscriber leaves the effect owning one disposable; behaviour is unchanged. * docs(dashboard): correct why watchSnapshotInputs sits outside the effect The effect owns four disposables (offOpenChanged, offRequested, the store unsubscribe, and the trailing timer), not one. State the real reason the subscribe is hoisted so nobody inlines it back and re-reds the gate. * test(dashboard): pin that the bridge subscribes only while the pop-out is open The lazy wiring exists so an enabled-but-closed pop-out costs nothing — a live subscriber would rebuild a cross-worktree snapshot on unrelated store writes. Nothing pinned the unsubscribe on close.
What
#11012 added repo icons to the dashboard snapshot, keyed by
repoId. Its own commit message notes the tradeoff:That republish is the problem:
MAX_REPO_ICON_DATA_URL_LENGTH = 400 * 1024(src/shared/repo-icon.ts:11) — each image icon is up to 400KB.build-dashboard-snapshot.ts:196puts an icon on the snapshot for every repo that contributes a card, rebuilt fresh each call.useDashboardPopoutBridge.ts:9—PUBLISH_THROTTLE_MS = 250, so up to 4 publishes/sec for as long as the pop-out is open.So with image icons configured, the bridge structured-clones hundreds of KB to megabytes per second across the window boundary, re-sending bytes the pop-out already has. Icons change approximately never.
Scope of exposure: only while the dashboard pop-out is open, and only for repos with uploaded image icons — provider-derived icons are short
https://URLs, not data URLs. Real, but conditional.Fix
Publish
repoIconsByRepoIdonly when it actually changed. Comparison is by reference, not deep value: icons come off immutable store repo records, so an unchanged repo yields the identical object, and a rebuilt record correctly counts as changed.The two paths where the pop-out could be starting from nothing still force a full send:
setOpen(true)onSnapshotRequestedThe pop-out retains the last map it was given when the field is omitted. An explicitly empty map still clears, so removing an icon works.
Contract safety
No shared-type change:
repoIconsByRepoIdis already optional onDashboardSnapshot, andisDashboardRepoIconsalready returnstrueforundefined(src/main/ipc/dashboard-payload-validation.ts:63-65), so the main-process validator accepts the omitted field as-is. Both renderer bundles ship together, so there is no cross-version skew.The in-window path (
useLiveDashboardSnapshot) builds locally and never crosses IPC — untouched.Tests
useDashboardSnapshot.test.tsx— retains icons on an omitting republish; replaces them when a new map arrives (and an omission after that retains the new map, not the old); honours an explicitly empty map.useDashboardPopoutBridge.test.tsx—repoIconsUnchangedunit tests: first publish always counts as changed; reference vs. structurally-equal; added/removed/swapped-same-size keys; null icons.Mutation-checked — deleting the retention branch fails 2 of the new cases:
With the fix:
27 passed (27)across the bridge, pop-out, kanban board, and payload-validation suites.pnpm run tcclean.Found by a release-readiness scan of
v1.4.159..v1.4.160-rc.3.