feat: show the manual refresh button for toolbar-less viewers (pdf / image / binary) - #501
Open
huaruoji wants to merge 1 commit into
Open
feat: show the manual refresh button for toolbar-less viewers (pdf / image / binary)#501huaruoji wants to merge 1 commit into
huaruoji wants to merge 1 commit into
Conversation
The refresh button (issue omdsh-dev#167) was gated on a hoisted editor toolbar, so pdf / image / binary-download tabs — whose viewers never report one — had no way to reload a file changed on disk. The reload already works for them: the load effect's 'loading' pass unmounts the current viewer and the 'ready' pass remounts it, so path-fetching previewers like PdfView re-read the file into a fresh blob URL. Now every file tab gets the button; the dirty-draft confirm stays text-editor-only (toolbar). Tests: new case D in editor-refresh.spec.tsx — a toolbar-less viewer (mock pdf/image shape) renders the refresh button and re-runs the load.
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.
背景
刷新按钮(#167)被
toolbar !== null条件挡住:只有会向上报告 toolbar 的文本类 viewer(markdown/html/code)能看到它。而 pdf / image / binary-download 这类预览器从不挂 toolbar,所以用户打开 PDF 标签、文件在磁盘上更新后,没有任何入口重新加载——这正是 #167 要解决的场景的漏网分支。改动
src/client/EditorHost.tsx:把刷新按钮的门槛从toolbar !== null放宽为!showEmpty(仅隐藏无路径的「文件主页」空态标签)。刷新机制本身无需改动——load effect 的'loading'阶段会卸载当前 viewer、'ready'阶段重新挂载,因此像PdfView这类按 path 重新 fetch 的预览器会重建 blob URL、读到磁盘新字节(服务端/sidebar/file带cache-control: no-cache,无需缓存破坏参数)。脏草稿确认逻辑保持不变(
toolbar?.dirty,仅文本编辑有 toolbar)。测试
tests/editor-refresh.spec.tsx新增用例 D:注册一个不报告 toolbar 的 viewer(模拟 pdf/image 形态),断言全量 107 文件 / 1138 用例通过,
pnpm typecheck通过。