From 3ede092adc86fb85c1c6a51019064624421e3fdc Mon Sep 17 00:00:00 2001 From: Richard R Date: Tue, 17 Feb 2026 22:12:11 -0700 Subject: [PATCH] feat: Make word highlighting enabled by default by inverting its environment variable logic, updating documentation, and removing `NEXT_PUBLIC_NODE_ENV` from Playwright tests. --- .github/workflows/playwright.yml | 1 - docs-site/docs/reference/environment-variables.md | 4 ++-- src/components/documents/DocumentSettings.tsx | 2 +- src/contexts/TTSContext.tsx | 3 ++- src/types/config.ts | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 2564e12..39702a6 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -42,7 +42,6 @@ jobs: run: pnpm exec playwright install --with-deps - name: Run Playwright tests env: - NEXT_PUBLIC_NODE_ENV: test API_BASE: https://api.deepinfra.com/v1/openai API_KEY: ${{ secrets.DEEPINFRA_API_KEY }} run: pnpm exec playwright test --reporter=list,github,html diff --git a/docs-site/docs/reference/environment-variables.md b/docs-site/docs/reference/environment-variables.md index 50866d2..3aeb812 100644 --- a/docs-site/docs/reference/environment-variables.md +++ b/docs-site/docs/reference/environment-variables.md @@ -15,7 +15,7 @@ This is the single reference page for OpenReader WebUI environment variables. | `NEXT_PUBLIC_DEFAULT_TTS_MODEL` | Client feature flags | `kokoro` | Override default TTS model | | `NEXT_PUBLIC_SHOW_ALL_DEEPINFRA_MODELS` | Client feature flags | `true` unless set to `false` | Set `false` to restrict DeepInfra models | | `NEXT_PUBLIC_ENABLE_AUDIOBOOK_EXPORT` | Client feature flags | `true` unless set to `false` | Set `false` to hide audiobook export UI | -| `NEXT_PUBLIC_ENABLE_WORD_HIGHLIGHT` | Client feature flags | `false` unless set to `true` | Set `true` to enable word highlight + alignment | +| `NEXT_PUBLIC_ENABLE_WORD_HIGHLIGHT` | Client feature flags | `true` unless set to `false` | Set `false` to disable word highlight + alignment | | `API_BASE` | TTS provider | none | Point to your OpenAI-compatible TTS base URL | | `API_KEY` | TTS provider | `none` fallback in TTS route | Set when provider requires auth | | `TTS_CACHE_MAX_SIZE_BYTES` | TTS caching | `268435456` (256 MB) | Tune in-memory TTS cache size | @@ -387,7 +387,7 @@ Controls whether audiobook export UI/actions are shown in the client. Controls word-by-word highlighting UI and timestamp-alignment behavior. -- Default behavior: disabled unless set to `true` +- Default behavior: enabled unless explicitly set to `false` - Applies in both development and production - Requires working timestamp generation (for example `WHISPER_CPP_BIN`) - Affects: diff --git a/src/components/documents/DocumentSettings.tsx b/src/components/documents/DocumentSettings.tsx index a5cabec..e31419e 100644 --- a/src/components/documents/DocumentSettings.tsx +++ b/src/components/documents/DocumentSettings.tsx @@ -12,7 +12,7 @@ import type { TTSAudiobookChapter } from '@/types/tts'; import type { AudiobookGenerationSettings } from '@/types/client'; const canExportAudiobook = process.env.NEXT_PUBLIC_ENABLE_AUDIOBOOK_EXPORT !== 'false'; -const canWordHighlight = process.env.NEXT_PUBLIC_ENABLE_WORD_HIGHLIGHT === 'true'; +const canWordHighlight = process.env.NEXT_PUBLIC_ENABLE_WORD_HIGHLIGHT?.toLowerCase() !== 'false'; const viewTypeTextMapping = [ { id: 'single', name: 'Single Page' }, diff --git a/src/contexts/TTSContext.tsx b/src/contexts/TTSContext.tsx index 2dde974..3e0e425 100644 --- a/src/contexts/TTSContext.tsx +++ b/src/contexts/TTSContext.tsx @@ -101,7 +101,8 @@ interface SetTextOptions { const CONTINUATION_LOOKAHEAD = 600; const SENTENCE_ENDING = /[.?!…]["'”’)\]]*\s*$/; -const wordHighlightFeatureEnabled = process.env.NEXT_PUBLIC_ENABLE_WORD_HIGHLIGHT === 'true'; +const wordHighlightFeatureEnabled = + process.env.NEXT_PUBLIC_ENABLE_WORD_HIGHLIGHT?.toLowerCase() !== 'false'; // Tiny silent WAV used to unlock HTML5 audio on iOS/Safari. const SILENT_WAV_DATA_URI = diff --git a/src/types/config.ts b/src/types/config.ts index 95879bb..418f977 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -1,7 +1,8 @@ import type { DocumentListState } from '@/types/documents'; -const wordHighlightEnabledByDefault = process.env.NEXT_PUBLIC_ENABLE_WORD_HIGHLIGHT === 'true'; +const wordHighlightEnabledByDefault = + process.env.NEXT_PUBLIC_ENABLE_WORD_HIGHLIGHT?.toLowerCase() !== 'false'; export type ViewType = 'single' | 'dual' | 'scroll';