Skip to content

[feat] canvas: show project structure before node media - #1

Closed
Redivesue wants to merge 2 commits into
mainfrom
feat/446-stage-1-structure-first
Closed

Redivesue wants to merge 2 commits into
mainfrom
feat/446-stage-1-structure-first

Conversation

@Redivesue

@Redivesue Redivesue commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stage 1 of 2 for progressive canvas loading (ThinkFlowLab#446). Opening or switching a canvas no longer waits for every node's media.

  • The workspace becomes interactive from the opened project snapshot. Media then fills in per node, with loading, failed and retry states.
  • Node media fields keep a stable asset source (opendirector-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-canvas returns text bodies, so hidden text, copy and export do not depend on a later read.
  • reference-catalog checks files against its one snapshot instead of replaying history for each asset.

Stage 2 (independent, prioritised node media) is a separate pull request that builds on this one.

Linked issue

Labels

  • Labels applied. I cannot set labels on this repository. Intended: type:feat, area:canvas, area:performance.

Test plan

Local, on this commit (rebased onto 8258d4b0):

  • tsc --noEmit, check:i18n, check:browser-locale, check:browser-manifest and pre-commit run --from-ref main pass.
  • Frontend: 973 passed.
  • Browser, against the isolated fixture: canvas_progressive_load (both languages, 3 of 3 runs), canvas_switch, structured_editors, editor_save, timeline_workflow (includes a real MP4 export), canvas_crop and local_output_delivery pass.
  • Packaged desktop app on an isolated data directory, measured before the rebase: image preview, video playback, audio, original download, image editor, timeline editor and same-asset paste.

Not run or not passing:

  • The full Python suite and full browser gate were run on stage 2, which contains this commit, not separately on this commit.
  • Desktop archive export and MP4 export were not exercised in the packaged app.
  • The packaged desktop smoke test fails with A dialog obscures the canvas. It fails the same way on main.

Left to CI: the repository's pull request checks.

Evidence that it works

  • Media attached, or N/A because:

Node states on this commit, in English and Chinese: one media read is held open, one fails, one has loaded, and the text node arrived with the canvas. After Retry, the failed node recovers on its own.

Six-direction switch benchmark on three heavy fixtures: A image-heavy (180 nodes, 0.67 GiB of assets), B video-heavy (89 nodes, 2.05 GiB), C mixed with editors (116 nodes, 0.97 GiB). Apple M2, 16 GiB, macOS 26.5. Browser runtime: Chrome 158 headless against the source server. Desktop: the packaged Electron 45 app.

Per direction: 4 warm-up switches excluded, then 10 measured switches. Values are 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, because with it Chromium keeps every response Blob until the browser closes.

Measured on 52102ed0 (base) and this change before the rebase (9b50c442). The rebase adds three upstream commits that do not touch canvas open or media reads. The CI fixes after measurement only change how an editor probes a saved asset's size and how the browser test seeds its fixture.

Browser Usable, base Usable, stage 1 Content, base Content, stage 1
A→B 18652 / 21725 238 / 295 18764 / 21841 5976 / 8143
B→A 9714 / 12286 298 / 336 11264 / 15870 6770 / 7160
C→B 19870 / 21496 249 / 265 20002 / 21620 10826 / 13078
B→C 8915 / 9912 306 / 365 9510 / 10375 5920 / 6713
A→C 7658 / 7839 285 / 1898 7979 / 8193 2878 / 4657
C→A 5034 / 5420 312 / 411 6342 / 6697 7554 / 8111
Desktop Usable, base Usable, stage 1 Content, base Content, stage 1
A→B 5866 / 8623 266 / 277 6065 / 8805 2904 / 3138
B→A 8140 / 9365 376 / 498 9995 / 10909 8052 / 8308
C→B 3404 / 4507 239 / 257 ¹ 3566 / 4743 3024 / 5308 ¹
B→C 3459 / 3688 256 / 261 ¹ 3863 / 4176 3510 / 3543 ¹
A→C 5369 / 7974 622 / 1792 5790 / 8390 3280 / 4355
C→A 7863 / 8674 300 / 436 9324 / 10129 6565 / 7838

¹ The stage 1 desktop C↔B run stopped at switch 9 of 24, so these rows have 3 and 2 measured samples. See Known limitations.

Click feedback P90 is at most 31 ms with stage 1 (67 ms on base), within the 100 ms budget. Usable median is within 500 ms in every direction. Usable P90 misses the 1000 ms budget for A→C in both runtimes at this stage; stage 2 brings it under.

Cold open after a server restart, usable median: A 15339 → 2066 ms (browser) and 8250 → 1418 ms (desktop); B 7289 → 1269 and 3630 → 719; C 4033 → 1481 and 3487 → 878.

Peak Blob storage during a run drops from 1.0–2.8 GiB on base to 0.7–1.4 GiB, because hidden nodes are no longer read and text arrives with open-canvas. Base also logged failed side requests (409 on assistant/draft, timed-out tool-tasks reads) in every run; stage 1 logged none outside the stopped run.

Known limitations

  • Media reads do not retry a storage_busy lock timeout. In the stage 1 desktop C↔B run, six of C's media reads and one runtimes read got 409 storage_busy about 15 s after C opened, which matches the catalog lock timeout. As on main, each media read at this stage replays the project's history under the catalog lock, so a burst of reads on a project with many commits can queue past 15 s. Those nodes stayed on "Could not load media" until Retry. storageRequest and CreationClient.open already retry storage_busy, but transientReadFailure does not, so main has the same gap; there the read error is swallowed and the node shows no media. Stage 2 removes the per-read replay, which shortens the lock holds, but does not close the retry gap.
  • Switching away while the current canvas is still loading media is slower than a settled switch, and the benchmark above does not cover it. Measured separately, A→B 2 s after A became usable, with 47–94 of its 133 visible nodes still loading (browser runtime, 3 runs): 4.7–5.0 s from click to B usable on a warm server. The first such switch after a server restart took 48.8 s, because the first history replay of A (301 commits) holds the catalog lock and other requests queue behind it. On main the workspace stays inert until every node's media has loaded, so it cannot switch during that period at all.
  • While a canvas is open, its loaded media is held as Blobs, one copy per asset (about 177 MiB for A and 1.2 GiB for B in the packaged app). The copy is released when the canvas is closed or switched.
  • Video is still read as a whole file. Streaming and posters are outside this change.

Provider verification

  • No real-provider calls were made.

Bilingual UI

  • zh-CN and en-US are updated together. The progressive loading browser test runs in both languages.

Comment thread src/canvas/editorMedia.ts Fixed
Comment thread src/canvas/editorMedia.ts Fixed
[perf] agent: answer a wait group with one query (ThinkFlowLab#449)

The agent waited for generation one job at a time. Each poll issued its own
job.get request (954 across the traced run in ThinkFlowLab#449), read the whole project
snapshot, and emitted a separate tool record.

job.status answers up to 50 jobs from one snapshot and can wait server side for
terminal states, so one call covers a whole wait group. The group is resolved
once when the wait starts and stays frozen, so a job that settles mid-wait is
still named in the answer with its errorDetails and recovery rather than
disappearing. An empty group answers with a note instead of reading as success.
A long wait costs one CLI process per 60 s window instead of one per second,
and read-only queries no longer hold the turn's execution slot.

Discovery no longer costs one process per command: capabilities merges the
registered parser with the typed command models (56 commands), and
project show --summary returns identities and revisions instead of every record
body, including reference and editor-document identities so an edit can start
from it.

Measured on the same fixture: 14 jobs in one poll tick cost 180.6 ms and 14
snapshot reads before, 14.0 ms and 1 read after; command discovery drops from
33 CLI calls to 1; the project summary payload drops from 176,840 to 57,237
bytes. These are server calls, snapshot reads and payload sizes, not CLI
process counts.
@Redivesue
Redivesue force-pushed the feat/446-stage-1-structure-first branch from 9b50c44 to 68b0103 Compare November 24, 2026 04:53
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
@Redivesue
Redivesue force-pushed the feat/446-stage-1-structure-first branch from 68b0103 to d369be5 Compare November 24, 2026 05:01
@Redivesue

Copy link
Copy Markdown
Owner Author

Superseded by ThinkFlowLab#485, which merged both stages.

@Redivesue Redivesue closed this Nov 24, 2026
@Redivesue
Redivesue deleted the feat/446-stage-1-structure-first branch November 24, 2026 12:32
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.

3 participants