fix: harden opfs capability recovery

This commit is contained in:
Youzini-afk
2026-04-15 22:47:26 +08:00
parent 61d1260bfc
commit e2e51c9508
4 changed files with 210 additions and 23 deletions

View File

@@ -2186,6 +2186,47 @@ result = {
assert.equal(plan.reasons.includes("resolved-store-mismatch"), true);
}
{
const harness = await createGraphPersistenceHarness({
chatId: "chat-panel-open-capability-retry",
globalChatId: "chat-panel-open-capability-retry",
chatMetadata: {
integrity: "chat-panel-open-capability-retry-integrity",
},
});
harness.runtimeContext.extension_settings[MODULE_NAME] = {
graphLocalStorageMode: "auto",
};
harness.api.setLocalStoreCapabilitySnapshot({
checked: true,
checkedAt: Date.now(),
opfsAvailable: false,
reason: "UnknownError: transient-opfs-init-failure",
});
harness.api.setGraphPersistenceState({
loadState: "loaded",
chatId: "chat-panel-open-capability-retry",
reason: "healthy",
dbReady: true,
writesBlocked: false,
pendingPersist: false,
indexedDbLastError: "",
resolvedLocalStore: "indexeddb:indexeddb",
storagePrimary: "indexeddb",
storageMode: "indexeddb",
});
const plan = harness.api.buildPanelOpenLocalStoreRefreshPlan();
assert.equal(plan.shouldRefresh, true);
assert.equal(plan.forceCapabilityRefresh, true);
assert.equal(
plan.reasons.includes("capability-retryable-failure"),
true,
"可恢复的 OPFS 探测失败应在面板打开时触发重新探测",
);
}
{
const harness = await createGraphPersistenceHarness({
chatId: "chat-luker-panel-open",