Repository navigation
feat(chat): 粘贴会话链接即引用另一段对话(#1324 应用内方案) - #1326
Merged
Merged
Conversation
A reader can now hand one conversation to another turn without retyping it: the conversation overflow menu copies `pi-desktop://session/<id>` for every reader, not only developer mode, and Electron main resolves every such link in a draft into a bounded excerpt attachment before the turn starts. The link is the whole interaction, so `@` files and `/` commands keep their trigger symbols and the visible prompt is never rewritten. The excerpt travels with the message: it is stored on the message's attachment, quoted to the model as one `<session_reference>` block, and re-resolved from the referenced conversation's current content when a message that still contains the link is sent again. Only conversations of the same project are read, the current conversation is dropped before any read, and an unknown id, another project's conversation, or a `remote:` identifier stays plaintext, so a paste cannot make the app read a transcript its reader could not open. The transcript shows a reference as a chat-icon chip that opens the conversation it names. Registration as an operating-system protocol handler is deliberately not part of this change. refs vastsa#1324
A reference chip kept the name the referenced conversation carried when the link was pasted, so renaming that conversation — by hand, or by the first-turn summary — left every existing chip showing the old name. The chip now reads the conversation's current title from the session list and falls back to the name recorded on the message when this viewer no longer lists that conversation. The quoted block keeps the name recorded when the reference was made: it is a quotation, and the id is the identity. refs vastsa#1324
Owner
|
感谢实现,已完成审查并合入 main(merge commit 审查重点包括链接解析与有界摘录、同项目和自引用边界、附件持久化/模型请求接线、引用芯片与多语言。候选树上另跑了会话引用测试、agent-runtime 全量测试(1162 项)、shared(5 项)、i18n(29 项)、桌面引用测试(13 项)、host-core(746 项)、fmt/clippy 和文档检查,均通过。 后续可补自动化跨模块 E2E: |
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.
摘要
Issue #1324 的应用内方案(B):把
pi-desktop://session/<id>链接本身当作引用——在会话溢出菜单复制链接,粘贴进任意输入框草稿并发送,本轮就带上那段对话的有界摘录,消息上以芯片呈现,模型按引用块读到它。分支
feat/session-reference,基于origin/main1beb2e6a1(pnpm check:pr-base通过),2 个提交:feat(chat): reference another conversation by pasting its linkfix(chat): name a referenced conversation from its current titlerefs #1324(A 方案:注册
pi-desktop://为系统协议处理器、open-url/second-instance参数与安装器改动,仍在计划中,不在本 PR)包含内容
共享层
session-link.ts:pi-desktop://session/<id>的生成与解析(formatSessionLink/parseSessionLinks/isSessionLinkToken),单条消息最多 4 个引用;正则带负向前瞻((?![A-Za-z0-9_:/-])),所以remote:前缀 id 与更深路径不会被误判成引用。MessageAttachment新增kind: "session"与text,并补isRenderableAttachment类型守卫,让渲染层的文件附件路径能排除会话引用。Electron main
session-references.ts:派发前解析草稿里的每个链接,通过宿主session.get取有界摘录(最近 40 条消息 / 单字段 8 KB / 整段 16 KB,最新在后,并说明被边界截掉的更早条数),写进消息附件的text。remote:一律保持纯文本——粘贴不能读到读者本来打不开的转写。agent-ipc.ts:附件既写进持久消息(后续轮次继续读),也作为本轮文本传给 sidecar。Agent runtime
<session_reference name="…" session="…">排在用户自己的话之后引用给模型;属性做转义。modelInput.text——现在统一走promptText(),并补了对应回归用例(先红后绿)。渲染层
会话引用 · 标题(9 语言目录),工具提示说明会打开哪段对话,点击打开被引用会话。session="<id>")。promptAttachmentsFromMessage与乐观消息路径都按isRenderableAttachment收窄,会话引用不会被当成可解析的文件引用。i18n / 文档 / 测试
nav.copySessionLink、chat.sessionReference、chat.sessionReferenceOpen。kind:"session"+text、agent-runtime 步骤 6、E2E 计划场景E2E-SESSION-reference-conversation-link。按 #1324 讨论确定的取舍
@文件、/命令保持不变,链接就是引用本身;草稿里它是纯文本,发送后才在消息上出现芯片。pi-desktop://暂不注册系统协议:本 PR 只做应用内引用,A 方案单独提。验证
pnpm check:pr-base通过(origin/main1beb2e6a1是 HEAD 的祖先)。pnpm build:js、pnpm lint(biome + 样式令牌)、pnpm -r --if-present typecheck、pnpm docs:check(548 页 / 83 组中英对照)。pnpm --filter @pi-desktop/desktop test— 3464 通过pnpm --filter @pi-desktop/shared test— 1168 通过;pnpm --filter @pi-desktop/i18n test— 29 通过;pnpm --filter @pi-desktop/agent-runtime test— 1167 通过cargo test -p host-core --locked— 746 通过;cargo fmt --check真机验证(zh-CN、独立配置目录、本地录制桩模型,走真实的会话溢出菜单与输入框):
已知问题
cargo clippy不可用(stable 工具链未安装cargo-clippy),Rust 侧只跑了cargo test与cargo fmt --check。AI 辅助说明
本 PR 的实现、文档与验证由 AI 编码代理协助完成:模型
deepseek-v4.1-flash,思考程度max。上面所有命令与真机结论都在本地实际执行过;发现并修掉的接线缺陷(模型实际收到的请求漏掉引用块)与上面列出的已知项都如实写在正文里,没有隐藏。