* fix(workspace-path): address opened files by absolute path `fileAddressFor` rewrote an absolute path inside the Session's directory into a relative address. A Sidebar tab opened that way named another file, or none, once the Session's directory moved and the page reloaded. The address now carries the absolute path whenever one is known: an absolute path is kept and a relative path is joined to the directory the caller supplies. A relative path stays relative only while that directory is unknown. * fix(ui-chat): resolve relative images from the Session's current directory A relative Markdown image used the Session header directory, so an image written while the Session worked in a worktree did not load. It now uses the directory the Session works in, the base relative file links already use. * fix(ui-reference): write picked and dropped files as absolute mentions A file or folder picked from the `@` list was sent as a path relative to the Session's directory, and a Desktop drop inside that directory was rewritten to a relative path. After the directory moved, the sent message named another file or none. A settled pick now joins the listed path to the Session's current directory, and a dropped or pasted file keeps the path the shell reports. Drill text stays relative. Hand-typed relative mentions are unchanged. * fix(deliverables): ask for absolute Markdown link and image targets The file-reference guidance allowed targets relative to the working directory. A relative target in an earlier reply named another file once the Session's directory moved, and a model working in a worktree sometimes wrote targets relative to the original project. The guidance now asks for absolute targets. The expected system prompts that assemble this section carry the new wording. * docs(notes): record how conversation file references survive directory moves * docs(notes): cite the earlier per-message implementation and its revert * test(snapshots): carry the absolute-target guidance into the session-send-message prompt * test(snapshots): add the subagent concurrency sentence to the timeline-follow-chat prompt The scenario's expected system prompt on master predates the subagent guidance sentence that states the shared concurrency limit, so its replay fails on master and on every branch that merges it. * docs(ui-conversation): remove the stale sentence on relative dropped paths --------- Co-authored-by: imccyu <[email protected]>
9.6 KiB
description, kind
| description | kind |
|---|---|
| Web @file 与 @session 引用 source:候选项、排序,以及原子行内引用(统一的文件/会话选取)。 | package-reference |
@deepseek-ai/dsh-client-ui-reference
English | 中文
概述
Web 用户需要从同一个 @ 补全菜单提及文件、文件夹或会话时,可以使用 dsh-client-ui-reference。菜单先列出文件,再列出会话;其中一组无法加载时,另一组仍然可用。选择文件、文件夹或会话会插入带稳定剪贴板形式的原子引用;文件夹行还允许用户在不关闭补全的情况下继续下钻。文件行省略多余的根目录位置,会话行仅在工作区与当前工作区不同时显示该工作区。会话 mention 会在捕获模型上下文前接受校验,而浏览候选项不会影响模型。
目录
使用本包
只要组合挂载了本包且存在宿主 ctx.fileReferences 提供方,该 source 即处于活动状态。输入 @ 后跟一个未加引号的 token,会先看到文件、再看到会话;打开 @"… 则只搜索文件。候选列表是补全菜单,不是搜索结果页:选一次、继续输入即可。
选择后会插入什么
选择文件会关闭补全,并显示为带文件图标与业务色文件名的原子行内引用。目录行携带两个动词:选定 pick(点击行主体或 Enter)把文件夹本身解析为同类原子引用——文件夹图标、带尾斜杠的标签、以规范 @dir/ mention 为序列化形式;钻取动作(Tab 或行尾 chevron)则保持带文件夹图标的可编辑路径纯文本,并让菜单在尾部斜杠处保持活跃,用户可以继续进入下一层。选定的文件或文件夹引用携带绝对路径,即列表中的路径与 Session 当前工作目录拼接的结果,因此该目录变化后发出的文本仍指向同一个文件;钻取文本仍相对该目录。Session 的目录未知,或绝对路径无法写成 mention 时,引用保留列表中的写法。包含空白的路径使用 @"path with spaces",用户显式打开的引号会继续保留。
选择会话会插入一个原子的行内引用,其隐藏 ref 与剪贴板表示均为宿主返回的规范 @[label](dsh-session:…) mention;可见形式为聊天气泡图标加会话标题。发送会经 session.prompt 携带该 mention,session-reference 服务会在 agent/pre-step 校验它并捕获模型上下文。
共享文件右键菜单最底部提供添加到对话。它将所选文件作为同类引用插入该 Session 的草稿,保留现有文字和选中内容,恢复输入焦点但不发送。引用记录解析后的绝对路径,不包含行号。打开菜单时 Session 不可编辑,或路径无法用 mention 语法表示时,此入口不可用;菜单打开期间草稿变为不可编辑时,点击会提示失败而不插入。切换界面语言时,已打开菜单的标题和失败提示随之更新。
已发送的文件与目录引用
在已发送消息、排队行和本地回显中,@path 或 @"path" token 只有在 Session 的文件系统确认该路径存在后才渲染为文件或目录引用。确认之前,以及路径不存在时(例如手写的 @notes),原文保持不变;邮箱地址永远不会匹配。在同一 Session、同一次页面加载内从候选中选择并发送的路径视为已确认,因此其回显会立即显示引用。
失败行为
某个候选领域不可用或失败时,该领域不产生任何行,另一领域仍正常列出。会话引用准备失败发生在提示词接受后,并会终止该 agent 轮次。
点击输入框中的文件引用,可在右侧栏预览文件当前的内容。带引号路径中的空格会保留,路径按输入框所属 Session 解析。文件夹和 Session 引用保留原有的编辑行为。
可交互文件标签从自身 Session Slot 获取 useContextMenu,通过文件引用注册接收路径解析能力。手势发生时按当前工作区根目录解析路径,Session 工作目录不会改变引用含义。只读展示标签不安装菜单处理器,也无需 Markdown Provider。
理解实现
实现细节——点击展开
该 source 把候选编码保留在注册 effect 内部:/client 导出接口只包含插件主体(apply/inject)。
候选流程
对于未加引号的 token,浏览器会同时启动 fileReferences/list 与 sessionReferenceResolver/candidates Remote 调用,再按文件、当前 Session 的直接 subagent、其他 Session 的确定性顺序排列。各行使用 resolver 的显示标题;subagent 优先使用创建标签,普通 Session 保持投影标题,并渲染在 locale 管理的分组标题下,不显示重复的原始 reference source 标题。会话行用宿主会话列表的 updatedAt 经该列表相同的相对时间分档标注时间,因此同一个会话在两处读到的时长一致;列表中没有的会话回落到候选自带的创建时间。下钻后的查询会发布一条从工作区根目录到当前目录的面包屑;每一节携带的下钻载荷与文件夹行相同,因此「回到某一步」与「进入某一层」是同一个结果。
候选请求要求客户端已持有该会话,并共用一个临时的 referenceCandidates 引用。两个发现调用都等待该会话首次历史打开成功;未持有会话或打开失败时,均不发送 RPC。候选请求的取消信号同时覆盖历史等待和两个调用,查询结束时释放临时引用。
序列化
文件选择把共享 @path 语法所定义的自然文本(使用绝对路径)保留为隐藏的序列化与剪贴板形式。会话选择使用规范的 @[label](dsh-session:…) mention;序列化永远不会根据可见标题重建身份。
插件还向 UserText 注册文件和目录匹配器,并拥有它们的 conversation.user.text.node renderer。每次查询返回原文偏移之后的下一个完整候选引用,不执行文件发现;共享计算器按原文位置裁定重叠。两个节点 renderer 都订阅绑定 Session 的 pathPresence 键控 Hook,其背后是 workspaceFiles/stat:stat 成功或 workspace-file/not-regular-file 失败(目录、无论指向何处的符号链接或其他非普通条目)即确认路径存在,workspace-file/not-found 判定不存在,其他失败则保持未确认,由下一个订阅者重试。插件持有这些结果,每个 Session 与路径保留一份,并在卸载时中止未完成的 stat;选定 pick 会把其路径记为已确认。存在性不通过 useResource 读取 file 资源:该 provider 在有读取方挂载期间为每个 Session 与路径保持一个 Host 变更订阅,而一次提及只需要一个结果。可交互的文件节点还通过 Injection 接收绑定 Session 的 openFile;导航失败时保留引用,提供局部重试/关闭对话框。目录节点仍为标签。
进一步探索
以下页面覆盖建议机制、引用 seam 与输入流水线。
- ui-input-trigger——该 source 注册进的行内建议机制。
- file-reference——
@fileseam 及其提供方约定。 - session-reference——
@sessionseam 与准备后快照的语义。 - Web 输入机器与 slash 流水线——引用与命令如何共享输入机器。
模型体验
间接影响模型体验:通过宿主拥有的提供方实现,本包的引用选择把文件指引与会话快照准备委托给它们。
KV Cache 影响
浏览候选项不会影响模型。选择文件或会话只会改变新用户消息的后缀,以及紧随该消息、由宿主准备的会话引用上下文;目标会话更早的历史保持不变。
已知限制与延期工作
这些限制说明引用 source 何时帮不上忙;它们是当前包约束。
- 候选失败有意保持静默:Remote 发现调用不可用或失败时,该领域不产生候选行。会话引用准备失败发生在提示词接受后,并会终止该 agent 轮次。
- 浏览器侧不扫描文件:Web 补全需要挂载宿主
ctx.fileReferences提供方;浏览器无法回退到自身文件系统。 - 已发送引用不跟随文件变化:路径的确认或不存在结果在一次页面加载内保持不变;之后创建或删除该路径,只有刷新页面后才会改变其引用的渲染。
- 手打的相对引用跟随 Session 的目录:手打的
@相对/路径,以及选中项携带绝对路径之前发出的引用,按 Session 的当前工作目录读取;该目录变化后,它会指向另一个文件或不存在的路径。 - 会话搜索仍仅使用元数据:发现流程通过
ctx.sessionReferenceResolver筛选 session id、cwd 与以日志为依据的最新标题;不搜索消息主体或完整 transcript。
开发备注
维护者的工作上下文——点击展开
无。