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

@ -242,7 +242,7 @@ pub fn check_overrides(o: &Overrides) -> Result<(), String> {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "camelCase", default)]
pub struct RefreshSettings {
/// Minutes between automatic store reads; 0 = off.
pub auto_minutes: u32,
@ -254,14 +254,14 @@ pub struct RefreshSettings {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "camelCase", default)]
pub struct CacheSettings {
/// Saved reads older than this many days are dropped; 0 = keep.
pub keep_days: u32,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "camelCase", default)]
pub struct NotifySettings {
pub review_state: bool,
pub low_reviews: bool,
@ -269,7 +269,7 @@ pub struct NotifySettings {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "camelCase", default)]
pub struct Settings {
pub refresh: RefreshSettings,
pub cache: CacheSettings,
@ -278,14 +278,29 @@ pub struct Settings {
pub channel: String,
}
// Every settings struct fills a missing field with its default (`#[serde(default)]`), so a file written by an older
// build that lacks a newer setting keeps the rest.
impl Default for RefreshSettings {
fn default() -> RefreshSettings {
RefreshSettings { auto_minutes: 0, on_launch: false, parallel: 4, icons: true }
}
}
impl Default for CacheSettings {
fn default() -> CacheSettings {
CacheSettings { keep_days: 30 }
}
}
impl Default for NotifySettings {
fn default() -> NotifySettings {
NotifySettings { review_state: true, low_reviews: true, crash: true }
}
}
impl Default for Settings {
fn default() -> Settings {
Settings {
refresh: RefreshSettings { auto_minutes: 0, on_launch: false, parallel: 4, icons: true },
cache: CacheSettings { keep_days: 30 },
notify: NotifySettings { review_state: true, low_reviews: true, crash: true },
channel: "stable".into(),
}
Settings { refresh: RefreshSettings::default(), cache: CacheSettings::default(), notify: NotifySettings::default(), channel: "stable".into() }
}
}