Repository navigation
[feat] canvas: show project structure first and load node media by priority - #485
Conversation
3c95a2d to
3a9ee03
Compare
| }, | ||
| { timeoutMs: 120_000, attempts: 3, ...options }, | ||
| ), | ||
| { |
There was a problem hiding this comment.
These are the two existing js/file-access-to-http findings on main, for the media content and thumbnail fetches in CreationClient. They are reported again because this PR wraps both calls in the read limiter. The URLs and their sources are unchanged: same-origin /api paths built from the project and asset IDs. The CodeQL check passes.
| }, | ||
| { timeoutMs: 120_000, attempts: 3 }, | ||
| ), | ||
| { priority: MEDIA_PRIORITY.visible }, |
Checked with no finding:
Ran: Not run: local |
Opening or switching a canvas waited for every node's media, including hidden nodes, before the workspace became interactive. Project the canvas from the opened snapshot and keep a stable asset source in node media fields. Object URLs are resolved only where media is displayed or read, so they no longer enter the document, undo history or save baseline. Saving compares asset identity, so a late media read cannot change a binding. Return text with open-canvas, show loading and failed states per node, and check reference-catalog files against its one snapshot. Refs ThinkFlowLab#446
Once the structure is interactive, every mounted node still started its media read at once and waited behind the catalog lock. Share a bounded priority queue across media reads, start on-screen nodes only when they reach the viewport, and cancel a display read once no on-screen consumer needs it. Explicit actions keep priority and are never cancelled by a display consumer leaving. Reuse the validated head for repeated media reads. An unproven chain still runs the full validation first, so a damaged ancestor keeps being rejected. Refs ThinkFlowLab#446
3a9ee03 to
7f70818
Compare
|
Updated per the review: #484 is closed, so this PR now carries both commits, rebased onto |
|
Supersedes my WITHHOLD. This PR now carries both stages (#484 is closed in its favour), the body has the media evidence, and the required checks are green on this SHA.
One correction to my earlier note, in the author's favour. I wrote that using the cached head in Accepted as disclosed, not fixed here: media reads still do not retry a Ran: Not run: the Python suite, browser gate, or packaged desktop app locally. This review used CI, source reading, and the recorded evidence in the body. |
Summary
Progressive canvas loading for #446, in two commits that can be reviewed one at a time. It replaces #484, which carried only the first commit. Opening or switching a canvas no longer waits for every node's media.
[feat] canvas: show project structure before node mediaopendirector-asset://<projectId>/<assetId>). Object URLs are resolved only where media is displayed or read, so they stay out of the document, undo history and save baseline.open-canvasreturns text bodies, so hidden text, copy and export do not depend on a later read.reference-catalogchecks files against its one snapshot instead of replaying history for each asset.[feat] canvas: load node media independently by priorityIntersectionObserver. There is no off-screen preload.Media reads and the cached project head
mainalready serves the cached head on hot read paths:snapshot()returns_current_record(...)[0]without checkingvalidated, andopen()and caught-up change polling use it too, to avoid replaying the chain under the catalog lock. This PR extends it toopen_mediawith a stricter rule. The cached head is used only after its chain has been validated; otherwise the read still runs the full_load, so a damaged ancestor is still rejected. The served bytes are still checked against the asset's fingerprint and size, so a rewritten media file is rejected as before.What changes: an ancestor commit rewritten on disk while the server runs is no longer caught by a media read until the server restarts. Saves and history reads still replay and validate the chain. The storage owner should confirm this trade-off for the media read path.
Linked issue
Labels
type:feat,area:canvas,area:performance.Test plan
Local, on this branch (both commits, rebased onto
aff774a8):tsc --noEmit,check:i18n,check:browser-locale,check:browser-manifest,generate_contracts.py --checkandpre-commit run --from-ref mainpass.-m cpu): 2922 passed, 118 skipped (Windows-only).scripts/run-browser-suite.mjs, Vite dev server and isolated API as in CI): 30 of 30, includingcanvas_progressive_loadin both languages.capability discoveryis flaky onmaintoo: run alone, it failed 1 of 3 times on3c151e15, waiting for "Service paused".apps/desktop/scripts/smoke.mjspasses: first run, canvas, media drag-and-drop, authenticated API, isolation, both locales, hidden-window Host, reopen and sidebar preferences. The earlierA dialog obscures the canvasfailure, which52102ed0also had, no longer occurs on this base.Not run:
timeline_workflowexports and checks a real MP4.Left to CI: the repository's pull request checks.
Evidence that it works
Recording, browser runtime on a warm server, the same fixtures: left
main(8258d4b0), right this branch (stage 1 and 2). The overlay, injected by the recording script, shows the time since the project click and when the canvas became usable: 9.26 s onmain, 0.27 s here, with media filling in afterwards.pr485-switch-main-vs-this-branch.mp4
Node states in English and Chinese: one media read held open, one failing with Retry, one loaded, and a text node that arrived with the canvas.
Six-direction switch benchmark on three heavy fixtures: A image-heavy (180 nodes, 0.67 GiB), B video-heavy (89 nodes, 2.05 GiB), C mixed with editors (116 nodes, 0.97 GiB). Apple M2, 16 GiB, macOS 26.5; Chrome 158 headless against the source server, and the packaged Electron 45 app. Per direction: 4 warm-up switches excluded, then 10 measured switches; median / P90 in ms, nearest-rank. "Usable" means the target title is shown, the workspace is not busy or inert, and every visible node is mounted. "Content" means every in-viewport image is decoded, video has
readyState >= 2, audio>= 1, and text is rendered. The driver uses CDP without the Network domain.Measured on
52102ed0(base), the stage 1 commit (9b50c442) and the stage 2 commit (417582ca), before rebasing ontoaff774a8. The upstream commits added since then (lease renewal, upload throughrequest(), a mask-composite edge, agent job-state queries, macOS DMG guidance) do not touch canvas open or media reads.¹ The stage 1 desktop C↔B run stopped at switch 9 of 24 on a
storage_busylock timeout, so these rows have 3 and 2 samples. Stage 2 completed 24 of 24 in every run.With stage 2, usable median is within 500 ms and usable P90 within 1000 ms in every direction (worst P90: 508 ms, desktop B→A). Click feedback P90 is at most 32 ms. Stage 2 logged no failed requests in any run; base logged 409s on
assistant/draftand timed-outtool-tasksreads in every run.Stage 2 is not uniformly faster than stage 1 to full content. Content median improves in 5 of 6 browser directions and 3 of 6 desktop directions. It regresses most on desktop A→B (2904 → 4713 ms), where B's large in-view videos now share 3 read slots, and on browser A→C (2878 → 4330 ms). This benchmark uses the fit-all view, which puts every node in the viewport, so it does not exercise viewport gating.
Cold open after a server restart, usable median, stage 1 → stage 2: browser A 2066 → 1812, B 1269 → 1363, C 1481 → 1753 ms; desktop A 1418 → 1384, B 719 → 701, C 878 → 900 ms (base: browser 15339 / 7289 / 4033, desktop 8250 / 3630 / 3487 ms).
Time to all in-view content after a cold open, base → stage 1 → stage 2: browser A 15535 → 12475 → 10916, B 7507 → 5546 → 5573, C 4033 → 3499 → 4506 ms; desktop A 8250 → 10473 → 9191, B 3801 → 3728 → 5335, C 3487 → 3576 → 3698 ms. On desktop, full content after a cold open is slower than on base for all three canvases, because the canvas becomes usable first and media then loads through 3 read slots.
Peak Blob storage per run: base 1.0–2.8 GiB, stage 1 0.7–1.4 GiB, stage 2 0.5–1.3 GiB.
Known limitations
storage_busylock timeout.storageRequestandCreationClient.openretry it, buttransientReadFailuredoes not, somainhas the same gap; there the read error is swallowed and the node shows no media. Here the node shows "Could not load media" with Retry. It happened in the stage 1 desktop C↔B run (six reads about 15 s after C opened, matching the catalog lock timeout) and once on a freshly restarted server with stage 2 (see the next item). Stage 2 shortens catalog lock holds, and its benchmark runs had no lock timeout.maintoo, where the workspace stays inert until every node's media has loaded.Provider verification
Bilingual UI
zh-CNanden-USare updated together:canvasNodes.media.loading,.failedand.retry.canvas_progressive_loadruns in both languages.