The desktop app ships with four views—Overview (#/), Items (#/items), Settings (#/settings), and an opt-in Developer playground (#/developer)—backed by a Go host in native mode and an in-memory adapter in browser preview mode.
Each frontend library owns a distinct layer while keeping Go authoritative for persisted data:
- Routing (React Router
HashRouter): src/main.tsx wraps the app in HashRouter alongside Vite’s relative base: './' (vite.config.ts), so routes resolve inside Wails’s embedded asset server and static previews without server-side URL rewrites. src/app.tsx moves keyboard focus to the page <h1> on route changes.
- Queries and offline local IPC (TanStack Query):
src/query.ts creates one app-owned QueryClient with networkMode: 'always' and retry: false for both queries and mutations so local Wails IPC works when the OS reports offline. Structured keys (itemsKey, settingsKey) drive targeted invalidation and cache updates.
- Forms and dual validation (React Hook Form + Zod):
pages/items.tsx and pages/settings.tsx wire useForm with zodResolver against schemas in src/host/contract.ts (titleSchema counts Unicode code points 1..200 to match Go’s []rune validation; itemSchema, settingsSchema, and updateStatusSchema parse host responses). Frontend validation gives immediate inline Field.ErrorText feedback, while Go (internal/items/database.go and internal/preferences/store.go) validates every write independently before touching SQLite or settings.json.
Saved settings and revision ordering
Preferences use schema version 1 and live in settings.json under the OS config directory (internal/preferences). Each record contains:
schemaVersion: 1
revision: monotonically increasing integer
theme: 'system' | 'light' | 'dark' (default 'system')
language: 'en' | 'de' (default 'en')
developerMode: boolean (default false)
In Settings (pages/settings.tsx), edits remain local form drafts until you click Save settings. Clicking Discard changes reverts to the last accepted host state; failed writes keep your draft visible so you can retry without changing the active appearance or language.
To prevent out-of-order responses or events from reverting newer saves, both Go and React track revision. The frontend helper newerSettings() in src/host/contract.ts ignores any read, mutation response, or settings:changed event whose revision is older than or equal to the revision in TanStack Query’s cache.
- Partial updates: Go’s
Patch struct uses pointer fields (*string, *bool), so passing developerMode: false turns it off while omitted fields stay untouched. Existing schema-1 files that omit developerMode load as false.
- Corrupt-file recovery: Clicking Reset settings restores defaults (
system, en, developerMode: false) without touching SQLite items. If settings.json is malformed, Go writes a timestamped .backup-* copy beside it before writing clean defaults. An unreadable file or failed backup reports an error and leaves recovery to you.
- Browser preview: Settings work during a preview session, but live only in memory and reset to defaults on reload.
Localization (English and German)
The desktop app bundles English (en.json) and German (de.json) resources synchronously (initAsync: false, react: { useSuspense: false }) in apps/desktop/frontend/src/i18n/locales/ using i18next and react-i18next’s useTranslation hook. There is no remote loader, browser language detector, or localStorage cache—avoid adding HTTP backends or auto-detectors that break offline execution or bypass saved settings.
- Single source of truth: Only the saved
language preference switches the UI language. Selecting another option in Settings does not change the active locale until you save (or reset back to English). Accepted changes update mounted screens, <html lang="..." dir="...">, and document.title together.
- Type-checked parity:
en.json defines the canonical key shape in src/i18n/index.ts; de.json must match all keys and interpolation placeholders.
- Semantic state over pre-translated strings: Store validation errors, update phases, and status results as semantic keys (such as
validation.title or updates.phases.available) and call t() during render so visible banners and inline errors update when the saved language changes.
- Host boundary: Reusable packages (
@wailspring/ui, @wailspring/docs, @wailspring/icons) never import i18next. Pass translated labels and children from the desktop app (including lightLabel, darkLabel, sample, and sourceLabel on @wailspring/docs/react specimens, and translated titles/bodies for OS notifications). The Astro site’s copy is independent of desktop locale files.
Developer mode (#/developer)
Developer mode is off by default. Toggle Developer mode in Settings and click Save settings—unsaved draft toggles grant no access.
Once enabled, a Developer link appears in the sidebar and #/developer lazy-loads (pages/developer.tsx), focusing its heading on navigation. Turning Developer mode off, resetting settings, or receiving a newer settings:changed event disabling it redirects immediately to #/settings.
The playground contains:
- Read-only diagnostics: App version, host mode (native or browser preview), saved theme, saved language, and build mode (development or production). It exposes no debug IPC endpoints and grants no extra native privileges.
- Interactive Park UI examples: Temporary local controls (button counter, switch, text input) wrapped in
@wailspring/docs/react ComponentPreview. Nothing in the playground writes to disk or calls native OS actions.
- Live token specimens:
ColorSwatches, TypographyScale, and SpacingScale from @wailspring/docs/react fed by @wailspring/docs metadata so you can inspect Wailspring tokens in the active desktop theme.
Native actions, updates, and browser preview
Native desktop mode (src/host/native.ts) connects the UI to OS clipboard, file dialogs, notifications, SQLite, preferences, and UpdateService. Choosing a file on Overview displays only the selected path without reading the file, and notification permissions are requested only on an explicit click.
Settings includes the App updates panel regardless of Developer mode. Local builds report updates as unconfigured and never contact GitHub. In a configured release build, Check for updates, Download update, and Restart to update (behind an inline Confirm restart step) are explicit user actions. While an operation runs, the UI polls local Go IPC status every 350ms for progress and stops polling when idle or unmounted; it never polls the remote release feed automatically. See Builds and updates.
Browser preview mode (pnpm run dev:desktop or pnpm run build:desktop) resolves #host to src/host/browser.ts. It never imports @wailsio/runtime or generated bindings, resets items and preferences on reload, and disables clipboard, file selection, notifications, and update actions with a visible preview banner.
Component workshop with Storybook
For isolated React component development and browser accessibility checks outside the desktop app, the workspace includes an optional Storybook for React & Vite app in apps/storybook/ (@wailspring/storybook), configured for Panda CSS with Storybook. It needs only Node 26 and pnpm 10.34.9—no Go, Wails, or native bindings.
# Start Storybook locally at http://127.0.0.1:6006
pnpm run storybook
# Type-check stories and Panda styles
pnpm run check:storybook
# Build the static bundle in apps/storybook/dist/
pnpm run build:storybook
# Install Playwright Chromium once, then run automated interaction + axe checks
pnpm --filter @wailspring/storybook test:install
pnpm run test:storybook
Storybook inherits designSystem: '@wailspring/ui', imports built public exports from @wailspring/ui and @wailspring/docs/react, bundles the same local fonts, and runs 17 stories across 4 theme/viewport projects (68 interaction and axe accessibility cases in light/dark at 1280×900 and 390×844). It stays separate from default pnpm run build, pnpm run check, pnpm test, and production bundles. See apps/storybook/README.md for adding stories and running the static bundle smoke test (pnpm --filter @wailspring/storybook test:static).
The desktop app ships with four views—Overview (
#/), Items (#/items), Settings (#/settings), and an opt-in Developer playground (#/developer)—backed by a Go host in native mode and an in-memory adapter in browser preview mode.Routing, queries, forms, and validation
Each frontend library owns a distinct layer while keeping Go authoritative for persisted data:
HashRouter):src/main.tsxwraps the app inHashRouteralongside Vite’s relativebase: './'(vite.config.ts), so routes resolve inside Wails’s embedded asset server and static previews without server-side URL rewrites.src/app.tsxmoves keyboard focus to the page<h1>on route changes.src/query.tscreates one app-ownedQueryClientwithnetworkMode: 'always'andretry: falsefor both queries and mutations so local Wails IPC works when the OS reports offline. Structured keys (itemsKey,settingsKey) drive targeted invalidation and cache updates.pages/items.tsxandpages/settings.tsxwireuseFormwithzodResolveragainst schemas insrc/host/contract.ts(titleSchemacounts Unicode code points1..200to match Go’s[]runevalidation;itemSchema,settingsSchema, andupdateStatusSchemaparse host responses). Frontend validation gives immediate inlineField.ErrorTextfeedback, while Go (internal/items/database.goandinternal/preferences/store.go) validates every write independently before touching SQLite orsettings.json.Saved settings and revision ordering
Preferences use schema version
1and live insettings.jsonunder the OS config directory (internal/preferences). Each record contains:schemaVersion:1revision: monotonically increasing integertheme:'system' | 'light' | 'dark'(default'system')language:'en' | 'de'(default'en')developerMode:boolean(defaultfalse)In Settings (
pages/settings.tsx), edits remain local form drafts until you click Save settings. Clicking Discard changes reverts to the last accepted host state; failed writes keep your draft visible so you can retry without changing the active appearance or language.To prevent out-of-order responses or events from reverting newer saves, both Go and React track
revision. The frontend helpernewerSettings()insrc/host/contract.tsignores any read, mutation response, orsettings:changedevent whose revision is older than or equal to the revision in TanStack Query’s cache.Patchstruct uses pointer fields (*string,*bool), so passingdeveloperMode: falseturns it off while omitted fields stay untouched. Existing schema-1 files that omitdeveloperModeload asfalse.system,en,developerMode: false) without touching SQLite items. Ifsettings.jsonis malformed, Go writes a timestamped.backup-*copy beside it before writing clean defaults. An unreadable file or failed backup reports an error and leaves recovery to you.Localization (English and German)
The desktop app bundles English (
en.json) and German (de.json) resources synchronously (initAsync: false,react: { useSuspense: false }) inapps/desktop/frontend/src/i18n/locales/usingi18nextandreact-i18next’suseTranslationhook. There is no remote loader, browser language detector, orlocalStoragecache—avoid adding HTTP backends or auto-detectors that break offline execution or bypass saved settings.languagepreference switches the UI language. Selecting another option in Settings does not change the active locale until you save (or reset back to English). Accepted changes update mounted screens,<html lang="..." dir="...">, anddocument.titletogether.en.jsondefines the canonical key shape insrc/i18n/index.ts;de.jsonmust match all keys and interpolation placeholders.validation.titleorupdates.phases.available) and callt()during render so visible banners and inline errors update when the saved language changes.@wailspring/ui,@wailspring/docs,@wailspring/icons) never importi18next. Pass translated labels and children from the desktop app (includinglightLabel,darkLabel,sample, andsourceLabelon@wailspring/docs/reactspecimens, and translated titles/bodies for OS notifications). The Astro site’s copy is independent of desktop locale files.Developer mode (
#/developer)Developer mode is off by default. Toggle Developer mode in Settings and click Save settings—unsaved draft toggles grant no access.
Once enabled, a Developer link appears in the sidebar and
#/developerlazy-loads (pages/developer.tsx), focusing its heading on navigation. Turning Developer mode off, resetting settings, or receiving a newersettings:changedevent disabling it redirects immediately to#/settings.The playground contains:
@wailspring/docs/reactComponentPreview. Nothing in the playground writes to disk or calls native OS actions.ColorSwatches,TypographyScale, andSpacingScalefrom@wailspring/docs/reactfed by@wailspring/docsmetadata so you can inspect Wailspring tokens in the active desktop theme.Native actions, updates, and browser preview
Native desktop mode (
src/host/native.ts) connects the UI to OS clipboard, file dialogs, notifications, SQLite, preferences, andUpdateService. Choosing a file on Overview displays only the selected path without reading the file, and notification permissions are requested only on an explicit click.Settings includes the App updates panel regardless of Developer mode. Local builds report updates as unconfigured and never contact GitHub. In a configured release build, Check for updates, Download update, and Restart to update (behind an inline Confirm restart step) are explicit user actions. While an operation runs, the UI polls local Go IPC status every 350ms for progress and stops polling when idle or unmounted; it never polls the remote release feed automatically. See Builds and updates.
Browser preview mode (
pnpm run dev:desktoporpnpm run build:desktop) resolves#hosttosrc/host/browser.ts. It never imports@wailsio/runtimeor generated bindings, resets items and preferences on reload, and disables clipboard, file selection, notifications, and update actions with a visible preview banner.Component workshop with Storybook
For isolated React component development and browser accessibility checks outside the desktop app, the workspace includes an optional Storybook for React & Vite app in
apps/storybook/(@wailspring/storybook), configured for Panda CSS with Storybook. It needs only Node 26 and pnpm 10.34.9—no Go, Wails, or native bindings.Storybook inherits
designSystem: '@wailspring/ui', imports built public exports from@wailspring/uiand@wailspring/docs/react, bundles the same local fonts, and runs 17 stories across 4 theme/viewport projects (68 interaction and axe accessibility cases in light/dark at1280×900and390×844). It stays separate from defaultpnpm run build,pnpm run check,pnpm test, and production bundles. Seeapps/storybook/README.mdfor adding stories and running the static bundle smoke test (pnpm --filter @wailspring/storybook test:static).