fix: enable selection-to-conversation popup in the markdown editor - #24
Merged
Menghuan1918 merged 1 commit intoAug 15, 2026
Merged
Conversation
The "add to conversation" selection popup was registered only for the catch-all code viewer (viewerId === 'code'), so selecting text in the CodeMirror editor of a markdown file produced no popup; insertion only worked in markdown preview mode via the separate DOM-selection handler. Extend the CodeMirror selection popup to the markdown editor (viewerId === 'markdown') so line-exact selections can be injected into the composer draft (\`\`\`rel/path:start-end\`\`\` payload), matching preview-mode behavior and the code viewer.
Contributor
Author
|
撤回:等本机试用验证通过后再重新打开提交。fix 分支与提交保留在 fork 上。 |
Contributor
Author
|
本机试用验证通过:重启 DSH 后,markdown 文件编辑态选中文字会弹出「添加到对话」,插入格式为 |
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.
问题
在 markdown 文件的编辑态(CodeMirror)里选中文字,不会出现「添加到对话」浮动按钮;只有预览态(渲染后 DOM 选区)能插入。原因:编辑器选区弹窗只在
viewerId === 'code'(通用代码查看器)时注册,markdown 编辑态被排除。改动
src/client/TextEditor.tsx中把选区弹窗的注册条件放宽:markdown 编辑态由此获得与代码查看器一致的「选中 → 添加到对话」体验,且行号来自编辑器选区(精确),插入格式为
\``相对路径:起止行 + 选中文本```(>500 字符时仅插路径:起止行引用),与selection-payload.ts` 现有约定一致。验证
pnpm typecheck✅pnpm test:382 passed / 22 failed —— 22 个失败全部是agent-pty.spec.ts/smoke.spec.ts的 node-ptyposix_spawnp failed(沙箱环境无法 spawn PTY,基线分支同样失败,与本次改动无关);客户端组件测试(selection-payload、markdown-copy-labels、sandbox-views 等)全部通过pnpm build(tsdown)后lib/client-editor.js已包含新条件