Skip to content

Move Tasks onto shared live reads - #6419

Merged
ymichael merged 2 commits into
mainfrom
bb/tasks-plugin-onto-shared-live-reads-thr_b5b43iearn
Oct 28, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/tasks-plugin-onto-shared-live-reads-thr_b5b43iearn

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Tasks kept its views live with its own query layer instead of BB's shared live reads. That layer was a signal scheduler fed by four useRealtime channels (tasks/projects/comments/threads:changed), per-view patchers, snapshot revision guards, a refresh-generation provider, a hand-written list edit layer and a 60 s pull request poll. The board loaded card metadata with one listAttachments call per card plus one listTaskThreads call per working task: 427 RPCs for a 400-card project. Every edit triggered 5–6 re-reads, each after the scheduler's 50 ms batching delay.

I checked #5670's listed bugs on main against a seeded dev instance before porting:

#5670 bug On main
Board loads through ~1,000 RPCs Reproduces: 427 RPCs for 400 cards, 400 of them listAttachments
Several re-reads per edit Reproduces: 5–6 reads per edit
Title/description edits don't refresh comments Not a bug on main: activity re-read on every task change, and nothing in it depends on title or description
Untagged project choices listBbProjects reads core data and refreshes on mount and reconnect, as before
A PAR-01 key miss is never refreshed Does not reproduce: the detail view re-read on any task change. The port keeps this (test below)

What changed

No Plugin SDK change. Main's keyed reads don't need #5670's "seed cold keyed reads from a list response": the views use plain tagged list reads, so the first paint stays one round trip.

  • Contract (shared/contract.ts, shared/tags.ts):
    • Reads declare tags.
    • Three internal reads replace client-side fan-out:
      • listAllTasks: unpaged; replaces the client page loop.
      • listTaskCardMeta: attachment counts and working agents for a project's cards in one read; replaces the per-card calls.
      • labelsByProject: keyed by project, keyTags; serves the All tasks list's labels.
  • Server (api, delegate, lifecycle, attachments, cli):
    • Every bb.realtime.publish becomes bb.rpc.experimental_invalidate with the matching tags.
    • This happens inside the domain handlers that RPC, the CLI and agent tools share, so every write path invalidates exactly once. The contract doesn't also declare invalidates: the server would then broadcast twice, and the editing client would re-read twice.
    • A whileWatched producer on listTaskPullRequests replaces the frontend 60 s poll. It refreshes a watched task's pull requests every 60 s while its last read had an open or draft PR.
  • UI:
    • Every view reads through experimental_useRpcQuery. List labels for all projects use experimental_useRpcKeyedQuery.
    • List row edits go through experimental_useRpcMutation with the shared optimistic cache. The dimmed pending rows come from pendingInputs.
    • The Refresh button uses experimental_useRpcRefresh. It spins only for a manual refresh or a reconnect, as before.
  • Deleted: shell/signal-scheduler.ts, shell/refresh.tsx, views/list/optimistic.ts, views/list/use-task-edits.ts, the board/list patchers, snapshot revision guards, visibility handling and the detail PR interval.
  • Kept: the localStorage snapshot for folders, projects and the sidebar summary. The shared cache doesn't persist across reloads, and this snapshot is what prevents Reload flashes: Tasks empty state, plugin route chrome, composer model and reasoning #1676's reload flash. It is now a plain initial value.
  • Docs: docs/api_to_audit.md lists the Tasks producer under watched reads.

Behaviour is the same for users. Changes that come from the shared cache:

  • Returning to a list scope you already opened (for example Active → All) paints its cached rows while it revalidates; main showed skeleton rows again. This is the repeat-visit behaviour Reload flashes: Tasks empty state, plugin route chrome, composer model and reasoning #1676 asked for.
  • List rows now refresh after a project prefix rename; on main they kept stale keys until the next task change.
  • Activity no longer re-reads on edits that don't write a comment.
  • A refused list edit (ok: false) shows its toast and re-reads the list to drop the prediction. It no longer rolls back locally first.

sidebarOpenTaskCount is now a tagged read. Other plugins can read the open-task count live with experimental_useRpcQuery({ pluginId: "tasks", … }), which is part of #5720's second ask.

