Skip to content

Bug: task dialog opens slowly and flashes Create task when closed #3939

Closed

Description

@yannickmonney

What happened?

Two problems with the task dialog on a project's Tasks board or list (/dashboard/<org>/projects/<project>/tasks/board?task=<id>):

  1. Opening a task is slow. After you click a card, the dialog shows its skeleton for a noticeable time before the task appears.
  2. Closing a task briefly shows the Create task dialog. When the dialog closes (X, Esc, a click on the backdrop, or browser Back), it turns into the empty Create task form for the length of the close animation and shrinks to that form's height. Then it disappears.

Steps to reproduce

  1. Open a project → Tasks (board or list) with at least one task.
  2. Click a task card. The dialog opens on a skeleton and takes a while to fill in.
  3. Close the dialog with X, Esc, the backdrop, or browser Back. For about 200 ms the dialog shows the empty "Create task" form before it disappears.

Expected behavior

  • A task opened from the board appears immediately, since the board already has that task's row.
  • On close, the open task fades out. The Create task form appears only when someone presses Create task.

Root cause

Line references are on main @ 19f18f6cbb.

Create task flash (confirmed from the code)

The board's edit dialog takes both its open state and its task from one value, openTaskId (services/platform/app/features/tasks/components/tasks-workspace.tsx:531-541):

<TaskModal
  taskId={openTaskId}
  open={openTaskId !== null}
  onOpenChange={(open) => { if (!open) setOpenTaskId(null); }}

Closing sets openTaskId to null, which changes open and taskId in the same render. Radix keeps the dialog content mounted while it plays the exit animation (data-[state=closed]:animate-out … zoom-out-95 duration-[var(--duration-standard)], 200 ms; see packages/ui/src/components/overlays/responsive-dialog.tsx:225 and packages/ui/src/globals.css:171). During that animation TaskModal has taskId === null, so it switches to create mode: taskId ? <EditTaskBody> : <CreateTaskBody> (task-modal.tsx:222-238). It also drops the fixed h-[85dvh] height (task-modal.tsx:204). The result is that the closing dialog shows an empty Create task form at the create form's height.

Every way of closing hits this. X, Esc and the backdrop call setOpenTaskId(null). Browser Back clears ?task=, and the render-time sync resets openTaskId to null (tasks-workspace.tsx:199-207). The mobile drawer (vaul) also keeps its content mounted while it slides out, so it probably flashes too. Each close also mounts a new CreateTaskBody, which starts that form's data reads for no reason.

Possible fixes:

  • Keep the last opened task id while the dialog closes: update the taskId prop only when a new non-null id arrives, and control open separately.
  • Give each TaskModal instance a fixed mode. The workspace already renders a separate instance for creating, so the edit instance should never render CreateTaskBody.

Slow open (suspected from the code, not yet profiled)

  • The board doesn't prefill or prefetch the task. Clicking a card only sets local state and pushes ?task=. EditTaskBody then runs useTask(taskId) (task-modal.tsx:1190), which sends a new GET /tasks/:id (services/platform/app/lib/backend/tasks.ts:295). The dialog shows its skeleton until that returns (task-modal.tsx:1346). Board rows and the detail read use the same taskView projection (tasks.ts:191, tasks.ts:310), so the card's row could fill the dialog immediately while the full read loads in the background. Home's task page already prefetches getTask in its route loader (services/platform/app/routes/dashboard/$id/tasks/$taskId.tsx:17). The board prefetches nothing, not even on hover or pointerdown.
  • The reads run one after another. Several reads start only after the task arrives, even though the route already gives the org and project: useProject(task?.projectId) (1198), useCurrentMemberContext(task?.organizationId) (1217), useActorDirectory(task?.organizationId, task?.projectId) (1222) and useTaskSubjectContract(…, task) (1243). getLiveRunForTask and getLatestRunForTask (1249, 1261) then wait for the subject-contract result. The dialog fills in over at least three sequential network round trips.
  • The whole board re-renders on open and close. The local openTaskId change re-renders TasksWorkspace, and the ?task= navigation re-renders TasksBoardPage → TasksWorkspace again. KanbanBoard, BoardColumn, TaskCard and TasksList aren't memoized, so every card renders again, twice per open and twice per close. On a large board this can take noticeable main-thread time.

Before choosing a fix, profile one open (Network waterfall + React Profiler) to see which of these costs the most.

Affected service

Platform (web app)

Before submitting

  • Searched existing issues (task dialog/modal, flash/flicker, Create task, slow open): no existing report.

