Skip to content

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

Closed
Redivesue wants to merge 1 commit into
ThinkFlowLab:mainfrom
Redivesue:feat/446-stage-1-structure-first
Closed

Redivesue wants to merge 1 commit into
ThinkFlowLab:mainfrom
Redivesue:feat/446-stage-1-structure-first

Conversation

@Redivesue

@Redivesue Redivesue commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stage 1 of 2 for progressive canvas loading (#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 by the repository's labeling workflow: type:feat, area:canvas, area:performance.

Test plan

Local, on this commit (rebased onto 3c151e15):

  • 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 (ad-hoc signed) on an isolated data directory: image preview, video playback, audio, original download, image editor, timeline editor and same-asset paste pass. Last run on stage 2 rebased onto 8258d4b0, which contains this change; the final rebase onto 3c151e15 adds only an agent job-state query.

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 failed with A dialog obscures the canvas before the rebase, the same way as on the base commit 52102ed0. It was not rerun after the rebase.

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

Evidence that it works

  • Media attached.

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.

pr484-node-states-en-US pr484-node-states-zh-CN pr484-node-states-recovered-en-US

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 four upstream commits (lease renewal, upload through request(), a mask-composite edge, agent job-state queries) 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. Time to all in-view content after a cold open does not improve the same way: browser A 15535 → 12475 ms, B 7507 → 5546, C 4033 → 3499; desktop A 8250 → 10473, B 3801 → 3728, C 3487 → 3576. On desktop, A's media finishes 2.2 s later than on base, because the canvas is usable first and media loads afterwards.

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.

@github-actions github-actions Bot added area:canvas Canvas, nodes and direct manipulation area:performance Performance and responsiveness / 性能与响应速度 type:feat New capability or behaviour labels Nov 24, 2026
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
@kunkunblueberry

Copy link
Copy Markdown
Collaborator

WITHHOLD d369be5 Refs #446

  • Required CI is red on this SHA, but not in a way the log attributes to this change. checks / python failed at tests/test_native_runtime.py::test_cancel_native_process_group[codex] (DID NOT RAISE ProcessLookupError, tests/process_helpers.py:166); the aggregate checks / checks then reports "Layer audit failed". Everything else passed: static, frontend, browser (assistant|isolated|voice), tests, CodeQL. The superset tip of [feat] canvas: show project structure first and load node media by priority #485 (3a9ee032) passed the same 2920 tests 13 minutes earlier, and this diff touches no native-runtime or process code, so a flake is the likely reading — I cannot certify that from one run. A rerun is needed before this can pass.
  • The required checks had not started when I opened this review: Release checks, CodeQL and DSH plugin checks were all action_required (first-time-contributor approval). I approved those runs; the numbers above are from that attempt.
  • User-visible change with no attached media. The evidence section names node-states-en-US.png, node-states-zh-CN.png and node-states-recovered-en-US.png only inside an HTML comment, and the checklist box is unchecked; there is no user-attachments URL in the body. Attach them, or mark N/A with a reason.
  • Validation on this tip is incomplete by your own account: the full Python suite and browser gate were run on stage 2 ([feat] canvas: show project structure first and load node media by priority #485), not here, and the packaged desktop smoke test failed with "A dialog obscures the canvas" before the rebase and was not rerun.
  • The body's base is stale: it says rebased onto 8258d4b0, while the base is now 3c151e15, which contains [perf] agent: answer a wait group with one query #455. The measurements are labelled 52102ed0 / 9b50c442.
  • Minor: the labels checklist says you cannot set labels, but type:feat, area:canvas and area:performance are applied. Correct the checkbox.

Checked with no finding, so the next review can start lower:

  • i18n parity: canvasNodes.media.loading, .failed and .retry exist in both en-US and zh-CN.
  • No revert of merged work: job_states and unfinished_jobs are still present in creation_canvas.py, and src/contracts/ is untouched.
  • The new media field value is presentation only. opendirector-asset://<projectId>/<assetId> is built in the projection and resolved at display or read; it is not sent as business data.
  • Every read path resolves it: fetchMediaSource/resolveMediaSource cover 30 call sites, and the three remaining raw fetch() calls are guarded (useWorkspaceTransfer resolves asset sources through originalMedia first; creationProjection fetches only non-data imported sources; canvasArchive.readMedia is the injectable export default).
  • Cross-project paste still registers into the target project through captureClipboardMedia's MediaSource + register, rather than leaving a node pointing at the source project.
  • The new browser test is registered in the gate lane in tests/browser/manifest.json and documented in docs/development/validation.md.

Ran: gh pr checks 484 on d369be5 (11 pass, checks / python failed, checks / checks failed as the summary); read the failed python log and identified the exact test; approved the three action_required workflow runs so required CI could execute; read the full 51-file diff; traced the media read and paste paths; compared i18n keys and the creation_canvas.py state against main.

Not run: tsc --noEmit, frontend tests, the browser gate, or the packaged desktop app locally. This review used CI and source reading only.

@Redivesue

Copy link
Copy Markdown
Contributor Author

The only failing check is checks / python: tests/test_native_runtime.py::test_cancel_native_process_group[codex] failed with DID NOT RAISE ProcessLookupError, and the other 2920 tests passed. This PR does not touch the agent runtime or that test, and the same commit passed checks / python in #485 and in the fork's CI. On POSIX, assert_process_exited calls os.kill(pid, 0) once without waiting, so a process that was killed but not yet reaped still counts as alive. Could a maintainer re-run the failed job? I can't re-run workflows here.

@kunkunblueberry

Copy link
Copy Markdown
Collaborator

I checked the flake hypothesis against the code rather than rerunning, and your reading is right about where it fails. tests/process_helpers.py::assert_process_exited makes exactly one check on both branches: on POSIX it is a bare with pytest.raises(ProcessLookupError): os.kill(pid, 0), and on Windows it is WaitForSingleObject(handle, 0) with a zero timeout. Neither waits for the parent to reap. A child that has been killed but is still a zombie keeps its PID, so os.kill(pid, 0) succeeds and the test fails with DID NOT RAISE ProcessLookupError purely on timing. That matches what you saw: the same tree passed checks / python on #485 (3a9ee032) and on #469, and this diff touches no process or runtime code.

So the defect is in the shared test helper on main, not in this pull request. The fix is to poll that helper with a bounded deadline instead of checking once — a separate change, and one worth making because every test that calls it inherits this flake.

I am not rerunning the failed job from this review: a Reviewer does not rerun a red required check to turn it green. The failed job is run 45330407296, job 138237467604, on d369be56; a maintainer or the Coordinator can re-run it, and if it inverts, the only thing left on my side is the missing media evidence I listed above.

@Redivesue

Copy link
Copy Markdown
Contributor Author

Closing in favor of #485, which contains this commit and the stage 2 commit; the review points from here are addressed there.

@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

area:canvas Canvas, nodes and direct manipulation area:performance Performance and responsiveness / 性能与响应速度 type:feat New capability or behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants