fix(overlay): gate the maturity legend on known-word highlighting

The session help color legend showed the four tier rows whenever
maturityEnabled was on, even with known-word highlighting off, where no
token is ever tinted. Extract isKnownWordMaturityLegendEnabled so the
legend requires both toggles, matching getKnownWordMaturityEnabled.
This commit is contained in:
2026-07-26 01:33:04 -07:00
parent 38060e0ead
commit 75566a49bf
2 changed files with 45 additions and 5 deletions
+15 -5
View File
@@ -1,4 +1,5 @@
import type { ModalStateReader, RendererContext } from '../context';
import type { RuntimeOptionId, RuntimeOptionState } from '../../types/runtime-options';
import {
buildSessionHelpSections,
type SessionHelpSection,
@@ -19,6 +20,19 @@ type SessionHelpBindingInfo = {
fallbackUnavailable: boolean;
};
/**
* Tiers only render when known-word highlighting is also on, matching
* getKnownWordMaturityEnabled in anki-integration/known-word-maturity.
*/
export function isKnownWordMaturityLegendEnabled(runtimeOptions: RuntimeOptionState[]): boolean {
const isOn = (id: RuntimeOptionId): boolean =>
runtimeOptions.some((option) => option.id === id && option.value === true);
return (
isOn('subtitle.annotation.knownWords.highlightEnabled') &&
isOn('subtitle.annotation.knownWords.maturityEnabled')
);
}
/**
* Maturity coloring is a live runtime toggle, so the color legend reads it from
* runtime options instead of the resolved subtitle style. A missing or failing
@@ -26,11 +40,7 @@ type SessionHelpBindingInfo = {
*/
async function readKnownWordMaturityEnabled(): Promise<boolean> {
try {
const runtimeOptions = await window.electronAPI.getRuntimeOptions();
return runtimeOptions.some(
(option) =>
option.id === 'subtitle.annotation.knownWords.maturityEnabled' && option.value === true,
);
return isKnownWordMaturityLegendEnabled(await window.electronAPI.getRuntimeOptions());
} catch {
return false;
}