Skip to content

feat(thread-chat): 支持所有 Thread 的行内 Artifact 引用 - #93

Draft
hifizz wants to merge 6 commits into
mainfrom
codex/inline-artifact-references
Draft

hifizz wants to merge 6 commits into
mainfrom
codex/inline-artifact-references

Conversation

@hifizz

@hifizz hifizz commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Project 已汇集各 Thread 的 Artifact,但 Composer 仍需手动复制正文,无法在一句话中明确指向多份产物。本 PR 按已确认的行内方案实现普通文字与 Artifact 引用混排,支持分叉探索后的比较、综合与继续讨论。

  • 同一 Project 内所有 Thread 都能引用自己及其他 Thread 的已完成 Artifact,主线没有特殊权限;候选支持标题、类型、来源 Thread 搜索。
  • Composer 使用 Lexical 原子节点与有序 Parts,接通列/画布共享草稿、结构化剪贴板、中文 @ 触发、发送失败保留和历史点击。
  • send/edit/fork/retry 保留引用身份和顺序;服务端只接受 ID,校验 Project 与来源状态后解析权威信息。
  • 模型在对应用户消息中接收完整 Artifact 正文;已有上下文正文复用,后续引用使用固定标记,超预算明确拒绝。来源重新生成不改变原 ID。
  • 编辑继续保留附件和已有 Quote;修正父 Thread Quote 在编辑分支首问时被错误重新限定为当前 Thread 的问题。
  • 新增 OpenSpec 与开发测试页。复用现有 JSONB/Artifact 存储,没有数据库 schema 或 migration 变更。

验证通过:

  • pnpm test:thread-chat:artifact-references(有序协议、完整模型正文、固定 ID、次数/字符预算、Drizzle Project 作用域、候选范围、send/edit/fork 回滚、Lexical 文档与剪贴板 round-trip)。
  • normalized-client-store、normalized-v1-api-contract、prompt-cache-contract。
  • TypeScript、改动 TS/JS 文件 ESLint、git diff --check、此变更的 OpenSpec strict 校验。

保留 Draft:当前浏览器环境拦截本地地址,尚未完成真实浏览器的 IME、菜单、删除/撤销和布局验收;未连接测试数据库或真实模型,SQL executor 替身及模型消息转换测试不代表数据库/模型联调通过。待验步骤记录在 openspec/changes/add-inline-artifact-references/verification.md,开发交互测试页为 /thread-chat-gate-3-harness/artifacts(仅 development + 本地访问)。

Refs #68

Sites demo 确认后的正式接入

用户已确认 交互 demo,本 PR 继续承载项目实现。列视图与画布均补上显式 @ 引用 按钮、按唯一 Artifact ID 统计的产物数量;按钮插入保持原光标位置,无选区时也能正确启动。沿用项目真实命令、数据库与模型上下文链路,不引入 demo 的模拟回复、失败开关或数据流调试面板。

新增工具栏光标/未聚焦插入测试通过;已重新通过 TypeScript、改动文件 ESLint、Artifact 回归、normalized-client-store、normalized-v1-api-contract、prompt-cache-contract 和 OpenSpec strict。此前标注的真实浏览器与数据库/模型联调仍待验收;尚未合并 main。

Artifact 上下文去重与缓存

在最新消息编辑修复之上,补充当前 Thread 自引用、forkContext 继承以及跨轮重复引用的正文去重。按实际选定消息从前往后处理;只有前文确实有完整且身份匹配的源工具正文或已展开引用时,后续 @ 才使用固定 ID、冻结标题与 previouslyIncludedInContext: true 标记。字段与顺序固定,不包含轮次、时间或动态位置;不反向改写前文,不修改数据库 schema。

验证:实际 AI SDK 模型消息中的正文计数、SDK 剔除不完整/临时工具后的全文补齐、同名不同 ID、原 Parts 不变、固定标记字节一致、追加消息后的模型前缀字节一致、重试确定性;Artifact 全量回归、prompt-cache-contract、TypeScript、ESLint、OpenSpec strict 和 diff 检查通过。真实提供商缓存命中率与账单尚未实测;新策略上线会改变旧重复展开前缀一次,后续追加保持稳定。

Preserve ordered text and artifact IDs throughout composer, history,
commands and model context. Allow every Thread including the source
Thread itself, with server-owned project checks and full-body expansion.

Refs #68
@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
thread-chatbot Error Error Sep 7, 2026 6:09am UTC

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Add explicit mention actions and unique-reference counts in column and canvas
composers. Preserve caret position when opening mentions from the toolbar.
Add selection and unfocused insertion regression coverage.

Refs #68, #93
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.

1 participant