Repository navigation
feat(settings): ask before leaving Fusion settings with unsaved edits - #1700
Merged
Merged
Conversation
Windows accepts `/` in most path APIs, but `explorer` does not: handed `/select,"C:/Users/me/pic.png"` it opens Documents (or Desktop) instead — the same wrong-folder symptom as a path that no longer exists, from a file that is right where the link says it is. That spelling is not exotic: it is how a model writes the link for a file it just saved the POSIX way, so "show in folder" on a perfectly present file revealed nowhere near it. Verified against the real file both ways: the backslash spelling selects the file, the forward-slash spelling lands on Documents. `select_argument` and the missing-file folder fallback now build their target from the native spelling; elsewhere `/` is the separator and nothing changes.
The system file picker answers with the provider's URI rather than a path (`content://` on Android), and the whole upload then reads through that provider. A provider may serve only a stream — no size, no random access — and the transfer reads one chunk at a time through a seekable handle, so it finds nothing left to send and stops with a stalled attachment. Images never met this: the photo picker and the converter both hand back files the app owns, which is why only documents failed. A picked document is now copied into the app's cache while the reader is still in the picker, and the message carries the copy. When the copy comes back empty (a size-driven copy of a stream reports success having written nothing) the whole document is read instead — the one read every provider supports — and the copy's size, not the provider's claim, becomes the message's size, so an announced size the bytes disagree with can no longer arrive at the desktop as an incomplete upload. The copy also moves the point of failure: a document nobody can read is refused before the waiting message's "+" cancels that message for a re-send, so the reader loses neither the file nor the message, and says which of the two it was.
The Fusion page keeps a draft and applies it only through its save action, but
every way out of it — another settings tab, a search result, the backdrop,
Escape, "back" on a paired machine — dropped the draft without a word. A user
who believed the change had already been applied kept the old configuration.
`unsavedGuard.tsx` gives the surface that owns navigation a guard: a page with a
draft registers what it holds, and leaving asks first (keep editing / discard /
save and leave). The settings dialog and the paired-machine settings page route
their exits through it and hand its API to the Fusion page.
The save action is now a bar pinned to the bottom of the page that says where
the draft stands ("unsaved changes", "saved", "changes apply only after you
save"), and is a primary button rather than the small secondary one that sat
under the participant list and read as a footnote.
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.
问题
Fusion 设置页的保存按钮原本是参与者列表之后的一个小号次要按钮,位于长列表末尾:要滚到底才看得到,看起来像脚注而不是「让改动生效」的那一步。而离开这个页面(切到其它设置页、点搜索结果、点遮罩、按 Esc、在配对机器页点「返回」)会把草稿直接丢掉,没有任何提示——用户很容易以为自己已经保存了,实际还是旧配置。
改动
离开前询问。 新增
desktop/src/features/settings/unsavedGuard.tsx:由拥有导航的那一层(设置对话框、配对机器设置页)托管守卫,带草稿的页面把「我在编辑什么 / 现在脏不脏 / 怎么保存」注册进来;离开时若有未保存改动,弹出「还有未保存的修改」,三选一:继续编辑 · 放弃修改 · 保存并离开(保存失败会留在原页并显示错误)。所有退出路径都经过它:设置页切换、搜索跳转、遮罩、Esc、远端页的返回。没有改动时直接走,不会打扰。保存动作变明显。 按钮移到底部常驻栏(
sticky,在内容之上),左侧用aria-live说明草稿状态:无改动「修改后需点击保存才会生效。」/ 有改动「有未保存的修改」/ 刚保存「已保存」;右侧是primary实心按钮,不再随列表滚出视野。persist()改为返回Promise<boolean>,供守卫判断「保存并离开」是否真的成功。验证
tsc --noEmit干净;eslint src/features/settings src/features/remote-peer零告警;相关区域vitest通过(新增 12 个用例:保存栏 2、页面守卫 5、设置对话框接线 4、远端返回 1)。