Repository navigation
feat(desktop): 单文件模式下 Markdown 文件显示渲染页、编辑/预览切换和目录按钮 (#2324) - #2334
Merged
Merged
Conversation
单文件模式原来对所有预览一律只显示源码。Markdown 文件现在与项目窗口一样, 标签栏有目录按钮和“编辑 / 编辑与预览 / 预览”切换,默认源码与渲染页并排; 渲染页只读当前文本和它引用的图片,所在文件夹之外的图片仍被拒绝, 不启动插件、索引、Git 等项目服务。SVG、HTML 仍只显示源码。 - editor_view.go:标签栏与组主体对 Markdown 不再排除单文件窗口 - standalone_test.go:单文件 Markdown 回归测试(切换、目录、渲染页、图片边界、无项目服务) - standalone_visual_test.go:明暗 × 中英无头截图 - 更新单文件模式 Agent Note 与功能矩阵条目
xiaoyumuxi
marked this pull request as ready for review
November 23, 2026 06:40
19 tasks done
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 / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
用命令行或“打开方式”以单文件模式打开
.md文件时,编辑区只有源码。标签栏没有「编辑 / 编辑与预览 / 预览」切换,也没有目录(Contents)按钮,用户既看不到渲染效果,也切不到大纲。原因是 #2225(95c0ad2ff)引入单文件模式时,标签栏和编辑组主体对所有预览一律加了!p.standalone排除。Markdown 渲染页只读当前文档文本和它引用的图片,不依赖插件、索引、Git 等项目服务,所以在单文件窗口里打开它不违背这个模式的边界。改动 / Changes
desktop/internal/workbench/editor_view.goeditorGroup:标签栏对 Markdown 文件不再排除单文件窗口,显示目录按钮和三段视图切换(默认“编辑与预览”)。SVG、HTML 的切换仍只在项目窗口出现。groupBody:先判断 Markdown,再走单文件窗口“只显示源码”的分支。所以单文件窗口里的 Markdown 文件使用与项目窗口相同的markdownDocument,SVG、HTML 和其他文件不受影响。desktop/internal/workbench/standalone_test.go:新增TestStandaloneMarkdownShowsItsPage,检查以下内容:../指向所在文件夹之外的图片被拒绝。desktop/internal/workbench/standalone_visual_test.go:新增TestVisualStandaloneMarkdown(vivahead lithevisual构建标签),生成明暗 × 中英四张截图。.agents/notes/implemented/feature/2026-11-20-cli-and-standalone-editor.md:在“决策”里写明 Markdown 渲染页在单文件模式可用,并写明它只读什么、SVG/HTML/图片/PDF 仍不预览。在“后果”里补充:打开 Markdown 时会创建一个网页视图,内存与项目窗口相同。shared/platform-feature-matrix/features/cli-single-file-mode.json:验证动作加入 Markdown 切换、目录和图片的检查,备注写明无头回归和截图已有、原生网页引擎下待两端验收,两端证据加入editor_view.go。两端仍为pending。docs/assets/single-file-markdown/:修复前后的无头截图。不在本 PR 范围内 / Out of scope
ResolveMarkdownReference的工作区边界一致,保持拒绝。类型专属:feat
多平台对齐
platform-specific),理由:范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/cli-single-file-mode.json:验证动作、备注、两端证据已更新;原生验收未做,两端保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空PluginRoot指向不存在的目录并断言插件没有装配shared/i18n/;插件的构建步骤、资源路径和补丁没有写进docs/ci-builds.md、Agent Note 或 SkillUI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=… ./scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/workbench -run TestVisualStandaloneMarkdown -count=1,提交 f9c0a83。场景是单文件模式打开notes.md,内容含标题、列表、Go 代码块和引用。覆盖明暗两种主题、en-US 和 zh-Hans,尺寸 1000×640。修复前的图是把editor_view.go临时换回main版本、用同一个测试生成的。修复前(单文件模式只有源码,标签栏没有切换和目录按钮):
修复后(标签栏右侧依次是目录、编辑、编辑与预览、预览、自动换行,默认源码与渲染页并排):
统一日志系统 / Structured logging
N/A:没有新增或改动生命周期里程碑、操作终态、降级或失败路径,渲染页沿用项目窗口已有的日志。
界面文案 / i18n
node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
ResolveMarkdownReference判断;本 PR 只改平台层“单文件窗口呈现哪个视图”的分支性能与内存 / Performance and memory
设置 / Settings
N/A:没有新增或修改设置。
插件契约 / Plugin contract
N/A:不涉及插件契约、能力版本或宿主方法。
发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh无用代码与重构 / Dead code and refactoring
验证 / Verification
./scripts/desktop/desktop-go.sh test ./internal/workbench -run TestStandaloneMarkdownShowsItsPage -count=1,editor_view.go临时换回main版本the strip of a Markdown file opened alone has no "Editor"editor_view.go./scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestStandalone|TestMarkdown|TestSVG|TestHTML' -count=1./scripts/desktop/desktop-go.sh test ./internal/workbench -count=1ok … workbench 346.975s)./scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/workbench -run TestVisualStandaloneMarkdown -count=1(修复前后各一次)gofmt -l desktop/internal/workbench./scripts/platform-feature-matrix/verify-platform-feature-matrix.shvalidated 221 platform capabilities./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD./scripts/agent-notes/verify-agent-notes.shok: 200 active Agent Note(s) verified./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh./scripts/desktop/verify/verify-runtime-bundle-immutability.shnode scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --checkdevelop-lithe第三节插件零依赖自查rg未能执行的检查和原因:
pending。提交前确认 / Final checks
main创建;目标分支:main.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图(截图状态栏里是测试临时目录路径,不含用户名)