feat: rendered-markdown preview toggle for remote (SSH) files#280
feat: rendered-markdown preview toggle for remote (SSH) files#280TranscriptionFactory wants to merge 1 commit into
Conversation
Remote (SSH) markdown files bypassed markdown routing: the code pane's Rendered|Raw toggle detected markdown only via local_path()/tab.path, both None for remote buffers, and the Rendered action emitted ReplaceWithFilePane -> FileNotebookView, which is local-only. Inline-render within CodeView (Option B): detect markdown via the active tab's location.language_path(); for remote tabs the toggle builds a read-only RichTextEditorView (Selectable) from a snapshot of the loaded buffer text via reset_with_markdown, stored per-tab, shown in render() in place of the editor. Local behavior is unchanged (still routes through RenderMarkdown -> ReplaceWithFilePane). Toggle selected-state is synced to the active tab's rendered state on tab switch. Snapshot semantics: preview does not auto-refresh on buffer sync; toggle Raw->Rendered re-renders. Adds a unit test for remote markdown detection. Next: optionally subscribe to buffer changes to live-refresh the preview. (cherry picked from commit afb91f5)
zerx-lab
left a comment
There was a problem hiding this comment.
(详见 inline comments 和下方总结 comment)
— 由 Claude Routine 自动生成;如需复评请 @ 维护者人工触发。
Generated by Claude Code
| // machinery. `RichTextEditorView` is referenced by the always-present `TabData` field, so | ||
| // it must be in scope unconditionally; the construction helpers are only used on the | ||
| // `local_fs` toggle path. | ||
| use crate::notebooks::editor::view::RichTextEditorView; |
There was a problem hiding this comment.
Question: 非 local_fs 构建下 RichTextEditorView 是否可用?
这条 use 没有 #[cfg(feature = "local_fs")] 守卫,注释声称「必须无条件在作用域内」(因为 TabData::rendered_markdown_view 字段持有它)。但如果 RichTextEditorView 本身只在 local_fs feature 下存在,非 local_fs 构建就会报 unresolved import。
请确认:crate::notebooks::editor::view::RichTextEditorView 在没有 local_fs 时是否也会被编译进来?如果不是,rendered_markdown_view 字段和这条 use 都需要加 #[cfg(feature = "local_fs")] 守卫(render 路径里的 if let Some(rendered) 分支也同步门控即可,因为字段在非 local_fs 下不存在)。
Generated by Claude Code
| )); | ||
| assert!(is_markdown_file( | ||
| remote("/home/user/doc.markdown").language_path() | ||
| )); |
There was a problem hiding this comment.
Question: CHANGELOG(无扩展名)是否会被 is_markdown_file 识别为 Markdown?
CHANGELOG 文件通常以多种格式存在(纯文本、Markdown、rst 等),没有统一的扩展名。is_markdown_file 函数是否明确地将无扩展名的 CHANGELOG 作为 Markdown 处理?如果它的实现只匹配 .md / .markdown 扩展名,这个断言会 panic 并导致 CI 失败。
建议先确认 is_markdown_file 对无扩展名文件的行为,如果它不支持,就把这条断言改为 assert!(!is_markdown_file(...)) 或移除。
Generated by Claude Code
Review 总结整体判断:Comment(需确认两处问题后可合并)。核心思路可行,在 阻塞问题
建议
看起来不错的地方
— 由 Claude Routine 自动生成;如需复评请 @ 维护者人工触发。 Generated by Claude Code |
What
Makes the code pane's Rendered | Raw toggle work for remote (SSH) markdown files. Previously the toggle did nothing useful for remote buffers.
Why
Remote markdown files bypassed markdown routing:
local_path()/tab.path, bothNonefor remote buffers.ReplaceWithFilePane→FileNotebookView, which is local-only.So opening a remote
.mdover SSH gave no rendered preview.How (inline render within
CodeView)location.language_path()(works for both local and remote tabs).RichTextEditorView(Selectable) from a snapshot of the loaded buffer text viareset_with_markdown, stored per-tab, and shown inrender()in place of the editor.RenderMarkdown→ReplaceWithFilePane).Snapshot semantics
The preview does not auto-refresh on buffer sync; toggling Raw → Rendered re-renders. (A follow-up could subscribe to buffer changes to live-refresh.)
Testing
cargo check -p warppasses. Adds a unit test for remote markdown detection. Please run./script/presubmitfor the full app crate + clippy/fmt in CI.