Repository navigation
Conversation
…kFlowLab#333) Add a shared backend resolver for assistant Markdown links. Relative destinations are matched through the turn's asset provenance and the canvas items that display the asset; explicit canvas/node/project links are also supported. Results are typed (focused, hidden, materialize, ambiguous, missing, cross-project, external) and store only stable IDs so moving, renaming or regrouping cannot invalidate them. Resolved links are persisted as canvasLinks on the assistant message at turn end. Link resolution never fails an accepted turn, and external links keep the existing policy. Add bilingual outcome copy and tests for resolution, ambiguity, code fences, persistence and mutation coverage. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
M1: 目录限定链接按完整 name/path 精确匹配,不再静默退化为 basename。 L1: @提及允许标题内标点,仅剥除后随空白/行尾的尾部标点;标题解析匹配最长词前缀。 L2: R1 变异选择器指向重复文件名用例,使其在新行为下红、旧行为下绿。 M2: 将 jsdom 依赖的 UI 点击用例退化为逻辑层断言(canvasLinkClickAction),纳入 node --test;UI 点击未做浏览器级覆盖。 Co-Authored-By: Claude Code <noreply@anthropic.com>
M1: @提及在句末标点后跟空白时按提及边界截断,@finished note. Next step 等不再解析为 missing;标题内句点(Chapter 2.1)保持完整。 L1: 前端 renderCanvasMentions 对齐后端 (?<!\w) 词边界,foo@Title 与锚点内 URL 不再被包成 canvas-reference;抽取纯函数并补 node --test 覆盖。 L2: link_targets 过滤空/纯空白 href,避免 [x]() 持久化为 missing 噪声。 M2: 补经 AgentTools 提交 generation.submit 的集成用例,断言产物 provenance.agentRunId == turn_id 且相对链接命中该产物。 Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
- 用快照中的已知标题做最长前缀匹配,替代标点/空格候选列表 - 边界校验:精确、句末标点、全空白后纯普通词、或紧邻 CJK - 更长但边界不可用的已知标题会遮蔽短标题,避免 @dr. Smith 99 回退到 Dr、@标题生成 99 回退到 标题 - 修复 CJK 紧邻完整标题时被短前缀抢先解析的问题 - 补对应回归用例 Co-Authored-By: Claude Code <noreply@anthropic.com>
Xingkai98
requested review from
hsliuustc0106 and
princepride
as code owners
November 17, 2026 07:37
github-actions
Bot
requested review from
FayeSpica,
Probiotics5333,
allendyu and
wuzhf9
November 17, 2026 07:37
| # Link resolution is navigation metadata; it must not | ||
| # fail a turn whose accepted result is already saved. | ||
| logger.exception('agent.canvas_links.failed project_id=%s turn_id=%s', | ||
| project_id, value.id) |
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
Agent replies can already contain Markdown links, but a relative destination
such as
[Finished video](output.mp4)has no project meaning. This change addsshared resolution and a project-reference renderer that turn such a destination
into a clickable canvas identity. Existing panel/workspace wiring consumes the
stable ID; full viewport behavior still needs canvas-level verification.
The resolver matches a relative filename against the turn's asset provenance
and the canvas items that display the asset, and also accepts explicit
canvas:<uuid>,node:<uuid>andproject:<uuid>/canvas:<uuid>targets. Itreturns typed outcomes (
focused,hidden,materialize,ambiguous,missing,cross-project,external). Only stable IDs are stored; position,title and group membership are resolved at click time, so moving, renaming or
regrouping never invalidates a saved link. External URLs keep the existing link
policy and are not persisted as project references.
Existing
AssistantReply,AssistantPanelandWorkspaceViewcomponents aremodified. The renderer preserves external-link policy and displays a bilingual
destination hint for cross-project references without focusing a local ID.
Changes
packages/core/src/opendirector/agent/canvas_links.py(new): Markdown linkextraction that ignores fenced/inline code, target normalization, provenance
aware asset→canvas-item resolution, ambiguity/cross-project/materialize
handling, canonical link formatting, and per-message enrichment.
apps/api/src/opendirector_api/agent.py: at turn end, read the final projectsnapshot and persist
canvasLinkson the assistant message. Resolution isbest-effort and never fails an accepted turn.
src/backend/chat.ts: use the generatedChatCanvasLinkpayload type.AssistantReplyrenders resolved project anchors;AssistantPanelforwardsnavigation to the existing workspace consumer.
src/i18n/messages/zh-CN/assistant.ts,src/i18n/messages/en-US/assistant.ts: four bilingual hint keys foroutcomes that cannot focus a node (materialize, ambiguous, missing,
cross-project). Focused and hidden links focus their node instead of showing
a hint, so they have no message key.
tests/test_canvas_links.py(new): resolution, ambiguity, hidden/materialize,cross-project, code-fence, stable-identity and persistence round-trip tests.
tests/canvasLinkMessages.test.ts(new): both catalogs resolve the new keyswithout leaking the other language.
The navigation result is generated from a Python domain contract and imported by the frontend. Persisted identities let reply links select and frame visible canvas nodes.
Verification
tests/canvasLinkRendering.test.mjsreportedFinished note [blocked], anchors=0 and a cross-projectfocus:same-id.After (current HEAD): that fixture was deleted in
1ab7e5bd; there is nobrowser/DOM-level render or click coverage. Click behavior is covered only at
the logic level by
tests/canvasLinkClick.test.ts(canvasLinkClickAction),which asserts focus vs. translated hint keys and that a colliding id is never
focused. The historical "2 passed" result is not reproducible on HEAD.
Review-r2 repaired tree (starting at
2f275325); paired evidence inreviews/review-r2.md:pytest tests/test_canvas_links.py -q→ 34 passed (existing/tmp/odstubsshim path; media/font inspection is not exercised).pytest tests/test_assistant_conversations.py tests/test_agent_citations.py -q→ 33 passed.
pytest tests/test_agent_gateway.py tests/test_agent_tools_voices.py tests/test_creation_contracts.py tests/test_capability_contract.py -q→ 253 passed.
node --test tests/referenceMentions.test.ts tests/assistantCitations.test.ts tests/i18n.test.ts tests/canvasLinkMessages.test.ts→ 20 passed.
npm run check:i18n→3020 keys, 0 problem(s).python3 scripts/generate_contracts.py --check→Creation contracts verified;base-relative contract diff → exit 1 (2 files, 499 insertions, 2 deletions).
Generator consistency passes; the functional diff is intentionally nonzero.
tests/canvasLinkRendering.test.mjswas deleted in1ab7e5bd; only thelogic-level
tests/canvasLinkClick.test.tsremains. The earlier "2 passed"and Chromium checks are historical and not reproducible on HEAD.
scripts/verify_canvas_link_mutations.py. The two historical UI mutants arenot reproducible on HEAD because their fixture
(
tests/canvasLinkRendering.test.mjs) was deleted; there is no current UImutation evidence. The older six-kill claim is likewise not reproducible on
2f275325(M2 survived; M4 source absent).Environment limitation: the existing linked
node_modulesisincomplete (no
react, nomediabunny), sonpm testreports 9 failures,including an
ERR_ASSERTIONintests/browserHost.test.ts:121and aMODULE_NOT_FOUNDintests/modelBrands.test.ts:28(historical full-suite run).Before repair
tscreports 5592 diagnostics, includingsrc/canvas/AssistantReply.tsx(1,41): TS2307; the repaired count is 5600.Typechecking fails, including changed UI files. No packages were installed for
this repair; component/browser fixtures reuse the reviewer's existing dependency tree.
Evidence pending real runtime/browser execution
The following are pending, not claimed as passing:
anchors and their focus callback are verified separately.
(missing, ambiguous, hidden/reveal, materialize, cross-project).
Codex, dsh and Bundled real sessions.
resolved through real project fixtures.
npm ci,npm run build, fullnpm test, fullPython suite) and
witnessloop check(the repository is not integrated; seethe working notes).
Merge Danger
Door: two-way. No migration or destructive project operation is added.
Blast Radius: assistant. Turn-scoped filename links now require matching
provenance; historical references must use stable IDs. Full canvas viewport and
runtime-matrix acceptance remain pending.
中文对照
标题
feat(assistant): 把对话链接解析为稳定的画布对象身份 (#333)
摘要
Agent 回复里可以出现 Markdown 链接,但
[Finished video](output.mp4)这样的相对路径本身没有工程含义。本次改动补上共享解析与项目引用渲染器,把目标解析为
稳定画布身份;现有面板和工作区已接线,完整画布取景仍需验证。
解析器会用本轮执行的素材溯源信息,把相对文件名匹配到显示该素材的画布对象;同时
支持显式
canvas:<uuid>、node:<uuid>和project:<uuid>/canvas:<uuid>。结果是带类型的(
focused、hidden、materialize、ambiguous、missing、cross-project、external)。持久化只保存稳定 ID;位置、标题和分组关系在点击时再解析,因此移动、重命名或重新分组都不会让已保存的链接失效。外部链接继续走
既有策略,不会作为工程引用持久化。
已修改现有
AssistantReply、AssistantPanel和WorkspaceView。跨工程引用显示双语提示与工程 ID,不会聚焦当前工程中碰巧同 ID 的对象。
改动
packages/core/src/opendirector/agent/canvas_links.py:解析 Markdown链接(忽略围栏代码和行内代码)、归一化目标、按素材溯源匹配画布对象、处理
歧义/跨工程/待上画布、规范化链接格式、按消息附加解析结果。
apps/api/src/opendirector_api/agent.py:回合结束时读取最终工程快照,把canvasLinks持久化到 assistant 消息;解析失败不影响已接受的回合。src/backend/chat.ts:使用生成的持久化字段类型;现有回复渲染器、面板与工作区消费该身份。assistant.ts:新增 4 个无法聚焦时的提示文案键(materialize、ambiguous、missing、cross-project)。focused/hidden 链接直接聚焦节点、
不显示提示,因此没有对应文案键。
tests/test_canvas_links.py和tests/canvasLinkMessages.test.ts。相对 base 有生成契约与既有 UI 组件变更;本次修复没有手改生成文件,也没有修改 CI 或依赖文件。
验证
/tmp/odstubsshim 路径,不代表真实媒体检查)。npm run check:i18n:0 problem(s)。Creation contracts verified;相对 base 的功能 diff 非零(2 文件,499 增、2 删)。tests/canvasLinkRendering.test.mjs已在
1ab7e5bd删除,仅保留逻辑层tests/canvasLinkClick.test.ts。此前的“2 passed”与 Chromium 检查属于历史记录,HEAD 不可复现。
scripts/verify_canvas_link_mutations.py捕获 10 个 Python 变异;历史 2 个 UI 变异因其 fixture 已删除而无法复现,HEAD 上没有 UI 变异证据。
历史“6 个全捕获”证据不适用于
2f275325。需要真实 runtime/浏览器证据的项(一律 pending,不声称已通过)
materialize、cross-project)的浏览器截图。
回复验证。
director 对象解析验证。
npm ci、npm run build、完整前端与 Python 套件)以及
witnessloop check(仓库尚未接入,见工作记录)。🤖 Generated with Claude Code