How you verified

  • pnpm exec turbo run typecheck lint test --filter='...[origin/main]' --continue:
    • bb-plugin-tasks: 398/398.
    • Lint: 21 warnings, the same count as main, none new.
    • Three failures, all outside Tasks (CI re-runs them):
      • @bb/app CommandPalette.test.tsx: a 10 s hook timeout; it passes alone, 71/71.
      • Two @bb/server builtin-plugin hot-reload fixture tests: they time out at load average 24–35.
  • New api/live-reads.test.ts checks that each write invalidates the tags of every read it must refresh and leaves the others alone:
    • A title edit refreshes that task's detail, both lists and the open count. It doesn't refresh another task, another project, activity or card metadata.
    • Status changes and comments refresh activity.
    • A REV-03 miss resolves when REV-3 is created.
    • Prefix renames, moves between projects, uploads, thread attaches, label changes, folders, presets and a CLI edit.
  • Also tested: listAllTasks past one page, and listTaskCardMeta contents.
  • api.test.ts: the producer refreshes every 60 s only while the PR is open, and stops when unwatched.
  • UI tests that pushed realtime events now drive experimental_invalidateRpc with the tags the server sends. Tests of the deleted layer were removed: signal-scheduler, optimistic, incremental, the badge coalescing test and the first-connection test (that policy now belongs to core).

Measured on a real dev instance (pnpm start:worktree), same data on both builds: 480 tasks in one project, 50 with attachments, 5 attached threads. Each build ran in the same headless Chromium at 1600×1000. Medians, main → branch:

Load (n=7) Time to first rows (in-page) Tasks RPCs
Board 364 → 203 ms 427 → 10
Project list 439 → 378 ms 29 → 12
All tasks 440 → 406 ms 32 → 12
Task detail 228 → 227 ms 29 → 17
Edit (n=5) Visible after Re-reads
Board: title edited elsewhere 77 → 34 ms 6 → 4
Board: drag to another column (optimistic) 23 → 28 ms 6 → 4
List: title edited elsewhere 64 → 21 ms 5 → 5
List: priority from the row menu (optimistic) 125 → 140 ms 5 → 5

The two optimistic rows (drag and priority menu) are both immediate on both builds, so their differences are noise. Counting toLocaleDateString calls during load showed the list renders its rows fewer times than on main (6,370 vs 10,226 calls). No edit triggered a double read.

Driven in the running app on the branch:

  • Detail page:
    • The status change appears in activity, and the badge count follows open/closed changes.
    • Title rename shows on the list. Comment, sub-task, and attachment upload and removal all update live.
  • A bb tasks update from the CLI updates an open detail view's title and activity live.
  • Detaching and re-attaching a thread via the CLI removes and restores the board card's working-agent chip live.
  • Board drag persists.
  • The Refresh button spins, then clears.
  • A detail page for an unknown key (PERF-0481) resolves once PERF-481 is created.

AGENT GENERATED

🤖 Generated with Claude Code

Michael Yong and others added 2 commits October 27, 2026 18:12
Tasks kept its views live with its own query layer: a signal scheduler,
patchers, snapshot revision guards, a refresh provider, a hand-written list
edit layer and a 60 s pull request poll. The board read attachments with one
RPC per card.

Reads now declare tags and the UI uses experimental_useRpcQuery,
experimental_useRpcKeyedQuery and experimental_useRpcMutation. The server
replaces bb.realtime.publish with bb.rpc.experimental_invalidate in the
domain handlers shared by RPC, CLI and agent tools. listAllTasks replaces the
client page loop, listTaskCardMeta batches board card metadata, and the keyed
labelsByProject read serves the all-projects list. A watched-read producer
refreshes open pull requests every 60 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changing a task's parent or deleting a parent task promotes subtasks to
board cards, but only invalidated task reads, so the promoted cards kept
missing attachment counts and working-agent chips. Both paths now also
invalidate the card metadata read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit a4fdbe1 into main Oct 28, 2026
94 of 95 checks passed
@ymichael
ymichael deleted the bb/tasks-plugin-onto-shared-live-reads-thr_b5b43iearn branch October 28, 2026 18:56
mistakeknot added a commit to mistakeknot/aleph that referenced this pull request Nov 2, 2026
Upstream: a4fdbe1 Move Tasks onto shared live reads (get-bb#6419)
Base:     1a4a1d2
Release:  0.48.0 (top of upstream CHANGELOG at this commit)

One conflict, plugins/tasks/views/detail/index.tsx (patch tasks-plugin):
upstream moved useTasksQuery to the shared live-read form
useTasksQuery("getTaskByKey", { taskKey }, selectTask). Kept Aleph's
DetailViewBody wrapper (the onClose header) and switched its query to the
new form. No other Aleph call site used the old callback form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
mistakeknot added a commit to mistakeknot/aleph that referenced this pull request Nov 2, 2026
Upstream get-bb#6419 moved Tasks change signals from realtime.publish to
rpc.experimental_invalidate, so the Aleph test that counted realtime
signals after async delivery saw none. It now asserts the comments tag
invalidation, matching upstream's own delivery test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

1 participant