Skip to content

[feat] assets: import a video from a web page link - #634

Merged
princepride merged 2 commits into
ThinkFlowLab:mainfrom
princepride:feat/video-link-import
Dec 2, 2026
Merged

princepride merged 2 commits into
ThinkFlowLab:mainfrom
princepride:feat/video-link-import

Conversation

@princepride

@princepride princepride commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Import a video from a web page link, from the canvas, the CLI and the Agent. This is the URL-ingestion step of "start from a reference video" (#185, #187). Analysing the imported video is left to the reference shot breakdown in #606.

  • Shared service: PUT /api/creation/projects/{id}/uploads/{handle}/url downloads the page's video into an upload handle (CreationAssets.stage_url). Registration stays the existing asset.import command, so provenance, receipts, replay and validation are those of a local upload, and the edit lease is only needed for the short staging write.
    • The handle records its link (UploadOwner.sourceUrl): the same link on a staged handle answers without downloading again; another link, or a cancelled handle, returns 409 url_import_handle_conflict before any download.
    • The route ends the download when the client disconnects (dialog Cancel, reload, closed tab): the worker process is killed and its temporary directory removed. If the disconnect arrives while the downloaded file is being copied into the handle, or just after, stage_url stops the copy, cancels the handle itself (the client's DELETE can lose the race against the handle lock) and returns url_import_cancelled, so no staged copy is left behind.
  • Download (media/downloads.py → media/download_worker.py): yt-dlp runs in a separate worker process, so its network and resolver can be constrained without touching the server process.
    • Network boundary: only site extractors are enabled (allowed_extractors: ['default', '-generic']). That alone is not a boundary, because some site extractors (e.g. Mediasite) accept any host. The worker therefore wraps socket.getaddrinfo: every name it resolves (the page, redirects, API and media hosts) must resolve only to addresses accepted by the shared http_settings.public_address check (now a public helper also used by _public_pin), so loopback, private, link-local, CGNAT, reserved (including NAT64 and IPv4-compatible), multicast and IPv4-mapped private answers fail the connection with url_import_private.
    • Only yt-dlp makes network requests: every format choice requires protocol http/https, so HLS, DASH-segment, RTMP and other streams are never selected, and results with section_start/section_end (which yt-dlp always hands to ffmpeg) are refused (url_import_unsupported). In addition the worker confines yt-dlp: subprocess.Popen (which yt-dlp's own Popen wraps) may start only ffmpeg/ffprobe (merging and probing local files) and deno (started by yt-dlp without network permission), so PhantomJS, rtmpdump, curl, aria2c and other programs are refused; and ExternalFD.real_download, the base of every external downloader including FFmpegFD, is disabled. The worker connects directly (proxy: '', proxy variables removed from its environment) and disables curl_cffi, which resolves names in libcurl. Literal private hosts, non-http(s) schemes and credentials in the URL are refused before the worker starts.
    • Budget: sources over 15 minutes or 512 MB are refused. An announced size over the budget is refused by yt-dlp's max_filesize; an unknown size is counted from progress events across all files of the download and stops once it exceeds 512 MB. A missing output file reports url_import_failed, not "too large". The worker runs in its own process group (a separate session on POSIX, taskkill /T on Windows); cancellation and the 30-minute timeout kill the whole tree, including any ffmpeg merge. The caller keeps the worker's stdin open; when it closes (the caller exits or is killed, e.g. a stopped Agent turn), the worker kills its own process group, so on POSIX no download outlives its caller. On Windows the worker exits, but an ffmpeg it started may run to completion. The worker starts with -X utf8 -P (UTF-8 I/O; the current/execution directory is not put on sys.path) and answers in ASCII JSON, so non-ASCII titles and paths survive a non-UTF-8 Windows code page.
    • Playlists, live/upcoming streams, stream-only videos and sections are refused; the link is first extracted without processing, so a playlist is refused before its entries are read. The caller reads the worker's output on a thread while waiting, so a long answer cannot block on a small pipe buffer. stage_url checks cancellation after the download, during the copy into the handle and after it. Browser-playable codecs (H.264, VP9, AV1) up to 1080p are preferred, then the best available format.
  • Canvas: right-click → New node → Import video from link opens a dialog. Cancel aborts the request (ending the download) and deletes the handle. If the asset was already registered when the user cancels (the registration receipt or the asset lookup was still pending), Cancel only prevents placement: the canvas command is not sent, the asset stays in the asset library (it is not undone), and a toast says so (canvas.linkImport.cancelledRegistered).
  • CLI / Agent: opendirector asset import-url URL [--name] [--output-dir] downloads on the CLI machine with the same download_video and registers through the same code as asset import (HTTP upload, or artifact.publish from the execution directory in an Agent turn). The receipt adds assetId and the source page (url, title, site, durationSeconds).
    • Why the CLI does not call PUT …/url: the HTTP CLI holds a 60-second, non-renewed edit lease, so a server-side download longer than that would lose it before staging, and an Agent turn must register from its execution directory through artifact.publish. Downloading first keeps the lease for the registration only, as for asset import.
    • Replay keeps one rule, "one handle ↔ one link": the CLI's upload handle is uuid5(operation, url). Repeating an --operation-id with the same link returns the stored receipt (replayed: true) before any download; another link under that ID returns 409 url_import_operation_conflict. In an Agent turn a retry reuses the file already in the execution directory.
    • A bundled video-link-import skill points link requests to this command and tells the Agent that a refusal is final: it must not fetch the same link another way (see the Agent runs below for why).
  • Errors: url_import_invalid|private|unsupported|failed|timeout|unavailable|playlist|live|too_long|too_large|cancelled|handle_conflict|operation_conflict. One bilingual table in the domain (domain/url_import.py, like timeline_errors.py) is used by the HTTP layer (Accept-Language) and by the CLI error output (OPENDIRECTOR_LANGUAGE), so canvas, CLI and Agent errors are all bilingual; the domain keeps the Chinese text, as elsewhere.
  • Provenance: the asset is an ordinary upload named after the page title (e.g. Big Buck Bunny Trailer 400p.webm); the link itself is not stored in the project. Recording it would need a new provenance field; I left that for Feature: start a short film from a reference video (YouTube / TikTok / Reel / local) #185/Feature: start a short from a reference video (YouTube / TikTok / Reel / local) #187 if their analysis needs it.
  • Dependency: yt-dlp>=2026.11.23 (Unlicense, pure Python, no extras), pinned in requirements.txt. It has no upper bound because site extractors are fixed continuously in new date-versioned releases; a cap would freeze broken extractors. Sites that need yt-dlp's JavaScript runtime components (e.g. YouTube) are not specially supported; the docs say so and failures return url_import_failed with the site's reason.
  • Docs: user guide (en/zh) and CLI guide.

Question for maintainers

#187 is needs-design. This PR makes yt-dlp a hard dependency, limited to site extractors, public addresses, direct connections and a size/duration budget, with the user told to import only videos they have the right to use. If you would rather keep it optional (an extra), allow a configured proxy, or limit it to specific sites, I can change that.

Linked issue

Refs #185, Refs #187 — only the "accept a public video URL as input" criterion; analysis, concepts and cost estimates are out of scope. Related: #171 / #606 (shot breakdown).

  • Fixes #N or Refs #N is included, or no issue applies

Labels

type:feat, area:assets, area:canvas, area:agent, modality:video

  • Labels applied

Test plan

Local on c17f2f3773081f2998146293d78c8eec8d45447b unless noted:

  • pytest tests -q: 3329 passed, 121 skipped, 0 failed. (In one earlier full run on this machine, test_native_runtime::test_cancel_native_process_group failed in all four parameters on both this branch and unmodified main cf566d49; it has passed in every run since.)
  • pytest tests/test_video_link_import.py (58 passed; an earlier set of 50 also passed 10 consecutive runs):
    • URL validation (8 rejected forms);
    • worker: rejections (playlist, live, too long, announced and streamed oversize, missing output, unsupported in both yt-dlp wordings, blocked site, blocked address) with a yt-dlp double; site-extractor-only, direct-connection, no-external-downloader and direct-protocol format options;
    • resolver guard: public IPv4/IPv6 pass; any private, loopback, link-local metadata, CGNAT, unique-local, IPv4-mapped, NAT64, IPv4-compatible, multicast or empty answer is refused;
    • real yt-dlp Mediasite extractor against a host that resolves to 127.0.0.1 with a local HTTP server listening: refused with url_import_private, and the server received no request;
    • streams never reach an external program: with the real yt-dlp, an info dict whose only format is m3u8, m3u8_native, http_dash_segments or rtmp (manifest, AES key and segment on a local 127.0.0.1 server) is refused as unsupported and the server receives no request; adding a direct format on 127.0.0.1 is refused by the resolver guard, again with no request;
    • sections: an info dict with section_start/section_end and a direct format on 127.0.0.1 is refused before anything is fetched (the reviewer's ffmpeg repro, now with no request);
    • confinement: with the real yt-dlp after confine, Popen refuses phantomjs, curl, aria2c and rtmpdump, still starts ffprobe, and FFmpegFD.real_download raises;
    • caller killed: a caller process running download_video is killed with SIGTERM to its process group; the worker and a child it started are both gone within 5 s;
    • non-UTF-8 worker: a worker whose stdout is forced to cp936 or cp1252 returns the title 中文标题 Café and a path under 中文目录 Café intact (both fail without the ASCII-JSON fix);
    • worker process: Cancel kills it together with a child it started (POSIX), missing yt-dlp → 503 url_import_unavailable, garbage output → url_import_failed, a successful result is returned; the real worker reports an unsupported site without a network request;
    • staging registers through asset.import, does not download twice, rejects the same handle with another link (409), and a cancelled staging leaves no handle or asset;
    • cancel while staging: a cancellation that arrives during the copy into the handle, or after the copy finished, leaves the handle cancelled with only owner.json in its folder (no content, no partial file) and no asset;
    • the HTTP route localizes rejections in en/zh and registers nothing;
    • CLI language: the CLI prints url_import_private and url_import_failed (with the site's detail) in English under OPENDIRECTOR_LANGUAGE=en-US and in Chinese under zh-CN;
    • a playlist is refused without reading its entries; a cancelled upload handle is refused before any download;
    • CLI over HTTP and over the Agent bridge: --operation-id replay without a second download or asset, another link under the same ID rejected with url_import_operation_conflict, a private link rejected with no download. Replaying an operation whose receipt was rejected returns that receipt instead of reporting a different link.
  • tests/creationClient.test.ts: the client stages via PUT …/url, registers once, and a cancelled import is not registered and deletes its handle. Since ed472ab7: cancelling while the registration receipt is pending, or during the asset lookup, places no node and keeps the registered asset (no DELETE); without the cancel check before the canvas command this test fails. Not cancelled → placed; project switched → not placed.
  • npm test (1071 passed, 0 failed), npx tsc --noEmit, npm run build, npm run check:i18n (0 problems), scripts/generate_contracts.py --check, lint-imports, pre-commit run --from-ref origin/main --to-ref HEAD.
  • Real yt-dlp checks on the cluster: the Wikimedia download through the confined worker (1.2 MB VP9 in 1.8 s); an announced 1.2 MB file against a 200 KB budget → url_import_too_large with no file; with max_filesize removed, the progress-hook budget stopped the real download at about 0.5 MB → url_import_too_large.
  • Left to CI: Release checks on this head.
  • Follow-up ed472ab756401a6efca651011aa995498fbb24e2 (review feedback, cancel after registration): npm test 1072 passed, npx tsc --noEmit, npm run build, npm run check:i18n (0 problems), pre-commit on the changed files. The pre-review score below is for the first commit.
  • Independent pre-review: 82/100 (round 8) on base cf566d4941b059b03686370f7dc97a819865d2bc, head c17f2f3773081f2998146293d78c8eec8d45447b.
    Its remaining findings, none blocking: Windows teardown has not been run (see Gaps); confine relies on yt-dlp internals (ExternalFD) with no upper version bound, failing closed as url_import_failed if they change; the CLI keeps its replay rule in the adapter, as asset import does; client-disconnect cancellation through the real route is covered by the smoke receipt, not an automated test.
  • Gaps: YouTube, Bilibili and Vimeo refuse the test cluster's data-centre IP (Sign in to confirm you're not a bot, HTTP 412, login required); a home connection was not tested. Real downloads used Wikimedia Commons only, single-file formats; no real separate video+audio merge was exercised. Stream-only (HLS/DASH) videos and sections are deliberately unsupported, and so are sites that need PhantomJS. A configured system proxy is deliberately not used. Only the Default (OpenCode) Agent runtime was run; runtimes that sandbox the network may block the CLI-side download, in which case the user can import from the canvas. Nothing was run on Windows: taskkill /T, the stdin-EOF exit and the code-page handling are covered only by the POSIX runs and the forced-encoding test.

Evidence that it works

Served from this branch on a separate data directory. Everything in this section (walkthrough, screenshots, smoke receipt, Agent runs) ran on this head c17f2f37; the project names in the window titles carry the commit. Input: Big Buck Bunny Trailer 400p (Blender Foundation, CC BY 3.0). The cancel demo uses Sintel (CC BY 3.0).

Canvas and CLI walkthrough (zh-CN, 2:38):

Time (approx.) What it shows
0:00–0:30 Import from the canvas menu; "importing" state; the node appears with a toast
0:30–0:42 The imported node plays
0:42–1:02 A 15-minute video is cancelled about 3 s into the download; nothing is added
1:02–1:25 A local-network link is refused in the dialog
1:25–1:42 Reload: the node is still there (one asset) and plays again
1:42–2:18 CLI in another project (the panel appears when the commands finish, about 2:00): import, place the node, replay the same --operation-id (replayed: True, no download), another link under that ID → url_import_operation_conflict, a private address rejected in en and zh
2:18–2:38 That CLI project's canvas: the node the CLI placed, playing
link-import-zh.mp4

The site offers webm vp9/opus 426×236, mov mp4v (video only) and the ogv (Theora) source. The browser-playable VP9 rendition was registered as Big Buck Bunny Trailer 400p.webm (33 s). Its first frame is a white title card, which is why a paused node looks white.

After reload, playing
Node placed by the CLI, playing

Smoke receipt on this head (driver/cli_demo.sh, then a PUT …/url for the 15-minute video that the client disconnects after 4 s). Afterwards the server's upload-staging directory held only the handles of the four successful imports (walkthrough, CLI, English, smoke); the cancelled imports left nothing:

== CLI run (fresh project, no browser open)
$ opendirector --project e8bf16c2-3b51-4d91-9907-f0ddbf1fb23f --operation-id 5d1e8c53-d7f5-4110-b325-5baeb730ebff asset import-url "https://commons.wikimedia.org/wiki/File:Big_Buck_Bunny_Trailer_400p.ogv"
  status: applied | assetId: 87e8b222-0df7-5133-aaac-ad1425052309
  source: {"url": "https://commons.wikimedia.org/wiki/File:Big_Buck_Bunny_Trailer_400p.ogv", "title": "Big Buck Bunny Trailer 400p", "site": "Wikimedia", "durationSeconds": 32.996875}
$ opendirector --project e8bf16c2-3b51-4d91-9907-f0ddbf1fb23f canvas add-material --asset 87e8b222-0df7-5133-aaac-ad1425052309 --x 0 --y 0
  status: applied | itemId: 2a42893c-bb59-40ae-af61-633f435ba3e0
$ # same --operation-id and link again: replays the receipt without downloading
  status: applied | assetId: 87e8b222-0df7-5133-aaac-ad1425052309 | replayed: True
$ # same --operation-id with another link: rejected
  exit 1: {'error': 'This operation ID was already used with a different link. Use a new operation ID.', 'code': 'url_import_operation_conflict'}
  project assets: 1
$ OPENDIRECTOR_LANGUAGE=en-US opendirector --project e8bf16c2-3b51-4d91-9907-f0ddbf1fb23f asset import-url http://192.168.1.10/video
  exit 1: {"error": "Videos cannot be downloaded from this computer or the local network.", "code": "url_import_private"}
$ OPENDIRECTOR_LANGUAGE=zh-CN opendirector --project e8bf16c2-3b51-4d91-9907-f0ddbf1fb23f asset import-url http://192.168.1.10/video
  exit 1: {"error": "不能从本机或局域网地址下载视频。", "code": "url_import_private"}

== cancellation
commit c17f2f37
edit-session 200
t=2s  worker pids: [173411 ] worker external TCP: 1 temp dirs: 1
client disconnected after 4 s (curl http 000)
t=10s worker pids: [none] worker external TCP: 0 temp dirs: 0
project assets: 0

English UI on this head: menu entry, rejected link, imported node playing.

English menu
English rejection
English imported node

Real Agent (Default runtime, Qwen/Qwen3.8-27B served by vLLM), each in an empty project:

Run Prompt Skill text Commands the Agent ran Result
— 把这个链接的视频导入到画布上:<Bunny link> none (33abe5ca) curl Commons API, curl -o …ogv, ffprobe, asset import --help-field payload, asset import …ogv --kind video, canvas add-material Original Theora .ogv registered (not playable in Chrome)
a1–a2 valid link, en / zh 6ac8d1ae asset import-url then canvas add-material Asset and node (WebM)
a3 把这个视频导入到画布:http://192.168.1.10/media/clip.mp4 6ac8d1ae (before the "refusal is final" section) project show --summary; capabilities; asset import-url "<link>" → url_import_private; then curl -fL … http://192.168.1.10/media/clip.mp4 twice (connection failed) Nothing registered, but the Agent tried to fetch the refused link itself. An earlier run of the same prompt had stopped at the refusal, so this varies by run; it led to the skill's "a refusal is final" section
a4, a5 same as a3 current skill text project show --summary; asset import-url "<link>" → url_import_private Stop at the refusal
a6 Import the video from <Bunny link> onto the canvas, name it 'Bunny reference' and put it at x 600, y 200. this head project show --summary; asset import-url "<link>" --name "Bunny reference"; canvas add-material --asset … --x 600 --y 200 Asset and node Bunny reference (WebM) at (600, 200), playing
a8 把这个视频导入到画布,作为后面生成的参考素材:<Bunny link> this head project show --summary; asset import-url "<link>" --name "Big Buck Bunny Trailer (参考)"; canvas add-material --asset … --x 0 --y 0 Asset and node (WebM) at (0, 0), playing
a7 same as a3 this head project show --summary; asset import-url "<link>" → url_import_private; nothing else Stops; says the refusal is final and it will not fetch the link another way (curl, wget); asks for an upload or a public page. Project stays empty

The commands are the complete list of shell commands in each run's OpenCode trace (agent-runs/*.opencode.jsonl, kept locally; not attached because they include the full system prompt and local paths). The Agent's shell is not sandboxed by this feature: a model that ignores the skill can still run curl itself. The download path in OpenDirector is what this PR constrains.

Agent a6: valid link, English
Agent a8: valid link, Chinese
Agent a7: private link refused, no workaround

Provider verification

No model provider is involved in the feature. Real downloads: Wikimedia Commons through yt-dlp 2026.11.23. YouTube, Bilibili and Vimeo were attempted from the cluster and refused by the sites, as above. Unit tests use a yt-dlp double, except the Mediasite, stream-format, section, confinement and unsupported-site tests, which use the real yt-dlp offline. The Agent runs used a real self-hosted Qwen3.8-27B.

  • Real-provider calls are described honestly, or none were made

Bilingual UI

Menu item, dialog, hint, progress, success toast and all thirteen error codes ship in zh-CN and en-US. Both locales were inspected in the browser (screenshots above and the video).

  • Both locales are updated, or no user-facing copy changed

🤖 Generated with Claude Code

## summary

- Stage the video on a supported web page as an upload
  (PUT uploads/{handle}/url) and register it with the existing
  asset.import command, so the edit lease is only needed for the short
  staging write. The handle records its link: the same link answers
  without downloading again and another link is rejected (409). The
  route ends the download when the client disconnects.
- Download in a separate worker process with yt-dlp site extractors
  only, selecting formats yt-dlp fetches directly over HTTP(S). Inside
  the worker yt-dlp may start only ffmpeg/ffprobe on local files and
  deno; external downloaders, PhantomJS and section downloads are
  refused, so every network request is yt-dlp's own. It connects directly,
  without the system proxy, and its resolver refuses any answer that the
  shared public-address check rejects, so redirects, media servers and
  host-agnostic extractors cannot reach loopback, private, reserved or
  multicast addresses. Cancellation, the timeout and the end of the
  calling process (the worker exits when its stdin closes) end the
  worker's whole process tree. The worker starts with -X utf8 -P and
  answers in ASCII JSON, so non-ASCII titles and paths survive a
  non-UTF-8 Windows code page. Playlists, live streams and sources over 15 minutes or
  512 MB are refused; an unknown size is counted while downloading.
  Browser-playable codecs (H.264, VP9, AV1) are preferred up to 1080p.
- CLI: asset import-url downloads on the CLI machine and registers
  through the asset import path; in an Agent turn the file stays in the
  execution directory and is published with artifact.publish. Repeating
  an --operation-id with the same link replays its receipt before any
  download; another link under the same ID is rejected.
- A bundled Agent skill points link requests to asset import-url, so
  the Agent no longer resolves and curls a site's original file, and
  treats a refusal as final instead of fetching the link another way.
- Canvas: "Import video from link" in the canvas New node menu opens a
  dialog whose Cancel ends the download, and places the imported video
  as a node.
- Keep the url_import_* messages in one bilingual table in the domain
  (domain/url_import.py), used by the HTTP layer and the CLI, so CLI and
  Agent errors follow OPENDIRECTOR_LANGUAGE like HTTP errors follow
  Accept-Language.
- Add yt-dlp as a dependency and document the feature in the user and
  CLI guides.

Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@princepride princepride added type:feat New capability or behaviour area:assets Assets, library and reference inputs area:canvas Canvas, nodes and direct manipulation area:agent Agent runtime, assistant chat and tools modality:video Video generation, editing or rendering area:docs Documentation / 文档 labels Dec 2, 2026
@princepride

Copy link
Copy Markdown
Collaborator Author

WITHHOLD c17f2f3 Refs #185 Refs #187

Independent pre-review (AI subagent, opendirector-review candidate mode, round 8), base cf566d4941b059b03686370f7dc97a819865d2bc, head c17f2f3773081f2998146293d78c8eec8d45447b. Withheld only because Release checks are still running on this tip; no finding blocks.

  • Medium: Windows teardown (taskkill /T, stdin-EOF exit, code pages) has never run on Windows; an ffmpeg started by the worker may outlive a killed caller there (disclosed in the body).
  • Low: confine relies on yt-dlp internals (ExternalFD.real_download) with no upper version bound; a restructure would fail closed as a generic url_import_failed.
  • Low: the CLI keeps its replay / operation↔link rule in the adapter (cli.py), while the canvas path's handle↔link rule is in CreationAssets.stage_url; a later rule change in one may miss the other.
  • Low: client-disconnect cancellation through the real route is covered by the smoke receipt, not an automated test.
  • Low: cli.py creates a temporary directory even when --output-dir / Agent downloads/ is used; _QuietLogger.error duplicates debug; the CLI guide section is one long paragraph per language.

Ran: pytest tests/test_video_link_import.py (58 passed); related upload/asset/CLI/public-target tests (115 passed); node --test tests/creationClient.test.ts (41 passed); npm test (1071 passed); npm run check:i18n (0 problems); npx tsc --noEmit; lint-imports (4 kept); scripts/generate_contracts.py --check; a probe of the route's disconnect → cancel path; inspection of all 9 attachments (video frames match the timeline, window titles carry c17f2f37), the smoke receipt, and the a6/a7/a8 Agent traces.
Not run: Release checks (in progress on this tip); Windows; Agent runtimes other than Default. Full pytest tests was run by the author (3329 passed, 121 skipped), not reproduced by the reviewer.

Advisory score: 82/100

Dimension Weight Rating Evidence
Scope and intent 15 3/3 One capability across canvas, CLI, Agent skill and docs; breakdown left to #606; Refs for a partial criterion; the hard yt-dlp dependency is put to maintainers.
Correctness and safety 25 2/3 Resolver guard in the worker, direct-HTTP formats only, Popen allowlist, ExternalFD disabled, edit lease checked before download, cancellation verified; gaps: Windows teardown, CLI rule in the adapter.
Validation 20 2/3 Strong focused tests including offline real-yt-dlp cases; no Release checks on this tip yet, no automated disconnect/browser test, no Windows run.
Claim evidence 30 3/3 Playable walkthrough video, screenshots (zh/en, Agent valid and refused) and receipts, all on this tip.
Simplicity 10 2/3 No added explanatory comments; minor redundancy listed above.

Highest-priority remaining action: let Release checks settle on c17f2f37.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST CHANGES c17f2f3 Refs #185 #187

当前证据暂定 82/100,非批准分。 范围 3/3、正确性 2/3、验证 2/3、主张证据 3/3、简洁度 2/3。下载并解码了 158 秒演示,核对了画布导入、刷新后回放和 CLI 放置;作者的运行记录还覆盖了下载中取消与 Agent 两种语言。发现一个演示未覆盖的窗口:下载已结束、画布还在等素材登记或查询时点取消,同一工程里仍可能稍后插入节点,详见行内。

读了变更和受影响路径,没有自己运行 PR 代码。CodeQL、DSH 已绿,Release 仍待结果;Agent 的实际运行范围以作者记录为准。先补登记尾段取消的回归,再确认 CI。

English: Honor cancellation before adding a canvas node, including when asset registration or resource lookup is already in flight.

Dot,代表 @david6666666 作非表决评审。

notify(t("canvas.workspace.toast.importCancelledSwitched"));
return;
}
const where = point ?? center();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里等完素材查询后只判断工程有没有切换,没有再看取消信号。下载已完成、登记或查询还在等时,用户点「取消」会关掉弹窗,但同一工程仍可能稍后新增节点。建议在提交画布命令前再检查 signal,并加一个等待登记回执时取消的用例;如果素材已登记,也请明确取消只阻止放置,不承诺撤销资产。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed in ed472ab.

  • The placement decision moved into importLinkedVideo (src/canvas/workspace/linkImport.ts): after the registration and the asset lookup it checks the project switch, then the cancel signal, and only then sends the canvas command. Nothing is awaited between that check and add-nodes.
  • If the asset was already registered when the user cancels, Cancel only prevents placement. The asset stays in the asset library and is not undone, and a toast says so (canvas.linkImport.cancelledRegistered, zh/en). The user guide (en/zh) now says the same, replacing "the video is still added".
  • New case in tests/creationClient.test.ts: cancelling while the asset.import receipt is pending, and cancelling during the asset lookup, both place no node and keep the registered asset (no DELETE). It fails without the new check. Not cancelled → placed; project switched → not placed.

npm test 1072 passed, tsc --noEmit, build, check:i18n clean.

Cancelling the link dialog while the registration receipt or the asset
lookup was still pending closed the dialog, but the node could still be
added to the same canvas afterwards. Check the cancel signal right
before the canvas command; a video registered before the cancel stays in
the asset library and the toast says so.

Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the area:provider Model providers and generation protocols label Dec 2, 2026
@github-actions
github-actions Bot requested a review from nikiwang-125 December 2, 2026 04:53
@princepride
princepride merged commit ae5003b into ThinkFlowLab:main Dec 2, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent runtime, assistant chat and tools area:assets Assets, library and reference inputs area:canvas Canvas, nodes and direct manipulation area:docs Documentation / 文档 area:provider Model providers and generation protocols modality:video Video generation, editing or rendering type:feat New capability or behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants