Skip to content

[perf] canvas: filter the asset list in the browser instead of per keystroke - #593

Merged
princepride merged 2 commits into
ThinkFlowLab:mainfrom
princepride:perf/asset-list-search
Nov 29, 2026
Merged

princepride merged 2 commits into
ThinkFlowLab:mainfrom
princepride:perf/asset-list-search

Conversation

@princepride

@princepride princepride commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The asset list (资产列表) asks the server for the whole listing again on every search change, visibility choice and type tab, although it already reads every page of the listing. Each of those reads recomputes inventory and usage over the project's full commit history, and the list is cleared while the read runs. On large projects, every pause in typing therefore blanks the list and waits on the server.

This PR:

  • Loads the unfiltered listing once when the list opens. Search, visibility and type tabs filter it in the browser, matching asset name or owning node title like the server's asset search. The browser ignores case with toLowerCase and the server with casefold; they differ only for a few characters such as German "ß", and Chinese text is unaffected. The text input uses useDeferredValue, so typing stays responsive on long lists. Type counts are computed from the same filtered rows. The server's asset-list and the agent's asset.search are unchanged.
  • Refreshes the open list when a project change can affect it, for example when an agent adds media. The current rows stay on screen until the new list is complete.
    • The list compares a fingerprint of the snapshot parts it is computed from: assets, owning nodes' titles, visibility and bindings, current results, pinned references and editor documents. Other events, such as moving or resizing nodes, don't reread it.
    • A refresh starts at least 2 s after the previous read ends, and a change that arrives during a load triggers one reload after it. A busy project therefore reads the list at most once every 2 s.
    • A failed background refresh keeps the rows on screen and shows "资产列表可能已过期" with a reload button; the next change refreshes the list again. Only a failed first read clears the list and shows the error.
    • Pages from different revisions are retried twice before the existing "资产列表已变化" error appears.
    • Rows removed by a delete leave as soon as the delete receipt arrives.
  • Makes video hover previews cancellable. They now use the same read as on-screen canvas media (MEDIA_PRIORITY.visible plus an abort signal), so moving off a row abandons the read. Before, every video previewed while moving down the list was downloaded in full, queued ahead of the canvas's own media and kept in memory.

Linked issue

  • No issue applies. Reported directly as the asset list and its search loading very slowly.

Labels

  • Labels applied (type:bug, area:assets, area:performance)

Test plan

  • Local:
    • npx tsc --noEmit
    • npm test (1032 passed)
    • npm run check:i18n (0 problems)
    • node tests/browser/creation_asset_list.mjs against the isolated tests/browser/creation_server.py + Vite, with Chrome for Testing. It passes, and unmodified main also passes it in the same setup. The test now also checks that:
      • search and type tabs send no listing requests;
      • the revision-mismatch error still appears after the list reads every page again;
      • an asset written while the list is open appears without reopening it;
      • five node moves with the list open send no listing requests;
      • eight text writes 300 ms apart cause at most one read per 2 s;
      • a failed refresh keeps the rows, shows the out-of-date notice, and the next change refreshes the list.
  • Left to CI: the rest of the browser suite and the Python suite (no backend change).

Evidence that it works

  • N/A for media: the list looks the same. Measured in the browser instead, on the same isolated API, with one fresh project per build (200 text assets, about 240 commits, 40 text nodes). The numbers are medians of 5 rounds after one warm-up; typing is 80 ms per key.
main this PR
Last key → filtered list settled 219 ms 1 ms
Clearing the search → full list settled 411 ms 43 ms
asset-list requests per search 4 0
Opening the list 186 ms 190 ms

Reads while the list stays open and the project changes, measured with the browser test's scenario on the first commit of this PR and on its final version:

List open, project changing first commit this PR
5 node moves, 100 ms apart 5 reads 0 reads
8 text writes, 300 ms apart (about 6 s in all) 13 reads 3 reads

main doesn't refresh an open list at all, so it sends no reads in either case, but it also doesn't show media an agent adds until the list is reopened.

The fixture server is fast. Each asset-list read scans the whole history, so the per-search cost grows with project size, while filtering in the browser does not.

Provider verification

  • No provider calls were made.

Bilingual UI

  • One new string, canvasNodes.assets.outdated: "资产列表可能已过期。" / "The asset list may be out of date."

🤖 Generated with Claude Code

…ystroke

The asset list re-read the whole listing from the server for every search
change, visibility choice and type tab, although it already reads every page
of it. Each read recomputes inventory and usage over the full commit history,
and the list was cleared while it ran. Load the unfiltered listing once when
the list opens and filter search, visibility and type in the browser, with the
same matching as the server's asset search.

The open list now refreshes when the project changes (an agent adding media,
for example), keeping the current rows on screen until the new list is
complete; a change during a load reloads once after it, and pages from
different revisions are retried before the list reports the change. Deleted
rows leave at once after the delete receipt.

Video hover previews now read like on-screen canvas media, at visible priority
with an abort signal, so moving the pointer down a list of videos abandons
reads nobody is waiting for instead of queueing every whole file ahead of the
canvas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@princepride princepride added area:assets Assets, library and reference inputs area:performance Performance and responsiveness / 性能与响应速度 type:bug Something is broken labels Nov 29, 2026
@github-actions github-actions Bot added the area:canvas Canvas, nodes and direct manipulation label Nov 29, 2026
The open list reread every page whenever the project's event cursor moved,
so moving nodes or an agent adding media one item at a time kept it reading,
and each read recomputes inventory and usage over the commit history. It now
compares a fingerprint of the snapshot parts the list is computed from
(assets, owning nodes' titles, visibility and bindings, current results,
pinned references, editor documents) and ignores other events, and refreshes
start at least 2 s after the previous read ends.

With the list open in the browser test, five node moves caused five list
reads before and none now; eight text writes 300 ms apart caused 13 reads
before and 3 now.

A failed background refresh no longer empties the list: the rows stay, a
notice says the list may be out of date, and the next change refreshes it
again. Only a failed first read clears the list and shows the error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@princepride
princepride merged commit de91d92 into ThinkFlowLab:main Nov 29, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:assets Assets, library and reference inputs area:canvas Canvas, nodes and direct manipulation area:performance Performance and responsiveness / 性能与响应速度 type:bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant