Skip to content

feat: show the manual refresh button for toolbar-less viewers (pdf / image / binary) - #501

Open
huaruoji wants to merge 1 commit into
omdsh-dev:mainfrom
huaruoji:feat/editor-refresh-all-viewers
Open

feat: show the manual refresh button for toolbar-less viewers (pdf / image / binary)#501
huaruoji wants to merge 1 commit into
omdsh-dev:mainfrom
huaruoji:feat/editor-refresh-all-viewers

Conversation

@huaruoji

@huaruoji huaruoji commented Sep 1, 2026

Copy link
Copy Markdown

背景

刷新按钮(#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/filecache-control: no-cache,无需缓存破坏参数)。

脏草稿确认逻辑保持不变(toolbar?.dirty,仅文本编辑有 toolbar)。

测试

tests/editor-refresh.spec.tsx 新增用例 D:注册一个不报告 toolbar 的 viewer(模拟 pdf/image 形态),断言

  1. 刷新按钮照常渲染;
  2. 无 Preview/Save 控件;
  3. 点击刷新后 load 重新执行(fsRead 调用数 1→2)。

全量 107 文件 / 1138 用例通过,pnpm typecheck 通过。

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.
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.

1 participant