保存遇宿主不可用保持 dirty,避免陈旧注册表覆盖未落盘输入

- 保存失败分流后不再无条件 setDirty(false):exportUnavailable 分支保留 dirty
- dirty 为真时 adoptable 保持 false,宿主恢复后的重读不会用旧注册表表单覆盖用户输入
- 冲突/未知失败仍归零 dirty,维持「同一份输入不反复打宿主」
This commit is contained in:
2026-10-07 11:08:13 +08:00
parent 00448e0b26
commit 075078f358
@@ -544,19 +544,25 @@ export function useTaonierExport({
return true;
} catch (error) {
if (projectPathRef.current !== projectPath) return false;
// 剩下的结果都要停下重试,等用户或下一次输入推着走:冲突等用户选、其余按 typed 失败给
// 建议。共同点是 `dirty` 归零,避免同一份输入反复打宿主。
setDirty(false);
// 冲突等用户选、其余按 typed 失败给建议。共同点是 `dirty` 归零,避免同一份输入反复
// 打宿主;但 `exportUnavailable` 例外:宿主恢复前这份输入仍未落盘,保持 dirty,
// 否则下一次重读会把它当成「干净」而用陈旧的注册表内容覆盖。
const structured = asTaonierSaveFailure(error);
if (!structured) {
setDirty(false);
throwToErrorPool(String(error), error);
return false;
}
if (structured.type === 'saveConflict') setConflict(structured);
else if (structured.type === 'exportUnavailable') {
if (structured.type === 'saveConflict') {
setDirty(false);
setConflict(structured);
} else if (structured.type === 'exportUnavailable') {
// 宿主侧事实故障:不落面板,直接抛给全局错误池上报。
throwToErrorPool(JSON.stringify(structured), error);
} else setFailure(structured);
} else {
setDirty(false);
setFailure(structured);
}
return false;
}
});