Harden Yomitan runtime state and profile policy handling

- Centralize external-profile read-only behavior in a shared Yomitan profile policy
- Clear parser/extension runtime state via dedicated helpers on load failures and reloads
- Prevent opening Yomitan settings when the Yomitan session is unavailable
- Add focused runtime-policy and state-clearing regression tests
This commit is contained in:
2026-03-11 22:56:50 -07:00
parent c9d5f6b6e3
commit 6ff89b9227
9 changed files with 220 additions and 60 deletions

View File

@@ -24,11 +24,16 @@ export function createOpenYomitanSettingsHandler(deps: {
deps.logWarn('Unable to open Yomitan settings: extension failed to load.');
return;
}
const yomitanSession = deps.getYomitanSession?.() ?? null;
if (!yomitanSession) {
deps.logWarn('Unable to open Yomitan settings: Yomitan session is unavailable.');
return;
}
deps.openYomitanSettingsWindow({
yomitanExt: extension,
getExistingWindow: deps.getExistingWindow,
setWindow: deps.setWindow,
yomitanSession: deps.getYomitanSession?.() ?? null,
yomitanSession,
});
})().catch((error) => {
deps.logError('Failed to open Yomitan settings window.', error);