Skip to content

feat: optimize rendering and stability of task components - #783

Merged
pikann merged 3 commits into
masterfrom
feature/optimize-rendering-and-stability-of-task-components
Nov 18, 2026
Merged

pikann merged 3 commits into
masterfrom
feature/optimize-rendering-and-stability-of-task-components

Conversation

@pikann

@pikann pikann commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #781 (platform becomes very slow: avatars missing/reloading, clicks in task details delayed by seconds, whole UI redrawn when a column loads its next page).

Root causes

  1. Unstable useQueries result. InteractionLayout got a new array every render, so tasks and everything derived from it recomputed on every commit, including when a task dialog opened.
  2. Unmemoized cards and rows. Board cards and table rows received inline closures and fresh arrays, so React.memo could not help and every card/row re-rendered on each commit.
  3. IdDirectory.seed() notified on unchanged data, re-rendering every member/sprint/agent subscriber after each page load.
  4. Presigned avatar URLs change on every API response (X-Amz-Signature / X-Amz-Date). Used as <img src>, each response made the browser re-download and flash every avatar.

Changes

  • New hooks useStableCallback (stable identity, calls the latest function) and useStableValue (keeps the previous reference while the value is structurally equal).
  • interaction-layout.tsx: useQueries now uses a stable combine function; the delete handler is stable.
  • board-view.tsx: new memoized BoardCardSlot, stable handlers and column definitions, shared empty-array defaults.
  • list-group.tsx / list-view.tsx: new memoized ListRowContent, stable handlers and group definitions, and each group's task array is built once per task change. The home page's assigned-tasks list shares ListGroup, so it benefits too.
  • id-directory.ts: seed() only notifies when something actually changed. Signed URLs that differ only by signature are treated as equal, and the first URL is kept for 20 minutes.
  • provider-logos.ts: stableSignedUrl in resolveAvatarSrc, the single choke point for all avatars, so every avatar in the app keeps a stable src. A new upload (different path) is picked up immediately, and the kept URL is replaced well before the 1h signature expires.

Tests

  • New e2e board-performance (feature + spec), run with 4x CPU throttling, 40 tasks per status, and avatar URLs re-signed on every response:
    • opening a task does not re-render the whole board;
    • opening a task does not re-render every table row (about 2800 renders before vs a limit of 400);
    • loading the next page of a column keeps the other cards' DOM nodes, does not re-fetch avatars, and does not block the main thread for long.
  • Unit tests for stableSignedUrl and for MemberDirectory handling re-signed avatars.
  • tsc -b clean, 1731 web unit tests pass, 149 related e2e specs pass (2 skipped), and Biome shows the same warnings as before.

Notes

  • Board open-task main-thread blocking at 4x throttle dropped from about 2.2 s to under 1 s. The rest is the task-detail dialog's editor mounting.
  • Not measured on the reporter's data or hardware. Each card/row still sets up several query observers, so initial mount cost still scales with row count. Deferring those hooks until needed is a possible follow-up. Gantt and subtask rows were audited but not measured.

🤖 Generated with Claude Code

- Introduced `useStableCallback` and `useStableValue` hooks to maintain stable identities for callbacks and values, reducing unnecessary re-renders in task-related components.
- Refactored `InteractionLayout`, `ListGroup`, and `ListView` components to utilize stable callbacks and values, improving performance during task updates and interactions.
- Implemented a `combineColumnQueries` function to optimize the handling of column queries in `InteractionLayout`, preventing excessive re-computation and re-renders.
- Enhanced `IdDirectory` to manage avatar URLs more efficiently, preventing unnecessary updates when only the signature changes.
- Added tests to ensure the stability of avatar URLs and the correct behavior of the `MemberDirectory` when handling re-signed avatars.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new board performance spec only runs on Chromium: it opens a CDP session and measures the Long Tasks API, both Chromium-only, so the firefox, webkit and mobile-safari projects will fail at newCDPSession. One beforeEach guard fixes it.