Activity

  1. added
    perf
    bug
    service: platform
    on Sep 29, 2026
  2. yannickmonney commented on Sep 29, 2026

    @yannickmonney
    ContributorAuthor

    Manual-cycle local baseline at main 3f9c3b4: I measured the actual task-list helpers with synthetic 50/350/2,000-task fixtures and 10,000-row stress controls. Across 84 cases (30 warmup + 100 measured batches each), the composed helper pass at the 2,000-task board cap was 0.44–0.84 ms median / 0.47–0.91 ms p95 across flat, mixed-subtask and wide-parent shapes. Twelve fixture correctness checks passed.

    These are batch-average Bun/JSC CPU timings on an M2 Max, not individual browser interaction, API or rendering percentiles. They exclude React commits/layout, HTTP and SQL. No new helper performance defect was established; this does not validate or disprove the reported task-dialog latency.

    The next local pass should measure a production-build dialog open/close: network waterfall, React commit duration, first meaningful content and exit animation at 50/350/2,000 rows. Prioritize that evidence before changing memoization or prefetching. Keep the confirmed close-mode flash and the still-unprofiled open cost as separate judgments, with keyboard/backdrop/Back/mobile and stale-data authorization controls.

  3. yannickmonney commented on Sep 29, 2026

    @yannickmonney
    ContributorAuthor

    Local round (TALE-362): the close flash is confirmed and fixed, and the slow open was the board re-rendering, not the detail read. Fix: #3948.

    Production builds on an isolated localhost stack with synthetic fixtures, one backend, A = main, B = the PR, interleaved. Full protocol on ad6e62759 vs 010af46cf; the exact head f37124f18 (after merging main @ 1e4ad7ffd) was checked again (below the tables).

    Verdicts

    Hypothesis Verdict Evidence
    Closing shows the empty Create task form Confirmed, fixed On main the create form filled 92–100 % of the exit frames of every close: X, Escape, backdrop, Back, on desktop and in the 390 px drawer, after moving to a subtask, and on the not-found state of a deleted, foreign-org or forbidden (403) task. On the PR: 0 frames; the task keeps its name and its height.
    No prefill or prefetch Not the cause GET /tasks/:id took ~30–60 ms. On main it started late (0.4 s / 1.8 s / 7.7 s after the click at 50 / 350 / 2,000 tasks), queued behind the click's synchronous re-render. The evidence does not support prefill.
    Reads run one after another True, secondary Two waves: the task, subtasks and upload policy; then activity, agent runs, comments, labels, dependencies and the watch state once the task renders. On the PR the second wave starts ~0.25–0.4 s after the first ends (50 / 350).
    The whole board re-renders on open and close Confirmed, dominant, fixed Every open and every close re-rendered every card twice, about 116–123 components per card. The PR renders 8 board components per open (the pressed card) and none per close.

    Main → PR (medians, 95 % bootstrap interval of the median)

    50 tasks 350 tasks 2,000 tasks
    Task shows after the click (cold open) 1.08 s (0.81–1.22) → 393 ms (333–476) 3.68 s (3.09–4.25) → 679 ms (589–830) 14.74 s (14.45–15.51) → 2.14 s (2.01–2.33)
    Click → next paint (Event Timing) 1.01 s → 308 ms 3.64 s → 628 ms 14.72 s → 2.06 s
    Discussion shows (cold open) 1.32 s → 596 ms 3.91 s → 912 ms 15.05 s → 2.38 s
    Task shows, reopening the same task 909 ms → 279 ms 3.80 s → 525 ms not run¹ → 1.89 s
    Task shows, another task 758 ms → 303 ms 3.19 s → 624 ms not run¹ → 2.04 s
    Escape → dialog gone 486 ms → 316 ms 2.60 s → 471 ms 9.11 s → 415 ms
    X → dialog gone 584 ms → 352 ms 3.55 s → 423 ms not run¹ → 483 ms
    Backdrop → dialog gone 554 ms → 309 ms 1.64 s → 464 ms not run¹ → 435 ms

    12 + 12 samples per size. ¹ On main the renderer of the 2,000-task page was OOM-killed three times in the sandbox's 4 GiB within three open/close pairs, so main ran one pair per page there (the cold open and its Escape close), alone on the host. Retained heap after GC stayed flat on both (below); the crashes are transient peaks while 2,000 cards re-render.

    React commits (production React through a devtools hook), components rendered per interaction, main → PR:

    50 350 2,000
    Cold open 14,636 → 2,338 84,338 → 2,294 464,844 → 2,484
    of which the board 12,354 → 8 82,100 → 8 462,588 → 8
    Escape close 13,992 → 2,298 83,738 → 2,306 464,443 → 2,328
    of which the board 12,346 → 0 82,092 → 0 462,580 → 0

    Main thread (Chrome traces, 350 tasks, cold open to settled): 3.44 s (script 2.49 s, style 0.34 s, GC 0.36 s) → 1.05 s (script 0.35 s, style 0.40 s, paint 0.16 s). Escape close: 3.54 s → 0.85 s.

    Memory after 20 (50, 350) or 6 (2,000) open/close cycles, GC forced: heap +5.0 / +6.0 / +9.3 MB on main, +4.4 / +4.0 / +3.1 MB on the PR; DOM nodes +246 / +246 / +204 on main, +77 / +77 / +35 on the PR. No leak on either; the growth is the opened tasks' cached reads.

    Exact head f37124f18 vs main @ 1e4ad7ffd (6 + 6 samples at 50 and 350 tasks, 3 + 3 at 2,000, a quieter host): the task shows 692 ms → 319 ms, 3.70 s → 589 ms, 18.47 s → 2.29 s; Escape at 350 tasks 1.70 s → 392 ms; the create form in 41/41, 40/40, 6/6 closing frames on main and 0/102, 0/90, 0/34 on the head; the lifecycle probes (subtask, Back chain, missing, foreign-org, 403) 0 frames on the head against 100 % on main, and neither build ever showed the foreign-org or forbidden task's title.

    What the PR changes

    1. TaskModal keeps the body it was open with while it closes (render-time state adjustment, as tasks-workspace.tsx already does for ?task=).
    2. The board and the list are memoized; the workspace's open handler keeps one identity (the route's callback is read through a ref, as FormDialog does); the board context's review refs are memoized; the board reads answer one stable empty array while pending or failed.
    3. The dependency picker keys the unfiltered board's own read (it read every task of the project again: 64 KB / 446 KB / 2.6 MB) and indexes its candidates (a linear lookup per option on every render: ~0.13 s of an open and ~0.33 s of a close at 2,000 tasks in CPU profiles).
    4. Manual layer: TASK-F53 and TASK-P4, and the performance guide no longer describes the retired Convex runtime.

    Measured, not fixed (follow-ups)

    1. A modal's style recalculation over a large page. A modal Radix layer sets pointer-events: none on <body>; the property is inherited, so every element recomputes, and the open forces it twice (Presence's getComputedStyle, then the dialog's focus()). That one change costs a forced recalculation of 105 ms at 350 tasks (9,324 elements) and 625 ms at 2,000 (48,199 elements) on this host; aria-hidden on the app root and data-scroll-locked cost ~0 ms. It is most of the PR's remaining ~2.1 s at 2,000 tasks. Options: stop the inheritance at the app root (the full-screen overlay already takes outside presses), content-visibility: auto on cards, or virtualised lanes, judged across every modal.
    2. ~41 react-query observers per card: 82,183 on the 2,000-task board, 26,058 of them on current-user and 26,057 on auth/session (4,608 each at 350). Query keeps observers in an array, so every observer the dialog adds or removes scans it: about 0.8 s of the Escape close at 2,000 tasks in a CPU profile. It is why the PR's Escape close there, gone after 0.4 s, still blocks the main thread ~1.7 s in all. Option: read the session and the user once per board.
    3. The Home panel re-renders on every ?task= change (useLocation feeds a memo with a new location object): 488 components here, 5,571 with ~750 assigned tasks.
    4. The second wave of reads could start with the first (they need only the task id): ~0.2 s earlier discussion at 350 tasks on this host.

    Setup and method

    • Host: shared VM (4 vCPUs visible), this sandbox's cgroup 2 CPUs and 4 GiB; the 1-min load average ranged 1.3–16 across samples (median ~5.9), which is why A and B ran back to back in alternating order (in alternating 3-sample blocks at 2,000 tasks). Absolute numbers are several times a laptop's: compare A with B.
    • Chromium 145.0.7632.6 headless (Playwright 1.58.2), 1440×900, a fresh context per sample, service worker blocked. Bun 1.4.2, Node 24.21.0, Vite 8.0.16, React 19.2.5, TanStack Router 1.168.10 / Query 5.97.0, Radix Dialog 1.1.15, vaul 1.1.2, PostgreSQL 16.13.
    • Serving: bun --bun vite build per tree; bun scripts/dev.ts with TALE_E2E_SERVE_BUILD=1 served A through vite preview and ran the backend; a second vite preview with the same environment served B against it.
    • Fixture: one org, an owner (measuring) and a member; projects of 50, 350 and 2,000 tasks created through the platform's own createTask: status mix ≈ 20/25/15/10/22/8 %, ~15 % subtasks, ~55 % described, ~50 % labelled, ~25 % due; 43 % assigned to the member and 2 % to the owner. Twelve measured tasks per project (the first three cards of four lanes), two comments each.
    • Sample: board load, then cold open → Escape, reopen → X, another task → backdrop. 2 warmups per variant per size (1 per block at 2,000), 12 measured samples. t = 0 is the input event's timestamp; "task shows" is the first frame after the dialog's name becomes the task's title. Bootstrap intervals from 4,000 resamples.
    • Traces (50 and 350 tasks, 5 pages per variant), React commit counts (3 pages; 2 and 1 at 2,000) and memory (3 pages; 2 at 2,000) ran as separate passes, so their instrumentation never touched the timings.
  4. yannickmonney commented on Sep 30, 2026

    @yannickmonney
    ContributorAuthor

    Exact-head receipt for #3948 (review follow-up). Production builds of main @ 1e4ad7ffd (A) and the PR @ 9d1d1e3db (B) ran on one backend and one database, with the same fixtures as above. The current head, 992e7f868, only adds pin text to tests/manual/, outside the app bundle. There were 10 samples per variant per size, interleaved (alternating 5-sample blocks at 2,000 tasks), with no crashed sample. On the 2-vCPU sandbox the 1-min load average ranged 1.65–10.0 (median 3.46).

    Median (95 % CI) 50 tasks 350 tasks 2,000 tasks
    Task shows after the click (cold open), main → PR 736 ms → 336 ms (302–376) 3.46 s → 672 ms (592–886) 15.60 s → 2.21 s (2.13–2.33)
    p90 of the same 873 → 393 ms 3.89 → 1.11 s 15.93 → 2.38 s
    Reopen the same task / another task (PR) 277 / 261 ms 586 / 592 ms 2.09 / 2.12 s
    Escape → dialog gone, main → PR 327 → 290 ms 1.58 s → 446 ms 10.16 s → 437 ms
    Closing frames with the create form, main → PR 69/69 → 0/182 65/65 → 0/140 20/20 → 0/119

    At 2,000 tasks main ran one open/close pair per page: in 4 GiB its renderer was OOM-killed three times in the first protocol. The rows the PR adds there have no main counterpart.

    Real-browser lifecycle on the PR, with the native Back. page.goBack() pops the ?task= entry the open pushed. Desktop: the X, Escape, the backdrop and native Back show the create form in 0 of 64–67 exit frames (main: 58–63 of 59–67). In the phone drawer: Escape, the backdrop and native Back show it in 0 of 299–301 (main: 266–281 of 267–282). Focus returns to the card after every close. Across a subtask, a Back chain, and a missing, foreign-org or forbidden (403) task, 0 exit frames show the create form, against every exit frame on main, and neither build shows the foreign or forbidden task's title. The component suite's own "Back" case is a harness that clears the id, which is what Back ends in; the native path is the probe's.

    Traces. At 350 tasks, a cold open to settled took 3.79 s on main (script 2.71 s) and 1.03 s on the PR (script 0.30 s, style 0.30 s). At 2,000 tasks the PR took 2.40 s, with style 1.46 s; main's 2,000-task traces were not taken (OOM risk). Raw traces are attached to TALE-362.

    What the PR does not reach, reported apart from it. TASK-P4's < 1 s target is missed on this host at 2,000 tasks (2.21 s median); no laptop was measured. Almost all of the rest is:

    1. pointer-events: none on <body> during a Radix modal, an inherited property that makes every element recompute. The open forces that twice. Measured alone, it costs 105 ms at 9,324 elements and 625 ms at 48,199. This is a design-system question.
    2. React-query observer bookkeeping: ~41 observers per card, 26,058 on current-user alone at 2,000 tasks. That is ~0.8 s of the Escape close there, which is why the PR's close, gone after 0.44 s, keeps the main thread busy ~1.2 s in all.
    3. The Home panel's re-render on every ?task= change: 488 components.
    4. Starting the second wave of reads with the first: ~0.2 s at 350 tasks.

    The review's React Doctor finding (a ref written during render, tasks-workspace.tsx:223) is fixed with the commit-phase pattern useFocusHandoff uses. React Doctor now reports 0 errors on the changed components, and a test holds that a click reaches the latest committed callback.

    The Bun helper baseline in the earlier comment timed list helpers only. None of these numbers rest on it.

  5. yannickmonney commented on Sep 30, 2026

    @yannickmonney
    ContributorAuthor

    Final local round for #3948, whose head is now 62f4a14ec. The head merges main b5ff70447; its production bundle is byte-identical to the merge 856a7c738's, which is the build measured here.

    Correction to the receipt above. My probe stamped "task shows" and "dialog gone" with the rAF callback's timestamp. That timestamp is the frame's begin time, and after a long task it can come before the change it stamps. The last run instead stamps the frame that shows the change, once it is produced, and records both stamps on each sample:

    • Opens: the old stamps ran 85–113 ms early at the median.
    • Closes: they ran much earlier. At 2,000 tasks the PR's Escape close is 2.05 s to the next rendered frame, not 0.44 s; main's is 17.5 s, not 10.2 s.
    • What the old close stamp caught: a screen recording at 2,000 tasks shows the fade ending on screen at ~0.45 s, which is what the old stamp measured. The page then renders nothing until ~2.16 s.

    Final head, corrected stamps. Main b5ff70447 against the PR 856a7c738, 10 + 10 samples per size, no crashed sample, with a 1-min load of 2.35–13.16 (median 4.87). Medians, main → PR:

    50 tasks 350 tasks 2,000 tasks
    Task shows after the click (cold open) 1.01 s → 526 ms 3.40 s → 727 ms 17.38 s → 2.11 s
    p90 of the same 1.33 s → 657 ms 3.76 s → 914 ms 18.93 → 2.48 s
    Escape → the page renders without the dialog 799 → 422 ms 3.22 s → 667 ms 17.46 → 2.05 s
    Closing frames that showed the create form 63/63 → 0/159 64/64 → 0/138 20/20 → 0/117

    At 2,000 tasks main ran one open/close pair per page. The PR's reopen there takes 2.14 s, another task 2.10 s, and X and the backdrop 2.09 and 2.07 s. The real-browser probes on the final head show 0 create-form frames on the PR for every close, native Back included, on desktop and in the drawer, against 58–289 on main. They show the same for the subtask, the Back-chain, the missing, the foreign-org and the forbidden cases. Focus returns to the card, and neither build showed the foreign or forbidden task.

    Revisions measured.

    Run main → PR Samples
    First protocol ad6e62759 → 010af46cf 12
    Follow-up 1e4ad7ffd → f37124f18 6, and 3 at 2,000 (2.29 s there; superseded)
    Receipt 1 1e4ad7ffd → 9d1d1e3db 10 (2.21 s, old stamp)
    Final b5ff70447 → 856a7c738 10 (2.00 s, old stamp)
    Final, frame stamps the same builds 10 (2.11 s)

    The PR's own runtime changed only once after the first protocol: 9d1d1e3db moved the callback ref's write into a layout effect. The rest are main's changes or text.

    Failed or invalid attempts, all kept:

    • First protocol: main at 2,000 tasks with three pairs per page stopped as its renderer ran out of memory, and the cgroup counted 3 OOM kills. After that, main ran one pair per page.
    • Block A-9: 1 renderer crash and 2 aborted samples, all replaced by a top-up block.
    • Early stamps: they included 4 of the PR's 10 reopens at 2,000 tasks reading ≈ 0 ms in the first final run.
    • Outlier: one main close of 116 s, at load 13.2.

    Still open, now tracked in #3974. On this 2-vCPU VM, TASK-P4 misses its < 1 s target at 2,000 tasks, and the page stays unresponsive about 1.6 s after the close's fade. This is not a laptop result. The four costs are:

    1. the style recalculation a modal Radix layer forces (pointer-events: none on <body>);
    2. ~41 react-query observers per card;
    3. the Home panel's re-render on ?task=;
    4. the dialog's second wave of reads.

    Every run's raw samples, traces, commit counts, probe frames, screen recordings, runner receipt and sha256 manifest are in TALE-362's delivery box.

  6. yannickmonney commented on Sep 30, 2026

    @yannickmonney
    ContributorAuthor

    Independent acceptance is complete. PR #3948 at b58676e was normally squash-merged as 0e7cf2d at 2026-09-30 07:40:44 UTC. The lifecycle/flash fix and measured improvement are accepted after exact-head CI and verification of all seven evidence archives (568 manifest entries plus 443 nested entries). Review: #3948 (comment)

    Closing this original repair report. The constrained 2-vCPU result at 2,000 tasks still misses the <1s target (~2.11s open/~2.05s Escape close), and the four residual costs remain open in #3974. Historical invalid timing, crashed/OOM attempts and original measurement-source labels are retained. This is not a laptop, newly measured final-head, production performance or deployment claim. Tale implementation task TALE-362 is Done; canonical intake TALE-374 is being completed against that independent acceptance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugperfservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions