From 08eb314196a0d6b2feef3682c0fa648a7168b525 Mon Sep 17 00:00:00 2001 From: CRT Date: Sun, 11 Oct 2026 01:36:34 +0000 Subject: [PATCH] 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 --- .forgejo/workflows/ci.yml | 4 +- CHANGELOG.md | 12 + apps/desktop/build/freeze-safe.ts | 68 ++++ apps/desktop/index.html | 2 + apps/desktop/public/boot.js | 132 ++++++++ apps/desktop/src-tauri/capabilities/main.json | 5 +- .../autogenerated/log_webview.toml | 11 + .../autogenerated/project_locate.toml | 11 + .../autogenerated/state_reset.toml | 11 + apps/desktop/src-tauri/src/commands.rs | 115 ++++++- apps/desktop/src-tauri/src/commands_list.rs | 3 + apps/desktop/src-tauri/src/lib.rs | 19 +- apps/desktop/src-tauri/src/logs.rs | 213 +++++++++++++ apps/desktop/src-tauri/src/sidecar.rs | 32 +- apps/desktop/src-tauri/src/store.rs | 173 +++++++++- apps/desktop/src-tauri/src/workspace.rs | 35 ++- apps/desktop/src-tauri/tests/state.rs | 201 ++++++++++++ apps/desktop/src/App.tsx | 30 +- apps/desktop/src/api.ts | 8 +- apps/desktop/src/dev/fixtures.ts | 3 + apps/desktop/src/i18n/en.ts | 24 ++ apps/desktop/src/i18n/tr.ts | 24 ++ apps/desktop/src/lib/crash.ts | 77 +++++ apps/desktop/src/lib/normalize.ts | 68 ++++ apps/desktop/src/main.tsx | 14 +- apps/desktop/src/screens/AppFolders.tsx | 18 +- apps/desktop/src/screens/AppView.tsx | 29 +- apps/desktop/src/screens/Portfolio.tsx | 6 +- apps/desktop/src/store.tsx | 20 +- apps/desktop/src/styles.css | 11 + apps/desktop/src/ui/ErrorBoundary.tsx | 61 ++++ apps/desktop/src/ui/FolderMissing.tsx | 42 +++ apps/desktop/tests/fixtures/state/README.txt | 8 + .../state/d1-missing-folders.host.json | 48 +++ .../fixtures/state/d1-missing-folders.json | 21 ++ .../tests/fixtures/state/d3-full.host.json | 92 ++++++ .../desktop/tests/fixtures/state/d3-full.json | 28 ++ .../tests/fixtures/state/empty.host.json | 31 ++ apps/desktop/tests/fixtures/state/empty.json | 1 + apps/desktop/tests/resilience.test.ts | 92 ++++++ apps/desktop/vite.config.ts | 4 +- docs/desktop.md | 30 ++ tools/ci.ts | 6 +- tools/desktop-boot-check.ts | 295 ++++++++++++++++++ tools/desktop-release.ts | 11 +- 45 files changed, 2080 insertions(+), 69 deletions(-) create mode 100644 apps/desktop/build/freeze-safe.ts create mode 100644 apps/desktop/public/boot.js create mode 100644 apps/desktop/src-tauri/permissions/autogenerated/log_webview.toml create mode 100644 apps/desktop/src-tauri/permissions/autogenerated/project_locate.toml create mode 100644 apps/desktop/src-tauri/permissions/autogenerated/state_reset.toml create mode 100644 apps/desktop/src-tauri/src/logs.rs create mode 100644 apps/desktop/src-tauri/tests/state.rs create mode 100644 apps/desktop/src/lib/crash.ts create mode 100644 apps/desktop/src/lib/normalize.ts create mode 100644 apps/desktop/src/ui/ErrorBoundary.tsx create mode 100644 apps/desktop/src/ui/FolderMissing.tsx create mode 100644 apps/desktop/tests/fixtures/state/README.txt create mode 100644 apps/desktop/tests/fixtures/state/d1-missing-folders.host.json create mode 100644 apps/desktop/tests/fixtures/state/d1-missing-folders.json create mode 100644 apps/desktop/tests/fixtures/state/d3-full.host.json create mode 100644 apps/desktop/tests/fixtures/state/d3-full.json create mode 100644 apps/desktop/tests/fixtures/state/empty.host.json create mode 100644 apps/desktop/tests/fixtures/state/empty.json create mode 100644 apps/desktop/tests/resilience.test.ts create mode 100644 tools/desktop-boot-check.ts diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index f029acf2..4014e849 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -1,5 +1,5 @@ # bun run ci on every push to main and every pull request into main: adapters, desktop version, tests, typecheck, -# desktop i18n / typecheck / build, desktop Rust tests and clippy, scrub. Runs on the VDS runner (docs/desktop-release.md). +# desktop i18n / typecheck / build, desktop boot check (headless Chromium), desktop Rust tests and clippy, scrub. Runs on the VDS runner (docs/desktop-release.md). # Publishes nothing: site/ is still published by Jenkins. name: ci @@ -52,5 +52,7 @@ jobs: rustup component add clippy bun --version && cargo --version bun install --frozen-lockfile + - name: Headless Chromium (desktop boot check) + run: bunx playwright install --with-deps chromium - name: bun run ci run: bun run ci diff --git a/CHANGELOG.md b/CHANGELOG.md index 12ad196d..3555958a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ## Unreleased +- Desktop: the signed release showed only its background colour and never started the sidecar. Cause: Tauri's + `freezePrototype` freezes `Object.prototype` before the bundle runs, and d3-color / d3-format (under the visx charts) + assign `constructor` / `toString` on plain objects while loading, which throws on a frozen prototype; the bundle + stopped before React drew anything. Saved state was not the cause. A Vite plugin (`apps/desktop/build/freeze-safe.ts`) + makes those assignments safe. So the window is never blank again: error boundaries for the whole window and each + screen and tab (Copy details, Reload, Reset saved state with a backup), `public/boot.js` for a bundle that fails to + load, `logs/host.log` and `logs/webview.log` in the app data folder (rotated, home as `~`, no keys or e-mail + addresses), a versioned `state.json` with an explicit migration from the D1-D3 format (original kept as + `state.json.v1.bak`; broken entries dropped one by one), "Folder not found" with Locate… / Remove for app folders + that are gone, and a boot check in CI and the macOS release (`tools/desktop-boot-check.ts`: the built window with the + release CSP and the frozen prototype on empty, D1 and D3 saved states). + - Icons: Phosphor replaces lucide (desktop: `@phosphor-icons/react` per-icon imports, "regular" weight, "fill" for the active nav item and notices; site and fixture art: Phosphor's own files). Store marks are now the real App Store and Google Play logos from simple-icons, in the neutral text colour next to the store's name; the trademark note is in diff --git a/apps/desktop/build/freeze-safe.ts b/apps/desktop/build/freeze-safe.ts new file mode 100644 index 00000000..f6460863 --- /dev/null +++ b/apps/desktop/build/freeze-safe.ts @@ -0,0 +1,68 @@ +// Tauri's `freezePrototype: true` (tauri.conf.json) runs Object.freeze(Object.prototype) before any page script. In +// strict code, assigning a property that an object only inherits from the frozen Object.prototype (`constructor`, +// `toString`, ...) then throws "Cannot assign to read only property": the JavaScript "override mistake". d3-color and +// d3-format (under @visx/scale) do exactly that while their modules load, so the bundle stopped before React rendered +// anything and the release window showed only its background colour. +// +// This plugin rewrites every `x.constructor = v`, `x.toString = v`, ... in dependencies into a call that does the same +// assignment and, only when that assignment hits the frozen prototype, defines the property on `x` itself instead +// (Object.defineProperty is allowed there). The release boot check (tools/desktop-boot-check.ts) loads the built +// bundle with the prototype frozen, as Tauri does, and fails on any uncaught error. +import type { Plugin } from 'vite'; + +/** The writable data properties of Object.prototype that freezing turns read-only for every plain object. */ +export const FROZEN_NAMES = ['constructor', 'toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable'] as const; +const QUICK = new RegExp(`\\.(?:${FROZEN_NAMES.join('|')})\\s*=(?!=)`); +export const HELPER = '__storeboundFreezeSafeSet'; +// Appended (function declarations hoist), so a leading "use strict" directive stays first. Works in strict and sloppy +// code: when `k` is only inherited from a frozen (read-only) data property, define it on `o`; otherwise assign. +const HELPER_SRC = `\nfunction ${HELPER}(o, k, v) { if (o !== null && (typeof o === 'object' || typeof o === 'function') && !Object.prototype.hasOwnProperty.call(o, k)) { for (var p = Object.getPrototypeOf(o); p !== null; p = Object.getPrototypeOf(p)) { var d = Object.getOwnPropertyDescriptor(p, k); if (!d) continue; if ('value' in d && !d.writable) { Object.defineProperty(o, k, { value: v, writable: true, enumerable: true, configurable: true }); return v; } break; } } o[k] = v; return v; }\n`; + +interface Node { type: string; start: number; end: number; [k: string]: unknown } + +function walk(node: unknown, visit: (n: Node) => void): void { + if (!node || typeof node !== 'object') return; + if (Array.isArray(node)) { for (const n of node) walk(n, visit); return; } + const n = node as Node; + if (typeof n.type === 'string') visit(n); + for (const k of Object.keys(n)) if (k !== 'type' && k !== 'start' && k !== 'end') walk(n[k], visit); +} + +/** Rewrites the assignments in one module's code; null when there is nothing to change. */ +export function rewrite(code: string, parse: (code: string) => unknown): string | null { + if (!QUICK.test(code)) return null; + const edits: { start: number; end: number; text: (inner: (s: number, e: number) => string) => string }[] = []; + walk(parse(code), n => { + if (n.type !== 'AssignmentExpression' || n.operator !== '=') return; + const left = n.left as Node & { object: Node; property: Node & { name?: string }; computed: boolean; optional?: boolean }; + if (left.type !== 'MemberExpression' || left.computed || left.object.type === 'Super') return; + if (!(FROZEN_NAMES as readonly string[]).includes(left.property.name ?? '')) return; + const right = n.right as Node; + edits.push({ start: n.start, end: n.end, text: inner => `${HELPER}(${inner(left.object.start, left.object.end)}, ${JSON.stringify(left.property.name)}, ${inner(right.start, right.end)})` }); + }); + if (!edits.length) return null; + // outermost edits only carry their inner text through `inner`, which applies nested edits recursively + edits.sort((a, b) => a.start - b.start || b.end - a.end); + const render = (s: number, e: number): string => { + let out = '', at = s; + for (const ed of edits) { + if (ed.start < at || ed.end > e || ed.start < s) continue; + out += code.slice(at, ed.start) + ed.text(render); + at = ed.end; + } + return out + code.slice(at, e); + }; + return render(0, code.length) + HELPER_SRC; +} + +export function freezeSafe(): Plugin { + return { + name: 'storebound-freeze-safe', + transform(code, id) { + const file = id.split('?')[0]!; + if (!/node_modules/.test(file) || !/\.(?:m?js|cjs)$/.test(file)) return null; + const out = rewrite(code, c => this.parse(c)); + return out === null ? null : { code: out, map: null }; + }, + }; +} diff --git a/apps/desktop/index.html b/apps/desktop/index.html index 3036910d..a1ca5d88 100644 --- a/apps/desktop/index.html +++ b/apps/desktop/index.html @@ -6,6 +6,8 @@ storebound + +
diff --git a/apps/desktop/public/boot.js b/apps/desktop/public/boot.js new file mode 100644 index 00000000..7aca3800 --- /dev/null +++ b/apps/desktop/public/boot.js @@ -0,0 +1,132 @@ +// storebound desktop: the first script of the window (a plain script, loaded before the app bundle; CSP allows only +// files of the app). If the bundle fails to load or React never draws (or later unmounts after an error no boundary +// caught), the window would show nothing but its background colour. This shows a plain error panel instead, with +// Copy details, Reload and Reset saved state (keeps a backup), and sends the error to logs/webview.log through the +// app's `log_webview` command until src/lib/crash.ts takes over. No framework, no strings from the network. +(function () { + 'use strict'; + var errors = []; + var shown = false; + + function invoke(cmd, args) { + try { + var i = window.__TAURI_INTERNALS__; + if (i && typeof i.invoke === 'function') return Promise.resolve(i.invoke(cmd, args || {})).catch(function () { return null; }); + } catch (e) { /* no host */ } + return Promise.resolve(null); + } + function text(e) { + if (!e) return 'unknown error'; + if (e instanceof Error) return e.name + ': ' + e.message; + if (typeof e === 'string') return e; + if (typeof e.message === 'string') return e.message; + try { return JSON.stringify(e); } catch (x) { return String(e); } + } + function root() { return document.getElementById('root'); } + function blank() { var r = root(); return !r || r.childElementCount === 0; } + function booted() { return document.documentElement.getAttribute('data-booted') === '1'; } + + function record(where, e, stack) { + var msg = text(e); + var entry = where + ': ' + msg + (stack ? '\n' + stack : ''); + errors.push(entry); + if (errors.length > 20) errors.shift(); + // src/lib/crash.ts logs once the bundle is running; before that, this does + if (!window.__storeboundCrashHandlers) invoke('log_webview', { level: 'error', message: where + ': ' + msg, detail: stack || null }); + // after start: at once; while starting, give React a moment (a non-fatal start error does not blank the window) + setTimeout(check, booted() ? 60 : 1500); + } + + function el(tag, cls, txt) { + var n = document.createElement(tag); + if (cls) n.className = cls; + if (txt) n.textContent = txt; + return n; + } + + function show(title, lead) { + if (shown) return; + shown = true; + var detail = 'storebound desktop · ' + (booted() ? 'after start' : 'during start') + ' · ' + new Date().toISOString() + '\n' + + (navigator.userAgent || '') + '\n\n' + (errors.length ? errors.join('\n\n') : 'No error was reported: the window stayed empty.'); + var host = root() || document.body; + while (host.firstChild) host.removeChild(host.firstChild); + var wrap = el('div', 'crash crash-full'); + wrap.id = 'boot-fallback'; + wrap.setAttribute('role', 'alert'); + wrap.setAttribute('data-crash', 'boot'); + var box = el('div', 'crash-box'); + box.appendChild(el('h2', '', title)); + box.appendChild(el('p', '', lead)); + box.appendChild(el('pre', 'crash-msg selectable', errors.length ? errors[errors.length - 1].split('\n')[0] : 'The window stayed empty.')); + var det = el('details'); + det.appendChild(el('summary', '', 'Details')); + det.appendChild(el('pre', 'crash-detail selectable', detail)); + box.appendChild(det); + var note = el('p', 'small muted'); + note.setAttribute('role', 'status'); + var actions = el('div', 'actions'); + var copy = el('button', 'btn', 'Copy details'); + copy.onclick = function () { + var done = function (ok) { note.textContent = ok ? 'Details copied.' : 'Could not copy: select the details and copy them by hand.'; }; + try { + navigator.clipboard.writeText(detail).then(function () { done(true); }, function () { done(fallbackCopy(detail)); }); + } catch (e) { done(fallbackCopy(detail)); } + }; + var reload = el('button', 'btn btn-primary', 'Reload'); + reload.onclick = function () { location.reload(); }; + var reset = el('button', 'btn btn-ghost', 'Reset saved state (keeps a backup)'); + reset.title = 'Starts with an empty list. The saved state is kept as a backup file, store keys stay in the keychain, app folders are not touched.'; + reset.onclick = function () { + invoke('state_reset').then(function (backup) { + if (backup === null || backup === undefined) return; + note.textContent = 'Saved state reset. Backup: ' + (backup || '-') + '. Reloading…'; + setTimeout(function () { location.reload(); }, 1200); + }); + }; + actions.appendChild(copy); + actions.appendChild(reload); + actions.appendChild(reset); + box.appendChild(actions); + box.appendChild(note); + box.appendChild(el('p', 'small muted', 'Also written to logs/webview.log in the app data folder (home folder shown as ~, no keys).')); + wrap.appendChild(box); + host.appendChild(wrap); + } + + function fallbackCopy(s) { + try { + var ta = el('textarea', 'sr'); + ta.value = s; + document.body.appendChild(ta); + ta.select(); + var ok = document.execCommand('copy'); + ta.remove(); + return ok; + } catch (e) { return false; } + } + + function check() { + if (shown || !blank() || !document.body) return; + if (booted()) show('storebound hit an error', 'The window was closed by an error. Your app folders, store keys and saved data are untouched. Reload usually fixes it; if it keeps happening, copy the details into a bug report.'); + else if (errors.length) show('storebound could not start', 'The window failed while starting. Your app folders, store keys and saved data are untouched. Reload, or reset the saved state if it keeps happening, and copy the details into a bug report.'); + } + + window.addEventListener('error', function (ev) { + // a script or stylesheet that failed to load has no ev.error + var t = ev.target; + if (t && t !== window && (t.src || t.href)) { record('load', 'could not load ' + (t.src || t.href)); return; } + record('window.onerror', ev.error || ev.message, ev.error && ev.error.stack); + }, true); + window.addEventListener('unhandledrejection', function (ev) { + if (!booted()) record('unhandledrejection', ev.reason, ev.reason && ev.reason.stack); + }); + // React's root reports an error no boundary caught (the tree is gone) here: src/main.tsx onUncaughtError + window.__storeboundBlank = function (message, stack) { record('react', message, stack); }; + // nothing drawn and nothing reported after a while: still say so + window.addEventListener('load', function () { + setTimeout(function () { + if (!booted() && blank()) { errors.push('start: the window was still empty 15 s after loading'); invoke('log_webview', { level: 'error', message: 'start: the window was still empty 15 s after loading', detail: null }); show('storebound could not start', 'The window stayed empty while starting. Your app folders, store keys and saved data are untouched. Reload, or reset the saved state if it keeps happening, and copy the details into a bug report.'); } + }, 15000); + }); +})(); diff --git a/apps/desktop/src-tauri/capabilities/main.json b/apps/desktop/src-tauri/capabilities/main.json index 300d2a21..b2f6d41c 100644 --- a/apps/desktop/src-tauri/capabilities/main.json +++ b/apps/desktop/src-tauri/capabilities/main.json @@ -49,6 +49,9 @@ "allow-project-import-fastlane", "allow-export-save", "allow-price-sheet-pick", - "allow-project-reveal" + "allow-project-reveal", + "allow-project-locate", + "allow-state-reset", + "allow-log-webview" ] } diff --git a/apps/desktop/src-tauri/permissions/autogenerated/log_webview.toml b/apps/desktop/src-tauri/permissions/autogenerated/log_webview.toml new file mode 100644 index 00000000..003cb607 --- /dev/null +++ b/apps/desktop/src-tauri/permissions/autogenerated/log_webview.toml @@ -0,0 +1,11 @@ +# Automatically generated - DO NOT EDIT! + +[[permission]] +identifier = "allow-log-webview" +description = "Enables the log_webview command without any pre-configured scope." +commands.allow = ["log_webview"] + +[[permission]] +identifier = "deny-log-webview" +description = "Denies the log_webview command without any pre-configured scope." +commands.deny = ["log_webview"] diff --git a/apps/desktop/src-tauri/permissions/autogenerated/project_locate.toml b/apps/desktop/src-tauri/permissions/autogenerated/project_locate.toml new file mode 100644 index 00000000..b7ecf480 --- /dev/null +++ b/apps/desktop/src-tauri/permissions/autogenerated/project_locate.toml @@ -0,0 +1,11 @@ +# Automatically generated - DO NOT EDIT! + +[[permission]] +identifier = "allow-project-locate" +description = "Enables the project_locate command without any pre-configured scope." +commands.allow = ["project_locate"] + +[[permission]] +identifier = "deny-project-locate" +description = "Denies the project_locate command without any pre-configured scope." +commands.deny = ["project_locate"] diff --git a/apps/desktop/src-tauri/permissions/autogenerated/state_reset.toml b/apps/desktop/src-tauri/permissions/autogenerated/state_reset.toml new file mode 100644 index 00000000..368381b0 --- /dev/null +++ b/apps/desktop/src-tauri/permissions/autogenerated/state_reset.toml @@ -0,0 +1,11 @@ +# Automatically generated - DO NOT EDIT! + +[[permission]] +identifier = "allow-state-reset" +description = "Enables the state_reset command without any pre-configured scope." +commands.allow = ["state_reset"] + +[[permission]] +identifier = "deny-state-reset" +description = "Denies the state_reset command without any pre-configured scope." +commands.deny = ["state_reset"] diff --git a/apps/desktop/src-tauri/src/commands.rs b/apps/desktop/src-tauri/src/commands.rs index 741eebb4..ba3564d3 100644 --- a/apps/desktop/src-tauri/src/commands.rs +++ b/apps/desktop/src-tauri/src/commands.rs @@ -321,10 +321,57 @@ pub async fn write_with_confirm(window: WebviewWindow, app: AppHandle, state: St Ok(json!({ "confirmed": true, "stage": "done", "dryRun": dry, "result": result })) } +/// An app folder as the window sees it: `missing` when the folder is gone (moved, renamed, deleted, or an old +/// worktree), so the app shows "Folder not found" with Locate / Remove instead of reading it. +#[derive(Debug, Clone, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ProjectView { + #[serde(flatten)] + pub project: Project, + pub missing: bool, +} + +pub fn project_view(p: &Project) -> ProjectView { + ProjectView { project: p.clone(), missing: !Path::new(&p.path).is_dir() } +} + #[tauri::command] -pub fn projects_list(window: WebviewWindow, state: State<'_, AppState>) -> Res> { +pub fn projects_list(window: WebviewWindow, state: State<'_, AppState>) -> Res> { guard(&window)?; - Ok(saved(&state)?.projects.clone()) + Ok(saved(&state)?.projects.iter().map(project_view).collect()) +} + +/// "Locate…" for a folder that moved: native folder picker; the folder must hold a storebound.config.ts and not be in +/// the list already. Keeps the app's id, accounts, links and saved reads. None = cancelled. +#[tauri::command] +pub async fn project_locate(window: WebviewWindow, app: AppHandle, state: State<'_, AppState>, id: String) -> Res> { + guard(&window)?; + if !saved(&state)?.projects.iter().any(|p| p.id == id) { + return Err(Fail::host("unknown project")); + } + let Some(dir) = pick_folder(&window, "Locate the app folder (with storebound.config.ts)").await? else { return Ok(None) }; + if !has_config(&dir) { + return Err(Fail::host(format!("no storebound.config.ts in {}", dir.display()))); + } + let path = dir.to_string_lossy().to_string(); + // the app's name from its config when the sidecar can read it; the old name otherwise + let name = match state.sidecar.get(&app).await { + Ok(r) => r.call("project.inspect", json!({ "project": path })).await.ok().and_then(|v| v["name"].as_str().map(str::to_string)), + Err(_) => None, + }; + let mut st = saved(&state)?; + if st.projects.iter().any(|p| p.path == path && p.id != id) { + return Err(Fail::host("this folder is already in the list")); + } + let p = st.projects.iter_mut().find(|p| p.id == id).ok_or_else(|| Fail::host("unknown project"))?; + p.path = path; + if let Some(n) = name.filter(|n| !n.trim().is_empty()) { + p.name = n; + } + let view = project_view(p); + persist(&state, &st)?; + crate::logs::host("info", &format!("app folder located: {}", view.project.path)); + Ok(Some(view)) } const CONFIG_NAMES: [&str; 3] = ["storebound.config.ts", "storebound.config.js", "storebound.config.json"]; @@ -671,7 +718,9 @@ pub async fn portfolio_status(window: WebviewWindow, app: AppHandle, state: Stat let (projects, parallel) = { let st = saved(&state)?; let ignored: Vec<&str> = st.overrides.ignored.iter().filter_map(|i| i.strip_prefix("project:")).collect(); - (st.projects.iter().filter(|p| !ignored.contains(&p.id.as_str())).cloned().collect::>(), st.settings.refresh.parallel.clamp(1, 8) as usize) + // folders that are gone are skipped (the window shows them as "Folder not found") + let projects = st.projects.iter().filter(|p| !ignored.contains(&p.id.as_str()) && Path::new(&p.path).is_dir()).cloned().collect::>(); + (projects, st.settings.refresh.parallel.clamp(1, 8) as usize) }; // store-only apps (live reads only): validated targets with their accounts' credentials let mut targets = Vec::new(); @@ -1026,6 +1075,66 @@ pub async fn app_reset(window: WebviewWindow, state: State<'_, AppState>) -> Res Ok(true) } +/// "Reset saved state" of the error screen: after a native confirmation, state.json is moved aside as +/// `state.json.reset-