Approach: sound — it removes the identity churn at its sources (combined query results, stable callbacks, memoized rows/cards, a directory that stops re-notifying on re-seeded avatars) rather than trimming the symptoms, and the presigned-URL cache keeps signature churn from reaching <img>.

Reviewed changes

  • Combined column queries. combineColumnQueries narrows each column query to { data, dataUpdatedAt, fetchStatus } — exactly what InteractionLayout reads — so tasks and everything derived from it keeps its identity between renders.
  • New stability hooks. useStableCallback and useStableValue, applied to drag/drop/click/delete handlers and to the column and group definitions every card and row receives.
  • Memoized leaves. BoardCardSlot and ListRowContent extracted as module-level memo components, with prop parity against the previous inline JSX verified for delete/move gating, canEdit, swimDef and subtasks.
  • Single grouping pass. ListView builds every group's tasks in one memoized pass instead of a filter per group per render, preserving global order and multi-group membership.
  • Member directory. IdDirectory.store skips the swap and the subscriber notification when a re-seed only differs by a presigned signature, killing the per-page notification storm from seedTaskPeople; the 20-minute keep window is comfortably inside the API's 1 h avatar TTL.
  • Stable avatars. stableSignedUrl caches presigned avatar URLs by signature-less path, so refetches no longer re-download every avatar or blink them back to initials.
  • Tests. Two directory tests for the re-sign behaviour, three for stableSignedUrl, and the three-scenario Playwright perf spec.

Biome is clean on all changed files, tsc -b reports nothing in them, and the 79 tests across board-view, task-card, member-directory, provider-logos and view-utils pass.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Comment thread apps/web/src/lib/provider-logos.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Chromium-only perf spec guarded. board-performance.spec.ts now skips non-Chromium projects in beforeEach, before any seeding, so firefox, webkit and mobile-safari no longer fail at newCDPSession and the CDP timing budgets stay meaningful.
  • Stable no-swimlane def. The render-scope noSwim/noSwimAll objects are replaced by a single module-scope NO_SWIMLANE, so cards in the fallback row keep a stable swimDef prop and BoardCardSlot's memo actually applies there. No consumer mutates group defs, so sharing the singleton is safe.
  • Shared signed-URL helpers. SIGNED_URL_KEEP_MS and isSignedUrl() are exported once from provider-logos.ts and consumed by id-directory.ts, removing the duplicated TTL constant and signature sniff. The module only has type-only imports, so the new import introduces no runtime cycle.

All three findings from the previous review are addressed and their threads resolved.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This run re-reviewed the c199fbd delta on top of the previously approved f8a3336: the stability hook now compares structurally, the member directory refreshes cached aliases again, and the avatar URL cache became signature-age aware and bounded.

  • Structural equality in useStableValue. The JSON-stringify comparison is replaced by a recursive deepEqual, so function-valued or undefined fields no longer count as equal (the old comparison could pin the first value forever) and property order no longer matters.
  • Cached aliases refresh on lookup. IdDirectory.store now writes a fetched record under keys already in the cache even when they were not part of the requested batch, restoring refresh of alternate ids while unknown non-requested keys are still skipped. Lookups still notify once per chunk, so this adds no notification traffic.
  • Signature-age-aware avatar cache. stableSignedUrl reads X-Amz-Date and keeps a fresher cached URL rather than swapping in an older-signed one. The cache is bounded at 500 entries, pruning expired entries first and clearing only as a last resort; when an avatar is uncached the input URL is returned, so it cannot flicker on data that has not been refetched.
  • Coverage. New cases assert that an older-signed URL cannot replace a fresh one and that a re-signed avatar is taken once the 20-minute keep window elapses.

All three threads from the first review remain resolved, and none needed action in this delta.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit 5913718 into master Nov 18, 2026
3 checks passed
@pikann
pikann deleted the feature/optimize-rendering-and-stability-of-task-components branch November 21, 2026 06:06
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.

[Bug] Platform works very slow

1 participant