Repository navigation
[feat] canvas: optimize image and video prompts with model media input - #465
Merged
Merged
Conversation
Probiotics5333
requested review from
hsliuustc0106 and
princepride
as code owners
November 23, 2026 09:17
1 of 7 tasks
- Add a prompt-optimization service that rewrites an image or video draft with its saved references and a configured text model. It returns text only: no job, no asset and no canvas edit. - Extend chat model input types to video and audio. The optimizer sends a full video to models with video input, samples frames for image-only models, and sends audio only when the model accepts it, reporting omitted audio in the result. - Expose the same rewrite through the canvas API, `canvas optimize-prompt` in the CLI and the `prompt_optimize` Agent tool, so both entry points share the service and the same validation. - Add the composer wand, progress and failure notes, abort on node switch or panel close, and Ctrl+Z undo after the draft is replaced. - Apply the built-in `h3-prompt-optimization` skill for H3 video models and document the workflow in both user guides. - Text nodes and a side-by-side compare/adopt layer are not part of this change; the composer replaces the draft and undo restores the original. - `pytest tests/test_prompt_optimization.py tests/test_model_configs.py`: 36 passed. - `tsc --noEmit` on the staged tree: clean. - `python scripts/generate_contracts.py --check`: verified. - `npm run check:i18n`: 0 problems. Refs: ThinkFlowLab#154
Probiotics5333
force-pushed
the
main
branch
2 times, most recently
from
November 24, 2026 17:39
a85f52c to
a3471d6
Compare
## summary - Follow the Agent panel's runtime, model and thinking level when optimizing a prompt, including the CLI default for Codex and Claude Code. The canvas sends the current selection with the request; the Agent tool passes the same selection, so both entry points share one model choice. - Add a `prompt_rewrite` bridge for CLI runtimes and map H3 official and Seedance 2.0 video profiles to their built-in optimization skills. - Report optimization progress, success and failure through canvas toasts; the running label keeps its three dots, slowly pulses between the muted and normal text colours, and the composer border shows a thin rotating band. - Share the assistant model selection helper between chat sending and prompt optimization, and update both user guides. ## validation - `npx tsc --noEmit` in the PR worktree: clean. - `pytest tests/test_prompt_optimization.py` (main checkout, identical service and tests): 2 passed, 1 skipped. - `python scripts/generate_contracts.py --check`: verified. - `node scripts/check-i18n.mjs`: 0 problems. Refs: ThinkFlowLab#154
…kFlowLab#154) ## summary - Read saved references without acquiring or moving the canvas edit lease. - Cancel local preview work when its HTTP client disconnects. - Validate the Windows CLI launch path and probe Codex through the same executable used for the rewrite. - Cover competing sessions, disconnects, and missing CLI entries. Refs: ThinkFlowLab#154
…lowLab#154) ## summary - Resolve Codex and Claude using literal installed command names so a request runtime cannot flow into executable path discovery. - Keep Windows package entry validation and cover both launchers. Refs: ThinkFlowLab#154
## summary - Wait for both the saved reply and the cleared active turn ID. - Document the race reproduced by delaying lease release on the PR base. Refs: ThinkFlowLab#154
Collaborator
Author
|
Collaborator
|
老哥挺猛 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add prompt optimization for image and video drafts, and extend text models with the media inputs it needs to read a node's references.
text/image/video/audioinput. The optimizer sends a full video to models with video input, samples frames for image-only models, and sends audio only when the model accepts it, reporting omitted audio in the result.prompt_rewritebridge.POST /api/creation/projects/{project}/items/{item}/optimize-prompt,opendirector canvas optimize-promptand theprompt_optimizeAgent tool.Scope not covered here: text nodes do not offer the button yet, and the result replaces the draft with undo rather than a side-by-side compare/adopt layer. The issue lists both as open design points, so the linked issue is referenced, not closed.
Linked issue
Refs #NincludedRefs #154
Labels
type:feat,area:canvas,area:agentTest plan
pytest tests/test_prompt_optimization.py— 2 passed, 1 skipped.npx tsc --noEmitin the rebased PR worktree — clean.python scripts/generate_contracts.py --check— verified.node scripts/check-i18n.mjs— 0 problems.checks.Evidence that it works
Provider verification
No real chat or media model was called. The tests exercise the request shape, reference markers, video frame sampling and audio gating with a mock transport; rewrite quality on a real chat model and the new skills' effect remain unverified.
Bilingual UI
generation.optimize.*, the new error codes and both user guides ship inzh-CNanden-US.