Skip to content

fix: enable selection-to-conversation popup in the markdown editor - #24

Merged
Menghuan1918 merged 1 commit into
omdsh-dev:mainfrom
log-li:fix/markdown-editor-selection-insert
Aug 15, 2026
Merged

fix: enable selection-to-conversation popup in the markdown editor#24
Menghuan1918 merged 1 commit into
omdsh-dev:mainfrom
log-li:fix/markdown-editor-selection-insert

Conversation

@log-li

@log-li log-li commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

问题

在 markdown 文件的编辑态(CodeMirror)里选中文字,不会出现「添加到对话」浮动按钮;只有预览态(渲染后 DOM 选区)能插入。原因:编辑器选区弹窗只在 viewerId === 'code'(通用代码查看器)时注册,markdown 编辑态被排除。

改动

src/client/TextEditor.tsx 中把选区弹窗的注册条件放宽:

- ...(viewerId === 'code' ? [
+ ...(viewerId === 'code' || viewerId === 'markdown' ? [

markdown 编辑态由此获得与代码查看器一致的「选中 → 添加到对话」体验,且行号来自编辑器选区(精确),插入格式为 \``相对路径:起止行 + 选中文本```(>500 字符时仅插 路径:起止行引用),与selection-payload.ts` 现有约定一致。

验证

  • pnpm typecheck
  • pnpm test:382 passed / 22 failed —— 22 个失败全部是 agent-pty.spec.ts / smoke.spec.ts 的 node-pty posix_spawnp failed(沙箱环境无法 spawn PTY,基线分支同样失败,与本次改动无关);客户端组件测试(selection-payload、markdown-copy-labels、sandbox-views 等)全部通过
  • pnpm build(tsdown)后 lib/client-editor.js 已包含新条件
  • 已在本机安装包中同步打补丁,重启 DSH 后人工验证 markdown 编辑态选区弹窗生效

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.
@log-li

log-li commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

撤回:等本机试用验证通过后再重新打开提交。fix 分支与提交保留在 fork 上。

@log-li log-li closed this Aug 14, 2026
@log-li log-li reopened this Aug 14, 2026
@log-li

log-li commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

本机试用验证通过:重启 DSH 后,markdown 文件编辑态选中文字会弹出「添加到对话」,插入格式为 路径:起止行 + 选中文本,行号精确。可正常评审/合并。

@Menghuan1918 Menghuan1918 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Menghuan1918
Menghuan1918 merged commit ecebc97 into omdsh-dev:main Aug 15, 2026
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.

2 participants