Desktop: never a blank window (frozen-prototype fix, error screens, logs, state migration, boot check)

The signed release showed only its background colour and never started the sidecar. Tauri's freezePrototype
freezes Object.prototype before the bundle runs; d3-color and d3-format (under the visx charts) assign
`constructor` / `toString` on plain objects while loading, which throws on a frozen prototype, so the bundle
stopped before React drew anything. The saved state was not the cause.

- build/freeze-safe.ts: Vite plugin that rewrites those assignments in dependencies into a helper that defines
  the property when the frozen prototype would refuse it
- error boundaries for the window, each screen and each app tab (Copy details, Reload, Reset saved state with a
  backup); public/boot.js shows the same panel when the bundle fails or the window stays empty
- logs/host.log (start, saved state, sidecar start/stop, panics) and logs/webview.log (log_webview), rotated,
  home as ~, keys, tokens and e-mail addresses replaced
- state.json `version` 2 with an explicit 1 -> 2 migration (original kept as state.json.v1.bak), per-entry
  tolerant parsing, partial settings keep their fields, unreadable files kept aside
- folders that are gone: "Folder not found" with Locate... (project_locate) / Remove; portfolio reads skip them
- tools/desktop-boot-check.ts: the built window with the release CSP and the frozen prototype, a mocked host from
  the state fixtures (empty, D1 with folders gone, D3) and the real sidecar, through every screen; in bun run ci,
  the Forgejo CI workflow and the macOS release
This commit is contained in:
CRTkafa 2026-10-11 01:36:34 +00:00
parent 209b8d0559
commit 08eb314196
45 changed files with 2080 additions and 69 deletions

View file

@ -18,7 +18,7 @@ export type { ToolStatus } from '../../../cli/lib/tools';
export interface LocalTools { tools: import('../../../cli/lib/tools').ToolStatus[] }
export interface SidecarStatus { running: boolean; version: string; protocol: string; methods: Pick<MethodDescriptor, 'method' | 'title' | 'description' | 'kind' | 'network' | 'destructive' | 'json'>[]; tools: LocalTools | null }
/** An app folder (one storebound.config.ts = one app on iOS and / or Android) and the accounts it uses. */
export interface Project { id: string; path: string; name: string; playAccount: string | null; appleAccount: string | null; added: string }
export interface Project { id: string; path: string; name: string; playAccount: string | null; appleAccount: string | null; added: string; /** The folder is gone (moved, renamed, deleted): shown as "Folder not found". */ missing?: boolean }
export type AccountKind = 'play' | 'apple';
export interface Account { id: string; label: string; kind: AccountKind; created: string; studio?: string | null }
export const STUDIO_COLORS = ['indigo', 'violet', 'rose', 'amber', 'emerald', 'teal', 'sky', 'slate'] as const;
@ -126,6 +126,12 @@ export const api = {
pickPriceSheet: (projectId: string) => invoke<string | null>('price_sheet_pick', { projectId }),
/** Shows a path of an app folder in the file manager, or opens a folder / the gallery page. */
reveal: (projectId: string, rel = '', open = false) => invoke<void>('project_reveal', { projectId, rel, open }),
/** "Locate…" for a folder that is gone: native folder picker; the same app with its new path, or null. */
locateProject: (id: string) => invoke<Project | null>('project_locate', { id }),
/** Native confirmation, then state.json is moved aside (a backup) and the app starts empty. The backup path (~) or null. */
resetState: () => invoke<string | null>('state_reset'),
/** One entry in <app data>/logs/webview.log (sanitized and rate-limited by the host). */
logWebview: (level: 'error' | 'warn' | 'info', message: string, detail?: string) => invoke<void>('log_webview', { level, message, detail: detail ?? null }),
};
export type ExportKind = 'csv' | 'md' | 'json' | 'txt';