Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Uninstall react renderer (#2927)
sarah2c62265cb89c
diff --git a/.changeset/uninstall-react-renderer.md b/.changeset/uninstall-react-renderer.mdnew file mode 100644index 000000000..04e0557ab--- /dev/null+++ b/.changeset/uninstall-react-renderer.md@@ -0,0 +1,5 @@+---+'@inkeep/open-knowledge': patch+---++The macOS uninstall flow now renders as a real part of the app instead of bare system-styled windows. The picker, survey, progress, and confirm/completion/failure screens are a dedicated React surface that loads the same typography, components, and light/dark theme as the editor, so uninstalling looks and behaves like the rest of OpenKnowledge. Screen order and survey timing are unchanged, as is the survey, progress, and notice copy. The picker's copy and selection controls were reworked to fit the new layout: the description now names the project selection, its two Select all / Select none buttons became one tri-state select-all checkbox in the list header, and the footer "N projects selected" count became a selected-of-total fraction beside it (keyboard Cmd/Ctrl+A select-all carries over).diff --git a/biome-plugins/README.md b/biome-plugins/README.mdindex df01e34ea..92d54dad0 100644--- a/biome-plugins/README.md+++ b/biome-plugins/README.md@@ -2,7 +2,7 @@Custom lint rules for this workspace, registered in [`biome.jsonc`](../biome.jsonc) at the top-level `plugins` array (workspace-wide) OR a scoped `overrides[].plugins` entry (file-specific — used when the rule's invariant only applies to a known subset of files). Each `.grit` file is a single GritQL pattern (or `or { ... }` of patterns) emitting diagnostics via `register_diagnostic()`.-Plugins surface as lint errors during `biome check` (i.e. `bun run lint` and `bun run check`) and as inline editor squiggles via the Biome LSP.+Plugins surface as lint errors during `biome check` (i.e. `pnpm lint` and `pnpm check`) and as inline editor squiggles via the Biome LSP.## Convention@@ -38,7 +38,7 @@ Test: [`packages/desktop/tests/integration/no-loosely-typed-webcontents-ipc.test### `no-raw-html-interactive-element.grit`-UI primitives discipline. Forbids raw JSX `<button>`, `<input>`, `<textarea>`, `<select>` inside production `.tsx` under `packages/{app,desktop,plugin}/src/**`. Consumers must use the shadcn primitives (`Button`, `Input`, `Textarea`, `Select`) from `@/components/ui/*`; if the primitive isn't installed yet, add it via `bunx --bun shadcn@latest add <name>` first. The rule catches the PR #937 failure mode: contributors (including Codex / Claude Code / human reviewers) introducing raw `<button>` JSX while a shadcn `<Button>` from `@/components/ui/button` was already imported in the same file.+UI primitives discipline. Forbids raw JSX `<button>`, `<input>`, `<textarea>`, `<select>` inside production `.tsx` under `packages/{app,desktop,plugin}/src/**`. Consumers must use the shadcn primitives (`Button`, `Input`, `Textarea`, `Select`) from `@/components/ui/*`; if the primitive isn't installed yet, add it via `pnpm dlx shadcn@latest add <name>` first. The rule catches the PR #937 failure mode: contributors (including Codex / Claude Code / human reviewers) introducing raw `<button>` JSX while a shadcn `<Button>` from `@/components/ui/button` was already imported in the same file.**Scoped via `overrides[].plugins`** to `packages/{app,desktop,plugin}/src/**/*.tsx`. Exemptions encoded as negative `!`-globs in the same `includes[]`:@@ -71,7 +71,7 @@ Test: [`packages/desktop/tests/integration/no-resolved-value-theme-source.test.tH6 cross-doc DOM bleed contract. `@tiptap/react`'s `PureEditorContent.componentDidMount` runs `element.append(...editor.view.dom.parentNode.childNodes)` — a sibling-vacuum primitive. When `view.dom` shares a parent with another editor's `view.dom` (e.g., V2 cache parked nodes, cross-Activity reconciliation transitions), the vacuum drags foreign content into the active wrapper. The structural fix is to render every `<EditorContent>` via `React.createPortal` into a per-Activity exclusively-owned DOM target, so `view.dom`'s parent only ever contains THIS editor's nodes.-The rule flags every JSX usage of `<EditorContent>` — both self-closing and child-bearing forms — and asks the author to suppress at the canonical portaled site (where the createPortal call lives) with `// biome-ignore lint/plugin/no-unportaled-editor-content: <reason>`. Adding a non-portaled `<EditorContent>` anywhere else in the codebase becomes a lint error, gated at editor-save / `bun run lint` time.+The rule flags every JSX usage of `<EditorContent>` — both self-closing and child-bearing forms — and asks the author to suppress at the canonical portaled site (where the createPortal call lives) with `// biome-ignore lint/plugin/no-unportaled-editor-content: <reason>`. Adding a non-portaled `<EditorContent>` anywhere else in the codebase becomes a lint error, gated at editor-save / `pnpm lint` time.Canonical sanctioned shape (TiptapEditor.tsx):@@ -84,6 +84,18 @@ createPortal(Plugin: [`biome-plugins/no-unportaled-editor-content.grit`](no-unportaled-editor-content.grit). Fixture: [`biome-plugins/__fixtures__/no-unportaled-editor-content.fixture.tsx`](__fixtures__/no-unportaled-editor-content.fixture.tsx). Test: [`packages/app/tests/integration/no-unportaled-editor-content.test.ts`](../packages/app/tests/integration/no-unportaled-editor-content.test.ts). See [PRECEDENTS.md #44](../PRECEDENTS.md) for the H6 cross-doc DOM bleed contract and [PRECEDENTS.md #42](../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the GritQL-plugin convention.+### `no-uninstall-forbidden-import.grit`++"Connects to nothing" first-hop feedback. The self-uninstall window's survey and completion screens render after `ok uninstall --yes` has stopped the local Hocuspocus server and removed `~/.ok`, so the uninstall entry must never reach the editor, the CRDT stack, the provider pool, or the server bootstrap — and must eager-load (no dynamic `import()`) so those screens paint from memory once teardown is under way.++Scoped via `overrides[].plugins` to `packages/app/src/uninstall/**` (test files exempt — a dom test legitimately does `await import('./main')` to prove the entry paints). Two diagnostics:+- A static import (`import … from`, `import type … from`, `import * as … from`, or side-effect `import`) whose source is an editor / CRDT / provider-pool / Hocuspocus-server specifier (`@/editor/*`, `@inkeep/open-knowledge-server`, `@hocuspocus/*`, `yjs`, `y-protocols`, `y-prosemirror`, `y-codemirror.next`, `y-indexeddb`, `@tiptap/y-tiptap`, `@tiptap/extension-collaboration*`). `@inkeep/open-knowledge-core` (shared types + constants) is deliberately allowed.+- Any dynamic `import()`.++This rule is **shallow, first-hop feedback only**. The authoritative gate is the transitive-module-graph test at [`packages/desktop/tests/unit/uninstall-module-graph.test.ts`](../packages/desktop/tests/unit/uninstall-module-graph.test.ts), which builds the entry alone and checks its whole loaded-module set — so it also catches a forbidden module reached indirectly through a shared `@/lib` / `@/components/ui` module, and re-export (`export … from`) edges GritQL cannot express.++Plugin: [`biome-plugins/no-uninstall-forbidden-import.grit`](no-uninstall-forbidden-import.grit). Fixture: [`biome-plugins/__fixtures__/no-uninstall-forbidden-import.fixture.tsx`](__fixtures__/no-uninstall-forbidden-import.fixture.tsx). Test: [`packages/desktop/tests/integration/no-uninstall-forbidden-import.test.ts`](../packages/desktop/tests/integration/no-uninstall-forbidden-import.test.ts). See [PRECEDENTS.md #42](../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the GritQL-plugin convention.+### `path-conditional-map-driven-origin.grit`Observer A origin discipline. Inside `packages/server/src/server-observers.ts`, every `Y.Doc.transact()` call MUST pass the sanctioned origin `OBSERVER_SYNC_ORIGIN` as its second argument (`doc.transact(fn, OBSERVER_SYNC_ORIGIN)`). Bare `doc.transact(fn)` - or a wrong origin - routes the write to `openknowledge-service` and breaks per-session UndoManager attribution (the `trackedOrigins` Set-identity match skips the transaction).@@ -247,6 +259,7 @@ Current production suppressions:- `no-resolved-value-theme-source`: 0 sites- `no-roundtrip-identity-oracle`: 0 sites- `no-inline-tolerance-class`: 0 sites+- `no-uninstall-forbidden-import`: 0 sites## Adding a new plugin@@ -291,14 +304,14 @@ Place at `biome-plugins/__fixtures__/<rule-name>.fixture.tsx`. **Pair positive c- 1+ positive case per pattern branch the rule has- 2-4 negative cases that resemble positive ones but should NOT fire (adjacent methods on the same objects, type declarations, unrelated functions with the same name)-The main `bun run lint` does NOT reach the `biome-plugins/` directory (lint paths are `packages docs *.json *.jsonc *.ts`), so the deliberately-bad fixture content is invisible to the main lint.+The main `pnpm lint` does NOT reach the `biome-plugins/` directory (lint paths are `packages docs *.json *.jsonc *.ts`), so the deliberately-bad fixture content is invisible to the main lint.### 4. Author the fixture-file testPlace at `packages/<host>/tests/<scope>/<rule-name>.test.ts` where `<host>` matches the package whose code the rule mainly targets. For `<scope>`: use `lint-plugins/` when `<host>` is `app` (`packages/app/tests/integration/` is in `md-audit`'s `DEFAULT_TEST_GLOBS` and requires `@covers-surface` / `@covers-construct` JSDoc tags scoped to markdown editor surfaces that don't apply to lint-plugin tests), and use `integration/` for all other hosts (`desktop`, `plugin`). Template:```ts-import { describe, expect, test } from 'bun:test';+import { describe, expect, test } from 'vitest';import { spawnSync } from 'node:child_process';import { join } from 'node:path';@@ -308,7 +321,7 @@ const FIXTURE_REL = 'biome-plugins/__fixtures__/<rule-name>.fixture.tsx';describe('<rule-name> GritQL plugin', () => {test('fires on exactly N positive cases (and on no negative case)', () => {- const result = spawnSync('bunx', ['biome', 'check', FIXTURE_REL], {+ const result = spawnSync('pnpm', ['exec', 'biome', 'check', FIXTURE_REL], {cwd: REPO_ROOT,encoding: 'utf-8',});@@ -345,10 +358,10 @@ The "plugin is registered" test catches the failure mode where a `.grit` file iscd public/open-knowledge# 1. Plugin loads + lint stays clean (after suppression comments at legitimate sites):-bun run lint+pnpm lint# 2. Fixture test fires the diagnostic on positive cases:-bun test packages/<host>/tests/integration/<rule-name>.test.ts+pnpm exec vitest run packages/<host>/tests/integration/<rule-name>.test.ts# 3. Mutation check (manual, one-time during dev):# Temporarily break the .grit pattern; re-run the test; confirm it FAILS;diff --git a/biome-plugins/__fixtures__/no-uninstall-forbidden-import.fixture.tsx b/biome-plugins/__fixtures__/no-uninstall-forbidden-import.fixture.tsxnew file mode 100644index 000000000..297ace212--- /dev/null+++ b/biome-plugins/__fixtures__/no-uninstall-forbidden-import.fixture.tsx@@ -0,0 +1,65 @@+// FIXTURE — drives `no-uninstall-forbidden-import.test.ts` via shell-out to+// `biome check`. Not part of the main lint (lives outside the lint command's+// path list).+//+// Thirteen positive cases (deliberate violations — plugin must fire): one per+// forbidden specifier across every import shape (named / default / namespace /+// type / side-effect / subpath) plus a dynamic import. Paired with negative+// cases (clean usage that must NOT fire), including the allowed core package and+// the plain markdown-render prosemirror/@tiptap libs. Exact-equality (`toBe(13)`)+// in the test catches both false-negative regressions (drop below 13) and+// false-positive widenings (above 13).++// === Positive cases — must fire ===++import { DocumentContext } from '@/editor/DocumentContext'; // editor, named+import '@/editor/provider-pool'; // editor, side-effect+import { HocuspocusProvider } from '@hocuspocus/provider'; // hocuspocus, named+import type { AuthRejectionReason } from '@inkeep/open-knowledge-server'; // server, type-only+import { ySyncPlugin } from '@tiptap/y-tiptap'; // CRDT binding, named+import { yCollab } from 'y-codemirror.next'; // CRDT, named+import { IndexeddbPersistence } from 'y-indexeddb'; // CRDT, named+import yProsemirror from 'y-prosemirror'; // CRDT, default+import { Awareness } from 'y-protocols/awareness'; // CRDT, subpath+import * as Y from 'yjs'; // CRDT, namespace+import '@tiptap/extension-collaboration'; // CRDT extension, side-effect+import { CollaborationCursor } from '@tiptap/extension-collaboration-cursor'; // CRDT extension, named++// === Negative cases — must NOT fire ===++import type { UninstallScreenSpec } from '@inkeep/open-knowledge-core'; // shared types — allowed+import { UNINSTALL_FEEDBACK_REASONS } from '@inkeep/open-knowledge-core'; // shared constants — allowed+import { getSchema } from '@tiptap/core'; // plain markdown-render tiptap — not collab+import { EditorView } from 'prosemirror-view'; // plain markdown-render prosemirror — not collab+import React from 'react'; // allowed+import notYjs from 'yjs-not-real'; // must NOT prefix-match the exact `yjs` package+import { Button } from '@/components/ui/button'; // shadcn primitive — allowed+import { i18n } from '@/lib/i18n'; // allowed++// (13) Dynamic import — the eager-load invariant forbids any dynamic import+// under src/uninstall, regardless of the target.+export async function lazyThing() {+ return import('./some-local-module');+}++// Reference every binding so unused-import diagnostics don't crowd the output the+// test greps. The references are inert — this file is never executed.+export const used = [+ DocumentContext,+ HocuspocusProvider,+ Y,+ Awareness,+ yProsemirror,+ yCollab,+ IndexeddbPersistence,+ ySyncPlugin,+ CollaborationCursor,+ Button,+ UNINSTALL_FEEDBACK_REASONS,+ getSchema,+ EditorView,+ React,+ notYjs,+ i18n,+];+export type UsedType = AuthRejectionReason | UninstallScreenSpec;diff --git a/biome-plugins/no-uninstall-forbidden-import.grit b/biome-plugins/no-uninstall-forbidden-import.gritnew file mode 100644index 000000000..d3189a3d8--- /dev/null+++ b/biome-plugins/no-uninstall-forbidden-import.grit@@ -0,0 +1,65 @@+// no-uninstall-forbidden-import — "connects to nothing" first-hop feedback.+//+// The self-uninstall window's survey and completion screens render AFTER+// `ok uninstall --yes` has stopped the local Hocuspocus server and removed+// `~/.ok`, so the uninstall entry must never reach the editor, the CRDT stack,+// the provider pool, or the server bootstrap. It also must eager-load (no+// dynamic `import()`) so those screens paint from memory once teardown is+// under way.+//+// This rule is SHALLOW, first-hop feedback only — it sees a forbidden specifier+// written directly in an in-scope file. The authoritative gate is the+// transitive-module-graph test+// (`packages/desktop/tests/unit/uninstall-module-graph.test.ts`), which also+// catches a forbidden module reached indirectly through a shared `@/lib` /+// `@/components/ui` module, and re-export (`export … from`) edges this rule+// cannot express in GritQL.+//+// `@inkeep/open-knowledge-core` (shared types + feedback constants, no server+// deps) is deliberately allowed; only the editor / CRDT / provider-pool /+// Hocuspocus-server surface is forbidden.+//+// Scoped via `overrides[].plugins` to `packages/app/src/uninstall/**`. Suppress+// a legitimate exception (none expected) with:+// // biome-ignore lint/plugin/no-uninstall-forbidden-import: <reason>+//+// See PRECEDENTS.md #42 (GritQL plugins are the canonical custom-enforcement+// mechanism).++language js++// The regex matches the source string literal. Biome's node-text regex needs the+// `.*['\"]…['\"].*` wrapper (bare `['\"]…['\"]` does not match), same shape as+// `no-resolved-value-theme-source.grit`. `[^'\"]*` for in-string segments so a+// match can't cross the closing quote; `(/[^'\"]*)?` keeps exact-package names+// from prefix-matching (`yjs` yes, `yjs-not-real` no). One top-level `or` — each+// branch registers its own diagnostic (a `.grit` file is a single pattern).+or {+ `import $clause from $src` as $node where {+ $src <: r"(?s).*['\"](?:@/editor/[^'\"]*|@inkeep/open-knowledge-server[^'\"]*|@hocuspocus/[^'\"]*|@tiptap/y-tiptap[^'\"]*|@tiptap/extension-collaboration[^'\"]*|yjs(?:/[^'\"]*)?|y-protocols(?:/[^'\"]*)?|y-prosemirror(?:/[^'\"]*)?|y-codemirror\.next(?:/[^'\"]*)?|y-indexeddb(?:/[^'\"]*)?)['\"].*",+ register_diagnostic(+ span = $node,+ message = "Forbidden module in the uninstall entry — the uninstall window must connect to nothing (survey/completion run after the server is stopped and ~/.ok is removed). Drop this editor / CRDT / provider-pool / Hocuspocus-server import; keep only shared types + constants from @inkeep/open-knowledge-core. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-uninstall-forbidden-importgrit"+ )+ },+ `import * as $ns from $src` as $node where {+ $src <: r"(?s).*['\"](?:@/editor/[^'\"]*|@inkeep/open-knowledge-server[^'\"]*|@hocuspocus/[^'\"]*|@tiptap/y-tiptap[^'\"]*|@tiptap/extension-collaboration[^'\"]*|yjs(?:/[^'\"]*)?|y-protocols(?:/[^'\"]*)?|y-prosemirror(?:/[^'\"]*)?|y-codemirror\.next(?:/[^'\"]*)?|y-indexeddb(?:/[^'\"]*)?)['\"].*",+ register_diagnostic(+ span = $node,+ message = "Forbidden module in the uninstall entry — the uninstall window must connect to nothing (survey/completion run after the server is stopped and ~/.ok is removed). Drop this editor / CRDT / provider-pool / Hocuspocus-server import; keep only shared types + constants from @inkeep/open-knowledge-core. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-uninstall-forbidden-importgrit"+ )+ },+ `import $src` as $node where {+ $src <: r"(?s).*['\"](?:@/editor/[^'\"]*|@inkeep/open-knowledge-server[^'\"]*|@hocuspocus/[^'\"]*|@tiptap/y-tiptap[^'\"]*|@tiptap/extension-collaboration[^'\"]*|yjs(?:/[^'\"]*)?|y-protocols(?:/[^'\"]*)?|y-prosemirror(?:/[^'\"]*)?|y-codemirror\.next(?:/[^'\"]*)?|y-indexeddb(?:/[^'\"]*)?)['\"].*",+ register_diagnostic(+ span = $node,+ message = "Forbidden module in the uninstall entry — the uninstall window must connect to nothing (survey/completion run after the server is stopped and ~/.ok is removed). Drop this editor / CRDT / provider-pool / Hocuspocus-server import; keep only shared types + constants from @inkeep/open-knowledge-core. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-uninstall-forbidden-importgrit"+ )+ },+ `import($arg)` as $node where {+ register_diagnostic(+ span = $node,+ message = "Dynamic import under src/uninstall — the uninstall screens must eager-load so the completion/failure screens paint from memory after teardown starts removing files. Use a static import. See https://github.com/inkeep/open-knowledge/blob/main/biome-plugins/README.md#no-uninstall-forbidden-importgrit"+ )+ }+}diff --git a/biome.jsonc b/biome.jsoncindex fcd4e8387..b4430adb2 100644--- a/biome.jsonc+++ b/biome.jsonc@@ -153,6 +153,29 @@],"plugins": ["./biome-plugins/playwright-prefer-to-have-count.grit"]},+ {+ // "Connects to nothing" first-hop feedback. The self-uninstall window's+ // survey/completion screens render after `ok uninstall --yes` stops the+ // local Hocuspocus server and removes ~/.ok, so the uninstall entry must+ // never import the editor / CRDT / provider-pool / Hocuspocus-server+ // surface, and must eager-load (no dynamic import). This is SHALLOW+ // first-hop feedback; the authoritative gate is the transitive-graph test+ // at packages/desktop/tests/unit/uninstall-module-graph.test.ts, which+ // also catches indirect and re-export pull-ins GritQL can't express.+ // @inkeep/open-knowledge-core (shared types + constants) is allowed.+ // Test files are excluded: the invariant is about the SHIPPED entry graph,+ // and a dom test legitimately does `await import('./main')` to prove the+ // entry paints (a dynamic import the eager-load rule would otherwise flag).+ "includes": [+ "packages/app/src/uninstall/**/*.ts",+ "packages/app/src/uninstall/**/*.tsx",+ "!packages/app/src/uninstall/**/*.test.ts",+ "!packages/app/src/uninstall/**/*.test.tsx",+ "!packages/app/src/uninstall/**/*.dom.test.tsx",+ "biome-plugins/__fixtures__/no-uninstall-forbidden-import.fixture.tsx"+ ],+ "plugins": ["./biome-plugins/no-uninstall-forbidden-import.grit"]+ },{// UI primitives discipline (see PR #937 retrospective). Scoped to// packages/{app,desktop,plugin}/src/**/*.tsx — production UI surfaces.diff --git a/packages/app/src/components/ui/button.tsx b/packages/app/src/components/ui/button.tsxindex db9195d9a..3e2271d53 100644--- a/packages/app/src/components/ui/button.tsx+++ b/packages/app/src/components/ui/button.tsx@@ -13,6 +13,8 @@ const buttonVariants = cva('bg-primary text-primary-foreground hover:bg-primary/80 [a]:hover:bg-primary/80 font-mono uppercase',outline:'border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50',+ 'outline-mono':+ 'border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50 font-mono uppercase',secondary:'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',ghost:diff --git a/packages/app/src/components/ui/checkbox.tsx b/packages/app/src/components/ui/checkbox.tsxindex 0e8e2830a..008b7b9fa 100644--- a/packages/app/src/components/ui/checkbox.tsx+++ b/packages/app/src/components/ui/checkbox.tsx@@ -1,14 +1,17 @@-import { CheckIcon } from 'lucide-react';+import { CheckIcon, MinusIcon } from 'lucide-react';import { Checkbox as CheckboxPrimitive } from 'radix-ui';import type * as React from 'react';import { cn } from '@/lib/utils';function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {+ // The indeterminate ("mixed") state gets the same filled treatment as checked,+ // with a dash instead of a check — a checkmark in an unfilled box reads as a+ // half-broken checked state. Radix emits `data-state="indeterminate"`.return (<CheckboxPrimitive.Rootdata-slot="checkbox"className={cn(- 'peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary',+ 'peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground dark:data-[state=indeterminate]:bg-primary',className,)}{...props}@@ -17,7 +20,7 @@ function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPdata-slot="checkbox-indicator"className="grid place-content-center text-current transition-none [&>svg]:size-3.5">- <CheckIcon />+ {props.checked === 'indeterminate' ? <MinusIcon /> : <CheckIcon />}</CheckboxPrimitive.Indicator></CheckboxPrimitive.Root>);diff --git a/packages/app/src/globals.css b/packages/app/src/globals.cssindex 7a0fd4919..f553b4933 100644--- a/packages/app/src/globals.css+++ b/packages/app/src/globals.css@@ -121,16 +121,17 @@@source "../../../node_modules/streamdown/dist/*.js";/*- * index.html is the only place the `antialiased` body class is used, and it- * sits outside the src glob above. Under packages/app's own `bun run dev` /- * `vite build` it's covered by the Vite HTML entry, but electron-vite dev- * (CWD=packages/desktop; the app's vite.config.ts is not used) relies solely- * on these @source- * directives — without this line `.antialiased` is never emitted there and+ * The HTML entries are the only place the `antialiased` body class is used,+ * and they sit outside the src glob above. Under packages/app's own+ * `bun run dev` / `vite build` they're covered by the Vite HTML entries, but+ * electron-vite dev (CWD=packages/desktop; the app's vite.config.ts is not+ * used) relies solely on these @source+ * directives — without these lines `.antialiased` is never emitted there and* desktop-dev text renders heavier than production. Keep in sync with the- * class in index.html.+ * classes in index.html / uninstall.html.*/@source "../index.html";+@source "../uninstall.html";@custom-variant dark (&:is(.dark *));diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.jsonindex 5baea6993..ee087292e 100644--- a/packages/app/src/locales/en/messages.json+++ b/packages/app/src/locales/en/messages.json@@ -349,6 +349,7 @@"5qQr1u": ["Allowed values for ", ["field"]],"5rnB76": ["Your edits stay on this computer"],"5tcmwY": ["Add value"],+ "5vAI6Z": ["It didn't fit into my workflow"],"5vYdh9": ["New thread with ", ["0"]],"5wV2qQ": ["and more"],"5y_9lO": ["Waiting for authorization"],@@ -655,6 +656,7 @@"CBsdhe": ["The agent isn't stopping. Force stop closes this thread and quits the agent."],"CCTop_": ["Recent"],"CFnavk": ["This project isn't a git repository, so worktrees aren't available."],+ "CHfFN_": ["Remove OpenKnowledge from ", ["0"]],"CKyk7Q": ["Go back"],"COr1Y7": ["Pick <0>openknowledge.skill</0> from your <1>Downloads</1> folder. It enables automatically."@@ -822,6 +824,7 @@["sizeLabel"]," tokens"],+ "ElyuiT": ["Thanks for giving OpenKnowledge a try."],"Emz5BG": ["Embeddings are computed only when a search runs and are cached locally under <0>.ok/local</0>."],@@ -1029,6 +1032,7 @@"J3HzPL": ["Collapse ", ["keyName"]],"J6N5MX": ["Couldn't construct the share URL. Try Done and re-share."],"J6mxC1": ["A network problem or GitHub outage interrupted the clone."],+ "J7nMqi": ["Uninstall OpenKnowledge"],"JCxGEX": ["No disconnected pages. Pages appear here only when they have no incoming and no outgoing graph edges."],@@ -1325,6 +1329,7 @@"OeAl1e": ["e.g. assets/uploads"],"OfhWJH": ["Reset"],"OgyJSr": ["Local only"],+ "Oi56Cu": ["Cleanup log"],"OiHJdA": ["Move through slash, wiki-link, tag, and path suggestions; accept or dismiss the active suggestion."],@@ -1388,6 +1393,7 @@"Couldn't restart the server automatically. Try running `ok stop all` in a terminal, then reopen this project — or restart your computer if it persists."],"PrJYSN": ["This folder isn't on GitHub yet. The link won't work until it's pushed."],+ "PrVaZo": ["Uninstall OpenKnowledge?"],"PrhzDE": ["Pan up"],"Q1mtyd": ["Hide sidebar"],"Q5fqMz": ["Connection error — try again"],@@ -1421,6 +1427,7 @@"Qw-7Ie": ["A simple place to write, with one file per topic and a daily journal. Pick this if you just want to start writing and let the links between notes build up over time."],+ "QySH4I": ["Detected OpenKnowledge projects"],"QyioBP": ["Move up"],"R0cyYB": [[@@ -1489,6 +1496,7 @@" has been moved, renamed, or deleted in your local copy, and that change hasn't synced yet."],"S33tz3": ["Not connected"],+ "S3qu11": ["It was a trial or one-off project"],"S48xcO": ["pending"],"S60KvX": ["Delete this conversation?"],"S6l5dv": ["Could not start creating a new item"],@@ -1675,6 +1683,7 @@"W8vpBM": ["starter pack"],"W9_Bub": ["Local changes overlap with incoming sync"],"WFEbV1": ["Flag common markdown issues in the editor. Powered by <0>markdownlint<1/></0>."],+ "WGMoTY": ["Bugs, crashes, or it felt unreliable"],"WHPvOb": ["All files are hidden by view filters."],"WJjviG": ["What to include"],"WL6puM": ["Path resolves outside project"],@@ -1828,6 +1837,7 @@"ZARuZJ": ["Couldn't load files"],"ZBt4rI": ["Instruction for the AI"],"ZBxvV3": ["New Terminal"],+ "ZDOq9A": ["What you share is sent to the OpenKnowledge team."],"ZI8uvA": ["No problems found."],"ZNK2Tq": ["root"],"ZQJ1IV": ["Activate the last editor tab."],@@ -1866,6 +1876,7 @@"ZxXhLY": ["Hide Files (", ["sidebarShortcut"], ")"],"Zz25kq": ["Show Files (", ["sidebarShortcut"], ")"],"_0JUKX": ["Bug reporting needs the OpenKnowledge desktop app."],+ "_2cM9E": ["recent"],"_5qBNl": ["AI tools & CLI"],"_6FVBz": ["Jump to tab 1-8"],"_7UQ7y": ["Whole word"],@@ -1940,6 +1951,7 @@"aM23Wr": ["page-name"],"aOp3hw": ["Couldn't move to Trash"],"aQD_86": ["Failed to update the embeddings provider — ", ["detail"]],+ "aQyGJc": ["Something else"],"aRI3Om": ["Close Window"],"aWlJai": ["Starting sign-in flow"],"a_u4ck": ["Loading tags"],@@ -1960,6 +1972,7 @@"aoa6xA": ["network error (is `ok ui` running?)"],"arUUsK": ["Product updates"],"ax9kie": ["Link preview settings not yet loaded — try again in a moment"],+ "axQ1h6": ["Anything you'd like to add? (optional)"],"az8lvo": ["Off"],"b18t0_": ["Close diff"],"b3Thhd": ["Upload failed"],@@ -1978,6 +1991,7 @@"bF22t6": ["Remove field ", ["field"]],"bGa3Fk": ["Uploading file"],"bH382I": ["Edit this HTML — the preview updates live."],+ "bKt9Jk": ["No active or recent OpenKnowledge projects were found."],"bSD4im": ["Search worktrees and branches"],"bS_boY": ["Replace current match"],"bUUVED": ["Asset"],@@ -2013,6 +2027,7 @@"cGV6Mh": ["Show a preview card when you hover an external link in the editor. This setting applies only to this computer."],+ "cH0dkG": ["It was missing a feature I needed"],"cHhH3i": ["a required git tool"],"cIptmH": ["In the Claude Desktop App"],"cKjLuT": ["(project + user)"],@@ -2052,6 +2067,7 @@"cgl-gn": ["Connected to GitHub"],"chL5IG": ["Community"],"cklVjM": ["Timeline"],+ "clJ3qM": ["Done."],"cn1sLi": ["Couldn't connect OpenKnowledge tools to Claude Code. Please try again."],"cnGeoo": ["Delete"],"cqQyPB": ["Folder name"],@@ -2370,6 +2386,7 @@"iv452l": ["Documentation for ", ["0"], " (opens in browser)"],"iy64Li": ["Full sync — your edits are committed and pushed to your remote automatically."],"iycx_A": ["Pushing"],+ "j2229h": ["Removing OpenKnowledge files…"],"j2kt1j": ["Open a new session with your preferred AI. With text selected, stage it there instead of running it."],@@ -2383,6 +2400,7 @@"jEdF24": ["Missing page: ", ["linkTitle"], ". Click to create."],"jKd3AP": ["Could not enable the terminal: ", ["0"]],"jL3gox": ["Select a value"],+ "jO18NZ": ["I'm switching to another tool"],"jPUPvG": ["Couldn't resolve the conflict for ", ["filePath"], "."],"jRAGrQ": ["Configure agents"],"jRHdCz": ["Failed to load PDF"],@@ -2435,6 +2453,7 @@["semanticTotalCount"]," ready. Results may be incomplete."],+ "kCjkGY": ["This may take a moment. Your markdown content is kept."],"kCqCyf": ["Open CodeMirror's lint diagnostics panel."],"kDwcbW": ["Go to line ", ["displayLine"], " in ", ["0"]],"kFLlsI": ["Insert a footnote reference + matching definition stub."],@@ -2469,6 +2488,9 @@"ka6Eke": ["Open file on disk"],"kdzzOK": ["Off — search ranks by keyword only. No content leaves this computer."],"keNFEd": ["Set identity"],+ "keop3U": [+ "This removes OpenKnowledge’s settings and integrations from your Mac and any projects you select below, but keeps your markdown content and authored skills."+ ],"khCa4M": ["Teaches coding agents in this project to read and write through OpenKnowledge."],"kj9pAE": ["Creating page"],"kknhfj": ["No changes"],@@ -2666,6 +2688,7 @@"Git identity isn't set — commits use a default author. Set yours so teammates see your name."],"nrXDdR": ["Field name"],+ "nsUDL8": [["0"], " of ", ["1"], " projects selected"],"nskygk": ["Choose agent"],"nwtY4N": ["Something went wrong"],"nxlOpL": ["OpenKnowledge is using this GitHub account."],@@ -2722,6 +2745,7 @@["docName"],"\" could not be cleared. Reload to retry."],+ "oxdGJn": ["Before you go, mind sharing why?"],"p0Iq25": ["Insert link"],"p2LEhJ": ["Personal access token"],"p8TjFD": ["Collapse session dock"],@@ -2882,6 +2906,7 @@["currentLabel"],"</1>)."],+ "s_ereB": ["active"],"saIASg": ["Second item"],"saYiIO": ["Path cannot contain null bytes"],"scu3wk": ["Model"],@@ -2936,6 +2961,7 @@"toyw51": ["Mermaid diagram controls"],"tsiTqO": ["Paste your API key"],"tsyExA": ["Connect your AI tools to OpenKnowledge"],+ "tzGWeg": ["Preparing to uninstall OpenKnowledge"],"tzZ6ha": ["Connect to GitHub Enterprise Server"],"u-9fWA": ["See <0>Architecture</0> for the system overview."],"u3BOHd": [["fileCount", "plural", { "one": ["#", " file"], "other": ["#", " files"] }]],@@ -2993,6 +3019,7 @@"uksqrP": ["Repository not found. It may have been renamed, deleted, or moved."],"ul1Atu": ["Converting..."],"un8kBM": ["Creating page: ", ["linkTitle"], "."],+ "uoJF_D": ["It was too hard to set up or get started"],"ur2XSb": ["Visual editor"],"uuoHOU": ["Command failed."],"uynXup": [["tokens", "plural", { "one": ["token"], "other": ["tokens"] }]],@@ -3068,6 +3095,7 @@"wbv9xO": ["Create new project"],"wdxz7K": ["Source"],"weP6me": ["Couldn't load docs — type @ again to retry"],+ "wgNoIs": ["Select all"],"wlwXUk": ["You picked ~/Downloads. Files there are usually transient — consider a stable folder instead."],@@ -3099,10 +3127,12 @@"xCdTnb": ["Close new tab"],"xDBki3": ["Heading suggestions"],"xDEcka": ["The provider is rate-limiting this key. Try again in a moment."],+ "xEb24l": ["Let us follow up by email"],"xFQRu4": ["I already have it locally"],"xG4tb6": ["Lost connection to \"", ["docName"], "\"."],"xHGM4U": ["Hide HTML preview"],"xK291b": ["Two-page (odd)"],+ "xMsnTe": ["Send & continue"],"xNyj3h": ["Reinstall for Claude Chat & Cowork"],"xOTzt5": ["just now"],"xSVO3J": ["What gets created"],@@ -3163,6 +3193,7 @@"yQE2r9": ["Loading"],"yQyglE": ["No matching docs"],"yR5LHI": ["Enter a 6-digit hex like #1A2B3C"],+ "yU_9ur": ["To do."],"yUxR-Q": ["Expand ", ["keyName"]],"yWSvcf": ["Content root"],"yWWThY": ["Asset reference"],diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.poindex a46b42773..060e41038 100644--- a/packages/app/src/locales/en/messages.po+++ b/packages/app/src/locales/en/messages.po@@ -230,6 +230,12 @@ msgstr "{0} isn't installed yet — opening its download page."msgid "{0} needs {1}"msgstr "{0} needs {1}"+#. placeholder {0}: selected.size+#. placeholder {1}: projects.length+#: src/uninstall/UninstallPickerScreen.tsx+msgid "{0} of {1} projects selected"+msgstr "{0} of {1} projects selected"+#. placeholder {0}: templates.length#: src/components/empty-state/CreateView.tsxmsgid "{0} templates available"@@ -852,6 +858,10 @@ msgstr "Activate the next editor tab."msgid "Activate the previous editor tab."msgstr "Activate the previous editor tab."+#: src/uninstall/UninstallPickerScreen.tsx+msgid "active"+msgstr "active"+#: src/components/ActivityModeContent.tsxmsgid "Active"msgstr "Active"@@ -1134,6 +1144,10 @@ msgstr "any doc named {0}"msgid "Anyone can see"msgstr "Anyone can see"+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Anything you'd like to add? (optional)"+msgstr "Anything you'd like to add? (optional)"+#: src/components/settings/SearchSection.tsxmsgid "API key set"msgstr "API key set"@@ -1369,6 +1383,10 @@ msgstr "Becomes the document's content when someone creates a doc from this tempmsgid "Before syncing, set your identity for git commits:"msgstr "Before syncing, set your identity for git commits:"+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Before you go, mind sharing why?"+msgstr "Before you go, mind sharing why?"+#: src/editor/slash-command/items.tsxmsgid "Below"msgstr "Below"@@ -1497,6 +1515,10 @@ msgstr "Bug report {0}"msgid "Bug reporting needs the OpenKnowledge desktop app."msgstr "Bug reporting needs the OpenKnowledge desktop app."+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Bugs, crashes, or it felt unreliable"+msgstr "Bugs, crashes, or it felt unreliable"+#: src/components/empty-state/use-create-suggestions.tsmsgid "Build a competitor research knowledge base. Start with an overview page, then add cross-linked pages for each competitor, their products and pricing, and the sources behind every claim."msgstr "Build a competitor research knowledge base. Start with an overview page, then add cross-linked pages for each competitor, their products and pricing, and the sources behind every claim."@@ -1575,6 +1597,7 @@ msgstr "Can't safely edit this tool's config"#: src/editor/components/CodePreviewEditModal.tsx#: src/editor/extensions/InternalLinkPropPanel.tsx#: src/editor/extensions/WikiLinkPropPanel.tsx+#: src/uninstall/UninstallPickerScreen.tsxmsgid "Cancel"msgstr "Cancel"@@ -1702,6 +1725,10 @@ msgstr "Claude Code is installed, but OpenKnowledge tools aren't connected to itmsgid "Claude Desktop"msgstr "Claude Desktop"+#: src/uninstall/UninstallNoticeScreen.tsx+msgid "Cleanup log"+msgstr "Cleanup log"+#: src/components/settings/SearchSection.tsxmsgid "Clear"msgstr "Clear"@@ -3083,6 +3110,10 @@ msgstr "Detected from the editors this project is set up for. Adjust to controlmsgid "Detected on this machine"msgstr "Detected on this machine"+#: src/uninstall/UninstallPickerScreen.tsx+msgid "Detected OpenKnowledge projects"+msgstr "Detected OpenKnowledge projects"+#: src/components/CommandPalette.tsx#: src/components/handoff/OpenInAgentMenuItem.tsxmsgid "Detecting"@@ -3268,6 +3299,10 @@ msgstr "done"msgid "Done"msgstr "Done"+#: src/uninstall/UninstallNoticeScreen.tsx+msgid "Done."+msgstr "Done."+#. placeholder {0}: item.displayName#: src/components/acp/ThreadView.tsxmsgid "Download {0}"@@ -3477,6 +3512,7 @@ msgid "Email"msgstr "Email"#: src/components/SubscribeForm.tsx+#: src/uninstall/UninstallSurveyScreen.tsxmsgid "Email address"msgstr "Email address"@@ -4725,6 +4761,10 @@ msgstr "I already have it locally"msgid "I already have it locally →"msgstr "I already have it locally →"+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "I'm switching to another tool"+msgstr "I'm switching to another tool"+#: src/components/AutoSyncEnableWarning.tsxmsgid "If an update arrives for something you are editing, you choose which version to keep, like a merge conflict."msgstr "If an update arrives for something you are editing, you choose which version to keep, like a merge conflict."@@ -4987,6 +5027,22 @@ msgstr "Invalid input — pick a different folder."msgid "Invalid patch payload"msgstr "Invalid patch payload"+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "It didn't fit into my workflow"+msgstr "It didn't fit into my workflow"++#: src/uninstall/UninstallSurveyScreen.tsx+msgid "It was a trial or one-off project"+msgstr "It was a trial or one-off project"++#: src/uninstall/UninstallSurveyScreen.tsx+msgid "It was missing a feature I needed"+msgstr "It was missing a feature I needed"++#: src/uninstall/UninstallSurveyScreen.tsx+msgid "It was too hard to set up or get started"+msgstr "It was too hard to set up or get started"+#: src/lib/keyboard-shortcuts.tsmsgid "Italic"msgstr "Italic"@@ -5089,6 +5145,10 @@ msgstr "Let agents use OpenKnowledge without asking"msgid "Let Tab leave the source editor instead of indenting."msgstr "Let Tab leave the source editor instead of indenting."+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Let us follow up by email"+msgstr "Let us follow up by email"+#: src/components/SkillProperties.tsxmsgid "Level"msgstr "Level"@@ -5829,6 +5889,10 @@ msgstr "Next tab"msgid "No <0>.markdownlint.*</0> file yet — every rule runs on the same defaults as the VS Code markdownlint extension: all on, except line length."msgstr "No <0>.markdownlint.*</0> file yet — every rule runs on the same defaults as the VS Code markdownlint extension: all on, except line length."+#: src/uninstall/UninstallPickerScreen.tsx+msgid "No active or recent OpenKnowledge projects were found."+msgstr "No active or recent OpenKnowledge projects were found."+#: src/components/settings/ConfigureAgentsSection.tsxmsgid "No agents available."msgstr "No agents available."@@ -6942,6 +7006,10 @@ msgstr "Preparing search"msgid "Preparing share URL..."msgstr "Preparing share URL..."+#: src/uninstall/UninstallApp.tsx+msgid "Preparing to uninstall OpenKnowledge"+msgstr "Preparing to uninstall OpenKnowledge"+#: src/components/PublishToGitHubDialog.tsxmsgid "Preview browsers can't auto-copy. Use Cmd/Ctrl+C on the URL above, or open OK in the desktop app."msgstr "Preview browsers can't auto-copy. Use Cmd/Ctrl+C on the URL above, or open OK in the desktop app."@@ -7206,6 +7274,10 @@ msgstr "Reason: {reason} ({osDetail})"msgid "Receiving objects"msgstr "Receiving objects"+#: src/uninstall/UninstallPickerScreen.tsx+msgid "recent"+msgstr "recent"+#: src/components/NavigatorApp.tsxmsgid "Recent"msgstr "Recent"@@ -7365,6 +7437,11 @@ msgstr "Remove item {0}"msgid "Remove link"msgstr "Remove link"+#. placeholder {0}: project.path+#: src/uninstall/UninstallPickerScreen.tsx+msgid "Remove OpenKnowledge from {0}"+msgstr "Remove OpenKnowledge from {0}"+#: src/components/TemplateForm.tsxmsgid "Remove property"msgstr "Remove property"@@ -7390,6 +7467,10 @@ msgstr "Removes this skill from your editors."msgid "Removing"msgstr "Removing"+#: src/uninstall/UninstallProgressScreen.tsx+msgid "Removing OpenKnowledge files…"+msgstr "Removing OpenKnowledge files…"+#: src/components/AppMenubar.tsx#: src/components/command-palette-commands.ts#: src/components/FileTree.tsx@@ -7998,6 +8079,10 @@ msgstr "See the full install guide"msgid "Select a value"msgstr "Select a value"+#: src/uninstall/UninstallPickerScreen.tsx+msgid "Select all"+msgstr "Select all"+#: src/components/AppMenubar.tsxmsgid "Select All"msgstr "Select All"@@ -8067,6 +8152,10 @@ msgstr "Semantic search is on, but no API key is set — search falls back to kemsgid "Send"msgstr "Send"+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Send & continue"+msgstr "Send & continue"+#: src/components/command-palette-commands.ts#: src/components/HelpPopover.tsxmsgid "Send feedback"@@ -8501,6 +8590,7 @@ msgstr "Skills teach agents repeatable tasks. Author them here; install a skill#. Secondary button — dismisses the dialog without wiring any tools#: src/components/AuthModal.tsx#: src/components/McpConsentDialogBody.tsx+#: src/uninstall/UninstallSurveyScreen.tsxmsgid "Skip"msgstr "Skip"@@ -8525,6 +8615,10 @@ msgstr "Small section heading."msgid "Something broke"msgstr "Something broke"+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Something else"+msgstr "Something else"+#: src/components/AppErrorBoundary.tsxmsgid "Something went wrong"msgstr "Something went wrong"@@ -9068,6 +9162,10 @@ msgstr "Testing"msgid "Text"msgstr "Text"+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Thanks for giving OpenKnowledge a try."+msgstr "Thanks for giving OpenKnowledge a try."+#: src/components/SubscribeForm.tsxmsgid "Thanks for subscribing. Watch your inbox for product updates."msgstr "Thanks for subscribing. Watch your inbox for product updates."@@ -9394,6 +9492,10 @@ msgstr "this item"msgid "This looks like a drive root (e.g., C:\\). Scaffolding here will scan an entire drive."msgstr "This looks like a drive root (e.g., C:\\). Scaffolding here will scan an entire drive."+#: src/uninstall/UninstallProgressScreen.tsx+msgid "This may take a moment. Your markdown content is kept."+msgstr "This may take a moment. Your markdown content is kept."+#: src/components/SeedDialog.tsxmsgid "This pack is already set up here."msgstr "This pack is already set up here."@@ -9465,6 +9567,10 @@ msgstr "This project's running server doesn't support live editing. Restart Openmsgid "This project's server (v{0}) is newer than this app (v{1})."msgstr "This project's server (v{0}) is newer than this app (v{1})."+#: src/uninstall/UninstallPickerScreen.tsx+msgid "This removes OpenKnowledge’s settings and integrations from your Mac and any projects you select below, but keeps your markdown content and authored skills."+msgstr "This removes OpenKnowledge’s settings and integrations from your Mac and any projects you select below, but keeps your markdown content and authored skills."+#. placeholder {0}: skill.bundledVersion ?? ''#. placeholder {1}: skill.installedVersion#: src/components/SkillUpdateDialog.tsx@@ -9535,6 +9641,10 @@ msgstr "Title"msgid "To do"msgstr "To do"+#: src/uninstall/UninstallNoticeScreen.tsx+msgid "To do."+msgstr "To do."+#: src/lib/keyboard-shortcuts.tsmsgid "Toggle a bullet list."msgstr "Toggle a bullet list."@@ -9748,6 +9858,14 @@ msgstr "Uninstall"msgid "Uninstall everywhere"msgstr "Uninstall everywhere"+#: src/uninstall/UninstallPickerScreen.tsx+msgid "Uninstall OpenKnowledge"+msgstr "Uninstall OpenKnowledge"++#: src/uninstall/UninstallPickerScreen.tsx+msgid "Uninstall OpenKnowledge?"+msgstr "Uninstall OpenKnowledge?"+#. placeholder {0}: skill.name#. placeholder {1}: label(removed)#: src/components/skill-actions.tsx@@ -10124,6 +10242,10 @@ msgstr "What were you doing?"msgid "What would you like to create?"msgstr "What would you like to create?"+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "What you share is sent to the OpenKnowledge team."+msgstr "What you share is sent to the OpenKnowledge team."+#: src/components/HelpPopover.tsxmsgid "What's new"msgstr "What's new"@@ -10325,6 +10447,7 @@ msgid "You're subscribed!"msgstr "You're subscribed!"#: src/components/FeedbackForm.tsx+#: src/uninstall/UninstallSurveyScreen.tsxmsgid "[email protected]"msgstr "[email protected]"diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.jsonindex 27b5694fa..602c273ea 100644--- a/packages/app/src/locales/pseudo/messages.json+++ b/packages/app/src/locales/pseudo/messages.json@@ -349,6 +349,7 @@"5qQr1u": ["Àĺĺōŵēď vàĺũēś ƒōŕ ", ["field"]],"5rnB76": ["Ŷōũŕ ēďĩţś śţàŷ ōń ţĥĩś ćōḿƥũţēŕ"],"5tcmwY": ["Àďď vàĺũē"],+ "5vAI6Z": ["Ĩţ ďĩďń'ţ ƒĩţ ĩńţō ḿŷ ŵōŕķƒĺōŵ"],"5vYdh9": ["Ńēŵ ţĥŕēàď ŵĩţĥ ", ["0"]],"5wV2qQ": ["àńď ḿōŕē"],"5y_9lO": ["Ŵàĩţĩńĝ ƒōŕ àũţĥōŕĩźàţĩōń"],@@ -655,6 +656,7 @@"CBsdhe": ["Ţĥē àĝēńţ ĩśń'ţ śţōƥƥĩńĝ. Ƒōŕćē śţōƥ ćĺōśēś ţĥĩś ţĥŕēàď àńď ǫũĩţś ţĥē àĝēńţ."],"CCTop_": ["Ŕēćēńţ"],"CFnavk": ["Ţĥĩś ƥŕōĴēćţ ĩśń'ţ à ĝĩţ ŕēƥōśĩţōŕŷ, śō ŵōŕķţŕēēś àŕēń'ţ àvàĩĺàƀĺē."],+ "CHfFN_": ["Ŕēḿōvē ŌƥēńĶńōŵĺēďĝē ƒŕōḿ ", ["0"]],"CKyk7Q": ["Ĝō ƀàćķ"],"COr1Y7": ["Ƥĩćķ <0>ōƥēńķńōŵĺēďĝē.śķĩĺĺ</0> ƒŕōḿ ŷōũŕ <1>Ďōŵńĺōàďś</1> ƒōĺďēŕ. Ĩţ ēńàƀĺēś àũţōḿàţĩćàĺĺŷ."@@ -822,6 +824,7 @@["sizeLabel"]," ţōķēńś"],+ "ElyuiT": ["Ţĥàńķś ƒōŕ ĝĩvĩńĝ ŌƥēńĶńōŵĺēďĝē à ţŕŷ."],"Emz5BG": ["Ēḿƀēďďĩńĝś àŕē ćōḿƥũţēď ōńĺŷ ŵĥēń à śēàŕćĥ ŕũńś àńď àŕē ćàćĥēď ĺōćàĺĺŷ ũńďēŕ <0>.ōķ/ĺōćàĺ</0>."],@@ -1029,6 +1032,7 @@"J3HzPL": ["Ćōĺĺàƥśē ", ["keyName"]],"J6N5MX": ["Ćōũĺďń'ţ ćōńśţŕũćţ ţĥē śĥàŕē ŨŔĹ. Ţŕŷ Ďōńē àńď ŕē-śĥàŕē."],"J6mxC1": ["À ńēţŵōŕķ ƥŕōƀĺēḿ ōŕ ĜĩţĤũƀ ōũţàĝē ĩńţēŕŕũƥţēď ţĥē ćĺōńē."],+ "J7nMqi": ["Ũńĩńśţàĺĺ ŌƥēńĶńōŵĺēďĝē"],"JCxGEX": ["Ńō ďĩśćōńńēćţēď ƥàĝēś. Ƥàĝēś àƥƥēàŕ ĥēŕē ōńĺŷ ŵĥēń ţĥēŷ ĥàvē ńō ĩńćōḿĩńĝ àńď ńō ōũţĝōĩńĝ ĝŕàƥĥ ēďĝēś."],@@ -1325,6 +1329,7 @@"OeAl1e": ["ē.ĝ. àśśēţś/ũƥĺōàďś"],"OfhWJH": ["Ŕēśēţ"],"OgyJSr": ["Ĺōćàĺ ōńĺŷ"],+ "Oi56Cu": ["Ćĺēàńũƥ ĺōĝ"],"OiHJdA": ["Ḿōvē ţĥŕōũĝĥ śĺàśĥ, ŵĩķĩ-ĺĩńķ, ţàĝ, àńď ƥàţĥ śũĝĝēśţĩōńś; àććēƥţ ōŕ ďĩśḿĩśś ţĥē àćţĩvē śũĝĝēśţĩōń."],@@ -1388,6 +1393,7 @@"Ćōũĺďń'ţ ŕēśţàŕţ ţĥē śēŕvēŕ àũţōḿàţĩćàĺĺŷ. Ţŕŷ ŕũńńĩńĝ `ōķ śţōƥ àĺĺ` ĩń à ţēŕḿĩńàĺ, ţĥēń ŕēōƥēń ţĥĩś ƥŕōĴēćţ — ōŕ ŕēśţàŕţ ŷōũŕ ćōḿƥũţēŕ ĩƒ ĩţ ƥēŕśĩśţś."],"PrJYSN": ["Ţĥĩś ƒōĺďēŕ ĩśń'ţ ōń ĜĩţĤũƀ ŷēţ. Ţĥē ĺĩńķ ŵōń'ţ ŵōŕķ ũńţĩĺ ĩţ'ś ƥũśĥēď."],+ "PrVaZo": ["Ũńĩńśţàĺĺ ŌƥēńĶńōŵĺēďĝē?"],"PrhzDE": ["Ƥàń ũƥ"],"Q1mtyd": ["Ĥĩďē śĩďēƀàŕ"],"Q5fqMz": ["Ćōńńēćţĩōń ēŕŕōŕ — ţŕŷ àĝàĩń"],@@ -1421,6 +1427,7 @@"Qw-7Ie": ["À śĩḿƥĺē ƥĺàćē ţō ŵŕĩţē, ŵĩţĥ ōńē ƒĩĺē ƥēŕ ţōƥĩć àńď à ďàĩĺŷ Ĵōũŕńàĺ. Ƥĩćķ ţĥĩś ĩƒ ŷōũ Ĵũśţ ŵàńţ ţō śţàŕţ ŵŕĩţĩńĝ àńď ĺēţ ţĥē ĺĩńķś ƀēţŵēēń ńōţēś ƀũĩĺď ũƥ ōvēŕ ţĩḿē."],+ "QySH4I": ["Ďēţēćţēď ŌƥēńĶńōŵĺēďĝē ƥŕōĴēćţś"],"QyioBP": ["Ḿōvē ũƥ"],"R0cyYB": [[@@ -1489,6 +1496,7 @@" ĥàś ƀēēń ḿōvēď, ŕēńàḿēď, ōŕ ďēĺēţēď ĩń ŷōũŕ ĺōćàĺ ćōƥŷ, àńď ţĥàţ ćĥàńĝē ĥàśń'ţ śŷńćēď ŷēţ."],"S33tz3": ["Ńōţ ćōńńēćţēď"],+ "S3qu11": ["Ĩţ ŵàś à ţŕĩàĺ ōŕ ōńē-ōƒƒ ƥŕōĴēćţ"],"S48xcO": ["ƥēńďĩńĝ"],"S60KvX": ["Ďēĺēţē ţĥĩś ćōńvēŕśàţĩōń?"],"S6l5dv": ["Ćōũĺď ńōţ śţàŕţ ćŕēàţĩńĝ à ńēŵ ĩţēḿ"],@@ -1675,6 +1683,7 @@"W8vpBM": ["śţàŕţēŕ ƥàćķ"],"W9_Bub": ["Ĺōćàĺ ćĥàńĝēś ōvēŕĺàƥ ŵĩţĥ ĩńćōḿĩńĝ śŷńć"],"WFEbV1": ["Ƒĺàĝ ćōḿḿōń ḿàŕķďōŵń ĩśśũēś ĩń ţĥē ēďĩţōŕ. Ƥōŵēŕēď ƀŷ <0>ḿàŕķďōŵńĺĩńţ<1/></0>."],+ "WGMoTY": ["ßũĝś, ćŕàśĥēś, ōŕ ĩţ ƒēĺţ ũńŕēĺĩàƀĺē"],"WHPvOb": ["Àĺĺ ƒĩĺēś àŕē ĥĩďďēń ƀŷ vĩēŵ ƒĩĺţēŕś."],"WJjviG": ["Ŵĥàţ ţō ĩńćĺũďē"],"WL6puM": ["Ƥàţĥ ŕēśōĺvēś ōũţśĩďē ƥŕōĴēćţ"],@@ -1828,6 +1837,7 @@"ZARuZJ": ["Ćōũĺďń'ţ ĺōàď ƒĩĺēś"],"ZBt4rI": ["Ĩńśţŕũćţĩōń ƒōŕ ţĥē ÀĨ"],"ZBxvV3": ["Ńēŵ Ţēŕḿĩńàĺ"],+ "ZDOq9A": ["Ŵĥàţ ŷōũ śĥàŕē ĩś śēńţ ţō ţĥē ŌƥēńĶńōŵĺēďĝē ţēàḿ."],"ZI8uvA": ["Ńō ƥŕōƀĺēḿś ƒōũńď."],"ZNK2Tq": ["ŕōōţ"],"ZQJ1IV": ["Àćţĩvàţē ţĥē ĺàśţ ēďĩţōŕ ţàƀ."],@@ -1866,6 +1876,7 @@"ZxXhLY": ["Ĥĩďē Ƒĩĺēś (", ["sidebarShortcut"], ")"],"Zz25kq": ["Śĥōŵ Ƒĩĺēś (", ["sidebarShortcut"], ")"],"_0JUKX": ["ßũĝ ŕēƥōŕţĩńĝ ńēēďś ţĥē ŌƥēńĶńōŵĺēďĝē ďēśķţōƥ àƥƥ."],+ "_2cM9E": ["ŕēćēńţ"],"_5qBNl": ["ÀĨ ţōōĺś & ĆĹĨ"],"_6FVBz": ["ĵũḿƥ ţō ţàƀ 1-8"],"_7UQ7y": ["Ŵĥōĺē ŵōŕď"],@@ -1940,6 +1951,7 @@"aM23Wr": ["ƥàĝē-ńàḿē"],"aOp3hw": ["Ćōũĺďń'ţ ḿōvē ţō Ţŕàśĥ"],"aQD_86": ["Ƒàĩĺēď ţō ũƥďàţē ţĥē ēḿƀēďďĩńĝś ƥŕōvĩďēŕ — ", ["detail"]],+ "aQyGJc": ["Śōḿēţĥĩńĝ ēĺśē"],"aRI3Om": ["Ćĺōśē Ŵĩńďōŵ"],"aWlJai": ["Śţàŕţĩńĝ śĩĝń-ĩń ƒĺōŵ"],"a_u4ck": ["Ĺōàďĩńĝ ţàĝś"],@@ -1960,6 +1972,7 @@"aoa6xA": ["ńēţŵōŕķ ēŕŕōŕ (ĩś `ōķ ũĩ` ŕũńńĩńĝ?)"],"arUUsK": ["Ƥŕōďũćţ ũƥďàţēś"],"ax9kie": ["Ĺĩńķ ƥŕēvĩēŵ śēţţĩńĝś ńōţ ŷēţ ĺōàďēď — ţŕŷ àĝàĩń ĩń à ḿōḿēńţ"],+ "axQ1h6": ["Àńŷţĥĩńĝ ŷōũ'ď ĺĩķē ţō àďď? (ōƥţĩōńàĺ)"],"az8lvo": ["Ōƒƒ"],"b18t0_": ["Ćĺōśē ďĩƒƒ"],"b3Thhd": ["Ũƥĺōàď ƒàĩĺēď"],@@ -1978,6 +1991,7 @@"bF22t6": ["Ŕēḿōvē ƒĩēĺď ", ["field"]],"bGa3Fk": ["Ũƥĺōàďĩńĝ ƒĩĺē"],"bH382I": ["Ēďĩţ ţĥĩś ĤŢḾĹ — ţĥē ƥŕēvĩēŵ ũƥďàţēś ĺĩvē."],+ "bKt9Jk": ["Ńō àćţĩvē ōŕ ŕēćēńţ ŌƥēńĶńōŵĺēďĝē ƥŕōĴēćţś ŵēŕē ƒōũńď."],"bSD4im": ["Śēàŕćĥ ŵōŕķţŕēēś àńď ƀŕàńćĥēś"],"bS_boY": ["Ŕēƥĺàćē ćũŕŕēńţ ḿàţćĥ"],"bUUVED": ["Àśśēţ"],@@ -2013,6 +2027,7 @@"cGV6Mh": ["Śĥōŵ à ƥŕēvĩēŵ ćàŕď ŵĥēń ŷōũ ĥōvēŕ àń ēxţēŕńàĺ ĺĩńķ ĩń ţĥē ēďĩţōŕ. Ţĥĩś śēţţĩńĝ àƥƥĺĩēś ōńĺŷ ţō ţĥĩś ćōḿƥũţēŕ."],+ "cH0dkG": ["Ĩţ ŵàś ḿĩśśĩńĝ à ƒēàţũŕē Ĩ ńēēďēď"],"cHhH3i": ["à ŕēǫũĩŕēď ĝĩţ ţōōĺ"],"cIptmH": ["Ĩń ţĥē Ćĺàũďē Ďēśķţōƥ Àƥƥ"],"cKjLuT": ["(ƥŕōĴēćţ + ũśēŕ)"],@@ -2052,6 +2067,7 @@"cgl-gn": ["Ćōńńēćţēď ţō ĜĩţĤũƀ"],"chL5IG": ["Ćōḿḿũńĩţŷ"],"cklVjM": ["Ţĩḿēĺĩńē"],+ "clJ3qM": ["Ďōńē."],"cn1sLi": ["Ćōũĺďń'ţ ćōńńēćţ ŌƥēńĶńōŵĺēďĝē ţōōĺś ţō Ćĺàũďē Ćōďē. Ƥĺēàśē ţŕŷ àĝàĩń."],"cnGeoo": ["Ďēĺēţē"],"cqQyPB": ["Ƒōĺďēŕ ńàḿē"],@@ -2370,6 +2386,7 @@"iv452l": ["Ďōćũḿēńţàţĩōń ƒōŕ ", ["0"], " (ōƥēńś ĩń ƀŕōŵśēŕ)"],"iy64Li": ["Ƒũĺĺ śŷńć — ŷōũŕ ēďĩţś àŕē ćōḿḿĩţţēď àńď ƥũśĥēď ţō ŷōũŕ ŕēḿōţē àũţōḿàţĩćàĺĺŷ."],"iycx_A": ["Ƥũśĥĩńĝ"],+ "j2229h": ["Ŕēḿōvĩńĝ ŌƥēńĶńōŵĺēďĝē ƒĩĺēś…"],"j2kt1j": ["Ōƥēń à ńēŵ śēśśĩōń ŵĩţĥ ŷōũŕ ƥŕēƒēŕŕēď ÀĨ. Ŵĩţĥ ţēxţ śēĺēćţēď, śţàĝē ĩţ ţĥēŕē ĩńśţēàď ōƒ ŕũńńĩńĝ ĩţ."],@@ -2383,6 +2400,7 @@"jEdF24": ["Ḿĩśśĩńĝ ƥàĝē: ", ["linkTitle"], ". Ćĺĩćķ ţō ćŕēàţē."],"jKd3AP": ["Ćōũĺď ńōţ ēńàƀĺē ţĥē ţēŕḿĩńàĺ: ", ["0"]],"jL3gox": ["Śēĺēćţ à vàĺũē"],+ "jO18NZ": ["Ĩ'ḿ śŵĩţćĥĩńĝ ţō àńōţĥēŕ ţōōĺ"],"jPUPvG": ["Ćōũĺďń'ţ ŕēśōĺvē ţĥē ćōńƒĺĩćţ ƒōŕ ", ["filePath"], "."],"jRAGrQ": ["Ćōńƒĩĝũŕē àĝēńţś"],"jRHdCz": ["Ƒàĩĺēď ţō ĺōàď ƤĎƑ"],@@ -2435,6 +2453,7 @@["semanticTotalCount"]," ŕēàďŷ. Ŕēśũĺţś ḿàŷ ƀē ĩńćōḿƥĺēţē."],+ "kCjkGY": ["Ţĥĩś ḿàŷ ţàķē à ḿōḿēńţ. Ŷōũŕ ḿàŕķďōŵń ćōńţēńţ ĩś ķēƥţ."],"kCqCyf": ["Ōƥēń ĆōďēḾĩŕŕōŕ'ś ĺĩńţ ďĩàĝńōśţĩćś ƥàńēĺ."],"kDwcbW": ["Ĝō ţō ĺĩńē ", ["displayLine"], " ĩń ", ["0"]],"kFLlsI": ["Ĩńśēŕţ à ƒōōţńōţē ŕēƒēŕēńćē + ḿàţćĥĩńĝ ďēƒĩńĩţĩōń śţũƀ."],@@ -2469,6 +2488,9 @@"ka6Eke": ["Ōƥēń ƒĩĺē ōń ďĩśķ"],"kdzzOK": ["Ōƒƒ — śēàŕćĥ ŕàńķś ƀŷ ķēŷŵōŕď ōńĺŷ. Ńō ćōńţēńţ ĺēàvēś ţĥĩś ćōḿƥũţēŕ."],"keNFEd": ["Śēţ ĩďēńţĩţŷ"],+ "keop3U": [+ "Ţĥĩś ŕēḿōvēś ŌƥēńĶńōŵĺēďĝē’ś śēţţĩńĝś àńď ĩńţēĝŕàţĩōńś ƒŕōḿ ŷōũŕ Ḿàć àńď àńŷ ƥŕōĴēćţś ŷōũ śēĺēćţ ƀēĺōŵ, ƀũţ ķēēƥś ŷōũŕ ḿàŕķďōŵń ćōńţēńţ àńď àũţĥōŕēď śķĩĺĺś."+ ],"khCa4M": ["Ţēàćĥēś ćōďĩńĝ àĝēńţś ĩń ţĥĩś ƥŕōĴēćţ ţō ŕēàď àńď ŵŕĩţē ţĥŕōũĝĥ ŌƥēńĶńōŵĺēďĝē."],"kj9pAE": ["Ćŕēàţĩńĝ ƥàĝē"],"kknhfj": ["Ńō ćĥàńĝēś"],@@ -2666,6 +2688,7 @@"Ĝĩţ ĩďēńţĩţŷ ĩśń'ţ śēţ — ćōḿḿĩţś ũśē à ďēƒàũĺţ àũţĥōŕ. Śēţ ŷōũŕś śō ţēàḿḿàţēś śēē ŷōũŕ ńàḿē."],"nrXDdR": ["Ƒĩēĺď ńàḿē"],+ "nsUDL8": [["0"], " ōƒ ", ["1"], " ƥŕōĴēćţś śēĺēćţēď"],"nskygk": ["Ćĥōōśē àĝēńţ"],"nwtY4N": ["Śōḿēţĥĩńĝ ŵēńţ ŵŕōńĝ"],"nxlOpL": ["ŌƥēńĶńōŵĺēďĝē ĩś ũśĩńĝ ţĥĩś ĜĩţĤũƀ àććōũńţ."],@@ -2722,6 +2745,7 @@["docName"],"\" ćōũĺď ńōţ ƀē ćĺēàŕēď. Ŕēĺōàď ţō ŕēţŕŷ."],+ "oxdGJn": ["ßēƒōŕē ŷōũ ĝō, ḿĩńď śĥàŕĩńĝ ŵĥŷ?"],"p0Iq25": ["Ĩńśēŕţ ĺĩńķ"],"p2LEhJ": ["Ƥēŕśōńàĺ àććēśś ţōķēń"],"p8TjFD": ["Ćōĺĺàƥśē śēśśĩōń ďōćķ"],@@ -2882,6 +2906,7 @@["currentLabel"],"</1>)."],+ "s_ereB": ["àćţĩvē"],"saIASg": ["Śēćōńď ĩţēḿ"],"saYiIO": ["Ƥàţĥ ćàńńōţ ćōńţàĩń ńũĺĺ ƀŷţēś"],"scu3wk": ["Ḿōďēĺ"],@@ -2936,6 +2961,7 @@"toyw51": ["Ḿēŕḿàĩď ďĩàĝŕàḿ ćōńţŕōĺś"],"tsiTqO": ["Ƥàśţē ŷōũŕ ÀƤĨ ķēŷ"],"tsyExA": ["Ćōńńēćţ ŷōũŕ ÀĨ ţōōĺś ţō ŌƥēńĶńōŵĺēďĝē"],+ "tzGWeg": ["Ƥŕēƥàŕĩńĝ ţō ũńĩńśţàĺĺ ŌƥēńĶńōŵĺēďĝē"],"tzZ6ha": ["Ćōńńēćţ ţō ĜĩţĤũƀ Ēńţēŕƥŕĩśē Śēŕvēŕ"],"u-9fWA": ["Śēē <0>Àŕćĥĩţēćţũŕē</0> ƒōŕ ţĥē śŷśţēḿ ōvēŕvĩēŵ."],"u3BOHd": [["fileCount", "plural", { "one": ["#", " ƒĩĺē"], "other": ["#", " ƒĩĺēś"] }]],@@ -2993,6 +3019,7 @@"uksqrP": ["Ŕēƥōśĩţōŕŷ ńōţ ƒōũńď. Ĩţ ḿàŷ ĥàvē ƀēēń ŕēńàḿēď, ďēĺēţēď, ōŕ ḿōvēď."],"ul1Atu": ["Ćōńvēŕţĩńĝ..."],"un8kBM": ["Ćŕēàţĩńĝ ƥàĝē: ", ["linkTitle"], "."],+ "uoJF_D": ["Ĩţ ŵàś ţōō ĥàŕď ţō śēţ ũƥ ōŕ ĝēţ śţàŕţēď"],"ur2XSb": ["Vĩśũàĺ ēďĩţōŕ"],"uuoHOU": ["Ćōḿḿàńď ƒàĩĺēď."],"uynXup": [["tokens", "plural", { "one": ["ţōķēń"], "other": ["ţōķēńś"] }]],@@ -3068,6 +3095,7 @@"wbv9xO": ["Ćŕēàţē ńēŵ ƥŕōĴēćţ"],"wdxz7K": ["Śōũŕćē"],"weP6me": ["Ćōũĺďń'ţ ĺōàď ďōćś — ţŷƥē @ àĝàĩń ţō ŕēţŕŷ"],+ "wgNoIs": ["Śēĺēćţ àĺĺ"],"wlwXUk": ["Ŷōũ ƥĩćķēď ~/Ďōŵńĺōàďś. Ƒĩĺēś ţĥēŕē àŕē ũśũàĺĺŷ ţŕàńśĩēńţ — ćōńśĩďēŕ à śţàƀĺē ƒōĺďēŕ ĩńśţēàď."],@@ -3099,10 +3127,12 @@"xCdTnb": ["Ćĺōśē ńēŵ ţàƀ"],"xDBki3": ["Ĥēàďĩńĝ śũĝĝēśţĩōńś"],"xDEcka": ["Ţĥē ƥŕōvĩďēŕ ĩś ŕàţē-ĺĩḿĩţĩńĝ ţĥĩś ķēŷ. Ţŕŷ àĝàĩń ĩń à ḿōḿēńţ."],+ "xEb24l": ["Ĺēţ ũś ƒōĺĺōŵ ũƥ ƀŷ ēḿàĩĺ"],"xFQRu4": ["Ĩ àĺŕēàďŷ ĥàvē ĩţ ĺōćàĺĺŷ"],"xG4tb6": ["Ĺōśţ ćōńńēćţĩōń ţō \"", ["docName"], "\"."],"xHGM4U": ["Ĥĩďē ĤŢḾĹ ƥŕēvĩēŵ"],"xK291b": ["Ţŵō-ƥàĝē (ōďď)"],+ "xMsnTe": ["Śēńď & ćōńţĩńũē"],"xNyj3h": ["Ŕēĩńśţàĺĺ ƒōŕ Ćĺàũďē Ćĥàţ & Ćōŵōŕķ"],"xOTzt5": ["Ĵũśţ ńōŵ"],"xSVO3J": ["Ŵĥàţ ĝēţś ćŕēàţēď"],@@ -3163,6 +3193,7 @@"yQE2r9": ["Ĺōàďĩńĝ"],"yQyglE": ["Ńō ḿàţćĥĩńĝ ďōćś"],"yR5LHI": ["Ēńţēŕ à 6-ďĩĝĩţ ĥēx ĺĩķē #1À2ß3Ć"],+ "yU_9ur": ["Ţō ďō."],"yUxR-Q": ["Ēxƥàńď ", ["keyName"]],"yWSvcf": ["Ćōńţēńţ ŕōōţ"],"yWWThY": ["Àśśēţ ŕēƒēŕēńćē"],diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.poindex a134cf0e0..3be750309 100644--- a/packages/app/src/locales/pseudo/messages.po+++ b/packages/app/src/locales/pseudo/messages.po@@ -230,6 +230,12 @@ msgstr ""msgid "{0} needs {1}"msgstr ""+#. placeholder {0}: selected.size+#. placeholder {1}: projects.length+#: src/uninstall/UninstallPickerScreen.tsx+msgid "{0} of {1} projects selected"+msgstr ""+#. placeholder {0}: templates.length#: src/components/empty-state/CreateView.tsxmsgid "{0} templates available"@@ -848,6 +854,10 @@ msgstr ""msgid "Activate the previous editor tab."msgstr ""+#: src/uninstall/UninstallPickerScreen.tsx+msgid "active"+msgstr ""+#: src/components/ActivityModeContent.tsxmsgid "Active"msgstr ""@@ -1130,6 +1140,10 @@ msgstr ""msgid "Anyone can see"msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Anything you'd like to add? (optional)"+msgstr ""+#: src/components/settings/SearchSection.tsxmsgid "API key set"msgstr ""@@ -1365,6 +1379,10 @@ msgstr ""msgid "Before syncing, set your identity for git commits:"msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Before you go, mind sharing why?"+msgstr ""+#: src/editor/slash-command/items.tsxmsgid "Below"msgstr ""@@ -1493,6 +1511,10 @@ msgstr ""msgid "Bug reporting needs the OpenKnowledge desktop app."msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Bugs, crashes, or it felt unreliable"+msgstr ""+#: src/components/empty-state/use-create-suggestions.tsmsgid "Build a competitor research knowledge base. Start with an overview page, then add cross-linked pages for each competitor, their products and pricing, and the sources behind every claim."msgstr ""@@ -1571,6 +1593,7 @@ msgstr ""#: src/editor/components/CodePreviewEditModal.tsx#: src/editor/extensions/InternalLinkPropPanel.tsx#: src/editor/extensions/WikiLinkPropPanel.tsx+#: src/uninstall/UninstallPickerScreen.tsxmsgid "Cancel"msgstr ""@@ -1698,6 +1721,10 @@ msgstr ""msgid "Claude Desktop"msgstr ""+#: src/uninstall/UninstallNoticeScreen.tsx+msgid "Cleanup log"+msgstr ""+#: src/components/settings/SearchSection.tsxmsgid "Clear"msgstr ""@@ -3079,6 +3106,10 @@ msgstr ""msgid "Detected on this machine"msgstr ""+#: src/uninstall/UninstallPickerScreen.tsx+msgid "Detected OpenKnowledge projects"+msgstr ""+#: src/components/CommandPalette.tsx#: src/components/handoff/OpenInAgentMenuItem.tsxmsgid "Detecting"@@ -3264,6 +3295,10 @@ msgstr ""msgid "Done"msgstr ""+#: src/uninstall/UninstallNoticeScreen.tsx+msgid "Done."+msgstr ""+#. placeholder {0}: item.displayName#: src/components/acp/ThreadView.tsxmsgid "Download {0}"@@ -3473,6 +3508,7 @@ msgid "Email"msgstr ""#: src/components/SubscribeForm.tsx+#: src/uninstall/UninstallSurveyScreen.tsxmsgid "Email address"msgstr ""@@ -4721,6 +4757,10 @@ msgstr ""msgid "I already have it locally →"msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "I'm switching to another tool"+msgstr ""+#: src/components/AutoSyncEnableWarning.tsxmsgid "If an update arrives for something you are editing, you choose which version to keep, like a merge conflict."msgstr ""@@ -4983,6 +5023,22 @@ msgstr ""msgid "Invalid patch payload"msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "It didn't fit into my workflow"+msgstr ""++#: src/uninstall/UninstallSurveyScreen.tsx+msgid "It was a trial or one-off project"+msgstr ""++#: src/uninstall/UninstallSurveyScreen.tsx+msgid "It was missing a feature I needed"+msgstr ""++#: src/uninstall/UninstallSurveyScreen.tsx+msgid "It was too hard to set up or get started"+msgstr ""+#: src/lib/keyboard-shortcuts.tsmsgid "Italic"msgstr ""@@ -5085,6 +5141,10 @@ msgstr ""msgid "Let Tab leave the source editor instead of indenting."msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Let us follow up by email"+msgstr ""+#: src/components/SkillProperties.tsxmsgid "Level"msgstr ""@@ -5825,6 +5885,10 @@ msgstr ""msgid "No <0>.markdownlint.*</0> file yet — every rule runs on the same defaults as the VS Code markdownlint extension: all on, except line length."msgstr ""+#: src/uninstall/UninstallPickerScreen.tsx+msgid "No active or recent OpenKnowledge projects were found."+msgstr ""+#: src/components/settings/ConfigureAgentsSection.tsxmsgid "No agents available."msgstr ""@@ -6938,6 +7002,10 @@ msgstr ""msgid "Preparing share URL..."msgstr ""+#: src/uninstall/UninstallApp.tsx+msgid "Preparing to uninstall OpenKnowledge"+msgstr ""+#: src/components/PublishToGitHubDialog.tsxmsgid "Preview browsers can't auto-copy. Use Cmd/Ctrl+C on the URL above, or open OK in the desktop app."msgstr ""@@ -7202,6 +7270,10 @@ msgstr ""msgid "Receiving objects"msgstr ""+#: src/uninstall/UninstallPickerScreen.tsx+msgid "recent"+msgstr ""+#: src/components/NavigatorApp.tsxmsgid "Recent"msgstr ""@@ -7361,6 +7433,11 @@ msgstr ""msgid "Remove link"msgstr ""+#. placeholder {0}: project.path+#: src/uninstall/UninstallPickerScreen.tsx+msgid "Remove OpenKnowledge from {0}"+msgstr ""+#: src/components/TemplateForm.tsxmsgid "Remove property"msgstr ""@@ -7386,6 +7463,10 @@ msgstr ""msgid "Removing"msgstr ""+#: src/uninstall/UninstallProgressScreen.tsx+msgid "Removing OpenKnowledge files…"+msgstr ""+#: src/components/AppMenubar.tsx#: src/components/command-palette-commands.ts#: src/components/FileTree.tsx@@ -7994,6 +8075,10 @@ msgstr ""msgid "Select a value"msgstr ""+#: src/uninstall/UninstallPickerScreen.tsx+msgid "Select all"+msgstr ""+#: src/components/AppMenubar.tsxmsgid "Select All"msgstr ""@@ -8063,6 +8148,10 @@ msgstr ""msgid "Send"msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Send & continue"+msgstr ""+#: src/components/command-palette-commands.ts#: src/components/HelpPopover.tsxmsgid "Send feedback"@@ -8497,6 +8586,7 @@ msgstr ""#. Secondary button — dismisses the dialog without wiring any tools#: src/components/AuthModal.tsx#: src/components/McpConsentDialogBody.tsx+#: src/uninstall/UninstallSurveyScreen.tsxmsgid "Skip"msgstr ""@@ -8521,6 +8611,10 @@ msgstr ""msgid "Something broke"msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Something else"+msgstr ""+#: src/components/AppErrorBoundary.tsxmsgid "Something went wrong"msgstr ""@@ -9064,6 +9158,10 @@ msgstr ""msgid "Text"msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "Thanks for giving OpenKnowledge a try."+msgstr ""+#: src/components/SubscribeForm.tsxmsgid "Thanks for subscribing. Watch your inbox for product updates."msgstr ""@@ -9390,6 +9488,10 @@ msgstr ""msgid "This looks like a drive root (e.g., C:\\). Scaffolding here will scan an entire drive."msgstr ""+#: src/uninstall/UninstallProgressScreen.tsx+msgid "This may take a moment. Your markdown content is kept."+msgstr ""+#: src/components/SeedDialog.tsxmsgid "This pack is already set up here."msgstr ""@@ -9461,6 +9563,10 @@ msgstr ""msgid "This project's server (v{0}) is newer than this app (v{1})."msgstr ""+#: src/uninstall/UninstallPickerScreen.tsx+msgid "This removes OpenKnowledge’s settings and integrations from your Mac and any projects you select below, but keeps your markdown content and authored skills."+msgstr ""+#. placeholder {0}: skill.bundledVersion ?? ''#. placeholder {1}: skill.installedVersion#: src/components/SkillUpdateDialog.tsx@@ -9531,6 +9637,10 @@ msgstr ""msgid "To do"msgstr ""+#: src/uninstall/UninstallNoticeScreen.tsx+msgid "To do."+msgstr ""+#: src/lib/keyboard-shortcuts.tsmsgid "Toggle a bullet list."msgstr ""@@ -9744,6 +9854,14 @@ msgstr ""msgid "Uninstall everywhere"msgstr ""+#: src/uninstall/UninstallPickerScreen.tsx+msgid "Uninstall OpenKnowledge"+msgstr ""++#: src/uninstall/UninstallPickerScreen.tsx+msgid "Uninstall OpenKnowledge?"+msgstr ""+#. placeholder {0}: skill.name#. placeholder {1}: label(removed)#: src/components/skill-actions.tsx@@ -10120,6 +10238,10 @@ msgstr ""msgid "What would you like to create?"msgstr ""+#: src/uninstall/UninstallSurveyScreen.tsx+msgid "What you share is sent to the OpenKnowledge team."+msgstr ""+#: src/components/HelpPopover.tsxmsgid "What's new"msgstr ""@@ -10321,6 +10443,7 @@ msgid "You're subscribed!"msgstr ""#: src/components/FeedbackForm.tsx+#: src/uninstall/UninstallSurveyScreen.tsxmsgid "[email protected]"msgstr ""diff --git a/packages/app/src/uninstall/UninstallApp.dom.test.tsx b/packages/app/src/uninstall/UninstallApp.dom.test.tsxnew file mode 100644index 000000000..c2e05bb69--- /dev/null+++ b/packages/app/src/uninstall/UninstallApp.dom.test.tsx@@ -0,0 +1,79 @@+import type {+ OkUninstallBridge,+ UninstallDispatchResult,+ UninstallScreenSpec,+} from '@inkeep/open-knowledge-core';+import { cleanup, render, screen } from '@testing-library/react';+import { afterEach, describe, expect, test } from 'vitest';+import { UninstallApp } from './UninstallApp';++/**+ * Routing coverage for the uninstall entry root. Main answers the `ready` pull+ * with a screen spec and UninstallApp mounts the matching screen; jsdom has no+ * `window.okUninstall`, so without this the always-on tiers only ever reach the+ * loading fallback. Mocking that one renderer↔main seam drives each branch, and+ * the refused / rejected cases pin that a non-screen answer keeps the loading+ * placeholder rather than hanging the window.+ */++function stubBridge(ready: () => Promise<UninstallDispatchResult>): void {+ window.okUninstall = {+ ready,+ send: (): Promise<UninstallDispatchResult> => Promise.resolve({ kind: 'accepted' }),+ } satisfies OkUninstallBridge;+}++const sendsScreen = (spec: UninstallScreenSpec) => (): Promise<UninstallDispatchResult> =>+ Promise.resolve({ kind: 'screen', screen: spec });++describe('UninstallApp routing', () => {+ afterEach(() => {+ cleanup();+ window.okUninstall = undefined;+ });++ test('mounts the picker for a picker screen', async () => {+ stubBridge(sendsScreen({ kind: 'picker', projects: [] }));+ render(<UninstallApp />);+ expect(await screen.findByRole('heading', { name: 'Uninstall OpenKnowledge?' })).toBeDefined();+ });++ test('mounts the survey for a survey screen', async () => {+ stubBridge(sendsScreen({ kind: 'survey' }));+ render(<UninstallApp />);+ expect(await screen.findByText('Before you go, mind sharing why?')).toBeDefined();+ });++ test('mounts the progress screen for a progress screen', async () => {+ stubBridge(sendsScreen({ kind: 'progress' }));+ render(<UninstallApp />);+ expect(+ await screen.findByRole('heading', { name: 'Removing OpenKnowledge files…' }),+ ).toBeDefined();+ });++ test('mounts a notice for a notice screen', async () => {+ stubBridge(+ sendsScreen({+ kind: 'notice',+ notice: { title: 'All done', paragraphs: ['Cleanup finished.'], confirmLabel: 'Close' },+ }),+ );+ render(<UninstallApp />);+ expect(await screen.findByText('Cleanup finished.')).toBeDefined();+ });++ test('keeps the loading placeholder when main refuses', async () => {+ stubBridge(() => Promise.resolve({ kind: 'refused', reason: 'unknown-window' }));+ render(<UninstallApp />);+ expect(await screen.findByText('Preparing to uninstall OpenKnowledge')).toBeDefined();+ });++ test('keeps the loading placeholder when the ready invoke rejects', async () => {+ stubBridge(() => Promise.reject(new Error('ipc channel closed')));+ render(<UninstallApp />);+ // A rejected invoke must not hang the window or surface as an unhandled+ // rejection — requestUninstallScreen swallows it and the placeholder stays.+ expect(await screen.findByText('Preparing to uninstall OpenKnowledge')).toBeDefined();+ });+});diff --git a/packages/app/src/uninstall/UninstallApp.tsx b/packages/app/src/uninstall/UninstallApp.tsxnew file mode 100644index 000000000..4eee1cedf--- /dev/null+++ b/packages/app/src/uninstall/UninstallApp.tsx@@ -0,0 +1,76 @@+import type { UninstallScreenSpec } from '@inkeep/open-knowledge-core';+import { Trans } from '@lingui/react/macro';+import { useEffect, useState } from 'react';+import { requestUninstallScreen, sendUninstallIntent } from './bridge';+import { UninstallNoticeScreen } from './UninstallNoticeScreen';+import { UninstallPickerScreen } from './UninstallPickerScreen';+import { UninstallProgressScreen } from './UninstallProgressScreen';+import { UninstallSurveyScreen } from './UninstallSurveyScreen';++/**+ * Root of the uninstall renderer.+ *+ * Main decides which screen this window is and answers the `ready` pull with+ * it; the window itself carries no flow state. The fallback below is the gap+ * between first paint and main's answer, not a screen of its own.+ */+export function UninstallApp() {+ const [screen, setScreen] = useState<UninstallScreenSpec | null>(null);++ useEffect(() => {+ let live = true;+ void requestUninstallScreen().then((next) => {+ if (live) setScreen(next);+ });+ return () => {+ live = false;+ };+ }, []);++ if (screen !== null) {+ switch (screen.kind) {+ case 'picker':+ return (+ <UninstallPickerScreen+ projects={screen.projects}+ onConfirm={(selectedIndexes) =>+ sendUninstallIntent({ kind: 'picker-confirm', selectedIndexes })+ }+ onCancel={() => sendUninstallIntent({ kind: 'picker-cancel' })}+ />+ );+ case 'survey':+ return (+ <UninstallSurveyScreen+ onSend={(answers) => sendUninstallIntent({ kind: 'survey-send', ...answers })}+ onSkip={() => sendUninstallIntent({ kind: 'survey-skip' })}+ />+ );+ case 'progress':+ return <UninstallProgressScreen />;+ case 'notice':+ return (+ <UninstallNoticeScreen+ notice={screen.notice}+ onConfirm={() => sendUninstallIntent({ kind: 'notice-confirm' })}+ onCancel={() => sendUninstallIntent({ kind: 'notice-cancel' })}+ onRevealLog={() => sendUninstallIntent({ kind: 'notice-reveal-log' })}+ />+ );+ default: {+ // A new UninstallScreenSpec kind must add a case above rather than+ // silently falling through to the loading placeholder below.+ const _exhaustive: never = screen;+ return _exhaustive;+ }+ }+ }++ return (+ <main className="flex min-h-dvh items-center justify-center bg-background p-8 text-foreground">+ <p className="text-center text-muted-foreground text-sm">+ <Trans>Preparing to uninstall OpenKnowledge</Trans>+ </p>+ </main>+ );+}diff --git a/packages/app/src/uninstall/UninstallNoticeScreen.dom.test.tsx b/packages/app/src/uninstall/UninstallNoticeScreen.dom.test.tsxnew file mode 100644index 000000000..072fa9d12--- /dev/null+++ b/packages/app/src/uninstall/UninstallNoticeScreen.dom.test.tsx@@ -0,0 +1,160 @@+import type { UninstallNoticeScreen as UninstallNoticeSpec } from '@inkeep/open-knowledge-core';+import { cleanup, render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { afterEach, describe, expect, test, vi } from 'vitest';+import { UninstallNoticeScreen } from './UninstallNoticeScreen';++/** The two-button shape: a question whose safe answer is Cancel. */+const CONFIRM_NOTICE: UninstallNoticeSpec = {+ title: 'Uninstall OpenKnowledge?',+ paragraphs: [+ 'This removes OpenKnowledge’s settings and integrations from your Mac, but keeps your markdown content and authored skills.',+ 'When cleanup finishes, OpenKnowledge will help you remove the app itself, then quit.',+ ],+ confirmLabel: 'Uninstall OpenKnowledge',+ cancelLabel: 'Cancel',+ danger: true,+};++/** The single-button shape: an acknowledgement with a recap and one action left. */+const COMPLETION_NOTICE: UninstallNoticeSpec = {+ title: 'OpenKnowledge files were removed',+ subtitle: "Almost done. Here's what happened and what's left.",+ paragraphs: [],+ checklist: [+ {+ label: 'Kept your content',+ detail: 'Markdown files and authored skills were left untouched.',+ done: true,+ },+ {+ label: 'Removed OpenKnowledge files',+ detail: 'Cleaned up, including from 2 projects.',+ done: true,+ },+ {+ label: 'Move OpenKnowledge.app to the Trash',+ detail:+ 'Reveal in Finder shows the app and quits OpenKnowledge, so you can drag it to the Trash.',+ done: false,+ },+ ],+ logRevealLabel: 'Cleanup log',+ confirmLabel: 'Reveal in Finder',+};++const FAILURE_NOTICE: UninstallNoticeSpec = {+ title: 'Cleanup didn’t finish',+ paragraphs: ['Some files may not have been removed — details below.'],+ log: 'Deinitializing project: /Users/dev/Notes\ndeinit=1 global=0',+ footnote: 'Also saved to /Users/dev/Library/Logs/OpenKnowledge/uninstall.log',+ confirmLabel: 'Continue',+};++function renderNotice(notice: UninstallNoticeSpec) {+ const onConfirm = vi.fn();+ const onCancel = vi.fn();+ const onRevealLog = vi.fn();+ render(+ <UninstallNoticeScreen+ notice={notice}+ onConfirm={onConfirm}+ onCancel={onCancel}+ onRevealLog={onRevealLog}+ />,+ );+ return { onConfirm, onCancel, onRevealLog, user: userEvent.setup() };+}++describe('uninstall notice screen', () => {+ afterEach(cleanup);++ test('shows the confirm question with both answers', async () => {+ const { user, onConfirm, onCancel } = renderNotice(CONFIRM_NOTICE);++ expect(screen.getByRole('alertdialog', { name: 'Uninstall OpenKnowledge?' })).toBeDefined();+ for (const paragraph of CONFIRM_NOTICE.paragraphs) {+ expect(screen.getByText(paragraph)).toBeDefined();+ }++ await user.click(screen.getByRole('button', { name: 'Uninstall OpenKnowledge' }));+ expect(onConfirm).toHaveBeenCalledTimes(1);+ expect(onCancel).not.toHaveBeenCalled();+ });++ test('cancel holds focus on the two-button notice so Return cannot uninstall', () => {+ renderNotice(CONFIRM_NOTICE);++ expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Cancel' }));+ });++ test('confirm holds focus on a single-button notice, where there is nothing else to choose', () => {+ renderNotice(COMPLETION_NOTICE);++ expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Reveal in Finder' }));+ });++ // The asymmetry main also applies to a window close: an unanswered question+ // must not proceed, while an acknowledgement has no other outcome to reach.+ test('Escape cancels a two-button notice', async () => {+ const { user, onConfirm, onCancel } = renderNotice(CONFIRM_NOTICE);++ await user.keyboard('{Escape}');++ expect(onCancel).toHaveBeenCalledTimes(1);+ expect(onConfirm).not.toHaveBeenCalled();+ });++ test('Escape confirms a single-button notice', async () => {+ const { user, onConfirm, onCancel } = renderNotice(COMPLETION_NOTICE);++ await user.keyboard('{Escape}');++ expect(onConfirm).toHaveBeenCalledTimes(1);+ expect(onCancel).not.toHaveBeenCalled();+ });++ test('recaps what was kept and removed, and what the user still has to do', () => {+ renderNotice(COMPLETION_NOTICE);++ expect(screen.getByText("Almost done. Here's what happened and what's left.")).toBeDefined();+ for (const item of COMPLETION_NOTICE.checklist ?? []) {+ expect(screen.getByText(item.label)).toBeDefined();+ if (item.detail !== undefined) expect(screen.getByText(item.detail)).toBeDefined();+ }++ // State reaches a screen reader as a word, not only as the check glyph.+ expect(screen.getAllByText('Done.')).toHaveLength(2);+ expect(screen.getAllByText('To do.')).toHaveLength(1);+ });++ test('revealing the log leaves the notice up', async () => {+ const { user, onConfirm, onRevealLog } = renderNotice(COMPLETION_NOTICE);++ await user.click(screen.getByRole('button', { name: 'Cleanup log' }));++ expect(onRevealLog).toHaveBeenCalledTimes(1);+ // Revealing is not an answer — settling here would quit the flow early.+ expect(onConfirm).not.toHaveBeenCalled();+ });++ test('offers no log reveal when there is no log to reveal', () => {+ renderNotice(CONFIRM_NOTICE);++ expect(screen.queryByRole('button', { name: 'Cleanup log' })).toBeNull();+ });++ test('shows the cleanup detail and where the full log was written', () => {+ renderNotice(FAILURE_NOTICE);++ expect(screen.getByText('Some files may not have been removed — details below.')).toBeDefined();+ expect(+ screen.getByText('Also saved to /Users/dev/Library/Logs/OpenKnowledge/uninstall.log'),+ ).toBeDefined();++ // Keyboard users have to be able to scroll the log, so it is a named region.+ const log = screen.getByRole('region', { name: 'Cleanup log' });+ expect(log.textContent).toContain('deinit=1 global=0');+ expect(log.getAttribute('tabindex')).toBe('0');+ });+});diff --git a/packages/app/src/uninstall/UninstallNoticeScreen.tsx b/packages/app/src/uninstall/UninstallNoticeScreen.tsxnew file mode 100644index 000000000..f7c167dc7--- /dev/null+++ b/packages/app/src/uninstall/UninstallNoticeScreen.tsx@@ -0,0 +1,164 @@+import type {+ UninstallNoticeChecklistItem,+ UninstallNoticeScreen as UninstallNoticeSpec,+} from '@inkeep/open-knowledge-core';+import { Trans, useLingui } from '@lingui/react/macro';+import { Check } from 'lucide-react';+import { useEffect, useId } from 'react';+import { Button } from '@/components/ui/button';+import { cn } from '@/lib/utils';++interface UninstallNoticeScreenProps {+ notice: UninstallNoticeSpec;+ onConfirm: () => void;+ /** Only reachable on a two-button notice. */+ onCancel: () => void;+ /** Ask main to reveal the cleanup log. Non-terminal — the screen stays up. */+ onRevealLog: () => void;+}++function NoticeChecklist({ items }: { items: readonly UninstallNoticeChecklistItem[] }) {+ return (+ <ol className="mb-1.5">+ {items.map((item, index) => (+ <li key={item.label} className="relative pb-5 pl-[30px] last:pb-1">+ {index < items.length - 1 && (+ <span+ aria-hidden="true"+ className="absolute top-[22px] bottom-0.5 left-[9px] w-0.5 bg-border"+ />+ )}+ {/* The check glyph is a shape channel rather than colour alone, and the+ visually-hidden word carries the same state to a screen reader. */}+ <span+ aria-hidden="true"+ className={cn(+ 'absolute top-px left-0 inline-flex size-5 items-center justify-center rounded-full',+ item.done+ ? 'bg-primary/15 text-primary'+ : 'border-[1.5px] border-muted-foreground/50',+ )}+ >+ {item.done && <Check className="size-3" />}+ </span>+ <span className="sr-only">+ {item.done ? <Trans>Done.</Trans> : <Trans>To do.</Trans>}+ </span>+ <span className="block">+ <span className="font-medium">{item.label}</span>+ {item.detail !== undefined && (+ <span className="mt-0.5 block text-muted-foreground leading-snug">{item.detail}</span>+ )}+ </span>+ </li>+ ))}+ </ol>+ );+}++/**+ * The confirm, completion and failure screens. They differ only in the content+ * main sends down, so they are one component rather than three.+ *+ * Two shapes, and the difference is load-bearing: a notice carrying+ * `cancelLabel` is a question whose safe answer is Cancel, so Cancel holds+ * focus and Escape maps to it. A single-button notice is an acknowledgement+ * with nothing else to choose, so Escape confirms. Main maps a window close the+ * same two ways.+ */+export function UninstallNoticeScreen({+ notice,+ onConfirm,+ onCancel,+ onRevealLog,+}: UninstallNoticeScreenProps) {+ const { t } = useLingui();+ const titleId = useId();+ const bodyId = useId();+ const hasCancel = notice.cancelLabel !== undefined;++ useEffect(() => {+ const onKeyDown = (event: KeyboardEvent) => {+ if (event.key !== 'Escape') return;+ if (hasCancel) onCancel();+ else onConfirm();+ };+ document.addEventListener('keydown', onKeyDown);+ return () => {+ document.removeEventListener('keydown', onKeyDown);+ };+ }, [hasCancel, onCancel, onConfirm]);++ return (+ <div+ role="alertdialog"+ aria-labelledby={titleId}+ aria-describedby={bodyId}+ className="flex h-dvh flex-col bg-background text-foreground"+ >+ <header className="shrink-0 space-y-4 px-6 pt-5 pb-3.5">+ <h1 id={titleId} className="font-medium text-base leading-none">+ {notice.title}+ </h1>+ {notice.subtitle !== undefined && (+ <p className="text-muted-foreground text-sm leading-snug">{notice.subtitle}</p>+ )}+ </header>++ <div id={bodyId} className="flex min-h-0 flex-1 flex-col px-6 pt-1 pb-4 text-sm">+ {notice.paragraphs.map((text) => (+ <p key={text} className="mb-2.5 leading-normal">+ {text}+ </p>+ ))}+ {notice.checklist !== undefined && <NoticeChecklist items={notice.checklist} />}+ {notice.log !== undefined && (+ <section+ aria-label={t`Cleanup log`}+ // biome-ignore lint/a11y/noNoninteractiveTabindex: focusable scroll region per WCAG 2.1.1 — the log is the only in-product account of what cleanup failed to remove, so reading it must not require a pointer.+ tabIndex={0}+ className="subtle-scrollbar mt-0.5 mb-2.5 min-h-20 flex-1 overflow-auto rounded-lg border border-border border-dotted bg-muted/40 px-3 py-2.5 focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50"+ >+ <pre className="select-text whitespace-pre-wrap font-mono text-xs leading-relaxed wrap-anywhere">+ {notice.log}+ </pre>+ </section>+ )}+ {notice.footnote !== undefined && (+ <p className="select-text text-muted-foreground text-xs wrap-anywhere">+ {notice.footnote}+ </p>+ )}+ {notice.logRevealLabel !== undefined && (+ <p className="mt-0.5">+ <Button+ type="button"+ variant="link-muted"+ size="xs"+ className="h-auto px-0 underline underline-offset-2"+ onClick={onRevealLog}+ >+ {notice.logRevealLabel}+ </Button>+ </p>+ )}+ </div>++ <footer className="flex items-center justify-end gap-2.5 border-border border-t bg-muted/50 px-6 pt-3.5 pb-4">+ {notice.cancelLabel !== undefined && (+ <Button type="button" variant="outline-mono" autoFocus onClick={onCancel}>+ {notice.cancelLabel}+ </Button>+ )}+ <Button+ type="button"+ variant={notice.danger === true ? 'destructive' : 'default'}+ autoFocus={!hasCancel}+ onClick={onConfirm}+ >+ {notice.confirmLabel}+ </Button>+ </footer>+ </div>+ );+}diff --git a/packages/app/src/uninstall/UninstallPickerScreen.dom.test.tsx b/packages/app/src/uninstall/UninstallPickerScreen.dom.test.tsxnew file mode 100644index 000000000..703401410--- /dev/null+++ b/packages/app/src/uninstall/UninstallPickerScreen.dom.test.tsx@@ -0,0 +1,151 @@+import type { UninstallProjectRow } from '@inkeep/open-knowledge-core';+import { cleanup, render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { afterEach, describe, expect, test, vi } from 'vitest';+import { UninstallPickerScreen } from './UninstallPickerScreen';++const PROJECTS: readonly UninstallProjectRow[] = [+ { path: '/Users/dev/Notes', open: true, recent: true, running: true },+ { path: '/Users/dev/Work/Team Handbook', open: false, recent: true, running: false },+ { path: '/Users/dev/Personal/Journal', open: false, recent: true, running: false },+];++function renderPicker(projects: readonly UninstallProjectRow[] = PROJECTS) {+ const onConfirm = vi.fn();+ const onCancel = vi.fn();+ render(<UninstallPickerScreen projects={projects} onConfirm={onConfirm} onCancel={onCancel} />);+ return { onConfirm, onCancel, user: userEvent.setup() };+}++function checkboxFor(path: string) {+ return screen.getByRole('checkbox', { name: `Remove OpenKnowledge from ${path}` });+}++describe('uninstall project picker', () => {+ afterEach(cleanup);++ test('lists every detected project with a single status badge', () => {+ renderPicker();++ expect(screen.getByRole('heading', { name: 'Uninstall OpenKnowledge?' })).toBeDefined();+ expect(screen.getByRole('checkbox', { name: 'Select all' })).toBeDefined();+ expect(screen.getByRole('status').textContent).toBe('0 / 3');+ for (const project of PROJECTS) {+ expect(checkboxFor(project.path)).toBeDefined();+ }++ // open and/or running collapse to `active`; a recents-only project is `recent`.+ // PROJECTS[0] is open+running+recent → active; [1] and [2] are recent-only.+ const badges = screen.getAllByText(/^(active|recent)$/);+ expect(badges.map((el) => el.textContent)).toEqual(['active', 'recent', 'recent']);+ });++ test('nothing is selected until the user picks a project', () => {+ renderPicker();++ expect(screen.getByRole('status').textContent).toBe('0 / 3');+ for (const project of PROJECTS) {+ expect(checkboxFor(project.path).getAttribute('aria-checked')).toBe('false');+ }+ });++ test('the selected count follows what the user ticks and unticks', async () => {+ const { user } = renderPicker();++ await user.click(checkboxFor('/Users/dev/Notes'));+ expect(screen.getByRole('status').textContent).toBe('1 / 3');++ await user.click(checkboxFor('/Users/dev/Personal/Journal'));+ expect(screen.getByRole('status').textContent).toBe('2 / 3');++ await user.click(checkboxFor('/Users/dev/Notes'));+ expect(screen.getByRole('status').textContent).toBe('1 / 3');+ });++ test('the header checkbox selects every project, then clears them', async () => {+ const { user } = renderPicker();+ const selectAll = screen.getByRole('checkbox', { name: 'Select all' });++ await user.click(selectAll);+ for (const project of PROJECTS) {+ expect(checkboxFor(project.path).getAttribute('aria-checked')).toBe('true');+ }+ expect(selectAll.getAttribute('aria-checked')).toBe('true');+ expect(screen.getByRole('status').textContent).toBe('3 / 3');++ await user.click(selectAll);+ for (const project of PROJECTS) {+ expect(checkboxFor(project.path).getAttribute('aria-checked')).toBe('false');+ }+ expect(screen.getByRole('status').textContent).toBe('0 / 3');+ });++ test('the header checkbox is indeterminate when only some projects are ticked', async () => {+ const { user } = renderPicker();+ const selectAll = screen.getByRole('checkbox', { name: 'Select all' });++ await user.click(checkboxFor('/Users/dev/Notes'));+ expect(selectAll.getAttribute('aria-checked')).toBe('mixed');+ });++ test('clicking a project row toggles its checkbox', async () => {+ const { user } = renderPicker();++ await user.click(screen.getByText('/Users/dev/Work/Team Handbook'));++ expect(checkboxFor('/Users/dev/Work/Team Handbook').getAttribute('aria-checked')).toBe('true');+ expect(screen.getByRole('status').textContent).toBe('1 / 3');+ });++ test('confirming reports the selected indexes in ascending order', async () => {+ const { user, onConfirm, onCancel } = renderPicker();++ await user.click(checkboxFor('/Users/dev/Personal/Journal'));+ await user.click(checkboxFor('/Users/dev/Notes'));+ await user.click(screen.getByRole('button', { name: 'Uninstall OpenKnowledge' }));++ expect(onConfirm).toHaveBeenCalledTimes(1);+ expect(onConfirm).toHaveBeenCalledWith([0, 2]);+ expect(onCancel).not.toHaveBeenCalled();+ });++ test('confirming with nothing ticked reports an empty selection, not a cancel', async () => {+ const { user, onConfirm, onCancel } = renderPicker();++ await user.click(screen.getByRole('button', { name: 'Uninstall OpenKnowledge' }));++ expect(onConfirm).toHaveBeenCalledWith([]);+ expect(onCancel).not.toHaveBeenCalled();+ });++ test('cancelling reports a cancel and never a selection', async () => {+ const { user, onConfirm, onCancel } = renderPicker();++ await user.click(checkboxFor('/Users/dev/Notes'));+ await user.click(screen.getByRole('button', { name: 'Cancel' }));++ expect(onCancel).toHaveBeenCalledTimes(1);+ expect(onConfirm).not.toHaveBeenCalled();+ });++ test('Escape cancels', async () => {+ const { user, onCancel } = renderPicker();++ await user.keyboard('{Escape}');++ expect(onCancel).toHaveBeenCalledTimes(1);+ });++ test('the empty state explains that nothing was detected and can still be confirmed', async () => {+ const { user, onConfirm } = renderPicker([]);++ expect(+ screen.getByText('No active or recent OpenKnowledge projects were found.'),+ ).toBeDefined();+ // No projects → no select-all header and no rows.+ expect(screen.queryByRole('checkbox')).toBeNull();++ await user.click(screen.getByRole('button', { name: 'Uninstall OpenKnowledge' }));+ expect(onConfirm).toHaveBeenCalledWith([]);+ });+});diff --git a/packages/app/src/uninstall/UninstallPickerScreen.tsx b/packages/app/src/uninstall/UninstallPickerScreen.tsxnew file mode 100644index 000000000..28773d86a--- /dev/null+++ b/packages/app/src/uninstall/UninstallPickerScreen.tsx@@ -0,0 +1,230 @@+import type { UninstallProjectRow } from '@inkeep/open-knowledge-core';+import { Trans, useLingui } from '@lingui/react/macro';+import { useEffect, useId, useState } from 'react';+import { Badge } from '@/components/ui/badge';+import { Button } from '@/components/ui/button';+import { Checkbox } from '@/components/ui/checkbox';+import { Label } from '@/components/ui/label';++type ProjectStatus = 'active' | 'recent';++interface UninstallPickerScreenProps {+ projects: readonly UninstallProjectRow[];+ /** Indexes into `projects`, ascending. Main re-resolves them against its own list. */+ onConfirm: (selectedIndexes: number[]) => void;+ onCancel: () => void;+}++/**+ * One status per row. `open` (a live editor window) and `running` (a live server+ * process) both mean the project is in use right now, so they collapse to+ * `active`; the open/server split is an implementation detail the user doesn't+ * act on. A project only in the recents list is `recent`. `active` wins when+ * both hold — it is the distinction that bears on removing the project now.+ */+function projectStatus(project: UninstallProjectRow): ProjectStatus | null {+ if (project.open || project.running) return 'active';+ if (project.recent) return 'recent';+ return null;+}++/**+ * Trailing path segment, the way `node:path`'s `basename` reads it — the+ * renderer has no `node:path`, and this stays macOS-shaped like the rest of the+ * uninstall flow. Falls back to the whole path when there is no segment.+ */+function projectDisplayName(path: string): string {+ return path.split('/').filter(Boolean).at(-1) ?? path;+}++function ProjectStatusBadge({ status }: { status: ProjectStatus }) {+ const { t } = useLingui();+ const labels: Record<ProjectStatus, string> = {+ active: t`active`,+ recent: t`recent`,+ };+ return (+ <Badge variant="secondary" className="rounded-sm text-muted-foreground">+ {labels[status]}+ </Badge>+ );+}++function ProjectRow({+ project,+ checked,+ onCheckedChange,+}: {+ project: UninstallProjectRow;+ checked: boolean;+ onCheckedChange: (checked: boolean) => void;+}) {+ const { t } = useLingui();+ const checkboxId = useId();+ const status = projectStatus(project);++ return (+ <div className="grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2.5 border-border/60 border-b px-3 py-2.5 last:border-b-0 hover:bg-accent/40 max-sm:grid-cols-[auto_minmax(0,1fr)]">+ <Checkbox+ id={checkboxId}+ className="mt-0.5"+ checked={checked}+ onCheckedChange={(next) => onCheckedChange(next === true)}+ // Overrides the visible label so the row announces what ticking it does,+ // not just which project it is.+ aria-label={t`Remove OpenKnowledge from ${project.path}`}+ />+ <Label htmlFor={checkboxId} className="min-w-0 flex-col items-start gap-0.5 font-normal">+ <span className="w-full truncate font-medium text-sm">+ {projectDisplayName(project.path)}+ </span>+ <span className="w-full select-text break-words text-muted-foreground text-xs">+ {project.path}+ </span>+ </Label>+ {status !== null && (+ <div className="flex justify-end max-sm:col-start-2 max-sm:justify-start">+ <ProjectStatusBadge status={status} />+ </div>+ )}+ </div>+ );+}++/**+ * First screen of the desktop self-uninstall flow: confirm the uninstall, and+ * optionally pick projects to run `ok deinit` against.+ *+ * The rows are whatever main sent down; the only thing that travels back is a+ * set of indexes into that list, so this screen can never name a path main did+ * not already offer.+ */+export function UninstallPickerScreen({+ projects,+ onConfirm,+ onCancel,+}: UninstallPickerScreenProps) {+ const { t } = useLingui();+ const [selected, setSelected] = useState<ReadonlySet<number>>(() => new Set());+ const titleId = useId();+ const descriptionId = useId();+ const selectAllId = useId();++ const allSelected = projects.length > 0 && selected.size === projects.length;+ const selectAllState: boolean | 'indeterminate' = allSelected+ ? true+ : selected.size > 0+ ? 'indeterminate'+ : false;+ const setAllSelected = (next: boolean) =>+ setSelected(next ? new Set(projects.map((_, index) => index)) : new Set());++ useEffect(() => {+ const onKeyDown = (event: KeyboardEvent) => {+ if (event.key === 'Escape') {+ onCancel();+ return;+ }+ if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'a') {+ event.preventDefault();+ setSelected(new Set(projects.map((_, index) => index)));+ }+ };+ document.addEventListener('keydown', onKeyDown);+ return () => {+ document.removeEventListener('keydown', onKeyDown);+ };+ }, [onCancel, projects]);++ return (+ <div+ role="dialog"+ aria-labelledby={titleId}+ aria-describedby={descriptionId}+ className="flex h-dvh flex-col overflow-hidden bg-background text-foreground"+ >+ <header className="shrink-0 px-6 pt-5 pb-3.5 space-y-4">+ <h1 id={titleId} className="font-medium leading-none text-base">+ <Trans>Uninstall OpenKnowledge?</Trans>+ </h1>+ <p id={descriptionId} className="text-sm text-muted-foreground">+ <Trans>+ This removes OpenKnowledge’s settings and integrations from your Mac and any projects+ you select below, but keeps your markdown content and authored skills.+ </Trans>+ </p>+ </header>++ <section+ aria-label={t`Detected OpenKnowledge projects`}+ className="flex min-h-0 flex-1 flex-col px-6 py-3.5"+ >+ {projects.length === 0 ? (+ <div className="rounded-lg border border-border p-4">+ <p className="text-muted-foreground text-sm">+ <Trans>No active or recent OpenKnowledge projects were found.</Trans>+ </p>+ </div>+ ) : (+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-border">+ {/* Fixed select-all header row: a tri-state checkbox (all / some /+ none) plus the total count. Only the rows below it scroll. */}+ <div className="flex shrink-0 items-center gap-2.5 border-border border-b px-3 py-2.5 bg-muted/30">+ <Checkbox+ id={selectAllId}+ checked={selectAllState}+ onCheckedChange={(next) => setAllSelected(next === true)}+ />+ <Label htmlFor={selectAllId} className="flex-1 font-medium text-sm">+ <Trans>Select all</Trans>+ </Label>+ {/* Selected-of-total, announced on change (replaces a separate+ footer count). Visually a bare fraction; the aria-label spells+ it out for screen readers. */}+ <span+ role="status"+ aria-label={t`${selected.size} of ${projects.length} projects selected`}+ className="text-muted-foreground text-xs tabular-nums"+ >+ {selected.size} / {projects.length}+ </span>+ </div>+ {/* `overflow-y-scroll` over `auto` keeps the gutter present at every+ list length, so a row's tag column never shifts as rows are added. */}+ <div className="subtle-scrollbar min-h-0 flex-1 overflow-y-scroll [scrollbar-gutter:stable]">+ {projects.map((project, index) => (+ <ProjectRow+ key={project.path}+ project={project}+ checked={selected.has(index)}+ onCheckedChange={(next) => {+ setSelected((prev) => {+ const updated = new Set(prev);+ if (next) updated.add(index);+ else updated.delete(index);+ return updated;+ });+ }}+ />+ ))}+ </div>+ </div>+ )}+ </section>++ <footer className="flex items-center justify-end gap-2.5 border-border border-t bg-muted/50 px-6 pt-3.5 pb-4">+ {/* Cancel holds initial focus so Return cannot uninstall by accident. */}+ <Button type="button" variant="outline-mono" autoFocus onClick={onCancel}>+ <Trans>Cancel</Trans>+ </Button>+ <Button+ type="button"+ variant="destructive"+ onClick={() => onConfirm([...selected].sort((left, right) => left - right))}+ >+ <Trans>Uninstall OpenKnowledge</Trans>+ </Button>+ </footer>+ </div>+ );+}diff --git a/packages/app/src/uninstall/UninstallProgressScreen.dom.test.tsx b/packages/app/src/uninstall/UninstallProgressScreen.dom.test.tsxnew file mode 100644index 000000000..2b68f8c12--- /dev/null+++ b/packages/app/src/uninstall/UninstallProgressScreen.dom.test.tsx@@ -0,0 +1,25 @@+import { cleanup, render, screen } from '@testing-library/react';+import { afterEach, describe, expect, test } from 'vitest';+import { UninstallProgressScreen } from './UninstallProgressScreen';++describe('uninstall progress screen', () => {+ afterEach(cleanup);++ test('says what is happening and what is being kept', () => {+ render(<UninstallProgressScreen />);++ expect(screen.getByRole('heading', { name: 'Removing OpenKnowledge files…' })).toBeDefined();+ expect(+ screen.getByText('This may take a moment. Your markdown content is kept.'),+ ).toBeDefined();+ });++ test('announces itself as busy without asking for anything', () => {+ render(<UninstallProgressScreen />);++ // Cleanup is already running and cannot be answered, waived or interrupted;+ // main also refuses to let this window close while it runs.+ expect(screen.getByRole('status')).toBeDefined();+ expect(screen.queryAllByRole('button')).toHaveLength(0);+ });+});diff --git a/packages/app/src/uninstall/UninstallProgressScreen.tsx b/packages/app/src/uninstall/UninstallProgressScreen.tsxnew file mode 100644index 000000000..2a0116835--- /dev/null+++ b/packages/app/src/uninstall/UninstallProgressScreen.tsx@@ -0,0 +1,31 @@+import { Trans } from '@lingui/react/macro';+import { Loader2 } from 'lucide-react';++/**+ * Shown while the bundled CLI removes the OpenKnowledge footprint.+ *+ * Purely cosmetic and deliberately inert: there is nothing to answer and no way+ * out, because main prevents this window from closing until the cleanup it is+ * covering has finished.+ */+export function UninstallProgressScreen() {+ return (+ <main className="grid h-dvh place-items-center bg-background text-foreground">+ <div role="status" className="max-w-vw px-7 py-7 text-center">+ <Loader2+ aria-hidden="true"+ className="mx-auto mb-4 size-8 animate-spin text-primary motion-reduce:animate-none"+ />+ <h1 className="mb-2 font-medium text-base leading-none">+ {/* biome-ignore lint/plugin/microcopy-ellipsis: the uninstall migration to React is a+ pure render-swap — this heading is carried over verbatim from the screen it replaces,+ and a copy-parity gate compares the two. Reword both surfaces together or neither. */}+ <Trans>Removing OpenKnowledge files…</Trans>+ </h1>+ <p className="text-muted-foreground text-sm leading-relaxed">+ <Trans>This may take a moment. Your markdown content is kept.</Trans>+ </p>+ </div>+ </main>+ );+}diff --git a/packages/app/src/uninstall/UninstallSurveyScreen.dom.test.tsx b/packages/app/src/uninstall/UninstallSurveyScreen.dom.test.tsxnew file mode 100644index 000000000..270e3a785--- /dev/null+++ b/packages/app/src/uninstall/UninstallSurveyScreen.dom.test.tsx@@ -0,0 +1,141 @@+import { UNINSTALL_FEEDBACK_REASONS } from '@inkeep/open-knowledge-core';+import { cleanup, render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { afterEach, describe, expect, test, vi } from 'vitest';+import { UninstallSurveyScreen } from './UninstallSurveyScreen';++function renderSurvey() {+ const onSend = vi.fn();+ const onSkip = vi.fn();+ render(<UninstallSurveyScreen onSend={onSend} onSkip={onSkip} />);+ return { onSend, onSkip, user: userEvent.setup() };+}++function emailField(): HTMLInputElement {+ const field = screen.getByLabelText('Email address');+ if (!(field instanceof HTMLInputElement)) throw new Error('the email field is not an input');+ return field;+}++describe('uninstall churn survey', () => {+ afterEach(cleanup);++ test('offers every reason in the shared taxonomy, in its order and wording', () => {+ renderSurvey();++ expect(+ screen.getByRole('heading', { name: 'Thanks for giving OpenKnowledge a try.' }),+ ).toBeDefined();+ expect(screen.getByText('What you share is sent to the OpenKnowledge team.')).toBeDefined();++ // The labels this window renders are its own translations, while the slugs+ // and their order are the wire contract churn tickets are grouped by. Both+ // halves have to line up, or a ticket files under a reason nobody picked.+ expect(screen.getAllByRole('radio').map((radio) => radio.getAttribute('value'))).toEqual(+ UNINSTALL_FEEDBACK_REASONS.map((option) => option.value),+ );+ for (const option of UNINSTALL_FEEDBACK_REASONS) {+ expect(screen.getByRole('radio', { name: option.label })).toBeDefined();+ }+ });++ test('nothing is answered until the user fills something in', async () => {+ const { user, onSend } = renderSurvey();++ for (const radio of screen.getAllByRole('radio')) {+ expect(radio.getAttribute('aria-checked')).toBe('false');+ }+ await user.click(screen.getByRole('button', { name: 'Send & continue' }));++ expect(onSend).toHaveBeenCalledWith({});+ });++ test('sends the picked reason as its slug, not its label', async () => {+ const { user, onSend } = renderSurvey();++ await user.click(screen.getByRole('radio', { name: 'It was missing a feature I needed' }));+ await user.click(screen.getByRole('button', { name: 'Send & continue' }));++ expect(onSend).toHaveBeenCalledWith({ reason: 'missing-feature' });+ });++ test('sends the note alongside the reason, trimmed', async () => {+ const { user, onSend } = renderSurvey();++ await user.click(screen.getByRole('radio', { name: 'Something else' }));+ await user.type(+ screen.getByLabelText("Anything you'd like to add? (optional)"),+ ' it lagged ',+ );+ await user.click(screen.getByRole('button', { name: 'Send & continue' }));++ expect(onSend).toHaveBeenCalledWith({ reason: 'other', note: 'it lagged' });+ });++ test('a whitespace-only note is not an answer', async () => {+ const { user, onSend } = renderSurvey();++ await user.type(screen.getByLabelText("Anything you'd like to add? (optional)"), ' ');+ await user.click(screen.getByRole('button', { name: 'Send & continue' }));++ expect(onSend).toHaveBeenCalledWith({});+ });++ test('the email field is hidden and disabled until the user opts in', () => {+ renderSurvey();++ const field = emailField();+ expect(field.disabled).toBe(true);+ expect(field.closest('[hidden]')).not.toBeNull();+ });++ test('opting in reveals, enables and focuses the email field', async () => {+ const { user } = renderSurvey();++ await user.click(screen.getByRole('checkbox', { name: 'Let us follow up by email' }));++ const field = emailField();+ expect(field.disabled).toBe(false);+ expect(field.closest('[hidden]')).toBeNull();+ expect(document.activeElement).toBe(field);+ });++ test('sends the address once the user has opted in', async () => {+ const { user, onSend } = renderSurvey();++ await user.click(screen.getByRole('checkbox', { name: 'Let us follow up by email' }));+ await user.type(emailField(), '[email protected]');+ await user.click(screen.getByRole('button', { name: 'Send & continue' }));++ expect(onSend).toHaveBeenCalledWith({ email: '[email protected]' });+ });++ test('opting back out drops the address the user had typed', async () => {+ const { user, onSend } = renderSurvey();++ const optIn = screen.getByRole('checkbox', { name: 'Let us follow up by email' });+ await user.click(optIn);+ await user.type(emailField(), '[email protected]');+ await user.click(optIn);+ await user.click(screen.getByRole('button', { name: 'Send & continue' }));++ expect(onSend).toHaveBeenCalledWith({});+ });++ test('skipping answers nothing and never sends', async () => {+ const { user, onSend, onSkip } = renderSurvey();++ await user.click(screen.getByRole('radio', { name: 'Something else' }));+ await user.click(screen.getByRole('button', { name: 'Skip' }));++ expect(onSkip).toHaveBeenCalledTimes(1);+ expect(onSend).not.toHaveBeenCalled();+ });++ test('has no cancel affordance — both buttons continue the uninstall', () => {+ renderSurvey();++ expect(screen.queryByRole('button', { name: 'Cancel' })).toBeNull();+ expect(screen.getAllByRole('button')).toHaveLength(2);+ });+});diff --git a/packages/app/src/uninstall/UninstallSurveyScreen.tsx b/packages/app/src/uninstall/UninstallSurveyScreen.tsxnew file mode 100644index 000000000..2fad4b09e--- /dev/null+++ b/packages/app/src/uninstall/UninstallSurveyScreen.tsx@@ -0,0 +1,193 @@+import {+ UNINSTALL_FEEDBACK_EMAIL_MAX_LEN,+ UNINSTALL_FEEDBACK_NOTE_MAX_LEN,+ UNINSTALL_FEEDBACK_REASONS,+ type UninstallFeedbackReason,+} from '@inkeep/open-knowledge-core';+import { Trans, useLingui } from '@lingui/react/macro';+import { useEffect, useId, useRef, useState } from 'react';+import { Button } from '@/components/ui/button';+import { Checkbox } from '@/components/ui/checkbox';+import { Input } from '@/components/ui/input';+import { Label } from '@/components/ui/label';+import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';+import { Textarea } from '@/components/ui/textarea';++/** What the user left behind; every field is absent when untouched. */+interface UninstallSurveyAnswers {+ reason?: UninstallFeedbackReason;+ note?: string;+ email?: string;+}++interface UninstallSurveyScreenProps {+ /** Send the answers and continue the uninstall. */+ onSend: (answers: UninstallSurveyAnswers) => void;+ /** Continue the uninstall having asked nothing. */+ onSkip: () => void;+}++/**+ * The reason labels, translated.+ *+ * `UNINSTALL_FEEDBACK_REASONS` stays the source of the taxonomy — its order and+ * its `value` slugs are the wire contract — but its `label` half is plain+ * English for the two consumers that have no Lingui (Electron main, the CLI).+ * This window does have Lingui, so it renders its own translated labels and+ * keeps the English ones verbatim. A test pins both halves together, so adding+ * a reason without a label here fails rather than rendering a blank row.+ */+function useUninstallReasonLabels(): Record<UninstallFeedbackReason, string> {+ const { t } = useLingui();+ return {+ 'workflow-fit': t`It didn't fit into my workflow`,+ 'missing-feature': t`It was missing a feature I needed`,+ 'hard-to-start': t`It was too hard to set up or get started`,+ unreliable: t`Bugs, crashes, or it felt unreliable`,+ 'switched-tool': t`I'm switching to another tool`,+ 'one-off': t`It was a trial or one-off project`,+ other: t`Something else`,+ };+}++/**+ * The optional churn survey, shown after the uninstall is already confirmed and+ * the removal has already succeeded.+ *+ * Both buttons continue the uninstall — this screen has no cancel path — and+ * nothing here is required, so it deliberately has no Escape handler: the only+ * exits are the two buttons or a deliberate window close, which main maps to+ * "continue with nothing".+ */+export function UninstallSurveyScreen({ onSend, onSkip }: UninstallSurveyScreenProps) {+ const { t } = useLingui();+ const reasonLabels = useUninstallReasonLabels();+ const [reason, setReason] = useState<string>('');+ const [note, setNote] = useState('');+ const [emailOptIn, setEmailOptIn] = useState(false);+ const [email, setEmail] = useState('');+ const emailRef = useRef<HTMLInputElement>(null);+ const titleId = useId();+ const egressId = useId();+ const legendId = useId();+ const noteId = useId();+ const optInId = useId();+ const emailId = useId();++ useEffect(() => {+ if (emailOptIn) emailRef.current?.focus();+ }, [emailOptIn]);++ return (+ <div+ role="dialog"+ aria-labelledby={titleId}+ aria-describedby={egressId}+ className="flex h-dvh flex-col bg-background text-foreground"+ >+ <header className="px-6 pt-5 pb-3.5 space-y-4">+ <h1 id={titleId} className="font-medium leading-none text-base">+ <Trans>Thanks for giving OpenKnowledge a try.</Trans>+ </h1>+ <p id={egressId} className="text-muted-foreground text-sm">+ <Trans>What you share is sent to the OpenKnowledge team.</Trans>+ </p>+ </header>++ {/* A real form, so a malformed address trips the browser's own validation+ instead of 400-ing the whole ticket away at the intake. */}+ <form+ className="flex min-h-0 flex-1 flex-col"+ onSubmit={(event) => {+ event.preventDefault();+ const trimmedNote = note.trim();+ const trimmedEmail = emailOptIn ? email.trim() : '';+ onSend({+ ...(reason === '' ? {} : { reason: reason as UninstallFeedbackReason }),+ ...(trimmedNote === '' ? {} : { note: trimmedNote }),+ ...(trimmedEmail === '' ? {} : { email: trimmedEmail }),+ });+ }}+ >+ <div className="subtle-scrollbar min-h-0 flex-1 overflow-y-auto px-6 pt-1 pb-4">+ {/* The heading is a plain element rather than a fieldset/legend: Radix+ already gives the list `role="radiogroup"`, so a legend would wrap+ it in a second labelled group and announce the question twice. */}+ <div className="mb-6">+ <p id={legendId} className="mb-2 font-medium text-sm">+ <Trans>Before you go, mind sharing why?</Trans>+ </p>+ <RadioGroup aria-labelledby={legendId} value={reason} onValueChange={setReason}>+ {UNINSTALL_FEEDBACK_REASONS.map((option) => (+ <div key={option.value} className="flex items-center gap-2.5 rounded-md px-1 py-1">+ <RadioGroupItem id={`${legendId}-${option.value}`} value={option.value} />+ <Label+ htmlFor={`${legendId}-${option.value}`}+ className="font-normal text-sm leading-snug"+ >+ {reasonLabels[option.value]}+ </Label>+ </div>+ ))}+ </RadioGroup>+ </div>++ <div className="mb-6">+ <Label htmlFor={noteId} className="mb-2 font-medium text-sm">+ <Trans>Anything you'd like to add? (optional)</Trans>+ </Label>+ <Textarea+ id={noteId}+ rows={3}+ maxLength={UNINSTALL_FEEDBACK_NOTE_MAX_LEN}+ value={note}+ onChange={(event) => setNote(event.target.value)}+ />+ </div>++ <div className="mb-2 flex items-center gap-2.5">+ <Checkbox+ id={optInId}+ checked={emailOptIn}+ onCheckedChange={(next) => setEmailOptIn(next === true)}+ />+ <Label htmlFor={optInId} className="font-medium text-sm">+ <Trans>Let us follow up by email</Trans>+ </Label>+ </div>++ <div className="mb-6" hidden={!emailOptIn}>+ <Label htmlFor={emailId} className="mb-2 font-medium text-sm sr-only">+ <Trans>Email address</Trans>+ </Label>+ <Input+ id={emailId}+ ref={emailRef}+ type="email"+ maxLength={UNINSTALL_FEEDBACK_EMAIL_MAX_LEN}+ autoComplete="email"+ spellCheck={false}+ placeholder={t`[email protected]`}+ // Disabled, not merely hidden: a hidden-but-validatable field makes+ // the browser silently refuse the submit (it cannot focus what it+ // must report on), which would strand the user on a screen with no+ // visible problem.+ disabled={!emailOptIn}+ value={email}+ onChange={(event) => setEmail(event.target.value)}+ />+ </div>+ </div>++ <footer className="flex items-center justify-end gap-2.5 border-border border-t bg-muted/50 px-6 pt-3.5 pb-4">+ <Button type="button" variant="outline-mono" autoFocus onClick={onSkip}>+ <Trans>Skip</Trans>+ </Button>+ <Button type="submit">+ <Trans>Send & continue</Trans>+ </Button>+ </footer>+ </form>+ </div>+ );+}diff --git a/packages/app/src/uninstall/bridge.test.ts b/packages/app/src/uninstall/bridge.test.tsnew file mode 100644index 000000000..23ad0cb49--- /dev/null+++ b/packages/app/src/uninstall/bridge.test.ts@@ -0,0 +1,80 @@+// @vitest-environment jsdom+// jsdom (not the default node env) so `window.okUninstall` exists to stub — the+// bridge reads it. This tests the bridge FUNCTIONS, not a React mount, so it is+// deliberately not a `.dom.test.tsx` (that suffix is the Tier-3 RTL-mount+// contract; see tests/integration/dom-test-filename-stop-rule.test.ts).+import type { OkUninstallBridge, UninstallDispatchResult } from '@inkeep/open-knowledge-core';+import { afterEach, describe, expect, test } from 'vitest';+import { requestUninstallScreen, sendUninstallIntent } from './bridge';++/**+ * The bridge is the renderer's only channel to main, and the window has no way+ * to recover from a dead one — so `requestUninstallScreen` owes its caller a+ * plain `null` on every failure mode (no bridge, a `refused`, or a rejected+ * invoke) rather than a rejected promise the caller's catch-less `.then` would+ * drop, hanging the window on its loading placeholder.+ */+function bridgeWith(ready: () => Promise<UninstallDispatchResult>): OkUninstallBridge {+ return {+ ready,+ send: (): Promise<UninstallDispatchResult> => Promise.resolve({ kind: 'accepted' }),+ };+}++describe('requestUninstallScreen', () => {+ afterEach(() => {+ window.okUninstall = undefined;+ });++ test('returns null when the window has no bridge', async () => {+ window.okUninstall = undefined;+ expect(await requestUninstallScreen()).toBeNull();+ });++ test('returns the screen main answers the ready pull with', async () => {+ window.okUninstall = bridgeWith(() =>+ Promise.resolve({ kind: 'screen', screen: { kind: 'progress' } }),+ );+ expect(await requestUninstallScreen()).toEqual({ kind: 'progress' });+ });++ test('returns null when main refuses', async () => {+ window.okUninstall = bridgeWith(() =>+ Promise.resolve({ kind: 'refused', reason: 'unknown-window' }),+ );+ expect(await requestUninstallScreen()).toBeNull();+ });++ test('resolves to null instead of rejecting when the ready invoke rejects', async () => {+ window.okUninstall = bridgeWith(() => Promise.reject(new Error('ipc channel closed')));+ await expect(requestUninstallScreen()).resolves.toBeNull();+ });+});++describe('sendUninstallIntent', () => {+ afterEach(() => {+ window.okUninstall = undefined;+ });++ test('is a no-op when the window has no bridge', () => {+ window.okUninstall = undefined;+ expect(() => sendUninstallIntent({ kind: 'picker-cancel' })).not.toThrow();+ });++ test('swallows a rejected send so a teardown race is not an unhandled rejection', async () => {+ let sent: unknown;+ window.okUninstall = {+ ready: () => Promise.resolve({ kind: 'refused', reason: 'unknown-window' }),+ send: (intent): Promise<UninstallDispatchResult> => {+ sent = intent;+ // Settling a screen destroys the window, tearing the channel down under+ // this in-flight invoke — the intent is fire-and-forget by contract.+ return Promise.reject(new Error('channel torn down'));+ },+ };+ expect(() => sendUninstallIntent({ kind: 'notice-confirm' })).not.toThrow();+ expect(sent).toEqual({ kind: 'notice-confirm' });+ // Let the swallowing `.catch` run; the test fails on an unhandled rejection.+ await Promise.resolve();+ });+});diff --git a/packages/app/src/uninstall/bridge.ts b/packages/app/src/uninstall/bridge.tsnew file mode 100644index 000000000..6d615ef3d--- /dev/null+++ b/packages/app/src/uninstall/bridge.ts@@ -0,0 +1,55 @@+/**+ * `window.okUninstall` — the uninstall renderer's only channel to the main+ * process. Exposed by `packages/desktop/src/preload/uninstall.ts`; the contract+ * types are declared once in core and imported here as types only, so nothing+ * from that package reaches this entry's runtime graph.+ *+ * Absent outside Electron (a browser opening `uninstall.html` directly, a dom+ * test rendering a screen), so every accessor tolerates its absence — there is+ * no meaningful uninstall to drive without a main process behind it.+ */++import type {+ OkUninstallBridge,+ UninstallIntent,+ UninstallScreenSpec,+} from '@inkeep/open-knowledge-core';++declare global {+ interface Window {+ okUninstall?: OkUninstallBridge;+ }+}++/**+ * Ask main which screen this window is. `null` when there is no bridge, when+ * the `ready` invoke rejects (an IPC-level failure), or when main refused — a+ * refusal means this window is not one main is waiting on, which no amount of+ * retrying changes.+ */+export async function requestUninstallScreen(): Promise<UninstallScreenSpec | null> {+ const bridge = typeof window === 'undefined' ? undefined : window.okUninstall;+ if (bridge === undefined) return null;+ try {+ const result = await bridge.ready();+ return result.kind === 'screen' ? result.screen : null;+ } catch {+ // A rejected invoke (the channel torn down, or a future throw in main) is+ // as unrecoverable as a `refused`, and the caller does not `.catch()`.+ // Return null so the window keeps its loading placeholder rather than+ // hanging on a discarded rejection.+ return null;+ }+}++/**+ * Report a user action. Fire-and-forget by design: an intent that settles a+ * screen makes main destroy this window, which tears the channel down under the+ * in-flight invoke, so a rejection here says nothing about whether main acted.+ * The screen's own teardown is the acknowledgement.+ */+export function sendUninstallIntent(intent: UninstallIntent): void {+ const bridge = typeof window === 'undefined' ? undefined : window.okUninstall;+ if (bridge === undefined) return;+ void bridge.send(intent).catch(() => undefined);+}diff --git a/packages/app/src/uninstall/main.dom.test.tsx b/packages/app/src/uninstall/main.dom.test.tsxnew file mode 100644index 000000000..1fc291403--- /dev/null+++ b/packages/app/src/uninstall/main.dom.test.tsx@@ -0,0 +1,18 @@+import { waitFor } from '@testing-library/react';+import { expect, test } from 'vitest';++// Exercises the real entry module, not just the root component: a blank+// uninstall window is the failure this seam exists to catch, and it can come+// from anywhere in the entry's import graph (an unresolvable module, a catalog+// that never activates, a mount that never runs) — not only from the screen.+test('the uninstall entry paints content into the document', async () => {+ document.body.innerHTML = '<div id="root"></div>';++ await import('./main');++ const root = document.getElementById('root');+ await waitFor(() => {+ expect(root?.children.length ?? 0).toBeGreaterThan(0);+ expect(root?.textContent?.trim()).not.toBe('');+ });+});diff --git a/packages/app/src/uninstall/main.tsx b/packages/app/src/uninstall/main.tsxnew file mode 100644index 000000000..975fb98cd--- /dev/null+++ b/packages/app/src/uninstall/main.tsx@@ -0,0 +1,34 @@+/**+ * Entry for the `uninstall.html` renderer — the self-uninstall flow's own+ * window, separate from the editor entry in `src/main.tsx`.+ *+ * **This entry must connect to nothing.** The survey and completion screens+ * render *after* `ok uninstall --yes` has stopped the local Hocuspocus server+ * and removed `~/.ok`, so nothing reachable from here may touch the editor,+ * the CRDT stack, a provider pool, or the server bootstrap. Everything loads+ * eagerly (no dynamic `import()`) so the later screens paint from memory once+ * teardown is under way.+ */+import { I18nProvider } from '@lingui/react';+import { StrictMode } from 'react';+import { createRoot } from 'react-dom/client';+// Side-effect import: loads + activates the i18n catalog before first render.+import { i18n } from '@/lib/i18n';+import { UninstallApp } from './UninstallApp';+// Both faces the screens reference: Inter for `--font-sans`, JetBrains Mono for+// `--font-mono` (project paths, source badges, the mono-uppercase filled+// buttons). Without the mono import the window falls back to system mono.+import '@fontsource-variable/inter';+import '@fontsource-variable/jetbrains-mono';+import '../globals.css';++const root = document.getElementById('root');+if (!root) throw new Error('Root element not found');++createRoot(root).render(+ <StrictMode>+ <I18nProvider i18n={i18n}>+ <UninstallApp />+ </I18nProvider>+ </StrictMode>,+);diff --git a/packages/app/src/uninstall/uninstall-copy-parity.dom.test.tsx b/packages/app/src/uninstall/uninstall-copy-parity.dom.test.tsxnew file mode 100644index 000000000..edac5c804--- /dev/null+++ b/packages/app/src/uninstall/uninstall-copy-parity.dom.test.tsx@@ -0,0 +1,140 @@+import type { UninstallProjectRow } from '@inkeep/open-knowledge-core';+import { cleanup, render } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { afterEach, describe, expect, test } from 'vitest';+import { UninstallPickerScreen } from './UninstallPickerScreen';+import { UninstallProgressScreen } from './UninstallProgressScreen';+import { UninstallSurveyScreen } from './UninstallSurveyScreen';++/**+ * Copy lock for the render-swap: the picker, survey, and progress screens moved+ * their user-facing copy out of hand-written inline HTML and into Lingui+ * `<Trans>` / t`…`. This freezes the strings each screen renders today and+ * asserts the migrated React screens still render them verbatim, so an+ * accidental reword fails a test rather than passing an eyeball.+ *+ * Provenance differs by screen, so read this as a current-copy lock, not a+ * verbatim-parity-with-the-old-windows gate. The survey and progress strings+ * are the pre-migration originals, captured from the inline-HTML builders+ * (`buildDesktopUninstall{Feedback,Progress}Html`) and checked+ * substring-for-substring against their rendered output before those builders+ * were deleted. The picker's copy was deliberately reworked during the+ * migration — the description merged into one line and reworded to name the+ * project selection, the muted hint and scroll line dropped, the open/running+ * tags collapsed to `active`, and the footer count restyled into a header+ * selected-of-total fraction — so the picker strings below are the current+ * intended copy, not the pre-migration originals.+ *+ * The notice screens are out of scope here: their copy is main-process data+ * (`desktopUninstall{Confirm,Completion,Failure,FinalStep}Notice`) rendered+ * through, not migrated to, Lingui, and stays pinned by the desktop notice+ * builder tests.+ */++/** Text, accessible names, and placeholders — everything the user can read. */+function readableCopy(container: HTMLElement): string {+ const attrs: string[] = [];+ for (const el of container.querySelectorAll('[aria-label], [placeholder]')) {+ const label = el.getAttribute('aria-label');+ const placeholder = el.getAttribute('placeholder');+ if (label !== null) attrs.push(label);+ if (placeholder !== null) attrs.push(placeholder);+ }+ return [container.textContent ?? '', ...attrs].join('\n');+}++const PICKER_COPY = [+ 'Uninstall OpenKnowledge?',+ 'This removes OpenKnowledge’s settings and integrations from your Mac and any projects you select below, but keeps your markdown content and authored skills.',+ 'Select all',+ 'Cancel',+ 'Uninstall OpenKnowledge',+ 'Detected OpenKnowledge projects',+ 'Remove OpenKnowledge from ',+];++const SURVEY_COPY = [+ 'Thanks for giving OpenKnowledge a try.',+ 'What you share is sent to the OpenKnowledge team.',+ 'Before you go, mind sharing why?',+ "It didn't fit into my workflow",+ 'It was missing a feature I needed',+ 'It was too hard to set up or get started',+ 'Bugs, crashes, or it felt unreliable',+ "I'm switching to another tool",+ 'It was a trial or one-off project',+ 'Something else',+ "Anything you'd like to add? (optional)",+ 'Let us follow up by email',+ 'Email address',+ '[email protected]',+ 'Skip',+ 'Send & continue',+];++const PROGRESS_COPY = [+ 'Removing OpenKnowledge files…',+ 'This may take a moment. Your markdown content is kept.',+];++const twoProjects: readonly UninstallProjectRow[] = [+ { path: '/work/a', open: true, recent: false, running: true },+ { path: '/work/b', open: false, recent: true, running: false },+];+const oneProject: readonly UninstallProjectRow[] = [+ { path: '/work/a', open: false, recent: true, running: false },+];++describe('uninstall copy parity', () => {+ afterEach(cleanup);++ test('picker renders the original copy, tags, and plural forms', () => {+ const { container } = render(+ <UninstallPickerScreen projects={twoProjects} onConfirm={() => {}} onCancel={() => {}} />,+ );+ const copy = readableCopy(container);++ for (const line of PICKER_COPY) expect(copy, line).toContain(line);+ // Status badges intentionally diverge from the inline-HTML open/running/recent+ // tags: open + running collapse to `active` (the open/server split is not a+ // user decision), leaving `active` / `recent`. twoProjects has one of each.+ for (const status of ['active', 'recent']) expect(copy).toContain(status);+ // Header selected-of-total counter (none selected yet, two projects).+ expect(copy).toContain('0 / 2');+ });++ test('picker renders the singular plural forms', async () => {+ const user = userEvent.setup();+ const { container, getByRole } = render(+ <UninstallPickerScreen projects={oneProject} onConfirm={() => {}} onCancel={() => {}} />,+ );++ let copy = readableCopy(container);+ expect(copy).toContain('0 / 1');++ await user.click(getByRole('checkbox', { name: 'Select all' }));+ copy = readableCopy(container);+ expect(copy).toContain('1 / 1');+ });++ test('picker renders the empty-state copy', () => {+ const { container } = render(+ <UninstallPickerScreen projects={[]} onConfirm={() => {}} onCancel={() => {}} />,+ );+ expect(readableCopy(container)).toContain(+ 'No active or recent OpenKnowledge projects were found.',+ );+ });++ test('survey renders the original copy', () => {+ const { container } = render(<UninstallSurveyScreen onSend={() => {}} onSkip={() => {}} />);+ const copy = readableCopy(container);+ for (const line of SURVEY_COPY) expect(copy, line).toContain(line);+ });++ test('progress renders the original copy', () => {+ const { container } = render(<UninstallProgressScreen />);+ const copy = readableCopy(container);+ for (const line of PROGRESS_COPY) expect(copy, line).toContain(line);+ });+});diff --git a/packages/app/uninstall.html b/packages/app/uninstall.htmlnew file mode 100644index 000000000..0610c7d3c--- /dev/null+++ b/packages/app/uninstall.html@@ -0,0 +1,42 @@+<!doctype html>+<html lang="en">++<head>+ <meta name="color-scheme" content="light dark" />+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <title>Uninstall OpenKnowledge</title>+ <!--+ Theme stamp. Unlike index.html this reads NOTHING local — not+ localStorage (a distinct `file://` document cannot see the editor+ renderer's persisted next-themes value) and not `prefers-color-scheme`+ (the OS preference is not the app's theme when the user has overridden+ it). The main process resolves the app's appearance and passes it in the+ `theme` query, which this applies synchronously so the first painted+ frame is already correct. Producer: `resolveUninstallEntryTarget` in+ packages/desktop/src/main/uninstall-window.ts — keep the key in sync.+ Absent or unrecognized value means light, so a directly-opened file still+ renders deterministically.++ Single-line script body — biome's HTML formatter reindents inline-script+ content on every pass, producing an infinite deny-loop at pre-commit.+ -->+ <script>(() => { try { if (new URLSearchParams(location.search).get('theme') === 'dark') document.documentElement.classList.add('dark'); } catch {} })();</script>+ <!--+ Paints the window background from the same `--sidebar` token the app chrome+ uses, so the frame between window-show and React's first paint isn't a+ white flash. Placeholders are substituted at build time by+ chromeTokensVitePlugin (same plugin, same values as index.html).++ Single-line style body — same biome HTML-formatter constraint as the+ script above.+ -->+ <style>html { background-color: __OK_CHROME_BG_LIGHT__ } html.dark { background-color: __OK_CHROME_BG_DARK__ }</style>+</head>++<body class="antialiased">+ <div id="root"></div>+ <script type="module" src="/src/uninstall/main.tsx"></script>+</body>++</html>diff --git a/packages/app/vite.config.ts b/packages/app/vite.config.tsindex a57a2cfef..38352fb16 100644--- a/packages/app/vite.config.ts+++ b/packages/app/vite.config.ts@@ -6,6 +6,7 @@ import { chromeTokensVitePlugin } from './src/build/chrome-tokens-vite-plugin';import { rejectionLoopGuardPlugin } from './src/build/rejection-loop-guard-plugin';import { hocuspocusPlugin } from './src/server/hocuspocus-plugin';import { RENDERER_DEDUPE } from './vite.dedupe';+import { RENDERER_HTML_ENTRIES, rendererHtmlInput } from './vite.entries';import { RENDERER_BABEL_OPTIONS } from './vite.react-babel';// Inject the app's own version onto import.meta.env.VITE_APP_VERSION for the@@ -35,12 +36,12 @@ export default defineConfig({// Playwright fixture overrides via `OK_TEST_VITE_CACHE_DIR`.cacheDir: viteCacheDir,optimizeDeps: {- // Scope the dependency scanner to the real app entry. Vite's default+ // Scope the dependency scanner to the real app entries. Vite's default// entries glob (every `**/*.html`) also picks up// `scripts/audit-strings/viewer-template.html`, which wastes scan work// and appeared as a scan entry in the CI dep-scan failures ("Failed to// run dependency scan … The server is being restarted or closed").- entries: ['index.html'],+ entries: Object.values(RENDERER_HTML_ENTRIES),},// Default Vite envPrefix is `VITE_` only — keep it that way. The cold-mount// PROD-build override lives at `VITE_OK_PERF_INSTRUMENT` (alongside the@@ -93,6 +94,12 @@ export default defineConfig({// catches a future regression but doesn't fire on every clean build.chunkSizeWarningLimit: 1500,rolldownOptions: {+ // Two HTML entries: the editor shell and the self-uninstall window.+ // Absolute paths (not root-relative strings) because rollup resolves+ // input ids against CWD, not Vite's `root`. Built from the shared map+ // so this build and the Electron renderer build cannot disagree about+ // which entries exist — see `vite.entries.ts`.+ input: rendererHtmlInput(import.meta.dirname),// Filter known false-positive warnings. Re-evaluate when bumping// rolldown / vite. Anything not matched falls through to default.onLog(level, log, defaultHandler) {diff --git a/packages/app/vite.entries.ts b/packages/app/vite.entries.tsnew file mode 100644index 000000000..668efbe50--- /dev/null+++ b/packages/app/vite.entries.ts@@ -0,0 +1,48 @@+import { resolve } from 'node:path';++/**+ * Shared HTML-entry map for the renderer's Vite configs.+ *+ * **Single source of truth** — `packages/app/vite.config.ts` (web / `ok ui` /+ * dev path) and `packages/desktop/electron.vite.config.ts` (Electron renderer+ * path) BOTH build their `build.*Options.input` from this map. Same rationale+ * as `vite.dedupe.ts` and `vite.react-babel.ts`: a new entry is declared once+ * and both builds pick it up, so the two configs cannot drift.+ *+ * Drift here is silent and only bites in packaged builds. The two builds feed+ * different consumers:+ *+ * - `packages/app`'s own `vite build` → `dist/` → copied to+ * `packages/cli/dist/public/` → shipped as `<Resources>/app/` by+ * electron-builder. **This is what a packaged window loads.**+ * - `packages/desktop`'s `electron-vite build` → `out/renderer/` — the+ * unpackaged-dev fallback main uses when `ELECTRON_RENDERER_URL` is unset.+ *+ * An entry added to only one config therefore works in dev and 404s in the+ * shipped app.+ *+ * Entries are **flat siblings at the app root**, never nested in a+ * subdirectory: Vite emits shared assets to `<outDir>/assets/`, so every+ * entry HTML must sit at the same depth for the emitted relative `./assets/…`+ * URLs to resolve from all of them under `file://`.+ */+export const RENDERER_HTML_ENTRIES = {+ index: 'index.html',+ uninstall: 'uninstall.html',+} as const satisfies Record<string, `${string}.html`>;++export type RendererEntryName = keyof typeof RENDERER_HTML_ENTRIES;++/**+ * Absolute `rollupOptions.input` map for a renderer build rooted at `appRoot`.+ *+ * The `Record<RendererEntryName, …>` return type is load-bearing: adding a key+ * to `RENDERER_HTML_ENTRIES` fails typecheck here until it is wired in, which+ * is what keeps the map and the input in lockstep.+ */+export function rendererHtmlInput(appRoot: string): Record<RendererEntryName, string> {+ return {+ index: resolve(appRoot, RENDERER_HTML_ENTRIES.index),+ uninstall: resolve(appRoot, RENDERER_HTML_ENTRIES.uninstall),+ };+}diff --git a/packages/core/src/constants/uninstall-feedback.ts b/packages/core/src/constants/uninstall-feedback.tsindex 2c465c891..5e2ef6e12 100644--- a/packages/core/src/constants/uninstall-feedback.ts+++ b/packages/core/src/constants/uninstall-feedback.ts@@ -21,6 +21,15 @@ export const UNINSTALL_FEEDBACK_REASONS = Object.freeze([{ value: 'other', label: 'Something else' },] as const satisfies readonly { readonly value: string; readonly label: string }[]);+/**+ * The intake's own `message` / `email` ceilings; overrunning either 400s the+ * whole ticket. Shared so the surface that lets a user type (the uninstall+ * window's `maxlength`) and the surface that clamps what they typed (the main+ * process, before it posts) cannot disagree about where the limit is.+ */+export const UNINSTALL_FEEDBACK_NOTE_MAX_LEN = 10_000;+export const UNINSTALL_FEEDBACK_EMAIL_MAX_LEN = 320;+/** A single offered reason, as rendered by the desktop window and CLI prompt. */type UninstallFeedbackReasonOption = (typeof UNINSTALL_FEEDBACK_REASONS)[number];@@ -33,8 +42,8 @@ const UNINSTALL_FEEDBACK_REASON_VALUES: ReadonlySet<unknown> = new Set(/*** Narrow an inbound slug to the taxonomy. The desktop window hands its answers- * back to the main process through a navigation URL, so the slug arrives as an- * arbitrary string and has to be re-checked before it can be filed.+ * back to the main process over IPC, so the slug arrives as an arbitrary string+ * and has to be re-checked before it can be filed.*/export function isUninstallFeedbackReason(value: unknown): value is UninstallFeedbackReason {return UNINSTALL_FEEDBACK_REASON_VALUES.has(value);diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex b69099137..596f8320e 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -290,6 +290,8 @@ export { PRODUCT_NAME } from './constants/product.ts';export { DEFAULT_SERVER_HOST } from './constants/server.ts';export {isUninstallFeedbackReason,+ UNINSTALL_FEEDBACK_EMAIL_MAX_LEN,+ UNINSTALL_FEEDBACK_NOTE_MAX_LEN,UNINSTALL_FEEDBACK_REASONS,type UninstallFeedbackReason,} from './constants/uninstall-feedback.ts';@@ -1137,6 +1139,16 @@ export {THEME_PLUGIN_IDS,THEME_PLUGINS,} from './theme/theme-plugins.ts';+export type {+ OkUninstallBridge,+ UninstallDispatchRequest,+ UninstallDispatchResult,+ UninstallIntent,+ UninstallNoticeChecklistItem,+ UninstallNoticeScreen,+ UninstallProjectRow,+ UninstallScreenSpec,+} from './uninstall-bridge.ts';export {HIDDEN_CONFIG_BASENAMES,isHiddenDocName,diff --git a/packages/core/src/uninstall-bridge.ts b/packages/core/src/uninstall-bridge.tsnew file mode 100644index 000000000..070eea4b0--- /dev/null+++ b/packages/core/src/uninstall-bridge.ts@@ -0,0 +1,107 @@+/**+ * `window.okUninstall` — the contract between the desktop self-uninstall+ * window's React renderer and the Electron main process.+ *+ * Shape lives in core so the desktop package (which exposes it through+ * `contextBridge.exposeInMainWorld` and services it in main) and the app+ * package (which renders the screens) compile against one declaration instead+ * of two drifting copies. Pure interfaces, zero imports.+ *+ * The security posture the shape encodes: main sends a screen DOWN, the+ * renderer sends an opaque intent UP. No intent carries a filesystem path —+ * the picker answers with indexes into the list main handed it, so a renderer+ * that lies can only ever name projects main already chose to offer. Deletion+ * authorization, target derivation and the `/Applications` + realpath guards+ * stay in main, which never reads a path out of an intent.+ */++/** One project row the picker offers. `path` is display-only, sent downward. */+export interface UninstallProjectRow {+ readonly path: string;+ readonly open: boolean;+ readonly recent: boolean;+ readonly running: boolean;+}++/** A done/pending line in the completion screen's recap. */+export interface UninstallNoticeChecklistItem {+ readonly label: string;+ readonly detail?: string;+ /** `true` = already done; `false` = the one remaining action. */+ readonly done: boolean;+}++/** The confirm / completion / failure screens, which differ only in content. */+export interface UninstallNoticeScreen {+ readonly title: string;+ readonly subtitle?: string;+ readonly paragraphs: readonly string[];+ readonly checklist?: readonly UninstallNoticeChecklistItem[];+ readonly footnote?: string;+ /**+ * When set, renders a link with this text that asks main to reveal the+ * cleanup log. The log's path stays in main and never reaches the renderer.+ */+ readonly logRevealLabel?: string;+ /** Monospace scrollable block (the cleanup log). */+ readonly log?: string;+ readonly confirmLabel: string;+ /** When present the notice is a two-button question; closing means cancel. */+ readonly cancelLabel?: string;+ /** Style the confirm control as destructive. */+ readonly danger?: boolean;+}++/** What main asked this uninstall window to render. */+export type UninstallScreenSpec =+ | { readonly kind: 'picker'; readonly projects: readonly UninstallProjectRow[] }+ | { readonly kind: 'survey' }+ | { readonly kind: 'progress' }+ | { readonly kind: 'notice'; readonly notice: UninstallNoticeScreen };++/**+ * Everything the renderer can say. Deliberately closed and path-free.+ *+ * `selectedIndexes` indexes the `projects` array of the picker screen main+ * sent; main re-resolves them against its own candidate list and discards+ * anything out of range, so the worst a hostile renderer can do is select a+ * different subset of the projects main already collected.+ */+export type UninstallIntent =+ | { readonly kind: 'picker-confirm'; readonly selectedIndexes: readonly number[] }+ | { readonly kind: 'picker-cancel' }+ | {+ readonly kind: 'survey-send';+ readonly reason?: string;+ readonly note?: string;+ readonly email?: string;+ }+ | { readonly kind: 'survey-skip' }+ | { readonly kind: 'notice-confirm' }+ | { readonly kind: 'notice-cancel' }+ | { readonly kind: 'notice-reveal-log' };++/** `ready` is the renderer asking which screen it is; the rest are intents. */+export type UninstallDispatchRequest = { readonly kind: 'ready' } | UninstallIntent;++/**+ * `refused` is not an error path the renderer can recover from — it means the+ * sender is not a live uninstall window main is waiting on, or the payload+ * wasn't a recognizable intent. Main takes no action either way.+ */+export type UninstallDispatchResult =+ | { readonly kind: 'screen'; readonly screen: UninstallScreenSpec }+ | { readonly kind: 'accepted' }+ | { readonly kind: 'refused'; readonly reason: 'unknown-window' | 'invalid-intent' };++/**+ * The `window.okUninstall` surface. The one preload bundle serves every window+ * but exposes this only when `isUninstallPreload(process.argv)` holds; editor+ * windows get `okDesktop` instead and never see `okUninstall`.+ */+export interface OkUninstallBridge {+ /** Ask main which screen this window is. */+ ready(): Promise<UninstallDispatchResult>;+ /** Report a user action. Resolving does not mean the window stays open. */+ send(intent: UninstallIntent): Promise<UninstallDispatchResult>;+}diff --git a/packages/desktop/electron.vite.config.ts b/packages/desktop/electron.vite.config.tsindex 2614cf745..9ad59f753 100644--- a/packages/desktop/electron.vite.config.ts+++ b/packages/desktop/electron.vite.config.ts@@ -5,6 +5,7 @@ import { defineConfig } from 'electron-vite';import { injectAppVersionEnv } from '../app/src/build/app-version';import { chromeTokensVitePlugin } from '../app/src/build/chrome-tokens-vite-plugin';import { RENDERER_DEDUPE } from '../app/vite.dedupe';+import { rendererHtmlInput } from '../app/vite.entries';import { RENDERER_BABEL_OPTIONS } from '../app/vite.react-babel';// Inject the app's version onto import.meta.env.VITE_APP_VERSION for the@@ -38,7 +39,7 @@ const appRoot = resolve(__dirname, '../app');// runs from `packages/desktop`, so without this the renderer Babel pass fails// with "Lingui was unable to find a config!". Point it at the app's config —// the renderer source IS `packages/app`. (`packages/app`'s own vite.config.ts-// needs no equivalent: `bun run dev`/`build` already run with that cwd.)+// needs no equivalent: `pnpm dev`/`build` already run with that cwd.)process.env.LINGUI_CONFIG ??= resolve(appRoot, 'lingui.config.ts');export default defineConfig({@@ -85,6 +86,16 @@ export default defineConfig({build: {sourcemap: 'hidden',rollupOptions: {+ // ONE preload entry, deliberately. A sandboxed preload's `require` is+ // a polyfill over an allowlist of module NAMES (`electron`, a few node+ // builtins) and cannot resolve a relative path, so every preload must+ // be a single self-contained file. Rolldown splits any module two+ // entries share into `chunks/` and offers no per-entry inlining knob+ // (`codeSplitting: false` is rejected outright for multi-input builds),+ // so a second entry here silently kills BOTH preloads: `window.okDesktop`+ // goes undefined and the editor falls into web mode. The uninstall+ // window's narrow bridge therefore ships inside this entry and is+ // selected at exposure time — see `src/preload/uninstall.ts`.input: { index: resolve(__dirname, 'src/preload/index.ts') },// CommonJS, not ESM. Electron's sandboxed preload (webPreferences.sandbox: true,// our locked default) only supports CommonJS — ESM preloads require@@ -132,7 +143,12 @@ export default defineConfig({outDir: resolve(__dirname, 'out/renderer'),sourcemap: 'hidden',rollupOptions: {- input: resolve(appRoot, 'index.html'),+ // Keyed multi-entry: the editor shell plus the self-uninstall window.+ // Shared with `packages/app/vite.config.ts` via `vite.entries.ts` —+ // the app build is what a PACKAGED window loads (its `dist/` ships as+ // `<Resources>/app/`), this build is the unpackaged-dev fallback, so+ // an entry declared in only one of them 404s in the shipped app.+ input: rendererHtmlInput(appRoot),},},server: {diff --git a/packages/desktop/src/main/desktop-uninstall.ts b/packages/desktop/src/main/desktop-uninstall.tsindex d41b09b03..e0eb86911 100644--- a/packages/desktop/src/main/desktop-uninstall.ts+++ b/packages/desktop/src/main/desktop-uninstall.ts@@ -15,12 +15,13 @@import { spawn as spawnChild } from 'node:child_process';import { existsSync, readFileSync } from 'node:fs';import { homedir } from 'node:os';-import { basename, dirname, join, resolve } from 'node:path';+import { dirname, join, resolve } from 'node:path';import {hasUninstallFeedbackContent,isUninstallFeedbackReason,postUninstallFeedback,- UNINSTALL_FEEDBACK_REASONS,+ UNINSTALL_FEEDBACK_EMAIL_MAX_LEN,+ UNINSTALL_FEEDBACK_NOTE_MAX_LEN,type UninstallFeedbackAnswers,type UninstallFeedbackResult,type UninstallFeedbackSubmission,@@ -66,7 +67,26 @@ export type RunDesktopUninstallCleanupResult =| { ok: true }| { ok: false; error: string; exitCode?: number | null };-export type DesktopUninstallUiPreviewMode = 'success' | 'failure';+/** Preview modes that walk the whole uninstall flow with cleanup stubbed out. */+export type DesktopUninstallFlowPreviewMode = 'success' | 'failure';++/**+ * Modes that open one screen instead of walking the flow, so a screen can be+ * exercised without any of the destructive steps behind it.+ *+ * `'renderer'` opens the React uninstall window on a notice — the surface the+ * font/theme/token smoke asserts against. `'picker'` opens the project picker+ * over illustrative candidates and resolves without proceeding. `'survey'`+ * opens the churn survey and reports the answers back on screen instead of+ * posting them anywhere. `'notice'` walks both notice shapes — the two-button+ * question and the single-button recap — and reports how each was answered,+ * which is what makes their opposite close semantics observable.+ */+type DesktopUninstallScreenPreviewMode = 'renderer' | 'picker' | 'survey' | 'notice';++export type DesktopUninstallUiPreviewMode =+ | DesktopUninstallFlowPreviewMode+ | DesktopUninstallScreenPreviewMode;/*** Resolve the dev-only uninstall UI preview mode from its env var. Returns null@@ -80,6 +100,10 @@ export function resolveDesktopUninstallUiPreviewMode(if (isPackaged) return null;if (raw === 'success' || raw === '1' || raw === 'true') return 'success';if (raw === 'failure' || raw === 'fail') return 'failure';+ if (raw === 'renderer') return 'renderer';+ if (raw === 'picker') return 'picker';+ if (raw === 'survey') return 'survey';+ if (raw === 'notice') return 'notice';return null;}@@ -152,339 +176,19 @@ export function collectDesktopUninstallProjectCandidates(return [...candidates.values()].filter((candidate) => exists(join(candidate.path, '.ok')));}-function desktopUninstallProjectSourceTags(candidate: DesktopUninstallProjectCandidate): string[] {- return [- candidate.open ? 'open' : null,- candidate.running ? 'running' : null,- candidate.recent ? 'recent' : null,- ].filter((tag): tag is string => tag !== null);-}--export function formatDesktopUninstallProjectList(- candidates: readonly DesktopUninstallProjectCandidate[],- maxRows = 8,-): string {- if (candidates.length === 0) return 'No recent, open, or running OpenKnowledge projects found.';-- const rows = candidates.slice(0, maxRows).map((candidate) => {- const tags = desktopUninstallProjectSourceTags(candidate);- return `• ${candidate.path}${tags.length > 0 ? ` (${tags.join(', ')})` : ''}`;- });- if (candidates.length > maxRows) {- rows.push(`• …and ${candidates.length - maxRows} more`);- }- return rows.join('\n');-}--function htmlEscape(value: string): string {- return value.replace(/[&<>"']/g, (ch) => {- switch (ch) {- case '&':- return '&';- case '<':- return '<';- case '>':- return '>';- case '"':- return '"';- case "'":- return ''';- default:- return ch;- }- });-}--function buildDesktopUninstallProjectRows(- candidates: readonly DesktopUninstallProjectCandidate[],-): string {- if (candidates.length === 0) {- return '<div class="empty-list">No recent, open, or running OpenKnowledge projects were found.</div>';- }-- return candidates- .map((candidate, index) => {- const name = basename(candidate.path) || candidate.path;- const tags = desktopUninstallProjectSourceTags(candidate)- .map((tag) => `<span class="tag">${htmlEscape(tag)}</span>`)- .join('');- return `<label class="project-row">- <input type="checkbox" data-index="${index}" aria-label="Remove OpenKnowledge from ${htmlEscape(candidate.path)}" />- <span class="project-main">- <span class="project-name">${htmlEscape(name)}</span>- <span class="project-path">${htmlEscape(candidate.path)}</span>- </span>- <span class="project-tags" aria-label="Project sources">${tags}</span>-</label>`;- })- .join('\n');-}--// The custom-scheme protocol shared by every uninstall window (picker, feedback,-// notice) — each window's will-navigate parser matches inbound URLs against it.-const DESKTOP_UNINSTALL_SCHEME = 'ok-desktop-uninstall:';-/**- * One source of truth for the type scale + neutral chrome shared by every- * uninstall window (picker, feedback, progress, notices). Each screen is its- * own inline-HTML document with a self-contained `<style>`, so without this the- * headings, body text, and muted lines drift apart between screens. Screens- * layer their own layout rules (and `h1` margins) on top.+ * Resolve renderer-supplied indexes against main's own candidate list. Anything+ * that cannot index that list is dropped, so the widest a selection can get is+ * the set of projects main already collected — the renderer never contributes a+ * path, only a choice among paths main offered.*/-const DESKTOP_UNINSTALL_BASE_CSS = ` :root { color-scheme: light dark; }- * { box-sizing: border-box; }- html, body { height: 100%; }- body {- margin: 0;- font: 14px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;- color: CanvasText;- background: Canvas;- }- h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }- .muted { color: color-mix(in srgb, CanvasText 68%, transparent); }`;--/**- * Inline, sandbox-friendly picker HTML. Main owns the candidate paths; the page- * returns only selected candidate indexes through a main-intercepted private- * navigation URL, not renderer-supplied paths.- */-export function buildDesktopUninstallProjectPickerHtml(- candidates: readonly DesktopUninstallProjectCandidate[],-): string {- const projectCount = candidates.length;- const projectWord = projectCount === 1 ? 'project' : 'projects';- return `<!doctype html>-<html lang="en">-<head>-<meta charset="utf-8" />-<meta- http-equiv="Content-Security-Policy"- content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:;"-/>-<meta name="viewport" content="width=device-width, initial-scale=1" />-<title>Uninstall OpenKnowledge</title>-<style>-${DESKTOP_UNINSTALL_BASE_CSS}- .dialog {- display: flex;- flex-direction: column;- height: 100vh;- min-height: 0;- }- .header {- padding: 22px 24px 14px;- border-bottom: 1px solid color-mix(in srgb, CanvasText 14%, transparent);- }- h1 { margin: 0 0 10px; }- p { margin: 0 0 8px; line-height: 1.42; }- .controls {- display: flex;- align-items: center;- justify-content: space-between;- gap: 12px;- margin-top: 14px;- }- .controls strong { font-weight: 600; }- .control-buttons { display: flex; gap: 8px; flex-wrap: wrap; }- button {- appearance: none;- border: 1px solid color-mix(in srgb, CanvasText 22%, transparent);- border-radius: 7px;- background: color-mix(in srgb, Canvas 88%, CanvasText 12%);- color: CanvasText;- padding: 6px 11px;- font: inherit;- cursor: default;- }- button:hover { background: color-mix(in srgb, Canvas 82%, CanvasText 18%); }- button:focus-visible { outline: 3px solid Highlight; outline-offset: 2px; }- .list-region {- flex: 1;- min-height: 0;- padding: 14px 24px;- }- .scroll-hint {- margin: 0 0 8px;- color: color-mix(in srgb, CanvasText 62%, transparent);- font-size: 13px;- }- .project-list {- height: calc(100% - 24px);- min-height: 180px;- overflow-y: scroll;- scrollbar-gutter: stable;- border: 1px solid color-mix(in srgb, CanvasText 16%, transparent);- border-radius: 10px;- background: color-mix(in srgb, Canvas 96%, CanvasText 4%);- }- .project-list::-webkit-scrollbar { width: 12px; height: 12px; }- .project-list::-webkit-scrollbar-track { background: color-mix(in srgb, Canvas 88%, CanvasText 12%); border-radius: 999px; }- .project-list::-webkit-scrollbar-thumb { background: color-mix(in srgb, CanvasText 36%, transparent); border: 3px solid transparent; border-radius: 999px; background-clip: content-box; }- .project-row {- display: grid;- grid-template-columns: auto minmax(0, 1fr) auto;- gap: 10px;- align-items: start;- padding: 10px 12px;- border-bottom: 1px solid color-mix(in srgb, CanvasText 10%, transparent);- }- .project-row:last-child { border-bottom: 0; }- .project-row:hover { background: color-mix(in srgb, Highlight 12%, transparent); }- .project-row input { margin: 2px 0 0; }- .project-main { min-width: 0; }- .project-name {- display: block;- font-weight: 600;- line-height: 1.25;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- }- .project-path {- display: block;- margin-top: 3px;- color: color-mix(in srgb, CanvasText 64%, transparent);- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;- font-size: 12.5px;- line-height: 1.35;- overflow-wrap: anywhere;- user-select: text;- }- .project-tags { display: flex; justify-content: flex-end; gap: 4px; flex-wrap: wrap; max-width: 190px; }- .tag {- border: 1px solid color-mix(in srgb, CanvasText 15%, transparent);- border-radius: 999px;- padding: 2px 6px;- color: color-mix(in srgb, CanvasText 72%, transparent);- background: color-mix(in srgb, Canvas 90%, CanvasText 10%);- font-size: 12px;- line-height: 1.2;- }- .empty-list { padding: 18px; color: color-mix(in srgb, CanvasText 62%, transparent); }- .footer {- display: flex;- align-items: center;- justify-content: space-between;- gap: 14px;- padding: 14px 24px 18px;- border-top: 1px solid color-mix(in srgb, CanvasText 14%, transparent);- }- .selected-count { color: color-mix(in srgb, CanvasText 68%, transparent); font-size: 13px; }- .footer-buttons { display: flex; gap: 10px; }- .danger {- border-color: color-mix(in srgb, #d70015 58%, CanvasText 12%);- background: color-mix(in srgb, #d70015 82%, black 18%);- color: white;- font-weight: 600;- }- .danger:hover { background: color-mix(in srgb, #d70015 74%, black 26%); }- @media (max-width: 640px) {- .project-row { grid-template-columns: auto minmax(0, 1fr); }- .project-tags { grid-column: 2; justify-content: flex-start; max-width: none; }- .footer { align-items: stretch; flex-direction: column; }- .footer-buttons { justify-content: flex-end; }- }-</style>-</head>-<body>- <main class="dialog" role="dialog" aria-labelledby="title" aria-describedby="description">- <section class="header">- <h1 id="title">Uninstall OpenKnowledge?</h1>- <p id="description">This removes OpenKnowledge’s settings and integrations from your Mac. Your markdown content and authored skills are kept.</p>- <p class="muted">Optionally select projects to also remove OpenKnowledge from. None are selected by default.</p>- <div class="controls">- <strong>${projectCount} detected ${projectWord}</strong>- <div class="control-buttons" aria-label="Project selection controls">- <button id="select-all" type="button">Select all</button>- <button id="select-none" type="button">Select none</button>- </div>- </div>- </section>- <section class="list-region" aria-label="Detected OpenKnowledge projects">- <p class="scroll-hint">Scrollable list — review all ${projectCount} ${projectWord} before uninstalling.</p>- <div class="project-list" id="project-list">-${buildDesktopUninstallProjectRows(candidates)}- </div>- </section>- <section class="footer">- <div class="selected-count" id="selected-count">0 projects selected.</div>- <div class="footer-buttons">- <button id="cancel" type="button" autofocus>Cancel</button>- <button id="confirm" class="danger" type="button">Uninstall OpenKnowledge</button>- </div>- </section>- </main>-<script>-(() => {- const boxes = Array.from(document.querySelectorAll('input[type="checkbox"][data-index]'));- const selectedCount = document.getElementById('selected-count');- const selectedIndexes = () => boxes- .filter((box) => box.checked)- .map((box) => Number(box.dataset.index))- .filter((index) => Number.isInteger(index));- const finish = (action, indexes = []) => {- window.location.href = 'ok-desktop-uninstall://' + action + '?indexes=' + encodeURIComponent(indexes.join(','));- };- const update = () => {- const count = selectedIndexes().length;- const noun = count === 1 ? 'project' : 'projects';- selectedCount.textContent = count + ' ' + noun + ' selected.';- };- const selectAll = () => { boxes.forEach((box) => { box.checked = true; }); update(); };- const selectNone = () => { boxes.forEach((box) => { box.checked = false; }); update(); };- const cancel = () => finish('cancel');- boxes.forEach((box) => box.addEventListener('change', update));- document.getElementById('select-all').addEventListener('click', selectAll);- document.getElementById('select-none').addEventListener('click', selectNone);- document.getElementById('cancel').addEventListener('click', cancel);- document.getElementById('confirm').addEventListener('click', () => {- finish('confirm', selectedIndexes());- });- document.addEventListener('keydown', (event) => {- if (event.key === 'Escape') cancel();- if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'a') {- event.preventDefault();- selectAll();- }- });- update();-})();-</script>-</body>-</html>`;-}--export function parseDesktopUninstallProjectPickerUrl(url: string): unknown | null {- let parsed: URL;- try {- parsed = new URL(url);- } catch {- return null;- }- if (parsed.protocol !== DESKTOP_UNINSTALL_SCHEME) return null;-- if (parsed.hostname === 'cancel') return { action: 'cancel' };- if (parsed.hostname !== 'confirm') return null;-- const indexesRaw = parsed.searchParams.get('indexes') ?? '';- const selectedIndexes = indexesRaw- .split(',')- .filter((part) => /^\d+$/.test(part))- .map((part) => Number.parseInt(part, 10));- return { action: 'confirm', selectedIndexes };-}--export function resolveDesktopUninstallProjectSelection(+export function selectDesktopUninstallProjectsByIndex(candidates: readonly DesktopUninstallProjectCandidate[],- raw: unknown,-): DesktopUninstallProjectCandidate[] | null {- if (raw == null || typeof raw !== 'object') return null;- const record = raw as Record<string, unknown>;- if (record.action !== 'confirm') return null;-- const rawIndexes = Array.isArray(record.selectedIndexes) ? record.selectedIndexes : [];+ rawIndexes: unknown,+): DesktopUninstallProjectCandidate[] {+ const indexes = Array.isArray(rawIndexes) ? rawIndexes : [];const selected = new Set<number>();- for (const value of rawIndexes) {+ for (const value of indexes) {if (Number.isInteger(value) && value >= 0 && value < candidates.length) {selected.add(value);}@@ -493,229 +197,34 @@ export function resolveDesktopUninstallProjectSelection(}// ----------------------------------------------------------------------------// Churn feedback screen+// Churn survey answers// ----------------------------------------------------------------------------const DESKTOP_UNINSTALL_FEEDBACK_SKIP_HOST = 'feedback-skip';-const DESKTOP_UNINSTALL_FEEDBACK_SEND_HOST = 'feedback-send';--/** The intake's own `message` / `email` ceilings; overrunning either 400s the whole ticket. */-const DESKTOP_UNINSTALL_FEEDBACK_NOTE_MAX_LEN = 10_000;-const DESKTOP_UNINSTALL_FEEDBACK_EMAIL_MAX_LEN = 320;--function buildDesktopUninstallFeedbackReasonRows(): string {- return UNINSTALL_FEEDBACK_REASONS.map(- (reason) => `<label class="reason-row">- <input type="radio" name="reason" value="${htmlEscape(reason.value)}" />- <span>${htmlEscape(reason.label)}</span>-</label>`,- ).join('\n');-}--/**- * The optional churn survey, shown after the uninstall is already confirmed.- * Both buttons continue the uninstall — this screen has no cancel path — and- * nothing here is required, so it deliberately has no Escape handler and no- * backdrop: the only exits are the two buttons or a deliberate window close.- */-export function buildDesktopUninstallFeedbackHtml(): string {- return `<!doctype html>-<html lang="en">-<head>-<meta charset="utf-8" />-<meta- http-equiv="Content-Security-Policy"- content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; form-action 'none'; base-uri 'none';"-/>-<meta name="viewport" content="width=device-width, initial-scale=1" />-<title>Before you go</title>-<style>-${DESKTOP_UNINSTALL_BASE_CSS}- .dialog, form {- display: flex;- flex-direction: column;- height: 100vh;- min-height: 0;- }- form { flex: 1; height: auto; }- .header { padding: 22px 24px 14px; }- .header .muted { margin: 0; }- h1 { margin: 0 0 8px; }- p { margin: 0; line-height: 1.42; }- .body {- flex: 1;- min-height: 0;- overflow-y: auto;- padding: 16px 24px 6px;- }- fieldset { margin: 0 0 16px; padding: 0; border: 0; }- legend { margin: 0 0 6px; padding: 0; font-weight: 600; }- .reason-row {- display: flex;- gap: 9px;- align-items: baseline;- padding: 6px 8px;- border-radius: 7px;- line-height: 1.35;- }- .reason-row:hover { background: color-mix(in srgb, Highlight 12%, transparent); }- .field { margin-bottom: 14px; }- .field > label { display: block; margin-bottom: 6px; font-weight: 600; }- textarea, input[type="email"] {- display: block;- width: 100%;- border: 1px solid color-mix(in srgb, CanvasText 22%, transparent);- border-radius: 7px;- background: color-mix(in srgb, Canvas 96%, CanvasText 4%);- color: CanvasText;- padding: 8px 10px;- font: inherit;- }- textarea { min-height: 72px; resize: vertical; }- textarea:focus-visible, input:focus-visible { outline: 3px solid Highlight; outline-offset: 1px; }- .optin { display: flex; gap: 9px; align-items: baseline; font-weight: 400; }- .footer {- display: flex;- justify-content: flex-end;- gap: 10px;- padding: 14px 24px 18px;- border-top: 1px solid color-mix(in srgb, CanvasText 14%, transparent);- }- button {- appearance: none;- border: 1px solid color-mix(in srgb, CanvasText 22%, transparent);- border-radius: 7px;- background: color-mix(in srgb, Canvas 88%, CanvasText 12%);- color: CanvasText;- padding: 7px 14px;- font: inherit;- cursor: default;- }- button:hover { background: color-mix(in srgb, Canvas 82%, CanvasText 18%); }- button:focus-visible { outline: 3px solid Highlight; outline-offset: 2px; }- /* Chromium's Highlight keyword is the pale selection blue — too light for a- filled button — so the primary uses the concrete macOS system blues. */- .primary {- border-color: transparent;- background: #007aff;- color: white;- font-weight: 600;- }- .primary:hover { background: color-mix(in srgb, #007aff 86%, black 14%); }- @media (prefers-color-scheme: dark) {- .primary { background: #0a84ff; }- .primary:hover { background: color-mix(in srgb, #0a84ff 86%, black 14%); }- }-</style>-</head>-<body>- <main class="dialog" role="dialog" aria-labelledby="title" aria-describedby="egress">- <section class="header">- <h1 id="title">Thanks for giving OpenKnowledge a try.</h1>- <p class="muted" id="egress">What you share is sent to the OpenKnowledge team.</p>- </section>- <form id="feedback">- <section class="body">- <fieldset>- <legend>Before you go, mind sharing why?</legend>-${buildDesktopUninstallFeedbackReasonRows()}- </fieldset>- <div class="field">- <label for="note">Anything you'd like to add? (optional)</label>- <textarea id="note" rows="3" maxlength="${DESKTOP_UNINSTALL_FEEDBACK_NOTE_MAX_LEN}"></textarea>- </div>- <div class="field">- <label class="optin"><input type="checkbox" id="email-optin" /> Let us follow up by email</label>- </div>- <div class="field" id="email-field" hidden>- <label for="email">Email address</label>- <input type="email" id="email" maxlength="${DESKTOP_UNINSTALL_FEEDBACK_EMAIL_MAX_LEN}" autocomplete="email" spellcheck="false" placeholder="[email protected]" disabled />- </div>- </section>- <section class="footer">- <button id="skip" type="button" autofocus>Skip</button>- <button id="send" class="primary" type="submit">Send & continue</button>- </section>- </form>- </main>-<script>-(() => {- const form = document.getElementById('feedback');- const optIn = document.getElementById('email-optin');- const emailField = document.getElementById('email-field');- const email = document.getElementById('email');- const finish = (action, params) => {- const query = params.length === 0 ? '' : '?' + params.join('&');- window.location.href = 'ok-desktop-uninstall://' + action + query;- };- optIn.addEventListener('change', () => {- emailField.hidden = !optIn.checked;- // Disabled, not merely hidden: a hidden-but-validatable field makes the- // browser silently refuse the submit (it cannot focus what it must report- // on), which would strand the user on a screen with no visible problem.- email.disabled = !optIn.checked;- if (optIn.checked) email.focus();- });- document.getElementById('skip').addEventListener('click', () => finish('feedback-skip', []));- // Submit rather than click, so a malformed address trips the browser's own- // validation instead of 400-ing the whole ticket away at the intake.- form.addEventListener('submit', (event) => {- event.preventDefault();- const params = [];- const reason = form.querySelector('input[name="reason"]:checked');- if (reason) params.push('reason=' + encodeURIComponent(reason.value));- const note = document.getElementById('note').value.trim();- if (note) params.push('note=' + encodeURIComponent(note));- const address = optIn.checked ? email.value.trim() : '';- if (address) params.push('email=' + encodeURIComponent(address));- finish('feedback-send', params);- });-})();-</script>-</body>-</html>`;-}-/*** Renderer text arriving at the main process: trim, drop blanks so an untouched* field never counts as an answer, and clamp to the intake's field limits.*/-function boundedFeedbackAnswer(raw: string | null, maxLength: number): string | undefined {- const trimmed = raw?.trim();- if (trimmed === undefined || trimmed === '') return undefined;+function boundedFeedbackAnswer(raw: unknown, maxLength: number): string | undefined {+ if (typeof raw !== 'string') return undefined;+ const trimmed = raw.trim();+ if (trimmed === '') return undefined;return trimmed.slice(0, maxLength);}/**- * Read the feedback window's answers off its private navigation URL. `null`- * means "not a feedback result" (the caller keeps waiting); an empty object- * means the user left without answering, which posts nothing but still- * proceeds with the uninstall.+ * Turn whatever the survey screen sent into answers safe to file: trim, drop+ * blanks, and clamp. The renderer's `maxlength` and this clamp both read+ * `UNINSTALL_FEEDBACK_*_MAX_LEN`, so they cannot disagree about the intake's+ * limits.*/-export function parseDesktopUninstallFeedbackUrl(url: string): UninstallFeedbackAnswers | null {- let parsed: URL;- try {- parsed = new URL(url);- } catch {- return null;- }- if (parsed.protocol !== DESKTOP_UNINSTALL_SCHEME) return null;- if (parsed.hostname === DESKTOP_UNINSTALL_FEEDBACK_SKIP_HOST) return {};- if (parsed.hostname !== DESKTOP_UNINSTALL_FEEDBACK_SEND_HOST) return null;-- const reason = parsed.searchParams.get('reason');- const note = boundedFeedbackAnswer(- parsed.searchParams.get('note'),- DESKTOP_UNINSTALL_FEEDBACK_NOTE_MAX_LEN,- );- const email = boundedFeedbackAnswer(- parsed.searchParams.get('email'),- DESKTOP_UNINSTALL_FEEDBACK_EMAIL_MAX_LEN,- );+export function normalizeDesktopUninstallFeedbackAnswers(raw: unknown): UninstallFeedbackAnswers {+ const record: Record<string, unknown> = typeof raw === 'object' && raw !== null ? { ...raw } : {};+ const note = boundedFeedbackAnswer(record.note, UNINSTALL_FEEDBACK_NOTE_MAX_LEN);+ const email = boundedFeedbackAnswer(record.email, UNINSTALL_FEEDBACK_EMAIL_MAX_LEN);return {// A slug outside the taxonomy would file a ticket nothing can group by;// dropping it keeps whatever the user actually wrote.- ...(isUninstallFeedbackReason(reason) ? { reason } : {}),+ ...(isUninstallFeedbackReason(record.reason) ? { reason: record.reason } : {}),...(note === undefined ? {} : { note }),...(email === undefined ? {} : { email }),};@@ -833,45 +342,6 @@ export async function runDesktopUninstallOutcomeStep(await deps.showCompletion();}-export function buildDesktopUninstallProgressHtml(): string {- return `<!doctype html>-<html lang="en">-<head>-<meta charset="utf-8" />-<meta- http-equiv="Content-Security-Policy"- content="default-src 'none'; style-src 'unsafe-inline';"-/>-<meta name="viewport" content="width=device-width, initial-scale=1" />-<title>Uninstalling OpenKnowledge</title>-<style>-${DESKTOP_UNINSTALL_BASE_CSS}- body { min-height: 100vh; display: grid; place-items: center; }- .wrap { text-align: center; padding: 28px; max-width: 360px; }- .spinner {- width: 34px;- height: 34px;- margin: 0 auto 18px;- border: 3px solid color-mix(in srgb, CanvasText 18%, transparent);- border-top-color: Highlight;- border-radius: 50%;- animation: spin 0.9s linear infinite;- }- h1 { margin: 0 0 8px; }- p { margin: 0; line-height: 1.42; color: color-mix(in srgb, CanvasText 68%, transparent); }- @keyframes spin { to { transform: rotate(360deg); } }-</style>-</head>-<body>- <main class="wrap" role="status" aria-live="polite">- <div class="spinner" aria-hidden="true"></div>- <h1>Removing OpenKnowledge files…</h1>- <p>This may take a moment. Your markdown content is kept.</p>- </main>-</body>-</html>`;-}-export function defaultDesktopUninstallLogPath(home: string = homedir(),now: Date = new Date(),@@ -909,9 +379,9 @@ export function readDesktopUninstallLogForDisplay(// ---------------------------------------------------------------------------/**- * A simple message dialog rendered as an inline HTML window. Native- * `dialog.showMessageBox` renders `detail` at macOS's fixed small font, which- * is what pushed these off NSAlert.+ * A notice rendered in the React uninstall window rather than a native+ * `dialog.showMessageBox`, whose `detail` sits at macOS's fixed small font —+ * which is what pushed these off NSAlert.*/interface DesktopUninstallChecklistItem {label: string;@@ -931,8 +401,8 @@ export interface DesktopUninstallNoticeSpec {footnote?: string;/*** When set, renders a subtle link with this text that reveals the cleanup log- * in Finder. The path itself never enters the HTML — main holds it and reveals- * on the intercepted `reveal-log` navigation (see `onRevealLog`).+ * in Finder. The path itself never reaches the renderer — main holds it and+ * reveals on the `notice-reveal-log` intent.*/logRevealLabel?: string;/** Monospace scrollable block (the cleanup log). */@@ -949,7 +419,7 @@ export function desktopUninstallConfirmNotice(): DesktopUninstallNoticeSpec {return {title: 'Uninstall OpenKnowledge?',paragraphs: [- 'This removes OpenKnowledge’s settings and integrations from your Mac. Your markdown content and authored skills are kept.',+ 'This removes OpenKnowledge’s settings and integrations from your Mac, but keeps your markdown content and authored skills.','When cleanup finishes, OpenKnowledge will help you remove the app itself, then quit.',],confirmLabel: 'Uninstall OpenKnowledge',@@ -1025,213 +495,6 @@ export function desktopUninstallFinalStepNotice(): DesktopUninstallNoticeSpec {};}-export function parseDesktopUninstallNoticeUrl(- url: string,-): 'confirm' | 'cancel' | 'reveal-log' | null {- let parsed: URL;- try {- parsed = new URL(url);- } catch {- return null;- }- if (parsed.protocol !== DESKTOP_UNINSTALL_SCHEME) return null;- if (parsed.hostname === 'notice-confirm') return 'confirm';- if (parsed.hostname === 'notice-cancel') return 'cancel';- // A non-terminal action: reveal the log in Finder without closing the notice.- if (parsed.hostname === 'notice-reveal-log') return 'reveal-log';- return null;-}--export function buildDesktopUninstallNoticeHtml(spec: DesktopUninstallNoticeSpec): string {- const paragraphs = spec.paragraphs.map((text) => `<p>${htmlEscape(text)}</p>`).join('\n');- const subtitle =- spec.subtitle === undefined ? '' : `<p class="subtitle">${htmlEscape(spec.subtitle)}</p>`;- const checklist =- spec.checklist === undefined- ? ''- : `<ol class="checklist">-${spec.checklist- .map((item) => {- // The ✓ glyph is a shape channel (not colour alone); the visually-hidden- // status word carries the same state to a screen reader.- const marker = item.done- ? '<span class="marker" aria-hidden="true">✓</span><span class="sr">Done. </span>'- : '<span class="marker" aria-hidden="true"></span><span class="sr">To do. </span>';- const detail =- item.detail === undefined ? '' : `<span class="cdetail">${htmlEscape(item.detail)}</span>`;- return ` <li class="${item.done ? 'done' : 'pending'}">${marker}<span class="citem"><span class="clabel">${htmlEscape(item.label)}</span>${detail}</span></li>`;- })- .join('\n')}-</ol>`;- const logBlock = spec.log === undefined ? '' : `<pre class="log">${htmlEscape(spec.log)}</pre>`;- const footnote =- spec.footnote === undefined ? '' : `<p class="footnote">${htmlEscape(spec.footnote)}</p>`;- // The path never enters the HTML — the link only carries the intercepted- // action; main reveals the log it already knows the path to.- const logReveal =- spec.logRevealLabel === undefined- ? ''- : `<p class="footnote"><a class="loglink" href="ok-desktop-uninstall://notice-reveal-log">${htmlEscape(spec.logRevealLabel)}</a></p>`;- const cancelButton =- spec.cancelLabel === undefined- ? ''- : `<button id="cancel" type="button" autofocus>${htmlEscape(spec.cancelLabel)}</button>`;- // Two-button notices keep focus on Cancel (destructive-safe default, matching- // NSAlert's cancel-default convention); single-button notices focus Continue.- const confirmAutofocus = spec.cancelLabel === undefined ? ' autofocus' : '';- const confirmClass = spec.danger ? 'danger' : 'primary';- return `<!doctype html>-<html lang="en">-<head>-<meta charset="utf-8" />-<meta- http-equiv="Content-Security-Policy"- content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline';"-/>-<meta name="viewport" content="width=device-width, initial-scale=1" />-<title>${htmlEscape(spec.title)}</title>-<style>-${DESKTOP_UNINSTALL_BASE_CSS}- .dialog {- display: flex;- flex-direction: column;- height: 100vh;- min-height: 0;- padding: 22px 24px 18px;- }- h1 { margin: 0 0 12px; }- .body { flex: 1; min-height: 0; display: flex; flex-direction: column; }- p { margin: 0 0 10px; line-height: 1.45; }- .log {- flex: 1;- min-height: 80px;- margin: 2px 0 10px;- padding: 10px 12px;- overflow: auto;- border: 1px solid color-mix(in srgb, CanvasText 16%, transparent);- border-radius: 8px;- background: color-mix(in srgb, Canvas 96%, CanvasText 4%);- font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;- line-height: 1.45;- white-space: pre-wrap;- overflow-wrap: anywhere;- user-select: text;- }- .footnote {- margin: 0;- color: color-mix(in srgb, CanvasText 62%, transparent);- font-size: 12.5px;- overflow-wrap: anywhere;- user-select: text;- }- .subtitle {- margin: -4px 0 16px;- color: color-mix(in srgb, CanvasText 60%, transparent);- line-height: 1.4;- }- .sr {- position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;- overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;- }- .checklist { list-style: none; margin: 0 0 6px; padding: 0; }- .checklist li { position: relative; padding: 0 0 14px 30px; }- .checklist li:last-child { padding-bottom: 4px; }- /* Vertical connector down the marker column, between consecutive steps. */- .checklist li:not(:last-child)::before {- content: ''; position: absolute; left: 9px; top: 22px; bottom: 2px;- width: 2px; background: color-mix(in srgb, CanvasText 15%, transparent);- }- .checklist .marker {- position: absolute; left: 0; top: 1px; width: 20px; height: 20px;- border-radius: 999px; display: inline-flex; align-items: center;- justify-content: center; font-size: 12px; line-height: 1;- }- .checklist li.done .marker { background: color-mix(in srgb, #007aff 15%, Canvas); color: #007aff; }- .checklist li.pending .marker {- border: 1.5px solid color-mix(in srgb, CanvasText 38%, transparent);- }- .checklist .citem { display: block; }- .checklist .clabel { font-weight: 600; }- .checklist li.done .clabel { font-weight: 500; }- .checklist .cdetail {- display: block; margin-top: 2px; line-height: 1.4;- color: color-mix(in srgb, CanvasText 60%, transparent);- }- .loglink { color: color-mix(in srgb, CanvasText 60%, transparent); text-underline-offset: 2px; cursor: default; }- .loglink:hover { color: CanvasText; }- @media (prefers-color-scheme: dark) {- .checklist li.done .marker { background: color-mix(in srgb, #0a84ff 22%, Canvas); color: #0a84ff; }- }- .buttons { display: flex; justify-content: flex-end; gap: 10px; padding-top: 14px; }- button {- appearance: none;- border: 1px solid color-mix(in srgb, CanvasText 22%, transparent);- border-radius: 7px;- background: color-mix(in srgb, Canvas 88%, CanvasText 12%);- color: CanvasText;- padding: 7px 14px;- font: inherit;- cursor: default;- }- button:hover { background: color-mix(in srgb, Canvas 82%, CanvasText 18%); }- button:focus-visible { outline: 3px solid Highlight; outline-offset: 2px; }- /* Chromium's Highlight keyword is the pale selection blue — too light for a- filled button — so the primary uses the concrete macOS system blues. */- .primary {- border-color: transparent;- background: #007aff;- color: white;- font-weight: 600;- }- .primary:hover { background: color-mix(in srgb, #007aff 86%, black 14%); }- @media (prefers-color-scheme: dark) {- .primary { background: #0a84ff; }- .primary:hover { background: color-mix(in srgb, #0a84ff 86%, black 14%); }- }- .danger {- border-color: color-mix(in srgb, #d70015 58%, CanvasText 12%);- background: color-mix(in srgb, #d70015 82%, black 18%);- color: white;- font-weight: 600;- }- .danger:hover { background: color-mix(in srgb, #d70015 74%, black 26%); }-</style>-</head>-<body>- <main class="dialog" role="alertdialog" aria-labelledby="title" aria-describedby="body">- <h1 id="title">${htmlEscape(spec.title)}</h1>-${subtitle}- <div class="body" id="body">-${paragraphs}-${checklist}-${logBlock}-${footnote}-${logReveal}- </div>- <div class="buttons">- ${cancelButton}- <button id="confirm" class="${confirmClass}" type="button"${confirmAutofocus}>${htmlEscape(spec.confirmLabel)}</button>- </div>- </main>-<script>-(() => {- const hasCancel = ${spec.cancelLabel === undefined ? 'false' : 'true'};- const finish = (action) => {- window.location.href = 'ok-desktop-uninstall://notice-' + action;- };- document.getElementById('confirm').addEventListener('click', () => finish('confirm'));- if (hasCancel) {- document.getElementById('cancel').addEventListener('click', () => finish('cancel'));- }- document.addEventListener('keydown', (event) => {- if (event.key === 'Escape') finish(hasCancel ? 'cancel' : 'confirm');- });-})();-</script>-</body>-</html>`;-}-function shellQuote(value: string): string {return `'${value.split("'").join("'\\''")}'`;}diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.tsindex 34d50b1c2..a016c77df 100644--- a/packages/desktop/src/main/index.ts+++ b/packages/desktop/src/main/index.ts@@ -70,12 +70,15 @@ import {} from '@inkeep/open-knowledge';import {CLIENT_VERSION_HEADER,+ hasUninstallFeedbackContent,PROTOCOL_VERSION,ServerInfoSuccessSchema,SPAWN_ERROR_LOG,TERMINAL_CLIS,type TerminalCli,type UninstallFeedbackAnswers,+ type UninstallIntent,+ type UninstallScreenSpec,} from '@inkeep/open-knowledge-core';import {assertGitAvailable,@@ -139,6 +142,7 @@ import type {} from '../shared/ipc-channels.ts';import { createHandler } from '../shared/ipc-handler.ts';import { registerPendingDelivery, sendToRenderer } from '../shared/ipc-send.ts';+import { UNINSTALL_PRELOAD_ARG } from '../shared/uninstall-preload-arg.ts';import { resolveShell } from '../utility/pty-host.ts';import { buildAboutPanelOptions } from './about-panel.ts';import { appendOkIgnoreSync } from './append-okignore.ts';@@ -195,12 +199,9 @@ import {import { createDebugIpc, type DebugIpcHandle } from './debug-ipc.ts';import { flushDesktopLogger, getLogger, getRootDesktopLogger } from './desktop-logger.ts';import {- buildDesktopUninstallFeedbackHtml,- buildDesktopUninstallNoticeHtml,- buildDesktopUninstallProgressHtml,- buildDesktopUninstallProjectPickerHtml,collectDesktopUninstallProjectCandidates,confirmDesktopUninstall,+ type DesktopUninstallFlowPreviewMode,type DesktopUninstallNoticeSpec,type DesktopUninstallProjectCandidate,type DesktopUninstallUiPreviewMode,@@ -210,17 +211,15 @@ import {desktopUninstallFailureNotice,desktopUninstallFinalStepNotice,isSupportedApplicationsBundle,- parseDesktopUninstallFeedbackUrl,- parseDesktopUninstallNoticeUrl,- parseDesktopUninstallProjectPickerUrl,+ normalizeDesktopUninstallFeedbackAnswers,type RunDesktopUninstallCleanupResult,readDesktopUninstallLogForDisplay,resolveAppBundleFromExecPath,- resolveDesktopUninstallProjectSelection,resolveDesktopUninstallUiPreviewMode,runDesktopUninstallCleanup,runDesktopUninstallFeedbackStep,runDesktopUninstallOutcomeStep,+ selectDesktopUninstallProjectsByIndex,} from './desktop-uninstall.ts';import { promptForExistingFolder, promptForExistingMarkdownFile } from './dialog-helpers.ts';import {@@ -374,6 +373,13 @@ import {import { getTerminalWindowContext, resolvePtyProjectRoot } from './terminal-window-registry.ts';import { applyThemeApplied } from './theme-applied-handler.ts';import { applyThemeSource, isOkThemeSource } from './theme-handler.ts';+import { createUninstallScreenRegistry } from './uninstall-ipc.ts';+import {+ loadUninstallEntry,+ noticeCloseIsConfirm,+ resolveUninstallEntryTarget,+ resolveUninstallWindowTheme,+} from './uninstall-window.ts';import {applyResetIncompatible,applyStateQuery,@@ -2644,10 +2650,13 @@ async function showMessageBoxAttached(options: MessageBoxOptions) {}/**- * Show a `DesktopUninstallNoticeSpec` in a styled utility window and resolve- * true on confirm. Closing the window without a button press means Cancel for- * a two-button notice; a single-button notice proceeds either way (there is- * nothing else to choose, and the flow must still quit).+ * Show a `DesktopUninstallNoticeSpec` in the React uninstall window and resolve+ * true on confirm.+ *+ * Closing the window without pressing a button means Cancel for a two-button+ * notice — an unanswered question must not proceed. A single-button notice has+ * nothing else to choose and the flow still has to finish, so closing it+ * confirms. The screen mirrors the same split on Escape.*/async function showDesktopUninstallNotice(spec: DesktopUninstallNoticeSpec,@@ -2659,64 +2668,38 @@ async function showDesktopUninstallNotice(onRevealLog?: () => void;} = {},): Promise<boolean> {- const parent = BrowserWindow.getFocusedWindow();- const closeMeansConfirm = spec.cancelLabel === undefined;+ const closeMeansConfirm = noticeCloseIsConfirm(spec);return new Promise((resolveNotice) => {- const win = createDesktopUninstallUtilityWindow({- parent,- width: options.width ?? 480,- height: options.height ?? 300,- title: spec.title,- modal: parent != null,- resizable: options.resizable ?? false,- });-let settled = false;- const finish = (confirmed: boolean) => {+ const finish = (confirmed: boolean, win?: BrowserWindow) => {if (settled) return;settled = true;resolveNotice(confirmed);- if (!win.isDestroyed()) win.destroy();+ if (win !== undefined && !win.isDestroyed()) win.destroy();};- win.webContents.on('will-navigate', (event, url) => {- const action = parseDesktopUninstallNoticeUrl(url);- if (action === 'reveal-log') {- // Non-terminal: reveal the log in Finder and leave the notice open.- event.preventDefault();- options.onRevealLog?.();- return;- }- if (action !== null) {- event.preventDefault();- finish(action === 'confirm');- return;- }- if (!url.startsWith('data:text/html')) event.preventDefault();- });-- win.on('close', (event) => {- if (settled) return;- event.preventDefault();+ void openDesktopUninstallRendererWindow({+ screen: { kind: 'notice', notice: spec },+ width: options.width ?? 480,+ height: options.height ?? 300,+ resizable: options.resizable ?? false,+ title: spec.title,+ onIntent: (intent, win) => {+ if (intent.kind === 'notice-reveal-log') {+ // Non-terminal: reveal the log in Finder and leave the notice up, so+ // the user can read what happened and still answer.+ options.onRevealLog?.();+ } else if (intent.kind === 'notice-confirm') {+ finish(true, win);+ } else if (intent.kind === 'notice-cancel') {+ finish(false, win);+ }+ },+ onClosed: () => finish(closeMeansConfirm),+ }).catch((err) => {+ getLogger('lifecycle').warn({ err }, 'desktop uninstall notice failed to load');finish(closeMeansConfirm);});- win.on('closed', () => {- if (settled) return;- settled = true;- resolveNotice(closeMeansConfirm);- });- win.once('ready-to-show', () => {- if (!win.isDestroyed()) win.show();- });-- void win- .loadURL(- `data:text/html;charset=utf-8,${encodeURIComponent(buildDesktopUninstallNoticeHtml(spec))}`,- )- .catch((err) => {- getLogger('lifecycle').warn({ err }, 'desktop uninstall notice failed to load');- finish(closeMeansConfirm);- });});}@@ -2729,6 +2712,12 @@ function createDesktopUninstallUtilityWindow(options: {title: string;modal?: boolean;resizable?: boolean;+ /**+ * Load the preload bridge and tag the window as the uninstall renderer, so+ * the preload exposes `okUninstall` instead of `okDesktop`. The inline-HTML+ * screens omit it and get no preload at all.+ */+ uninstallBridge?: boolean;}): BrowserWindow {const win = new BrowserWindow({width: options.width,@@ -2745,6 +2734,12 @@ function createDesktopUninstallUtilityWindow(options: {fullscreenable: false,webPreferences: {...DEFAULT_WIN_OPTS.webPreferences,+ ...(options.uninstallBridge === true+ ? {+ preload: join(__dirname, '../preload/index.js'),+ additionalArguments: [UNINSTALL_PRELOAD_ARG],+ }+ : {}),},});win.setMenu(null);@@ -2752,6 +2747,115 @@ function createDesktopUninstallUtilityWindow(options: {return win;}+/**+ * Every live React uninstall window, keyed by webContents id. Main answers+ * `ok:uninstall:dispatch` only for senders in here — see `uninstall-ipc.ts`.+ */+const uninstallScreens = createUninstallScreenRegistry();++/**+ * Open the React uninstall renderer (`packages/app/uninstall.html`) showing+ * `screen`, and resolve once it is visible.+ *+ * The theme is resolved here, in main, and travels in the entry query so the+ * renderer's inline stamp runs before the body parses — `ready-to-show` (and+ * therefore `show()`) cannot beat it, so there is no wrong-theme frame.+ *+ * The screen registration is torn down on `closed`, so a window main has+ * finished with can no longer drive the flow even if its renderer is still+ * executing.+ */+async function openDesktopUninstallRendererWindow(options: {+ screen: UninstallScreenSpec;+ width?: number;+ height?: number;+ minWidth?: number;+ minHeight?: number;+ title?: string;+ resizable?: boolean;+ /**+ * Refuse user-initiated closes. `destroy()` bypasses it, so main can still+ * take the window down when the step it covers is over.+ */+ preventClose?: boolean;+ /** Receives the window so a settling intent can close the screen it came from. */+ onIntent: (intent: UninstallIntent, win: BrowserWindow) => void;+ /**+ * Runs once the window is gone, however it went — user close, a settling+ * intent, or a load failure. Wired here rather than by the caller because a+ * window can close before this function's promise resolves, and a listener+ * attached afterwards would never fire.+ */+ onClosed?: () => void;+}): Promise<BrowserWindow> {+ const parent = BrowserWindow.getFocusedWindow();+ const win = createDesktopUninstallUtilityWindow({+ parent,+ width: options.width ?? 560,+ height: options.height ?? 420,+ minWidth: options.minWidth,+ minHeight: options.minHeight,+ title: options.title ?? 'Uninstall OpenKnowledge',+ resizable: options.resizable,+ uninstallBridge: true,+ });+ if (options.preventClose === true) {+ win.on('close', (event) => event.preventDefault());+ }+ const release = uninstallScreens.open(win.webContents.id, {+ screen: options.screen,+ onIntent: (intent) => options.onIntent(intent, win),+ });+ const shown = new Promise<void>((resolveShown) => {+ win.once('ready-to-show', () => {+ if (!win.isDestroyed()) win.show();+ resolveShown();+ });+ win.once('closed', () => {+ release();+ options.onClosed?.();+ resolveShown();+ });+ });++ const theme = resolveUninstallWindowTheme(nativeTheme.shouldUseDarkColors);+ try {+ await loadUninstallEntry(+ win,+ resolveUninstallEntryTarget(+ {+ devServerUrl: rendererDevUrl,+ isPackaged: app.isPackaged,+ resourcesPath: process.resourcesPath,+ mainDir: __dirname,+ },+ theme,+ ),+ );+ } catch (err) {+ // `win.destroy()` fires `closed` synchronously, which runs release()+ // (idempotent) and onClosed?.() through the `closed` handler. The explicit+ // release() here unregisters the window before destroy fires it again. The+ // re-throw reaches the caller's `.catch()`, but for any caller providing+ // `onClosed` its outer Promise has already settled through that closed path+ // by the time the catch runs — the `settled` guard makes it a no-op.+ release();+ if (!win.isDestroyed()) win.destroy();+ throw err;+ }+ await shown;+ return win;+}++/**+ * Show the project picker and resolve with the projects to also deinit, or+ * `null` when the user cancels.+ *+ * Closing the window IS a cancel — this screen is the flow's confirm gate, so+ * every exit that is not an explicit confirm has to leave the install alone.+ * (The churn survey deliberately maps close the other way; see+ * `showDesktopUninstallFeedbackWindow`.)+ */async function showDesktopUninstallProjectPicker(candidates: readonly DesktopUninstallProjectCandidate[],): Promise<DesktopUninstallProjectCandidate[] | null> {@@ -2763,57 +2867,40 @@ async function showDesktopUninstallProjectPicker(const height = Math.max(460, Math.min(680, workArea.height - 80));return new Promise((resolveSelection) => {- const win = createDesktopUninstallUtilityWindow({- parent,- width,- height,- minWidth: 560,- minHeight: 420,- title: 'Uninstall OpenKnowledge',- });-let settled = false;- const finish = (raw: unknown) => {+ const finish = (selection: DesktopUninstallProjectCandidate[] | null, win?: BrowserWindow) => {if (settled) return;settled = true;- resolveSelection(resolveDesktopUninstallProjectSelection(candidates, raw));- if (!win.isDestroyed()) win.destroy();+ resolveSelection(selection);+ if (win !== undefined && !win.isDestroyed()) win.destroy();};- win.webContents.on('will-navigate', (event, url) => {- const pickerResult = parseDesktopUninstallProjectPickerUrl(url);- if (pickerResult !== null) {- event.preventDefault();- finish(pickerResult);- return;- }- if (!url.startsWith('data:text/html')) event.preventDefault();- });-- win.on('close', (event) => {- if (settled) return;- event.preventDefault();- finish({ action: 'cancel' });- });- win.on('closed', () => {- if (settled) return;- settled = true;- resolveSelection(null);- });- win.once('ready-to-show', () => {- if (!win.isDestroyed()) win.show();+ void openDesktopUninstallRendererWindow({+ screen: {+ kind: 'picker',+ projects: candidates.map((candidate) => ({+ path: candidate.path,+ open: candidate.open,+ recent: candidate.recent,+ running: candidate.running,+ })),+ },+ width,+ height,+ minWidth: 560,+ minHeight: 420,+ onIntent: (intent, win) => {+ if (intent.kind === 'picker-confirm') {+ finish(selectDesktopUninstallProjectsByIndex(candidates, intent.selectedIndexes), win);+ } else if (intent.kind === 'picker-cancel') {+ finish(null, win);+ }+ },+ onClosed: () => finish(null),+ }).catch((err) => {+ getLogger('lifecycle').warn({ err }, 'desktop uninstall project picker failed to load');+ finish(null);});-- void win- .loadURL(- `data:text/html;charset=utf-8,${encodeURIComponent(- buildDesktopUninstallProjectPickerHtml(candidates),- )}`,- )- .catch((err) => {- getLogger('lifecycle').warn({ err }, 'desktop uninstall project picker failed to load');- finish({ action: 'cancel' });- });});}@@ -2834,55 +2921,33 @@ async function showDesktopUninstallFeedbackWindow(): Promise<UninstallFeedbackAnconst height = Math.max(520, Math.min(640, workArea.height - 80));return new Promise((resolveAnswers) => {- const win = createDesktopUninstallUtilityWindow({- parent,- width,- height,- minWidth: 480,- minHeight: 420,- title: 'Before you go',- });-let settled = false;- const finish = (answers: UninstallFeedbackAnswers) => {+ const finish = (answers: UninstallFeedbackAnswers, win?: BrowserWindow) => {if (settled) return;settled = true;resolveAnswers(answers);- if (!win.isDestroyed()) win.destroy();+ if (win !== undefined && !win.isDestroyed()) win.destroy();};- win.webContents.on('will-navigate', (event, url) => {- const answers = parseDesktopUninstallFeedbackUrl(url);- if (answers !== null) {- event.preventDefault();- finish(answers);- return;- }- if (!url.startsWith('data:text/html')) event.preventDefault();- });-- win.on('close', (event) => {- if (settled) return;- event.preventDefault();+ void openDesktopUninstallRendererWindow({+ screen: { kind: 'survey' },+ width,+ height,+ minWidth: 480,+ minHeight: 420,+ title: 'Before you go',+ onIntent: (intent, win) => {+ if (intent.kind === 'survey-send') {+ finish(normalizeDesktopUninstallFeedbackAnswers(intent), win);+ } else if (intent.kind === 'survey-skip') {+ finish({}, win);+ }+ },+ onClosed: () => finish({}),+ }).catch((err) => {+ getLogger('lifecycle').warn({ err }, 'desktop uninstall feedback window failed to load');finish({});});- win.on('closed', () => {- if (settled) return;- settled = true;- resolveAnswers({});- });- win.once('ready-to-show', () => {- if (!win.isDestroyed()) win.show();- });-- void win- .loadURL(- `data:text/html;charset=utf-8,${encodeURIComponent(buildDesktopUninstallFeedbackHtml())}`,- )- .catch((err) => {- getLogger('lifecycle').warn({ err }, 'desktop uninstall feedback window failed to load');- finish({});- });});}@@ -2905,41 +2970,31 @@ async function collectDesktopUninstallFeedback(): Promise<void> {}}+/**+ * Run `work` behind the progress screen, which stays up — and refuses to be+ * closed — until the work settles.+ */async function withDesktopUninstallProgress<T>(work: () => Promise<T>): Promise<T> {- const parent = BrowserWindow.getFocusedWindow();- const win = createDesktopUninstallUtilityWindow({- parent,+ // Cosmetic: a window that fails to load must neither skip the cleanup nor+ // leak, so a failure is logged and the work runs without it.+ const win = await openDesktopUninstallRendererWindow({+ screen: { kind: 'progress' },width: 420,height: 220,- title: 'Uninstalling OpenKnowledge',- modal: parent != null,resizable: false,- });- win.webContents.on('will-navigate', (event, url) => {- if (!url.startsWith('data:text/html')) event.preventDefault();- });- const preventClose = (event: { preventDefault(): void }) => event.preventDefault();- win.on('close', preventClose);- win.once('ready-to-show', () => {- if (!win.isDestroyed()) win.show();+ preventClose: true,+ title: 'Uninstalling OpenKnowledge',+ // Nothing on this screen can be pressed, so anything arriving here is noise.+ onIntent: () => undefined,+ }).catch((err) => {+ getLogger('lifecycle').warn({ err }, 'desktop uninstall progress window failed to load');+ return null;});try {- // The progress window is cosmetic — a failed load must neither skip the- // cleanup nor (being outside the finally) leak the close-prevented window.- try {- await win.loadURL(- `data:text/html;charset=utf-8,${encodeURIComponent(buildDesktopUninstallProgressHtml())}`,- );- } catch (err) {- getLogger('lifecycle').warn({ err }, 'desktop uninstall progress window failed to load');- }return await work();} finally {- if (!win.isDestroyed()) {- win.removeListener('close', preventClose);- win.destroy();- }+ if (win !== null && !win.isDestroyed()) win.destroy();}}@@ -3038,6 +3093,12 @@ async function startDesktopSelfUninstallFlow(): Promise<void> {** `OK_UNINSTALL_UI_PREVIEW=success` walks the happy path (feedback → completion);* `=failure` walks the failure notices. See `runDesktopUninstallUiPreview`.+ * `=renderer`, `=picker`, `=survey` and `=notice` skip the flow entirely and+ * open one screen — a notice, the project picker, the churn survey and both+ * notice shapes respectively — so a screen's fidelity and its IPC round trip+ * can be asserted on their own. Each settles by destroying its window, the same+ * shape the real screens use, which is the observable a smoke needs to prove an+ * intent actually reached main.*/function maybeRunDesktopUninstallUiPreview(): void {const mode = resolveDesktopUninstallUiPreviewMode(@@ -3045,11 +3106,147 @@ function maybeRunDesktopUninstallUiPreview(): void {app.isPackaged,);if (mode === null) return;- void runDesktopUninstallUiPreview(mode).catch((err) => {+ void runDesktopUninstallPreviewMode(mode).catch((err) => {getLogger('lifecycle').error({ err }, 'desktop uninstall UI preview failed');});}+async function runDesktopUninstallPreviewMode(mode: DesktopUninstallUiPreviewMode): Promise<void> {+ if (mode === 'renderer') {+ await openDesktopUninstallRendererWindow({+ screen: { kind: 'notice', notice: desktopUninstallConfirmNotice() },+ onIntent: (intent, win) => {+ getLogger('lifecycle').info(+ { intent: intent.kind },+ 'uninstall UI preview: renderer intent received',+ );+ if (!win.isDestroyed()) win.destroy();+ },+ });+ return;+ }+ if (mode === 'picker') {+ const selection = await showDesktopUninstallProjectPicker(+ desktopUninstallPreviewCandidates(osHomedir()),+ );+ getLogger('lifecycle').info(+ { cancelled: selection === null, selected: selection?.length ?? 0 },+ 'uninstall UI preview: project picker resolved',+ );+ // Echo what main resolved back onto the screen, so walking the picker shows+ // which projects the flow would actually have acted on rather than leaving+ // that to the log.+ await openDesktopUninstallRendererWindow({+ screen: {+ kind: 'notice',+ notice: {+ title: describeDesktopUninstallPreviewSelection(selection),+ paragraphs: selection?.map((candidate) => candidate.path) ?? [],+ confirmLabel: 'Close',+ },+ },+ onIntent: (_intent, win) => {+ if (!win.isDestroyed()) win.destroy();+ },+ });+ return;+ }+ if (mode === 'notice') {+ // The two shapes back to back, so one walkthrough shows both close+ // semantics: leaving the question unanswered must cancel, while leaving the+ // recap unanswered must still confirm.+ const confirmed = await showDesktopUninstallNotice(desktopUninstallConfirmNotice(), {+ height: 280,+ });+ let reveals = 0;+ const acknowledged = await showDesktopUninstallNotice(+ desktopUninstallCompletionNotice({ projectCount: 2 }),+ // Counted rather than revealed: a preview must not open Finder.+ { height: 440, onRevealLog: () => (reveals += 1) },+ );+ getLogger('lifecycle').info(+ { confirmed, acknowledged, reveals },+ 'uninstall UI preview: notices resolved',+ );+ await openDesktopUninstallRendererWindow({+ screen: {+ kind: 'notice',+ notice: {+ title: 'Notice results',+ paragraphs: [+ `confirm=${confirmed ? 'confirmed' : 'cancelled'}`,+ `completion=${acknowledged ? 'confirmed' : 'cancelled'}`,+ `revealLog=${reveals}`,+ ],+ confirmLabel: 'Close',+ },+ },+ onIntent: (_intent, win) => {+ if (!win.isDestroyed()) win.destroy();+ },+ });+ return;+ }+ if (mode === 'survey') {+ const answers = await showDesktopUninstallFeedbackWindow();+ getLogger('lifecycle').info(+ { answered: hasUninstallFeedbackContent(answers) },+ 'uninstall UI preview: churn survey resolved',+ );+ // Nothing is POSTed here — the answers are echoed onto the screen so+ // walking the survey shows exactly what the flow would have filed.+ await openDesktopUninstallRendererWindow({+ screen: {+ kind: 'notice',+ notice: {+ title: describeDesktopUninstallPreviewAnswers(answers),+ paragraphs: [],+ confirmLabel: 'Close',+ },+ },+ onIntent: (_intent, win) => {+ if (!win.isDestroyed()) win.destroy();+ },+ });+ return;+ }+ await runDesktopUninstallUiPreview(mode);+}++function describeDesktopUninstallPreviewSelection(+ selection: readonly DesktopUninstallProjectCandidate[] | null,+): string {+ if (selection === null) return 'Picker cancelled';+ if (selection.length === 0) return 'Picker confirmed with no projects';+ return `Picker confirmed: ${selection.map((candidate) => candidate.path).join(', ')}`;+}++/**+ * The whole answer set on one line. Names each field so the preview proves+ * which one an answer landed in, not just that something came through.+ */+function describeDesktopUninstallPreviewAnswers(answers: UninstallFeedbackAnswers): string {+ if (!hasUninstallFeedbackContent(answers)) return 'Survey continued unanswered';+ return [+ 'Survey answered',+ `reason=${answers.reason ?? '(none)'}`,+ `note=${answers.note ?? '(none)'}`,+ `email=${answers.email ?? '(none)'}`,+ ].join(' | ');+}++/**+ * Stand-in projects for the dev-only previews. These paths are never touched —+ * every preview mode stubs out or stops short of the cleanup step.+ */+function desktopUninstallPreviewCandidates(home: string): DesktopUninstallProjectCandidate[] {+ return [+ { path: `${home}/Notes`, open: true, recent: true, running: true },+ { path: `${home}/Work/Team Handbook`, open: false, recent: true, running: false },+ { path: `${home}/Personal/Journal`, open: false, recent: true, running: false },+ ];+}+/*** Show the feedback survey during a preview without ever reaching production* intake. Submits only when a non-production `OK_FEEDBACK_INTAKE_ORIGIN` is set;@@ -3075,7 +3272,7 @@ async function collectDesktopUninstallFeedbackPreview(): Promise<void> {);}-async function runDesktopUninstallUiPreview(mode: DesktopUninstallUiPreviewMode): Promise<void> {+async function runDesktopUninstallUiPreview(mode: DesktopUninstallFlowPreviewMode): Promise<void> {const log = getLogger('lifecycle');log.warn({ mode },@@ -3083,13 +3280,7 @@ async function runDesktopUninstallUiPreview(mode: DesktopUninstallUiPreviewMode));const home = osHomedir();- // Illustrative candidates so the picker has rows. These paths are never- // touched — the cleanup step below is stubbed out.- const candidates: DesktopUninstallProjectCandidate[] = [- { path: `${home}/Notes`, open: true, recent: true, running: true },- { path: `${home}/Work/Team Handbook`, open: false, recent: true, running: false },- { path: `${home}/Personal/Journal`, open: false, recent: true, running: false },- ];+ const candidates = desktopUninstallPreviewCandidates(home);const confirmation = await confirmDesktopUninstall({candidates,@@ -3724,6 +3915,14 @@ function registerIpcHandlers() {return appState.spellCheckEnabled;});+ // Self-uninstall renderer. The registry answers only senders it registered+ // as live uninstall screens, so an editor window that invokes this channel+ // gets `refused` and drives nothing. `event.sender.id` is the identity —+ // it is observed by main, not supplied by the payload.+ handle('ok:uninstall:dispatch', (event, request) =>+ uninstallScreens.dispatch(event.sender.id, request),+ );+// Per-session membership set for `ok:fs:remove-git-folder`. Populated// by `ok:fs:find-enclosing-git-root` returns; read by the destructive// handler via the `allowedGitRoots` dep on `removeGitFolder`. Scope-diff --git a/packages/desktop/src/main/uninstall-ipc.ts b/packages/desktop/src/main/uninstall-ipc.tsnew file mode 100644index 000000000..78d49b6e8--- /dev/null+++ b/packages/desktop/src/main/uninstall-ipc.ts@@ -0,0 +1,158 @@+/**+ * Main-side service for the uninstall window's `ok:uninstall:dispatch` channel.+ *+ * Kept free of `electron` imports so the whole authorization surface unit-tests+ * in the node tier; `index.ts` owns the `BrowserWindow` and passes its+ * `webContents.id` in.+ *+ * Two guarantees live here:+ *+ * 1. **Sender validation.** Only a webContents main itself registered as a+ * live uninstall screen is answered. Any other sender — an editor window,+ * a stale uninstall window main already finished with — gets `refused` and+ * triggers no side effect.+ * 2. **Payload containment.** `createHandler` casts its args without runtime+ * enforcement, so every inbound request is re-validated here. Unknown+ * shapes are refused; recognized ones are rebuilt field by field, which is+ * what keeps a hostile payload from smuggling extra properties into the+ * flow code that consumes the intent.+ */++import type {+ UninstallDispatchResult,+ UninstallIntent,+ UninstallScreenSpec,+} from '@inkeep/open-knowledge-core';+import { getLogger } from './desktop-logger.ts';+import { normalizeDesktopUninstallFeedbackAnswers } from './desktop-uninstall.ts';++/** One live uninstall window, from `open()` until its disposer runs. */+interface UninstallScreenSession {+ /** What this window renders. Answered to its `ready` request. */+ readonly screen: UninstallScreenSpec;+ /** Called at most once per user action; the flow code decides what settles. */+ readonly onIntent: (intent: UninstallIntent) => void;+}++export interface UninstallScreenRegistry {+ /** Register a window's screen. Returns a disposer that unregisters it. */+ open(webContentsId: number, session: UninstallScreenSession): () => void;+ /** Service one inbound request from `webContentsId`. Never throws. */+ dispatch(webContentsId: number, request: unknown): UninstallDispatchResult;+}++function isRecord(value: unknown): value is Record<string, unknown> {+ return typeof value === 'object' && value !== null;+}++/**+ * Keep only the array members that can index a list. Everything else — strings+ * that look like numbers, floats, negatives, objects — is dropped rather than+ * coerced: a renderer sending `"0"` is not a renderer this code should be+ * guessing the intent of. Negatives are refused here too (defense in depth); the+ * only survivors are non-negative safe integers. Upper-bound out-of-range+ * integers still survive and are discarded downstream, where the candidate list+ * that defines "in range" actually lives.+ */+function normalizeSelectedIndexes(raw: unknown): number[] {+ if (!Array.isArray(raw)) return [];+ return raw.filter(+ (value): value is number =>+ typeof value === 'number' && Number.isSafeInteger(value) && value >= 0,+ );+}++/**+ * Every intent kind this boundary recognizes, as data. Adding a kind to+ * `UninstallIntent` fails to compile here (the `satisfies`) and again at the+ * switch's `default` (the `never`), so a new intent can't be silently dropped.+ */+const RECOGNIZED_UNINSTALL_INTENT_KINDS = {+ 'picker-confirm': true,+ 'picker-cancel': true,+ 'survey-send': true,+ 'survey-skip': true,+ 'notice-confirm': true,+ 'notice-cancel': true,+ 'notice-reveal-log': true,+} satisfies Record<UninstallIntent['kind'], true>;++function isRecognizedUninstallIntentKind(value: unknown): value is UninstallIntent['kind'] {+ return typeof value === 'string' && value in RECOGNIZED_UNINSTALL_INTENT_KINDS;+}++/**+ * Rebuild a recognized intent from an arbitrary payload, or `null` when it is+ * not one. Rebuilding (rather than narrowing in place) is deliberate: the+ * object handed to the flow code contains only fields named here.+ */+export function normalizeUninstallIntent(raw: unknown): UninstallIntent | null {+ if (!isRecord(raw)) return null;+ if (!isRecognizedUninstallIntentKind(raw.kind)) return null;+ switch (raw.kind) {+ case 'picker-confirm':+ return {+ kind: 'picker-confirm',+ selectedIndexes: normalizeSelectedIndexes(raw.selectedIndexes),+ };+ case 'picker-cancel':+ return { kind: 'picker-cancel' };+ case 'survey-send':+ return { kind: 'survey-send', ...normalizeDesktopUninstallFeedbackAnswers(raw) };+ case 'survey-skip':+ return { kind: 'survey-skip' };+ case 'notice-confirm':+ return { kind: 'notice-confirm' };+ case 'notice-cancel':+ return { kind: 'notice-cancel' };+ case 'notice-reveal-log':+ return { kind: 'notice-reveal-log' };+ default: {+ const _exhaustive: never = raw.kind;+ return _exhaustive;+ }+ }+}++export function createUninstallScreenRegistry(): UninstallScreenRegistry {+ const sessions = new Map<number, UninstallScreenSession>();++ return {+ open(webContentsId, session) {+ sessions.set(webContentsId, session);+ return () => {+ if (sessions.get(webContentsId) === session) sessions.delete(webContentsId);+ };+ },++ dispatch(webContentsId, request) {+ const session = sessions.get(webContentsId);+ if (session === undefined) {+ // Straggler: a stale window main already finished with. Expected during+ // teardown, so debug rather than warn.+ getLogger('lifecycle').debug({ webContentsId }, 'uninstall dispatch from unknown window');+ return { kind: 'refused', reason: 'unknown-window' };+ }+ if (isRecord(request) && request.kind === 'ready') {+ return { kind: 'screen', screen: session.screen };+ }+ const intent = normalizeUninstallIntent(request);+ if (intent === null) {+ // A loaded window sending an unrecognized shape — a dev hot-reload /+ // version skew, or a future one-sided contract change. Without this the+ // user clicks a button that does nothing and nothing explains why.+ getLogger('lifecycle').warn(+ // Log the actual payload for a non-record (e.g. `42`, `null`) rather+ // than its typeof, so the entry is diagnosable. The uninstall renderer+ // is first-party (no remote content), so the value is a small refused+ // primitive, not attacker-controlled free-form input.+ { webContentsId, kind: isRecord(request) ? request.kind : request },+ 'uninstall dispatch refused: unrecognized intent',+ );+ return { kind: 'refused', reason: 'invalid-intent' };+ }+ session.onIntent(intent);+ return { kind: 'accepted' };+ },+ };+}diff --git a/packages/desktop/src/main/uninstall-window.ts b/packages/desktop/src/main/uninstall-window.tsnew file mode 100644index 000000000..aa36995a7--- /dev/null+++ b/packages/desktop/src/main/uninstall-window.ts@@ -0,0 +1,129 @@+/**+ * Entry resolution + theme resolution for the React uninstall renderer window+ * (`packages/app/uninstall.html`).+ *+ * Kept free of `electron` imports so the resolution logic is unit-testable in+ * the node tier; `index.ts` owns the `BrowserWindow` construction and passes+ * the process-shaped inputs in.+ */++import { join } from 'node:path';++/** Appearance the uninstall renderer paints its FIRST frame in. */+export type UninstallWindowTheme = 'light' | 'dark';++/**+ * Query key carrying the main-resolved theme to `uninstall.html`. Its inline+ * head script reads this key synchronously and adds the `dark` class before+ * the body parses, so the first painted frame is already correct.+ *+ * The uninstall window is a distinct `file://` document and cannot read the+ * editor renderer's persisted next-themes value, so main is the only party+ * that can answer "which theme". Keep in sync with the reader in+ * `packages/app/uninstall.html` — the contract is covered by+ * `tests/main/uninstall-window-theme-stamp.test.ts`, which executes that+ * script against a URL built from `resolveUninstallEntryTarget`.+ */+const UNINSTALL_THEME_QUERY_KEY = 'theme';++const UNINSTALL_HTML = 'uninstall.html';++/**+ * Where the uninstall renderer is loaded from. `url` is the electron-vite dev+ * server; `file` is a built bundle, whose `query` must be passed through to+ * `loadFile` so it survives into `location.search`.+ */+export type UninstallEntryTarget =+ | { readonly kind: 'url'; readonly url: string }+ | { readonly kind: 'file'; readonly path: string; readonly query: Record<string, string> };++export interface UninstallEntryDeps {+ /** electron-vite dev-server origin (`process.env.ELECTRON_RENDERER_URL`), or null. */+ readonly devServerUrl: string | null;+ /** `app.isPackaged`. */+ readonly isPackaged: boolean;+ /** `process.resourcesPath`. */+ readonly resourcesPath: string;+ /** `__dirname` of the running main bundle (`out/main`). */+ readonly mainDir: string;+}++/**+ * Resolve the uninstall window's theme from main-readable state.+ *+ * `nativeTheme.shouldUseDarkColors` is the right input rather than a raw OS+ * read: the editor renderer pushes the user's chosen theme into main through+ * `ok:theme:set-source`, so this resolves the APP's current appearance — a+ * user running the app in light mode on a dark OS gets a light uninstall+ * window. With no editor window opened this session the source is still+ * `'system'` and the value degrades to the OS preference, which is the+ * closest answer available: `themeSource` is deliberately not persisted (see+ * `theme-handler.ts`), so no other main-readable record of the app's theme+ * exists.+ */+export function resolveUninstallWindowTheme(shouldUseDarkColors: boolean): UninstallWindowTheme {+ return shouldUseDarkColors ? 'dark' : 'light';+}++/**+ * Whether closing the OS window on a notice CONFIRMS it (vs cancels).+ *+ * A one-button notice is an acknowledgement (`cancelLabel` absent) with no+ * "cancel" answer, so closing it proceeds; a two-button notice is a question+ * (`cancelLabel` present) whose safe answer is cancel, so a close cancels. This+ * gate is irreversible on the destructive confirm screen — a stray ⌘W or+ * window-manager close must not uninstall — so it lives here as a pure,+ * always-on-tested helper rather than only inline in the window closure, where+ * an inversion (`!== undefined`) would compile clean and ship green, reachable+ * only by the opt-in `OK_DESKTOP_E2E_SMOKE` E2E.+ */+export function noticeCloseIsConfirm(spec: { readonly cancelLabel?: string }): boolean {+ return spec.cancelLabel === undefined;+}++/**+ * Resolve where to load `uninstall.html` from, mirroring the three-way split+ * `index.ts` uses for `index.html`: dev server when electron-vite exports one,+ * `<Resources>/app/` in a packaged build (electron-builder copies+ * `packages/cli/dist/public/` there), and `out/renderer/` when running the+ * unpackaged build directly with no dev server.+ */+export function resolveUninstallEntryTarget(+ deps: UninstallEntryDeps,+ theme: UninstallWindowTheme,+): UninstallEntryTarget {+ if (deps.devServerUrl !== null && deps.devServerUrl !== '') {+ const origin = deps.devServerUrl.replace(/\/+$/, '');+ return {+ kind: 'url',+ url: `${origin}/${UNINSTALL_HTML}?${UNINSTALL_THEME_QUERY_KEY}=${theme}`,+ };+ }+ return {+ kind: 'file',+ path: deps.isPackaged+ ? join(deps.resourcesPath, 'app', UNINSTALL_HTML)+ : join(deps.mainDir, '..', 'renderer', UNINSTALL_HTML),+ query: { [UNINSTALL_THEME_QUERY_KEY]: theme },+ };+}++/** The `BrowserWindow` load surface, narrowed to what entry loading needs. */+export interface UninstallEntryLoaderLike {+ loadURL(url: string): Promise<void>;+ loadFile(filePath: string, options?: { query?: Record<string, string> }): Promise<void>;+}++/**+ * Load a resolved entry target. `loadFile` (not `loadURL` over a hand-built+ * `file://` string) is what keeps the packaged path working: it resolves the+ * path per-platform and encodes the query for us.+ */+export function loadUninstallEntry(+ loader: UninstallEntryLoaderLike,+ target: UninstallEntryTarget,+): Promise<void> {+ return target.kind === 'url'+ ? loader.loadURL(target.url)+ : loader.loadFile(target.path, { query: target.query });+}diff --git a/packages/desktop/src/preload/index.ts b/packages/desktop/src/preload/index.tsindex 504dbdbce..064182a53 100644--- a/packages/desktop/src/preload/index.ts+++ b/packages/desktop/src/preload/index.ts@@ -65,6 +65,8 @@ import type {} from '../shared/ipc-channels.ts';import { createInvoker } from '../shared/ipc-invoke.ts';import { resolveOkDesktopMode } from '../shared/ok-desktop-mode.ts';+import { isUninstallPreload } from '../shared/uninstall-preload-arg.ts';+import { createUninstallBridge } from './uninstall.ts';const invoke = createInvoker(ipcRenderer);@@ -842,4 +844,13 @@ if (parseArg('debug-keyring-smoke') === '1') {};}-contextBridge.exposeInMainWorld('okDesktop', bridge);+// The self-uninstall window gets `okUninstall` INSTEAD of `okDesktop`: it has+// no business reaching the editor's ~90-channel surface, and the cheapest way+// to guarantee it cannot is to never put that object on its window. One bundle+// serves both because a sandboxed preload must be a single self-contained file+// — see `./uninstall.ts`.+if (isUninstallPreload(process.argv)) {+ contextBridge.exposeInMainWorld('okUninstall', createUninstallBridge(invoke));+} else {+ contextBridge.exposeInMainWorld('okDesktop', bridge);+}diff --git a/packages/desktop/src/preload/uninstall.ts b/packages/desktop/src/preload/uninstall.tsnew file mode 100644index 000000000..a1859c3cd--- /dev/null+++ b/packages/desktop/src/preload/uninstall.ts@@ -0,0 +1,33 @@+/**+ * The self-uninstall window's half of the preload — `window.okUninstall`.+ *+ * Ships inside `preload/index.ts`'s bundle rather than as its own preload+ * entry: a sandboxed preload's `require` is a polyfill over an allowlist of+ * module names and cannot resolve a relative path, so a preload must be one+ * self-contained file, and a second rollup entry splits the module the two+ * would share into a chunk that neither can then load (see the preload block+ * in `electron.vite.config.ts`). Sharing the bundle costs nothing the renderer+ * can observe: `contextIsolation` keeps the preload's own scope unreachable+ * from the page, and `index.ts` exposes `okUninstall` INSTEAD of `okDesktop`+ * for this window — so the editor's ~90-channel bridge is genuinely absent+ * from the uninstall renderer's world.+ *+ * Main tags the window through `additionalArguments`; the flag and its reader+ * live in `shared/uninstall-preload-arg.ts`.+ */++import type {+ OkUninstallBridge,+ UninstallDispatchResult,+ UninstallIntent,+} from '@inkeep/open-knowledge-core';+import type { IpcInvoker } from '../shared/ipc-invoke.ts';++export function createUninstallBridge(invoke: IpcInvoker): OkUninstallBridge {+ return {+ ready: (): Promise<UninstallDispatchResult> =>+ invoke('ok:uninstall:dispatch', { kind: 'ready' }),+ send: (intent: UninstallIntent): Promise<UninstallDispatchResult> =>+ invoke('ok:uninstall:dispatch', intent),+ };+}diff --git a/packages/desktop/src/shared/ipc-channels.ts b/packages/desktop/src/shared/ipc-channels.tsindex 62b6c51f4..702865420 100644--- a/packages/desktop/src/shared/ipc-channels.ts+++ b/packages/desktop/src/shared/ipc-channels.ts@@ -30,7 +30,7 @@* existing channels is preferred over net-new hand-rolled channels until* that migration lands.*- * Count is 86 (ratchet cap 86). The 74→75 bump reconciled a merge collision:+ * Count is 89 (ratchet cap 89). The 74→75 bump reconciled a merge collision:* the worktree selector (`ok:worktree:dispatch`) and the terminal-controls PR* (`ok:terminal:cli-installed-map`) each landed in the base tree's single free* slot concurrently. The 75→76 bump then unioned in the desktop@@ -60,7 +60,11 @@* (`ok:terminal:set-dock-state`). The 87→88 bump reconciled the Windows/Linux* desktop port: the win/linux renderer menubar (`ok:menu:dispatch`, a* discriminated fold per the sharing-dispatch precedent — the custom-drawn menu- * bar's whole surface in one slot). Full rationale in the ratchet test header.+ * bar's whole surface in one slot). The 88→89 bump added the React self-uninstall+ * window (`ok:uninstall:dispatch`), the last renderer→main surface that still+ * rode a private URL scheme through `will-navigate`; folding all four screens+ * plus the screen pull into one slot keeps the whole migration at one channel.+ * Full rationale in the ratchet test header.*/import type {@@ -76,6 +80,8 @@ import type {OkFolderState,ShareTargetStatusResponse,TerminalCli,+ UninstallDispatchRequest,+ UninstallDispatchResult,WorktreeCreateRequest,WorktreeCreateResult,WorktreeListResult,@@ -1553,6 +1559,23 @@ export interface RequestChannels {result: MenuRendererSnapshot | undefined;};+ /**+ * The whole self-uninstall renderer surface in one discriminated channel+ * (the `ok:sharing:dispatch` precedent): `{kind:'ready'}` pulls the screen+ * main opened this window for, every other kind reports a user action.+ *+ * Serviced by `main/uninstall-ipc.ts`, which refuses any sender that is not+ * a live uninstall window. Intents are path-free by construction — the+ * picker answers with indexes into the list main sent — so deletion+ * authorization, target derivation and the `/Applications` + realpath guards+ * stay wholly in main. Contract types live in core so the app package's+ * uninstall entry compiles against the same declaration.+ */+ 'ok:uninstall:dispatch': {+ args: [request: UninstallDispatchRequest];+ result: UninstallDispatchResult;+ };+/*** Docked-terminal PTY surface (`ok:pty:*`). The renderer creates one PTY* per window; main mediates to a window-bound utilityProcess hostingdiff --git a/packages/desktop/src/shared/ipc-invoke.ts b/packages/desktop/src/shared/ipc-invoke.tsindex cb00a9b10..d0a85c6a8 100644--- a/packages/desktop/src/shared/ipc-invoke.ts+++ b/packages/desktop/src/shared/ipc-invoke.ts@@ -29,3 +29,6 @@ export function createInvoker(ipc: IpcRenderer) {...args: RequestChannels[K]['args']): Promise<RequestChannels[K]['result']> => ipc.invoke(channel, ...args);}++/** The bound invoker, for preload helpers that take it as a parameter. */+export type IpcInvoker = ReturnType<typeof createInvoker>;diff --git a/packages/desktop/src/shared/uninstall-preload-arg.ts b/packages/desktop/src/shared/uninstall-preload-arg.tsnew file mode 100644index 000000000..6818393c0--- /dev/null+++ b/packages/desktop/src/shared/uninstall-preload-arg.ts@@ -0,0 +1,15 @@+/**+ * The argv flag main sets on the self-uninstall window so the preload knows to+ * expose `okUninstall` instead of the editor's `okDesktop` bridge.+ *+ * Lives in `shared/` because it is a main↔preload contract with both halves in+ * this package: main passes it through `webPreferences.additionalArguments`,+ * preload reads it off `process.argv`. Same `--ok-*` convention as the editor+ * windows' bound config.+ */++export const UNINSTALL_PRELOAD_ARG = '--ok-uninstall=1';++export function isUninstallPreload(argv: readonly string[]): boolean {+ return argv.includes(UNINSTALL_PRELOAD_ARG);+}diff --git a/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts b/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.tsindex 144b90e66..881c698af 100644--- a/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts+++ b/packages/desktop/tests/integration/ipc-channel-count-ratchet.test.ts@@ -15,9 +15,9 @@* the cap moves with intentional changes to the cap constant, not with* incidental channel additions.*- * Mirrors `no-loosely-typed-webcontents-ipc.test.ts`'s shape — a Bun test- * with grep-walk over the source. Same enforcement guarantee, same `bun- * run check` gating.+ * Mirrors `no-loosely-typed-webcontents-ipc.test.ts`'s shape — a Vitest test+ * with grep-walk over the source. Same enforcement guarantee, same `pnpm+ * check` gating.*/import { readFileSync } from 'node:fs';@@ -362,8 +362,21 @@ const CHANNELS_SRC = readFileSync(SRC_PATH, 'utf-8');* push, wrong direction) and no renderer→main menu surface exists. The typed-ipc* migration remains the committed end state, with the `ipc-channels.ts` header* updated in lock-step.+ *+ * Bumped from 88 to 89 for the React self-uninstall window+ * (`ok:uninstall:dispatch`). The uninstall screens were the last renderer→main+ * surface still riding a private `ok-desktop-uninstall://` URL scheme+ * intercepted by `will-navigate`; moving them onto real IPC retires that+ * channel. Follows the `ok:sharing:dispatch` discriminated-union precedent —+ * the screen pull plus every intent from all four screens (picker, survey,+ * progress, notices) share ONE slot, so porting the remaining screens costs no+ * further channels. Could not fold into an existing channel: no renderer→main+ * uninstall surface existed, and the sender-validation rule (only a live+ * uninstall window is answered) is specific to this surface. The typed-ipc+ * migration remains the committed end state, with the `ipc-channels.ts` header+ * updated in lock-step.*/-const REQUEST_CHANNEL_CAP = 88;+const REQUEST_CHANNEL_CAP = 89;/*** Extract the body of an interface block by name. Returns the substringdiff --git a/packages/desktop/tests/integration/no-uninstall-forbidden-import.test.ts b/packages/desktop/tests/integration/no-uninstall-forbidden-import.test.tsnew file mode 100644index 000000000..6e1584923--- /dev/null+++ b/packages/desktop/tests/integration/no-uninstall-forbidden-import.test.ts@@ -0,0 +1,80 @@+/**+ * "Connects to nothing" first-hop feedback — `no-uninstall-forbidden-import`+ * GritQL plugin.+ *+ * Plugin: `biome-plugins/no-uninstall-forbidden-import.grit`+ * Fixture: `biome-plugins/__fixtures__/no-uninstall-forbidden-import.fixture.tsx`+ *+ * The fixture pairs 13 positive cases (12 forbidden static imports — one per+ * denylisted specifier across every import shape — plus one dynamic import) with+ * negative cases (the allowed core package, shadcn primitives, plain+ * markdown-render prosemirror/@tiptap, and `yjs-not-real` which must not+ * prefix-match `yjs`). The test asserts the plugin fires exactly 13 times.+ *+ * Exact equality (`toBe(13)`) catches drift in both directions:+ * - false-negative: a weakened pattern drops below 13 → fails+ * - false-positive: a widened pattern fires on a negative case → above 13 → fails+ *+ * This GritQL rule is only shallow first-hop feedback; the authoritative+ * "connects to nothing" gate is the transitive-module-graph test at+ * `tests/unit/uninstall-module-graph.test.ts`.+ */++import { spawnSync } from 'node:child_process';+import { join } from 'node:path';+import { describe, expect, test } from 'vitest';+import { readBiomeConfig } from '../../../../test-support/read-biome-config.test-helper.ts';++// __dirname → packages/desktop/tests/integration/. Repo root is 4 levels up.+const REPO_ROOT = join(__dirname, '..', '..', '..', '..');+const FIXTURE_REL = 'biome-plugins/__fixtures__/no-uninstall-forbidden-import.fixture.tsx';+const PLUGIN_REL = './biome-plugins/no-uninstall-forbidden-import.grit';++describe('no-uninstall-forbidden-import GritQL plugin', () => {+ test('fires on exactly 13 cases (12 forbidden imports + 1 dynamic import), and on no negative case', () => {+ const result = spawnSync('pnpm', ['exec', 'biome', 'check', FIXTURE_REL], {+ cwd: REPO_ROOT,+ encoding: 'utf-8',+ });+ expect(result.status).not.toBe(0);+ const output = `${result.stdout}\n${result.stderr}`;++ // Every diagnostic from this rule ends with the docs anchor; counting it+ // covers both message variants (forbidden import + dynamic import).+ const fires = (output.match(/no-uninstall-forbidden-importgrit/g) ?? []).length;+ expect(fires).toBe(13);+ const forbidden = (output.match(/Forbidden module in the uninstall entry/g) ?? []).length;+ const dynamic = (output.match(/Dynamic import under src\/uninstall/g) ?? []).length;+ expect(forbidden).toBe(12);+ expect(dynamic).toBe(1);++ // Each message names the fix (action verb-phrase substring) and links the docs.+ expect(output).toContain('must connect to nothing');+ expect(output).toContain('eager-load');+ expect(output).toMatch(/https?:\/\/[^\s]+/);+ expect(output).toContain('biome-plugins/README.md#no-uninstall-forbidden-importgrit');+ });++ test('is registered in biome.jsonc via overrides scoped to src/uninstall (not root plugins)', () => {+ const config = readBiomeConfig(REPO_ROOT);++ const rootPlugins = config.plugins ?? [];+ expect(rootPlugins).not.toContain(PLUGIN_REL);++ const overrides = config.overrides ?? [];+ const matchingOverride = overrides.find((entry) => (entry.plugins ?? []).includes(PLUGIN_REL));+ expect(matchingOverride).toBeDefined();++ const includes = matchingOverride?.includes ?? [];+ // Positive scope: the shipped uninstall entry source.+ expect(includes).toContain('packages/app/src/uninstall/**/*.ts');+ expect(includes).toContain('packages/app/src/uninstall/**/*.tsx');+ // Negative scope: test files are exempt — a dom test legitimately does+ // `await import('./main')` to prove the entry paints.+ expect(includes).toContain('!packages/app/src/uninstall/**/*.test.ts');+ expect(includes).toContain('!packages/app/src/uninstall/**/*.test.tsx');+ expect(includes).toContain('!packages/app/src/uninstall/**/*.dom.test.tsx');+ // Fixture self-include so this test's positive cases still trigger.+ expect(includes).toContain(FIXTURE_REL);+ });+});diff --git a/packages/desktop/tests/main/desktop-uninstall-feedback.test.ts b/packages/desktop/tests/main/desktop-uninstall-feedback.test.tsindex 49bb12d59..b5b30c4c4 100644--- a/packages/desktop/tests/main/desktop-uninstall-feedback.test.ts+++ b/packages/desktop/tests/main/desktop-uninstall-feedback.test.ts@@ -1,191 +1,15 @@-import {- hasUninstallFeedbackContent,- UNINSTALL_FEEDBACK_REASONS,- type UninstallFeedbackAnswers,- type UninstallFeedbackResult,+import type {+ UninstallFeedbackAnswers,+ UninstallFeedbackResult,} from '@inkeep/open-knowledge-core';import { describe, expect, test, vi } from 'vitest';import {- buildDesktopUninstallFeedbackHtml,confirmDesktopUninstall,type DesktopUninstallProjectCandidate,- parseDesktopUninstallFeedbackUrl,runDesktopUninstallFeedbackStep,runDesktopUninstallOutcomeStep,} from '../../src/main/desktop-uninstall.ts';-const html = buildDesktopUninstallFeedbackHtml();--describe('desktop uninstall feedback window', () => {- test('offers every shared reason as one single-select radio group', () => {- for (const reason of UNINSTALL_FEEDBACK_REASONS) {- expect(html).toContain(`<input type="radio" name="reason" value="${reason.value}"`);- }- const radios = html.match(/<input type="radio"/g) ?? [];- expect(radios).toHaveLength(UNINSTALL_FEEDBACK_REASONS.length);- // One shared `name` is what makes the group single-select.- const groupNames = new Set(- [...html.matchAll(/<input type="radio" name="([^"]+)"/g)].map((match) => match[1]),- );- expect(groupNames).toEqual(new Set(['reason']));- });-- test('renders the reason labels in taxonomy order, HTML-escaped', () => {- const positions = UNINSTALL_FEEDBACK_REASONS.map((reason) =>- html.indexOf(`value="${reason.value}"`),- );- expect(positions.every((position) => position >= 0)).toBe(true);- expect([...positions].sort((a, b) => a - b)).toEqual(positions);- expect(html).toContain('It didn't fit into my workflow');- expect(html).toContain('Bugs, crashes, or it felt unreliable');- });-- test('pre-selects no reason so an untouched form stays empty', () => {- expect(html).not.toMatch(/<input type="radio"[^>]*\schecked/);- });-- test('offers an optional note and an email field revealed by an opt-in', () => {- expect(html).toContain('<textarea');- expect(html).toContain('id="note"');- expect(html).toContain('id="email-optin"');- expect(html).toContain('type="email"');- // A real label plus a format-example placeholder (parity with the in-app- // feedback form's example, without falling back to placeholder-as-label).- expect(html).toContain('for="email"');- expect(html).toMatch(/id="email"[^>]*placeholder="you@company\.com"/);- // Hidden AND disabled until opted in: a hidden-but-validatable email input- // makes the browser refuse to submit rather than reveal the field.- expect(html).toMatch(/id="email-field"[^>]*\shidden/);- expect(html).toMatch(/id="email"[^>]*\sdisabled/);- });-- test('offers a skip and a send action, neither styled as the destructive button', () => {- expect(html).toContain('>Skip<');- expect(html).toContain('Send & continue');- expect(html).toContain('class="primary"');- // `.danger` / the destructive red belong to the confirm screen that already ran.- expect(html).not.toContain('danger');- expect(html).not.toContain('#d70015');- });-- test('states the data-egress disclosure under the heading, matching the CLI', () => {- // The survey collects an optional note + email, so it names where that goes.- // Wording is kept in parity with the CLI survey's disclosure line.- expect(html).toContain('What you share is sent to the OpenKnowledge team.');- expect(html).toContain('id="egress"');- // The "content is kept" reassurance lives on the completion screen, not here.- expect(html).not.toContain('markdown content');- // Shares the one type scale with the sibling windows (from the base CSS).- expect(html).toContain('font: 14px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;');- });-- test('cannot be light-dismissed by Escape or a backdrop', () => {- expect(html).not.toContain('keydown');- expect(html).not.toContain('Escape');- expect(html).not.toContain('backdrop');- expect(html).not.toContain('window.close');- });-- // `form-action` and `base-uri` do not fall back to `default-src`, so the only- // page here holding an email address states them, rather than resting the- // containment entirely on the inline script's preventDefault.- test('bounds form submission and base URI in the policy, not just the script', () => {- expect(html).toContain(- `content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; form-action 'none'; base-uri 'none';"`,- );- });-- test('opens focused on the exit that sends nothing, like its sibling windows', () => {- expect(html).toContain('<button id="skip" type="button" autofocus>');- });-- test('describes the dialog by its heading and the egress disclosure', () => {- expect(html).toContain('aria-labelledby="title"');- expect(html).toContain('aria-describedby="egress"');- });-- test('matches the sibling uninstall windows native-dialog vocabulary', () => {- expect(html).toContain(':root { color-scheme: light dark; }');- expect(html).toContain('font: 14px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;');- expect(html).toContain('color: CanvasText;');- expect(html).toContain('background: Canvas;');- expect(html).toContain(- 'button:focus-visible { outline: 3px solid Highlight; outline-offset: 2px; }',- );- });-- test('routes both actions through the intercepted private navigation scheme', () => {- expect(html).toContain("'ok-desktop-uninstall://'");- expect(html).toContain("finish('feedback-skip'");- expect(html).toContain("finish('feedback-send'");- });-});--describe('desktop uninstall feedback result channel', () => {- test('reads a full submission back off the URL', () => {- expect(- parseDesktopUninstallFeedbackUrl(- 'ok-desktop-uninstall://feedback-send?reason=missing-feature¬e=No%20outline%20view&email=leaver%40example.com',- ),- ).toEqual({- reason: 'missing-feature',- note: 'No outline view',- email: '[email protected]',- });- });-- test('round-trips note text containing URL and HTML metacharacters', () => {- const note = 'a=1 & b=2 <script> "quoted" — 👋\nsecond line';- const parsed = parseDesktopUninstallFeedbackUrl(- `ok-desktop-uninstall://feedback-send?note=${encodeURIComponent(note)}`,- );- expect(parsed).toEqual({ note });- });-- test('reads a skip as an empty, unpostable answer set', () => {- const parsed = parseDesktopUninstallFeedbackUrl('ok-desktop-uninstall://feedback-skip');- expect(parsed).toEqual({});- expect(parsed && hasUninstallFeedbackContent(parsed)).toBe(false);- });-- test('reads a send with nothing filled in as equally unpostable', () => {- const parsed = parseDesktopUninstallFeedbackUrl(- 'ok-desktop-uninstall://feedback-send?note=%20%20&email=',- );- expect(parsed).toEqual({});- expect(parsed && hasUninstallFeedbackContent(parsed)).toBe(false);- });-- test('keeps the rest of the submission when the reason slug is not in the taxonomy', () => {- expect(- parseDesktopUninstallFeedbackUrl(- 'ok-desktop-uninstall://feedback-send?reason=too-expensive¬e=cost',- ),- ).toEqual({ note: 'cost' });- });-- test('clamps oversized answers to the intake field limits', () => {- const parsed = parseDesktopUninstallFeedbackUrl(- `ok-desktop-uninstall://feedback-send?note=${'n'.repeat(12_000)}&email=${'e'.repeat(400)}`,- );- expect(parsed?.note).toHaveLength(10_000);- expect(parsed?.email).toHaveLength(320);- });-- test('ignores every URL that is not a feedback result', () => {- for (const url of [- 'ok-desktop-uninstall://confirm?indexes=0,1',- 'ok-desktop-uninstall://cancel',- 'ok-desktop-uninstall://notice-confirm',- 'https://openknowledge.ai/feedback-send',- 'data:text/html,<p>hi</p>',- 'not a url',- ]) {- expect(parseDesktopUninstallFeedbackUrl(url)).toBeNull();- }- });-});-/** Let every pending microtask run, so an abandoned promise shows up as done. */const settleQueue = () => new Promise((resolve) => setTimeout(resolve, 0));diff --git a/packages/desktop/tests/main/desktop-uninstall.test.ts b/packages/desktop/tests/main/desktop-uninstall.test.tsindex e3c8a83ac..c1090e041 100644--- a/packages/desktop/tests/main/desktop-uninstall.test.ts+++ b/packages/desktop/tests/main/desktop-uninstall.test.ts@@ -2,23 +2,18 @@ import { join } from 'node:path';import { describe, expect, test, vi } from 'vitest';import {buildDesktopUninstallCleanupScript,- buildDesktopUninstallNoticeHtml,- buildDesktopUninstallProgressHtml,- buildDesktopUninstallProjectPickerHtml,collectDesktopUninstallProjectCandidates,defaultDesktopUninstallLogPath,desktopUninstallCompletionNotice,desktopUninstallConfirmNotice,desktopUninstallFailureNotice,desktopUninstallFinalStepNotice,- formatDesktopUninstallProjectList,isSupportedApplicationsBundle,- parseDesktopUninstallNoticeUrl,- parseDesktopUninstallProjectPickerUrl,readDesktopUninstallLogForDisplay,resolveAppBundleFromExecPath,- resolveDesktopUninstallProjectSelection,+ resolveDesktopUninstallUiPreviewMode,runDesktopUninstallCleanup,+ selectDesktopUninstallProjectsByIndex,} from '../../src/main/desktop-uninstall.ts';describe('desktop self-uninstall helpers', () => {@@ -69,79 +64,40 @@ describe('desktop self-uninstall helpers', () => {]);});- test('formats a bounded candidate list with source tags', () => {- const formatted = formatDesktopUninstallProjectList(- [- { path: '/work/a', open: true, recent: false, running: true },- { path: '/work/b', open: false, recent: true, running: false },- ],- 1,- );- expect(formatted).toBe('• /work/a (open, running)\n• …and 1 more');- });-- test('builds a scrollable project picker with every candidate and bulk controls', () => {- const html = buildDesktopUninstallProjectPickerHtml([- { path: '/work/a', open: true, recent: false, running: true },- { path: '/work/<unsafe>&b', open: false, recent: true, running: false },- ]);-- expect(html).toContain('Select all');- expect(html).toContain('Select none');- expect(html).toContain('ok-desktop-uninstall://');- expect(html).toContain('overflow-y: scroll');- expect(html).toContain('Scrollable list — review all 2 projects');- expect(html).toContain('/work/a');- expect(html).toContain('/work/<unsafe>&b');- expect(html).not.toContain('…and');- // The drag-to-Trash instruction belongs to the post-cleanup dialog only.- expect(html).not.toContain('Trash');- });-- test('builds a progress page with a loading indicator', () => {- const html = buildDesktopUninstallProgressHtml();- expect(html).toContain('Removing OpenKnowledge files…');- expect(html).toContain('class="spinner"');- expect(html).toContain('role="status"');- });-- test('parses the private picker navigation URL into selected indexes', () => {- expect(- parseDesktopUninstallProjectPickerUrl('ok-desktop-uninstall://confirm?indexes=2%2C0%2Cbad'),- ).toEqual({ action: 'confirm', selectedIndexes: [2, 0] });- // Empty selection — the default, most common confirm (global-only uninstall).- expect(- parseDesktopUninstallProjectPickerUrl('ok-desktop-uninstall://confirm?indexes='),- ).toEqual({ action: 'confirm', selectedIndexes: [] });- expect(parseDesktopUninstallProjectPickerUrl('ok-desktop-uninstall://cancel')).toEqual({- action: 'cancel',- });- expect(- parseDesktopUninstallProjectPickerUrl('https://example.test/confirm?indexes=0'),- ).toBeNull();- });-- test('resolves project picker output by candidate index only', () => {+ test('resolves a picker intent to candidates the renderer could not have widened', () => {const candidates = [{ path: '/work/a', open: true, recent: false, running: false },{ path: '/work/b', open: false, recent: true, running: false },{ path: '/work/c', open: false, recent: false, running: true },];+ expect(selectDesktopUninstallProjectsByIndex(candidates, [1])).toEqual([candidates[1]]);+ expect(selectDesktopUninstallProjectsByIndex(candidates, [])).toEqual([]);++ // Everything a hostile renderer could try in place of an index: values that+ // reach past the list, values that are not indexes at all, and paths the+ // renderer would like to have deleted. None of it survives.expect(- resolveDesktopUninstallProjectSelection(candidates, {- action: 'confirm',- selectedIndexes: [2, 0, 2, 99, -1, '1'],- selectedPaths: ['/work/b'],- }),- ).toEqual([candidates[0], candidates[2]]);- expect(- resolveDesktopUninstallProjectSelection(candidates, {- action: 'confirm',- selectedIndexes: [],- }),+ selectDesktopUninstallProjectsByIndex(candidates, [+ 3,+ 99,+ -1,+ 1.5,+ Number.NaN,+ '0',+ '/etc/passwd',+ { path: '/etc/passwd' },+ null,+ ]),).toEqual([]);- expect(resolveDesktopUninstallProjectSelection(candidates, { action: 'cancel' })).toBeNull();+ expect(selectDesktopUninstallProjectsByIndex(candidates, '/etc/passwd')).toEqual([]);+ expect(selectDesktopUninstallProjectsByIndex(candidates, undefined)).toEqual([]);++ // Duplicates collapse and order follows main's list, not the renderer's.+ expect(selectDesktopUninstallProjectsByIndex(candidates, [2, 0, 2])).toEqual([+ candidates[0],+ candidates[2],+ ]);});test('builds a cleanup script that deinitializes selected projects before global uninstall', () => {@@ -250,51 +206,6 @@ describe('desktop self-uninstall helpers', () => {expect(desktopUninstallFinalStepNotice().paragraphs.join(' ')).toContain('Trash');});- test('notice html escapes content and finishes through the private scheme', () => {- const html = buildDesktopUninstallNoticeHtml({- title: 'T<itle>',- paragraphs: ['a&b'],- footnote: 'saved <here>',- log: 'line <1>',- confirmLabel: 'Continue',- });- expect(html).toContain('T<itle>');- expect(html).toContain('a&b');- expect(html).toContain('saved <here>');- expect(html).toContain('line <1>');- expect(html).toContain("'ok-desktop-uninstall://notice-' + action");- expect(html).not.toContain('id="cancel"');-- const twoButton = buildDesktopUninstallNoticeHtml(desktopUninstallConfirmNotice());- expect(twoButton).toContain('id="cancel"');- expect(twoButton).toContain('class="danger"');- });-- test('completion notice renders a checklist plus a Finder-reveal log link', () => {- const html = buildDesktopUninstallNoticeHtml(- desktopUninstallCompletionNotice({ projectCount: 1 }),- );- expect(html).toContain('class="checklist"');- expect(html).toContain('Move OpenKnowledge.app to the Trash');- // The log is a subtle link that reveals it, carrying only the action.- expect(html).toContain('class="loglink" href="ok-desktop-uninstall://notice-reveal-log"');- // Completion state is not colour-only: a visually-hidden word carries it too.- expect(html).toContain('Done. ');- expect(html).toContain('To do. ');- // No raw log path leaks into the markup.- expect(html).not.toContain('Library/Logs');- });-- test('parses notice URLs, rejecting foreign schemes and hosts', () => {- expect(parseDesktopUninstallNoticeUrl('ok-desktop-uninstall://notice-confirm')).toBe('confirm');- expect(parseDesktopUninstallNoticeUrl('ok-desktop-uninstall://notice-cancel')).toBe('cancel');- expect(parseDesktopUninstallNoticeUrl('ok-desktop-uninstall://notice-reveal-log')).toBe(- 'reveal-log',- );- expect(parseDesktopUninstallNoticeUrl('ok-desktop-uninstall://confirm?indexes=0')).toBeNull();- expect(parseDesktopUninstallNoticeUrl('https://example.test/notice-confirm')).toBeNull();- });-test('runDesktopUninstallCleanup spawns an attached shell and resolves on close', async () => {const listeners = new Map<string, (...args: unknown[]) => void>();const child = {@@ -362,3 +273,32 @@ describe('desktop self-uninstall helpers', () => {).resolves.toEqual({ ok: false, error: 'shell missing' });});});++describe('resolveDesktopUninstallUiPreviewMode', () => {+ test('always returns null in a packaged build, even for a valid mode', () => {+ // The isPackaged guard is the safety gate that keeps the non-destructive+ // preview scaffolding from ever short-circuiting the real cleanup path in a+ // shipped app. An inversion here would let a packaged build enter preview.+ for (const raw of ['success', 'failure', 'renderer', 'picker', 'survey', 'notice', '1']) {+ expect(resolveDesktopUninstallUiPreviewMode(raw, true)).toBeNull();+ }+ });++ test('maps each recognized env value to its mode in a dev build', () => {+ expect(resolveDesktopUninstallUiPreviewMode('success', false)).toBe('success');+ expect(resolveDesktopUninstallUiPreviewMode('1', false)).toBe('success');+ expect(resolveDesktopUninstallUiPreviewMode('true', false)).toBe('success');+ expect(resolveDesktopUninstallUiPreviewMode('failure', false)).toBe('failure');+ expect(resolveDesktopUninstallUiPreviewMode('fail', false)).toBe('failure');+ expect(resolveDesktopUninstallUiPreviewMode('renderer', false)).toBe('renderer');+ expect(resolveDesktopUninstallUiPreviewMode('picker', false)).toBe('picker');+ expect(resolveDesktopUninstallUiPreviewMode('survey', false)).toBe('survey');+ expect(resolveDesktopUninstallUiPreviewMode('notice', false)).toBe('notice');+ });++ test('returns null for an unset or unrecognized value in a dev build', () => {+ expect(resolveDesktopUninstallUiPreviewMode(undefined, false)).toBeNull();+ expect(resolveDesktopUninstallUiPreviewMode('', false)).toBeNull();+ expect(resolveDesktopUninstallUiPreviewMode('failed', false)).toBeNull();+ });+});diff --git a/packages/desktop/tests/main/uninstall-ipc.test.ts b/packages/desktop/tests/main/uninstall-ipc.test.tsnew file mode 100644index 000000000..105bd8361--- /dev/null+++ b/packages/desktop/tests/main/uninstall-ipc.test.ts@@ -0,0 +1,173 @@+import type { UninstallIntent, UninstallScreenSpec } from '@inkeep/open-knowledge-core';+import { describe, expect, it } from 'vitest';+import {+ createUninstallScreenRegistry,+ normalizeUninstallIntent,+} from '../../src/main/uninstall-ipc.ts';++const NOTICE: UninstallScreenSpec = {+ kind: 'notice',+ notice: { title: 'Uninstall OpenKnowledge?', paragraphs: [], confirmLabel: 'Uninstall' },+};++/** Register one screen and collect whatever intents reach the flow code. */+function openScreen(screen: UninstallScreenSpec = NOTICE) {+ const registry = createUninstallScreenRegistry();+ const received: UninstallIntent[] = [];+ const release = registry.open(7, { screen, onIntent: (intent) => received.push(intent) });+ return { registry, received, release };+}++describe('uninstall screen registry — sender validation', () => {+ it('answers the window it registered with that window’s screen', () => {+ const { registry } = openScreen();+ expect(registry.dispatch(7, { kind: 'ready' })).toEqual({ kind: 'screen', screen: NOTICE });+ });++ it('refuses a window it never opened, and runs nothing for it', () => {+ const { registry, received } = openScreen();++ expect(registry.dispatch(999, { kind: 'ready' })).toEqual({+ kind: 'refused',+ reason: 'unknown-window',+ });+ expect(registry.dispatch(999, { kind: 'notice-confirm' })).toEqual({+ kind: 'refused',+ reason: 'unknown-window',+ });+ expect(received).toEqual([]);+ });++ it('stops answering a window once its screen is released', () => {+ const { registry, received, release } = openScreen();+ release();++ expect(registry.dispatch(7, { kind: 'notice-confirm' })).toEqual({+ kind: 'refused',+ reason: 'unknown-window',+ });+ expect(received).toEqual([]);+ });++ it('keeps each open window on its own screen', () => {+ const registry = createUninstallScreenRegistry();+ const picker: UninstallScreenSpec = { kind: 'picker', projects: [] };+ registry.open(1, { screen: NOTICE, onIntent: () => {} });+ registry.open(2, { screen: picker, onIntent: () => {} });++ expect(registry.dispatch(1, { kind: 'ready' })).toEqual({ kind: 'screen', screen: NOTICE });+ expect(registry.dispatch(2, { kind: 'ready' })).toEqual({ kind: 'screen', screen: picker });+ });+});++describe('uninstall screen registry — intent delivery', () => {+ it('delivers each recognized intent once', () => {+ const { registry, received } = openScreen();++ expect(registry.dispatch(7, { kind: 'picker-cancel' })).toEqual({ kind: 'accepted' });+ expect(registry.dispatch(7, { kind: 'survey-skip' })).toEqual({ kind: 'accepted' });+ expect(registry.dispatch(7, { kind: 'notice-reveal-log' })).toEqual({ kind: 'accepted' });++ expect(received).toEqual([+ { kind: 'picker-cancel' },+ { kind: 'survey-skip' },+ { kind: 'notice-reveal-log' },+ ]);+ });++ it('delivers the two notice intents unswapped', () => {+ // notice-confirm and notice-cancel resolve completion opposite ways, and the+ // window is destroyed either way (no user feedback). A `case 'notice-confirm':+ // return { kind: 'notice-cancel' }` swap is TypeScript-undetectable, so pin+ // that each arrives as itself.+ const { registry, received } = openScreen();++ expect(registry.dispatch(7, { kind: 'notice-confirm' })).toEqual({ kind: 'accepted' });+ expect(registry.dispatch(7, { kind: 'notice-cancel' })).toEqual({ kind: 'accepted' });++ expect(received).toEqual([{ kind: 'notice-confirm' }, { kind: 'notice-cancel' }]);+ });++ it('refuses an unrecognized payload without running the flow', () => {+ const { registry, received } = openScreen();++ for (const payload of [+ { kind: 'delete-everything' },+ { kind: 42 },+ 'notice-confirm',+ null,+ undefined,+ [],+ ]) {+ expect(registry.dispatch(7, payload)).toEqual({ kind: 'refused', reason: 'invalid-intent' });+ }+ expect(received).toEqual([]);+ });+});++describe('normalizeUninstallIntent — payload containment', () => {+ it('keeps only the fields the intent declares, so no path can ride along', () => {+ const intent = normalizeUninstallIntent({+ kind: 'picker-confirm',+ selectedIndexes: [0],+ projectPaths: ['/'],+ appBundlePath: '/tmp/evil.app',+ logPath: '/etc/passwd',+ });++ expect(intent).toEqual({ kind: 'picker-confirm', selectedIndexes: [0] });+ expect(JSON.stringify(intent)).not.toContain('/tmp/evil.app');+ });++ it('drops selection entries that cannot index a list', () => {+ expect(+ normalizeUninstallIntent({+ kind: 'picker-confirm',+ selectedIndexes: ['0', 1.5, Number.NaN, null, { valueOf: () => 3 }, 2],+ }),+ ).toEqual({ kind: 'picker-confirm', selectedIndexes: [2] });+ });++ it('treats a non-array selection as no selection', () => {+ expect(normalizeUninstallIntent({ kind: 'picker-confirm', selectedIndexes: '0,1,2' })).toEqual({+ kind: 'picker-confirm',+ selectedIndexes: [],+ });+ });++ it('trims survey answers, drops blanks, and rejects an off-taxonomy reason', () => {+ expect(+ normalizeUninstallIntent({+ kind: 'survey-send',+ reason: 'not-a-real-reason',+ note: ' it was fine ',+ email: ' ',+ }),+ ).toEqual({ kind: 'survey-send', note: 'it was fine' });+ });++ it('keeps a reason that is in the taxonomy', () => {+ expect(normalizeUninstallIntent({ kind: 'survey-send', reason: 'missing-feature' })).toEqual({+ kind: 'survey-send',+ reason: 'missing-feature',+ });+ });++ it('ignores survey answers that are not strings', () => {+ expect(+ normalizeUninstallIntent({ kind: 'survey-send', note: { toString: () => 'x' }, email: 12 }),+ ).toEqual({ kind: 'survey-send' });+ });++ it('clamps survey answers to the intake’s field limits', () => {+ const intent = normalizeUninstallIntent({+ kind: 'survey-send',+ note: 'n'.repeat(20_000),+ email: `${'e'.repeat(400)}@example.com`,+ });++ expect(intent).toMatchObject({ kind: 'survey-send' });+ expect(intent?.kind === 'survey-send' && intent.note?.length).toBe(10_000);+ expect(intent?.kind === 'survey-send' && intent.email?.length).toBe(320);+ });+});diff --git a/packages/desktop/tests/main/uninstall-window-theme-stamp.test.ts b/packages/desktop/tests/main/uninstall-window-theme-stamp.test.tsnew file mode 100644index 000000000..1f05c4c87--- /dev/null+++ b/packages/desktop/tests/main/uninstall-window-theme-stamp.test.ts@@ -0,0 +1,97 @@+/**+ * Cross-file contract test for the uninstall window's theme stamp.+ *+ * Main resolves the theme and puts it in the entry query+ * (`resolveUninstallEntryTarget`); `packages/app/uninstall.html`'s inline head+ * script reads it back and adds the `dark` class. Nothing in the type system+ * links the two, so this executes the SHIPPED script against a query string+ * built by the SHIPPED producer — renaming the key on either side fails here.+ *+ * The script runs before any bundle loads and cannot be imported, so it is+ * extracted from the entry HTML and evaluated against a minimal DOM stub. The+ * end-to-end version of this assertion (real Electron, real `file://` window)+ * lives in `tests/smoke/uninstall-window-chrome.e2e.ts`.+ */++import { readFileSync } from 'node:fs';+import { dirname, join } from 'node:path';+import { fileURLToPath } from 'node:url';+import { runInNewContext } from 'node:vm';+import { describe, expect, it } from 'vitest';+import { resolveUninstallEntryTarget } from '../../src/main/uninstall-window.ts';++const UNINSTALL_HTML_PATH = join(+ dirname(fileURLToPath(import.meta.url)),+ '../../../app/uninstall.html',+);++const INLINE_SCRIPT_RE = /<script(?![^>]*\bsrc=)[^>]*>([\s\S]*?)<\/script>/g;++function inlineEntryScripts(): string[] {+ const html = readFileSync(UNINSTALL_HTML_PATH, 'utf8');+ return [...html.matchAll(INLINE_SCRIPT_RE)].map((match) => match[1] ?? '');+}++/**+ * Run every inline entry script against a stub document, returning the classes+ * they left on `<html>`. `search` is the `?…` the window was loaded with.+ */+function runEntryScripts(search: string): Set<string> {+ const classes = new Set<string>();+ const sandbox = {+ URLSearchParams,+ location: { search },+ document: {+ documentElement: {+ classList: {+ add: (name: string) => {+ classes.add(name);+ },+ },+ },+ },+ };+ for (const script of inlineEntryScripts()) runInNewContext(script, sandbox);+ return classes;+}++/** The `?…` main would load the window with for a given resolved theme. */+function entrySearchFor(theme: 'light' | 'dark'): string {+ const target = resolveUninstallEntryTarget(+ {+ devServerUrl: null,+ isPackaged: true,+ resourcesPath: '/Applications/OpenKnowledge.app/Contents/Resources',+ mainDir: '/Applications/OpenKnowledge.app/Contents/Resources/app.asar/out/main',+ },+ theme,+ );+ if (target.kind !== 'file') throw new Error('expected the packaged file target');+ return `?${new URLSearchParams(target.query).toString()}`;+}++describe('uninstall.html theme stamp', () => {+ it('has an inline script to run', () => {+ // Guards the extraction itself: an empty match set would make every+ // assertion below vacuously pass.+ expect(inlineEntryScripts().length).toBeGreaterThan(0);+ });++ it('applies dark when main resolved the app to dark', () => {+ expect(runEntryScripts(entrySearchFor('dark')).has('dark')).toBe(true);+ });++ it('stays light when main resolved the app to light', () => {+ expect(runEntryScripts(entrySearchFor('light')).has('dark')).toBe(false);+ });++ it('stays light with no query rather than reading the OS preference', () => {+ // A renderer-side `prefers-color-scheme` fallback would show the OS theme+ // when the user has overridden it in-app — main is the only authority.+ expect(runEntryScripts('').has('dark')).toBe(false);+ });++ it('stays light on an unrecognized value', () => {+ expect(runEntryScripts('?theme=sepia').has('dark')).toBe(false);+ });+});diff --git a/packages/desktop/tests/main/uninstall-window.test.ts b/packages/desktop/tests/main/uninstall-window.test.tsnew file mode 100644index 000000000..ababf1fea--- /dev/null+++ b/packages/desktop/tests/main/uninstall-window.test.ts@@ -0,0 +1,126 @@+import { describe, expect, it } from 'vitest';+import {+ loadUninstallEntry,+ noticeCloseIsConfirm,+ resolveUninstallEntryTarget,+ resolveUninstallWindowTheme,+ type UninstallEntryDeps,+} from '../../src/main/uninstall-window.ts';++const PACKAGED: UninstallEntryDeps = {+ devServerUrl: null,+ isPackaged: true,+ resourcesPath: '/Applications/OpenKnowledge.app/Contents/Resources',+ mainDir: '/Applications/OpenKnowledge.app/Contents/Resources/app.asar/out/main',+};++const UNPACKAGED: UninstallEntryDeps = {+ devServerUrl: null,+ isPackaged: false,+ resourcesPath: '/tmp/unused',+ mainDir: '/repo/packages/desktop/out/main',+};++describe('noticeCloseIsConfirm', () => {+ it('closing a one-button acknowledgement (no cancelLabel) confirms it', () => {+ // Post-teardown completion/failure notices: there is nothing to cancel, so+ // an OS window close proceeds.+ expect(noticeCloseIsConfirm({})).toBe(true);+ expect(noticeCloseIsConfirm({ cancelLabel: undefined })).toBe(true);+ });++ it('closing a two-button question (has cancelLabel) cancels it', () => {+ // The destructive confirm screen: a stray ⌘W / window-manager close must be+ // the SAFE answer, never an uninstall. Guards against a `!== undefined`+ // inversion shipping green (only the opt-in E2E would otherwise catch it).+ expect(noticeCloseIsConfirm({ cancelLabel: 'Cancel' })).toBe(false);+ });+});++describe('resolveUninstallWindowTheme', () => {+ it('follows the theme main already resolved for the app', () => {+ expect(resolveUninstallWindowTheme(true)).toBe('dark');+ expect(resolveUninstallWindowTheme(false)).toBe('light');+ });+});++describe('resolveUninstallEntryTarget', () => {+ it('prefers the electron-vite dev server when one is exported', () => {+ const target = resolveUninstallEntryTarget(+ { ...UNPACKAGED, devServerUrl: 'http://localhost:5173' },+ 'dark',+ );+ expect(target).toEqual({ kind: 'url', url: 'http://localhost:5173/uninstall.html?theme=dark' });+ });++ it('does not double the separator when the dev URL carries a trailing slash', () => {+ const target = resolveUninstallEntryTarget(+ { ...UNPACKAGED, devServerUrl: 'http://localhost:5173/' },+ 'light',+ );+ expect(target).toEqual({+ kind: 'url',+ url: 'http://localhost:5173/uninstall.html?theme=light',+ });+ });++ it('loads from the copied renderer under Resources in a packaged build', () => {+ // electron-builder copies packages/cli/dist/public/ (packages/app's own+ // vite build) to <Resources>/app/ — NOT electron-vite's out/renderer.+ expect(resolveUninstallEntryTarget(PACKAGED, 'dark')).toEqual({+ kind: 'file',+ path: '/Applications/OpenKnowledge.app/Contents/Resources/app/uninstall.html',+ query: { theme: 'dark' },+ });+ });++ it('falls back to out/renderer when running the unpackaged build with no dev server', () => {+ expect(resolveUninstallEntryTarget(UNPACKAGED, 'light')).toEqual({+ kind: 'file',+ path: '/repo/packages/desktop/out/renderer/uninstall.html',+ query: { theme: 'light' },+ });+ });++ it('treats an empty dev URL as absent', () => {+ const target = resolveUninstallEntryTarget({ ...UNPACKAGED, devServerUrl: '' }, 'light');+ expect(target.kind).toBe('file');+ });+});++describe('loadUninstallEntry', () => {+ function recordingLoader() {+ const calls: Array<{ method: 'loadURL' | 'loadFile'; args: unknown[] }> = [];+ return {+ calls,+ loadURL: async (url: string) => {+ calls.push({ method: 'loadURL', args: [url] });+ },+ loadFile: async (path: string, options?: { query?: Record<string, string> }) => {+ calls.push({ method: 'loadFile', args: [path, options] });+ },+ };+ }++ it('navigates the dev server target with loadURL', async () => {+ const loader = recordingLoader();+ await loadUninstallEntry(loader, { kind: 'url', url: 'http://localhost:5173/uninstall.html' });+ expect(loader.calls).toEqual([+ { method: 'loadURL', args: ['http://localhost:5173/uninstall.html'] },+ ]);+ });++ it('passes the theme query through loadFile so it survives into location.search', async () => {+ const loader = recordingLoader();+ await loadUninstallEntry(loader, resolveUninstallEntryTarget(PACKAGED, 'dark'));+ expect(loader.calls).toEqual([+ {+ method: 'loadFile',+ args: [+ '/Applications/OpenKnowledge.app/Contents/Resources/app/uninstall.html',+ { query: { theme: 'dark' } },+ ],+ },+ ]);+ });+});diff --git a/packages/desktop/tests/smoke/uninstall-ipc-bridge.e2e.ts b/packages/desktop/tests/smoke/uninstall-ipc-bridge.e2e.tsnew file mode 100644index 000000000..0bf491934--- /dev/null+++ b/packages/desktop/tests/smoke/uninstall-ipc-bridge.e2e.ts@@ -0,0 +1,117 @@+/**+ * The renderer↔main boundary of the uninstall window, exercised for real:+ * a built preload, a real `contextBridge` world, a real `ipcRenderer.invoke`,+ * and the real handler in main. Unit tests on either side of this seam can+ * both pass while the two never meet — a preload that never loads leaves+ * `window.okUninstall` undefined and every screen renders blank forever.+ *+ * Also pins the least-privilege half of the design: the uninstall window gets+ * its own tiny preload, so the editor's ~90-channel `window.okDesktop` bridge+ * must NOT be reachable from it. The editor window is checked in the same+ * launch so that assertion can't silently pass against a build where no+ * preload loads at all.+ *+ * Skip conditions match the other smokes: `OK_DESKTOP_E2E_SMOKE=1` opt-in,+ * darwin only, and a prior `pnpm run build:desktop`.+ */++import { existsSync, mkdtempSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { _electron as electron, type Page } from '@playwright/test';+import { expect, test } from './_helpers/smoke-test';++const __dirname = dirname(fileURLToPath(import.meta.url));+const MAIN_ENTRY = resolve(__dirname, '..', '..', 'out', 'main', 'index.js');++const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';+const DARWIN = process.platform === 'darwin';+const BUILD_EXISTS = existsSync(MAIN_ENTRY);++/** What main registers for `OK_UNINSTALL_UI_PREVIEW=renderer`. */+const CONFIRM_NOTICE_TITLE = 'Uninstall OpenKnowledge?';++async function findWindowByPath(+ app: import('@playwright/test').ElectronApplication,+ suffix: string,+): Promise<Page> {+ let match: Page | undefined;+ await expect(async () => {+ for (const page of app.windows()) {+ const pathname = await page.evaluate(() => window.location.pathname).catch(() => '');+ if (pathname.endsWith(suffix)) {+ match = page;+ return;+ }+ }+ throw new Error(`no window is at a path ending in ${suffix} yet`);+ }).toPass({ timeout: 20_000 });+ if (!match) throw new Error('unreachable');+ return match;+}++test.describe('uninstall renderer IPC bridge smoke', () => {+ test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');+ test.skip(!DARWIN, 'The uninstall flow is darwin-only.');+ test.skip(!BUILD_EXISTS, `Main build missing at ${MAIN_ENTRY} — run "pnpm run build:desktop".`);++ test('carries main’s screen down and the user’s intent back up', async ({ captureStderrFor }) => {+ const home = mkdtempSync(join(tmpdir(), 'ok-uninstall-ipc-'));++ const app = await electron.launch({+ args: [MAIN_ENTRY, `--user-data-dir=${join(home, 'electron-userdata')}`],+ // `renderer` opens the React uninstall window showing the confirm notice+ // and closes it on the first intent. Nothing is removed; gated on+ // `!app.isPackaged` in main.+ env: { ...process.env, OK_UNINSTALL_UI_PREVIEW: 'renderer' },+ timeout: 30_000,+ });+ captureStderrFor(app, { cleanupDirs: [home] });++ // Both windows are located by path, never by open order: the preview opens+ // the uninstall window alongside the cold-launch Navigator, and which one+ // `firstWindow()` returns is a race.+ await app.firstWindow({ timeout: 20_000 });+ const editorWindow = await findWindowByPath(app, '/index.html');+ const uninstallWindow = await findWindowByPath(app, '/uninstall.html');++ // The exposed surface is two methods and nothing else.+ const exposed = await uninstallWindow.evaluate(() => {+ const bridge = (window as { okUninstall?: object }).okUninstall;+ return bridge === undefined ? null : Object.keys(bridge).sort();+ });+ expect(exposed).toEqual(['ready', 'send']);++ // Least privilege: the editor bridge is not reachable from this window —+ // and the editor window proves the check discriminates.+ expect(await uninstallWindow.evaluate(() => 'okDesktop' in window)).toBe(false);+ expect(await editorWindow.evaluate(() => 'okDesktop' in window)).toBe(true);++ // Main → renderer: `ready` answers with the screen main opened this window+ // for, over the real channel.+ const screen = await uninstallWindow.evaluate(() =>+ (window as unknown as { okUninstall: { ready(): Promise<unknown> } }).okUninstall.ready(),+ );+ expect(screen).toMatchObject({+ kind: 'screen',+ screen: { kind: 'notice', notice: { title: CONFIRM_NOTICE_TITLE } },+ });++ // …and the renderer actually rendered what it was handed.+ await expect(+ uninstallWindow.getByRole('heading', { name: CONFIRM_NOTICE_TITLE }),+ ).toBeVisible();++ // Renderer → main: the intent reaches main, which closes the screen it came+ // from. The window going away IS the proof of receipt; awaiting the invoke+ // inside the page would race that teardown.+ const closed = uninstallWindow.waitForEvent('close', { timeout: 15_000 });+ await uninstallWindow.evaluate(() => {+ void (+ window as unknown as { okUninstall: { send(intent: unknown): Promise<unknown> } }+ ).okUninstall.send({ kind: 'notice-confirm' });+ });+ await closed;+ });+});diff --git a/packages/desktop/tests/smoke/uninstall-notice.e2e.ts b/packages/desktop/tests/smoke/uninstall-notice.e2e.tsnew file mode 100644index 000000000..b695c55af--- /dev/null+++ b/packages/desktop/tests/smoke/uninstall-notice.e2e.ts@@ -0,0 +1,144 @@+/**+ * Both notice shapes as the user meets them: the real bundled React screens in+ * real Electron windows, answered through the real `okUninstall` bridge.+ *+ * The dom tests cover the screen against hand-built callbacks, but only main+ * decides what an unanswered window means, and it decides opposite things for+ * the two shapes — a two-button question cancels, a single-button recap+ * confirms. That asymmetry is load-bearing (getting it backwards either quits+ * the flow early or strands a half-uninstalled app) and it is only observable+ * end to end, so it is asserted here.+ *+ * Skip conditions match the other smokes: `OK_DESKTOP_E2E_SMOKE=1` opt-in,+ * darwin only, and a prior `pnpm run build:desktop`.+ */++import { existsSync, mkdtempSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { _electron as electron, type Page } from '@playwright/test';+import { expect, test } from './_helpers/smoke-test';++const __dirname = dirname(fileURLToPath(import.meta.url));+const MAIN_ENTRY = resolve(__dirname, '..', '..', 'out', 'main', 'index.js');++const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';+const DARWIN = process.platform === 'darwin';+const BUILD_EXISTS = existsSync(MAIN_ENTRY);++const CONFIRM_HEADING = 'Uninstall OpenKnowledge?';+const COMPLETION_HEADING = 'OpenKnowledge files were removed';+const RESULTS_HEADING = 'Notice results';++/**+ * Every screen in this preview lives at the same path, so the heading is what+ * tells them apart — and waiting for it also waits out the window main is in+ * the middle of tearing down.+ */+async function findNoticeWindow(+ app: import('@playwright/test').ElectronApplication,+ heading: string,+): Promise<Page> {+ let match: Page | undefined;+ await expect(async () => {+ for (const page of app.windows()) {+ const pathname = await page.evaluate(() => window.location.pathname).catch(() => '');+ if (!pathname.endsWith('/uninstall.html')) continue;+ const title = await page+ .locator('h1')+ .first()+ .textContent({ timeout: 1_000 })+ .catch(() => null);+ if (title === heading) {+ match = page;+ return;+ }+ }+ throw new Error(`no uninstall window is showing "${heading}" yet`);+ }).toPass({ timeout: 20_000 });+ if (!match) throw new Error('unreachable');+ return match;+}++async function launchNoticePreview(+ prefix: string,+): Promise<{ app: import('@playwright/test').ElectronApplication; home: string }> {+ const home = mkdtempSync(join(tmpdir(), prefix));+ const app = await electron.launch({+ args: [MAIN_ENTRY, `--user-data-dir=${join(home, 'electron-userdata')}`],+ // `notice` shows the confirm question and the completion recap back to+ // back, then reports how main resolved each. Nothing is removed, nothing is+ // revealed in Finder; gated on `!app.isPackaged` in main.+ env: { ...process.env, OK_UNINSTALL_UI_PREVIEW: 'notice' },+ timeout: 30_000,+ });+ return { app, home };+}++test.describe('uninstall notice smoke', () => {+ test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');+ test.skip(!DARWIN, 'The uninstall flow is darwin-only.');+ test.skip(!BUILD_EXISTS, `Main build missing at ${MAIN_ENTRY} — run "pnpm run build:desktop".`);++ test('pressing each notice through carries the answer to main', async ({ captureStderrFor }) => {+ const { app, home } = await launchNoticePreview('ok-uninstall-notice-');+ captureStderrFor(app, { cleanupDirs: [home] });++ await app.firstWindow({ timeout: 20_000 });++ const confirm = await findNoticeWindow(app, CONFIRM_HEADING);+ await expect(+ confirm.getByText('When cleanup finishes, OpenKnowledge will help you remove the app itself'),+ ).toBeVisible();+ let closed = confirm.waitForEvent('close', { timeout: 15_000 });+ await confirm.getByRole('button', { name: 'Uninstall OpenKnowledge' }).click();+ await closed;++ const completion = await findNoticeWindow(app, COMPLETION_HEADING);+ // The recap is the point of this screen: two done items and the one thing+ // still left for the user to do.+ await expect(completion.getByText('Kept your content')).toBeVisible();+ await expect(completion.getByText('Removed OpenKnowledge files')).toBeVisible();+ await expect(completion.getByText('Move OpenKnowledge.app to the Trash')).toBeVisible();+ closed = completion.waitForEvent('close', { timeout: 15_000 });+ await completion.getByRole('button', { name: 'Reveal in Finder' }).click();+ await closed;++ const results = await findNoticeWindow(app, RESULTS_HEADING);+ await expect(results.getByText('confirm=confirmed')).toBeVisible();+ await expect(results.getByText('completion=confirmed')).toBeVisible();+ await expect(results.getByText('revealLog=0')).toBeVisible();+ });++ test('closing an unanswered question cancels, closing a recap confirms', async ({+ captureStderrFor,+ }) => {+ const { app, home } = await launchNoticePreview('ok-uninstall-notice-close-');+ captureStderrFor(app, { cleanupDirs: [home] });++ await app.firstWindow({ timeout: 20_000 });++ // Two buttons, so walking away from it must leave the install alone.+ const confirm = await findNoticeWindow(app, CONFIRM_HEADING);+ let closed = confirm.waitForEvent('close', { timeout: 15_000 });+ await confirm.close();+ await closed;++ const completion = await findNoticeWindow(app, COMPLETION_HEADING);+ // Revealing the log is not an answer — main takes the request and leaves+ // the screen up, or the user would lose the recap by reading the log.+ await completion.getByRole('button', { name: 'Cleanup log' }).click();+ await expect(completion.getByRole('heading', { name: COMPLETION_HEADING })).toBeVisible();++ // One button, so walking away is the only answer there is.+ closed = completion.waitForEvent('close', { timeout: 15_000 });+ await completion.close();+ await closed;++ const results = await findNoticeWindow(app, RESULTS_HEADING);+ await expect(results.getByText('confirm=cancelled')).toBeVisible();+ await expect(results.getByText('completion=confirmed')).toBeVisible();+ await expect(results.getByText('revealLog=1')).toBeVisible();+ });+});diff --git a/packages/desktop/tests/smoke/uninstall-picker.e2e.ts b/packages/desktop/tests/smoke/uninstall-picker.e2e.tsnew file mode 100644index 000000000..16e87c1d3--- /dev/null+++ b/packages/desktop/tests/smoke/uninstall-picker.e2e.ts@@ -0,0 +1,142 @@+/**+ * The project picker as the user meets it: the real bundled React screen in a+ * real Electron window, driven through real Radix controls, over the real+ * `okUninstall` bridge.+ *+ * The dom tests cover the screen's logic against a hand-built props object and+ * the main tests cover index→candidate resolution, but neither proves the two+ * halves meet — that main's candidate list survives the trip down, that the+ * shadcn checkboxes work outside jsdom, and that a confirm reaches main at all.+ *+ * Skip conditions match the other smokes: `OK_DESKTOP_E2E_SMOKE=1` opt-in,+ * darwin only, and a prior `pnpm run build:desktop`.+ */++import { existsSync, mkdtempSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { _electron as electron, type Page } from '@playwright/test';+import { expect, test } from './_helpers/smoke-test';++const __dirname = dirname(fileURLToPath(import.meta.url));+const MAIN_ENTRY = resolve(__dirname, '..', '..', 'out', 'main', 'index.js');++const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';+const DARWIN = process.platform === 'darwin';+const BUILD_EXISTS = existsSync(MAIN_ENTRY);++/** The stand-in projects `OK_UNINSTALL_UI_PREVIEW=picker` offers, home-relative. */+const PREVIEW_PROJECTS = ['/Notes', '/Work/Team Handbook', '/Personal/Journal'];++async function findWindowByPath(+ app: import('@playwright/test').ElectronApplication,+ suffix: string,+): Promise<Page> {+ let match: Page | undefined;+ await expect(async () => {+ for (const page of app.windows()) {+ const pathname = await page.evaluate(() => window.location.pathname).catch(() => '');+ if (pathname.endsWith(suffix)) {+ match = page;+ return;+ }+ }+ throw new Error(`no window is at a path ending in ${suffix} yet`);+ }).toPass({ timeout: 20_000 });+ if (!match) throw new Error('unreachable');+ return match;+}++test.describe('uninstall project picker smoke', () => {+ test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');+ test.skip(!DARWIN, 'The uninstall flow is darwin-only.');+ test.skip(!BUILD_EXISTS, `Main build missing at ${MAIN_ENTRY} — run "pnpm run build:desktop".`);++ test('renders main’s projects and carries a confirmed selection back', async ({+ captureStderrFor,+ }) => {+ const home = mkdtempSync(join(tmpdir(), 'ok-uninstall-picker-'));++ const app = await electron.launch({+ args: [MAIN_ENTRY, `--user-data-dir=${join(home, 'electron-userdata')}`],+ // `picker` opens only the project picker, over stand-in candidates, and+ // resolves without entering the flow. Nothing is removed; gated on+ // `!app.isPackaged` in main.+ env: { ...process.env, OK_UNINSTALL_UI_PREVIEW: 'picker' },+ timeout: 30_000,+ });+ captureStderrFor(app, { cleanupDirs: [home] });++ await app.firstWindow({ timeout: 20_000 });+ const picker = await findWindowByPath(app, '/uninstall.html');++ // Main → renderer: every candidate main collected is on screen, by path,+ // and the header selected-of-total counter starts at none of three.+ await expect(picker.getByRole('heading', { name: 'Uninstall OpenKnowledge?' })).toBeVisible();+ for (const suffix of PREVIEW_PROJECTS) {+ await expect(picker.getByText(suffix, { exact: false })).toBeVisible();+ }+ await expect(picker.getByText('0 / 3', { exact: true })).toBeVisible();++ // The real shadcn checkboxes toggle outside jsdom, and the counter follows.+ // Rows are addressed by their per-project accessible name so the tri-state+ // select-all checkbox in the list header is never mistaken for a row.+ const rowCheckbox = (suffix: string) =>+ picker.getByRole('checkbox', {+ name: new RegExp(`Remove OpenKnowledge from .*${suffix}$`),+ });+ await rowCheckbox('/Notes').click();+ await rowCheckbox('/Personal/Journal').click();+ await expect(picker.getByText('2 / 3', { exact: true })).toBeVisible();++ // The header checkbox is select-all / clear (the two inline buttons folded+ // into one tri-state control): a click from indeterminate selects all, the+ // next clears.+ const selectAll = picker.getByRole('checkbox', { name: 'Select all' });+ await selectAll.click();+ await expect(picker.getByText('3 / 3', { exact: true })).toBeVisible();+ await selectAll.click();+ await expect(picker.getByText('0 / 3', { exact: true })).toBeVisible();++ // Renderer → main: confirming settles the screen in main, which destroys+ // the window and reports back what it resolved the indexes to. That report+ // is the identity proof — main names the project the user actually ticked,+ // not just how many.+ await rowCheckbox('/Work/Team Handbook').click();+ const closed = picker.waitForEvent('close', { timeout: 15_000 });+ await picker.getByRole('button', { name: 'Uninstall OpenKnowledge' }).click();+ await closed;++ const resolved = await findWindowByPath(app, '/uninstall.html');+ const heading = resolved.getByRole('heading');+ await expect(heading).toContainText('Picker confirmed:');+ await expect(heading).toContainText('/Work/Team Handbook');+ await expect(heading).not.toContainText('/Notes');+ await expect(heading).not.toContainText('/Personal/Journal');+ });++ test('closing the picker window cancels rather than proceeding', async ({ captureStderrFor }) => {+ const home = mkdtempSync(join(tmpdir(), 'ok-uninstall-picker-close-'));++ const app = await electron.launch({+ args: [MAIN_ENTRY, `--user-data-dir=${join(home, 'electron-userdata')}`],+ env: { ...process.env, OK_UNINSTALL_UI_PREVIEW: 'picker' },+ timeout: 30_000,+ });+ captureStderrFor(app, { cleanupDirs: [home] });++ await app.firstWindow({ timeout: 20_000 });+ const picker = await findWindowByPath(app, '/uninstall.html');+ await expect(picker.getByRole('heading', { name: 'Uninstall OpenKnowledge?' })).toBeVisible();++ // No button pressed — main has to resolve this as a cancel and must not+ // leave the flow hanging on a window that is already gone.+ const closed = picker.waitForEvent('close', { timeout: 15_000 });+ await picker.close();+ await closed;++ const resolved = await findWindowByPath(app, '/uninstall.html');+ await expect(resolved.getByRole('heading')).toHaveText('Picker cancelled');+ });+});diff --git a/packages/desktop/tests/smoke/uninstall-survey.e2e.ts b/packages/desktop/tests/smoke/uninstall-survey.e2e.tsnew file mode 100644index 000000000..80b8e908e--- /dev/null+++ b/packages/desktop/tests/smoke/uninstall-survey.e2e.ts@@ -0,0 +1,146 @@+/**+ * The churn survey as the user meets it: the real bundled React screen in a+ * real Electron window, driven through real Radix controls, over the real+ * `okUninstall` bridge.+ *+ * The dom tests cover the screen's logic against hand-built callbacks and the+ * main tests cover answer normalization, but neither proves the two halves+ * meet — that a picked reason survives the trip up as its slug, that the Radix+ * radios and the reveal-on-opt-in email field work outside jsdom, and that+ * closing the window continues the uninstall instead of stalling it.+ *+ * Skip conditions match the other smokes: `OK_DESKTOP_E2E_SMOKE=1` opt-in,+ * darwin only, and a prior `pnpm run build:desktop`.+ */++import { existsSync, mkdtempSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { _electron as electron, type Page } from '@playwright/test';+import { expect, test } from './_helpers/smoke-test';++const __dirname = dirname(fileURLToPath(import.meta.url));+const MAIN_ENTRY = resolve(__dirname, '..', '..', 'out', 'main', 'index.js');++const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';+const DARWIN = process.platform === 'darwin';+const BUILD_EXISTS = existsSync(MAIN_ENTRY);++async function findWindowByPath(+ app: import('@playwright/test').ElectronApplication,+ suffix: string,+): Promise<Page> {+ let match: Page | undefined;+ await expect(async () => {+ for (const page of app.windows()) {+ const pathname = await page.evaluate(() => window.location.pathname).catch(() => '');+ if (pathname.endsWith(suffix)) {+ match = page;+ return;+ }+ }+ throw new Error(`no window is at a path ending in ${suffix} yet`);+ }).toPass({ timeout: 20_000 });+ if (!match) throw new Error('unreachable');+ return match;+}++async function launchSurveyPreview(+ prefix: string,+): Promise<{ app: import('@playwright/test').ElectronApplication; home: string }> {+ const home = mkdtempSync(join(tmpdir(), prefix));+ const app = await electron.launch({+ args: [MAIN_ENTRY, `--user-data-dir=${join(home, 'electron-userdata')}`],+ // `survey` opens only the churn survey and echoes what main resolved back+ // onto a notice. Nothing is removed and nothing is POSTed; gated on+ // `!app.isPackaged` in main.+ env: { ...process.env, OK_UNINSTALL_UI_PREVIEW: 'survey' },+ timeout: 30_000,+ });+ return { app, home };+}++test.describe('uninstall churn survey smoke', () => {+ test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');+ test.skip(!DARWIN, 'The uninstall flow is darwin-only.');+ test.skip(!BUILD_EXISTS, `Main build missing at ${MAIN_ENTRY} — run "pnpm run build:desktop".`);++ test('carries a filled-in survey back to main as answers', async ({ captureStderrFor }) => {+ const { app, home } = await launchSurveyPreview('ok-uninstall-survey-');+ captureStderrFor(app, { cleanupDirs: [home] });++ await app.firstWindow({ timeout: 20_000 });+ const survey = await findWindowByPath(app, '/uninstall.html');++ await expect(+ survey.getByRole('heading', { name: 'Thanks for giving OpenKnowledge a try.' }),+ ).toBeVisible();++ // The real Radix radio commits outside jsdom.+ await survey.getByRole('radio', { name: 'Bugs, crashes, or it felt unreliable' }).click();+ await survey.getByLabel("Anything you'd like to add? (optional)").fill('it kept crashing');++ // Opting in is what makes the address usable at all: the field ships+ // disabled so a hidden-but-validatable input cannot silently block submit.+ const email = survey.getByLabel('Email address');+ await expect(email).toBeHidden();+ await survey.getByRole('checkbox', { name: 'Let us follow up by email' }).click();+ await expect(email).toBeEnabled();+ await email.fill('[email protected]');++ // Renderer → main: sending settles the screen in main, which destroys the+ // window and reports back what it resolved. That report is the proof the+ // slug (not the label) made the trip.+ const closed = survey.waitForEvent('close', { timeout: 15_000 });+ await survey.getByRole('button', { name: 'Send & continue' }).click();+ await closed;++ const resolved = await findWindowByPath(app, '/uninstall.html');+ const heading = resolved.getByRole('heading');+ await expect(heading).toContainText('Survey answered');+ await expect(heading).toContainText('reason=unreliable');+ await expect(heading).toContainText('note=it kept crashing');+ await expect(heading).toContainText('[email protected]');+ });++ test('closing the survey window continues rather than cancelling', async ({+ captureStderrFor,+ }) => {+ const { app, home } = await launchSurveyPreview('ok-uninstall-survey-close-');+ captureStderrFor(app, { cleanupDirs: [home] });++ await app.firstWindow({ timeout: 20_000 });+ const survey = await findWindowByPath(app, '/uninstall.html');+ await expect(+ survey.getByRole('heading', { name: 'Thanks for giving OpenKnowledge a try.' }),+ ).toBeVisible();++ // No button pressed. Unlike the picker, this must NOT read as a cancel —+ // the uninstall was already confirmed, so an unanswered question has to+ // let the flow carry on with nothing.+ const closed = survey.waitForEvent('close', { timeout: 15_000 });+ await survey.close();+ await closed;++ const resolved = await findWindowByPath(app, '/uninstall.html');+ await expect(resolved.getByRole('heading')).toHaveText('Survey continued unanswered');+ });++ test('skipping continues with nothing filed', async ({ captureStderrFor }) => {+ const { app, home } = await launchSurveyPreview('ok-uninstall-survey-skip-');+ captureStderrFor(app, { cleanupDirs: [home] });++ await app.firstWindow({ timeout: 20_000 });+ const survey = await findWindowByPath(app, '/uninstall.html');++ // Answered, then skipped: skip discards rather than sending what is on screen.+ await survey.getByRole('radio', { name: 'Something else' }).click();+ const closed = survey.waitForEvent('close', { timeout: 15_000 });+ await survey.getByRole('button', { name: 'Skip' }).click();+ await closed;++ const resolved = await findWindowByPath(app, '/uninstall.html');+ await expect(resolved.getByRole('heading')).toHaveText('Survey continued unanswered');+ });+});diff --git a/packages/desktop/tests/smoke/uninstall-window-chrome.e2e.ts b/packages/desktop/tests/smoke/uninstall-window-chrome.e2e.tsnew file mode 100644index 000000000..5621db0e2--- /dev/null+++ b/packages/desktop/tests/smoke/uninstall-window-chrome.e2e.ts@@ -0,0 +1,130 @@+/**+ * The uninstall renderer's design-fidelity smoke — the assertion the whole+ * dedicated-entry migration exists to make true.+ *+ * The screens it replaces were inline `data:text/html` documents, which have+ * no base URL for a relative `@font-face` and shipped a `default-src 'none'`+ * CSP with no `font-src`; the app's Inter silently fell back to the macOS+ * system font. So the load-bearing assertion here is that the font actually+ * LOADED.+ *+ * Two obvious oracles are both worthless here, and a mutation run proved it:+ * `getComputedStyle().fontFamily` reads "Inter Variable, …" straight off the+ * declared stack whether or not anything loaded, and `document.fonts.check()`+ * answers "can text render without waiting for a download", which is TRUE for+ * an undefined family because the fallback is already available — a build with+ * the entry's font import stripped passed a `check()`-based version of this+ * test. Only the `FontFaceSet` entries discriminate: the family must be+ * REGISTERED (an `@font-face` reached this document) and at least one of its+ * faces must have reached `status === 'loaded'` (the file was really fetched).+ *+ * Design tokens are compared against the editor entry's own window in the same+ * launch rather than against a hardcoded value, so the two entries are proven+ * to resolve the same `globals.css`.+ *+ * Skip conditions match the other smokes: `OK_DESKTOP_E2E_SMOKE=1` opt-in,+ * darwin only, and a prior `pnpm run build:desktop`.+ */++import { existsSync, mkdtempSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { _electron as electron, type Page } from '@playwright/test';+import { expect, test } from './_helpers/smoke-test';++const __dirname = dirname(fileURLToPath(import.meta.url));+const MAIN_ENTRY = resolve(__dirname, '..', '..', 'out', 'main', 'index.js');++const SMOKE_ENABLED = process.env.OK_DESKTOP_E2E_SMOKE === '1';+const DARWIN = process.platform === 'darwin';+const BUILD_EXISTS = existsSync(MAIN_ENTRY);++/** The family `packages/app` loads via `@fontsource-variable/inter`. */+const APP_FONT_FAMILY = 'Inter Variable';++async function findWindowByPath(+ app: import('@playwright/test').ElectronApplication,+ suffix: string,+): Promise<Page> {+ let match: Page | undefined;+ await expect(async () => {+ for (const page of app.windows()) {+ const pathname = await page.evaluate(() => window.location.pathname).catch(() => '');+ if (pathname.endsWith(suffix)) {+ match = page;+ return;+ }+ }+ throw new Error(`no window is at a path ending in ${suffix} yet`);+ }).toPass({ timeout: 20_000 });+ if (!match) throw new Error('unreachable');+ return match;+}++test.describe('uninstall renderer chrome smoke', () => {+ test.skip(!SMOKE_ENABLED, 'Set OK_DESKTOP_E2E_SMOKE=1 to run Electron smoke tests.');+ test.skip(!DARWIN, 'The uninstall flow is darwin-only.');+ test.skip(!BUILD_EXISTS, `Main build missing at ${MAIN_ENTRY} — run "pnpm run build:desktop".`);++ test('loads the app font, the app tokens, and the theme main resolved', async ({+ captureStderrFor,+ }) => {+ const home = mkdtempSync(join(tmpdir(), 'ok-uninstall-chrome-'));++ const app = await electron.launch({+ args: [MAIN_ENTRY, `--user-data-dir=${join(home, 'electron-userdata')}`],+ // `renderer` opens the React uninstall window on its own — no picker, no+ // cleanup, nothing removed. Gated on `!app.isPackaged` in main.+ env: { ...process.env, OK_UNINSTALL_UI_PREVIEW: 'renderer' },+ timeout: 30_000,+ });+ captureStderrFor(app, { cleanupDirs: [home] });++ // Cold launch opens Navigator from `index.html`; the preview opens the+ // uninstall entry alongside it. Both are real `file://` documents off the+ // built bundle. Located by path rather than open order — `firstWindow()`+ // races between the two, and drawing the uninstall window for both halves+ // would make the token comparison below compare a value to itself.+ await app.firstWindow({ timeout: 20_000 });+ const editorWindow = await findWindowByPath(app, '/index.html');+ const uninstallWindow = await findWindowByPath(app, '/uninstall.html');++ // PRIMARY: the font is really loaded, not merely named in the cascade.+ const faceStatuses = await uninstallWindow.evaluate(async (family) => {+ await document.fonts.ready;+ return [...document.fonts]+ .filter((face) => face.family.replace(/["']/g, '') === family)+ .map((face) => face.status);+ }, APP_FONT_FAMILY);+ // Registered at all — an empty list is the "no @font-face reached this+ // document" failure, which is what the inline `data:` windows had.+ expect(faceStatuses.length).toBeGreaterThan(0);+ // Really fetched. Only the subsets whose glyphs are actually used load;+ // the rest stay 'unloaded', so one loaded face is the correct bar. A+ // failed fetch (bad base URL, CSP without font-src) lands on 'error'.+ expect(faceStatuses).toContain('loaded');++ // The window's theme is the one MAIN resolved, not an independent OS read+ // by the renderer. Asserted BEFORE the token comparison below, which is+ // itself theme-sensitive (`--primary` differs between light and dark) and+ // would otherwise absorb a theme regression into a confusing colour diff.+ const mainWantsDark = await app.evaluate(({ nativeTheme }) => nativeTheme.shouldUseDarkColors);+ const rendererIsDark = await uninstallWindow.evaluate(() =>+ document.documentElement.classList.contains('dark'),+ );+ expect(rendererIsDark).toBe(mainWantsDark);++ // The app's design tokens resolve identically in both entries.+ const readPrimary = (page: Page) =>+ page.evaluate(() =>+ getComputedStyle(document.documentElement).getPropertyValue('--primary').trim(),+ );+ const uninstallPrimary = await readPrimary(uninstallWindow);+ expect(uninstallPrimary).not.toBe('');+ expect(uninstallPrimary).toBe(await readPrimary(editorWindow));++ // The entry mounted — a resolved font on a blank page would prove nothing.+ await expect(uninstallWindow.locator('#root')).not.toBeEmpty();+ });+});diff --git a/packages/desktop/tests/support/uninstall-module-graph.test-helper.ts b/packages/desktop/tests/support/uninstall-module-graph.test-helper.tsnew file mode 100644index 000000000..009a2b1fa--- /dev/null+++ b/packages/desktop/tests/support/uninstall-module-graph.test-helper.ts@@ -0,0 +1,200 @@+import { fileURLToPath } from 'node:url';+import babel from '@rolldown/plugin-babel';+import react from '@vitejs/plugin-react';+import { build, type Plugin } from 'vite';+import { RENDERER_DEDUPE } from '../../../app/vite.dedupe';+import { RENDERER_BABEL_OPTIONS } from '../../../app/vite.react-babel';++/**+ * Builds the `uninstall` renderer entry with the real renderer pipeline (React ++ * React Compiler + the Lingui macro pass) and reports its whole transitive+ * module graph, so a test can prove the entry "connects to nothing" — no editor,+ * CRDT, provider-pool or Hocuspocus-server module is reachable.+ *+ * Why the WHOLE graph and not one output chunk: a forbidden module can be reached+ * indirectly through a shared `@/lib` / `@/components/ui` module, and in a+ * multi-entry build a shared vendor chunk can carry code a named chunk excludes.+ * The entry is therefore built ALONE (its own single-entry build), and the check+ * runs over rollup's loaded-module set (`this.getModuleIds()`) rather than any+ * emitted chunk — so every module here is reachable from this entry by+ * construction, and reachability is read before tree-shaking can hide a+ * side-effecting pull-in.+ */++const APP_ROOT = fileURLToPath(new URL('../../../app/', import.meta.url));+const UNINSTALL_ENTRY = fileURLToPath(+ new URL('../../../app/src/uninstall/main.tsx', import.meta.url),+);++/** Absolute-path marker for modules authored under the uninstall entry's source. */+export const UNINSTALL_SOURCE_DIR = fileURLToPath(+ new URL('../../../app/src/uninstall/', import.meta.url),+);++/**+ * Modules the uninstall entry must never reach. Matched against resolved absolute+ * module ids (pnpm stores third-party packages under `.pnpm/<name>@<ver>/node_modules/<name>/`,+ * so the `node_modules/(.pnpm/…/node_modules/)?` prefix covers both the hoisted+ * and content-addressed shapes). `@inkeep/open-knowledge-core` (shared types ++ * constants, no server deps) is deliberately NOT here — importing it is by design.+ */+export const FORBIDDEN_MODULE_PATTERNS: ReadonlyArray<{ category: string; pattern: RegExp }> = [+ // The app's editor bootstrap — the real connectivity risk (provider pool,+ // CRDT observers, doc context). Path-scoped so it covers every editor module.+ { category: 'editor', pattern: /[/\\]packages[/\\]app[/\\]src[/\\]editor[/\\]/ },+ // The Hocuspocus server library — stopped before the survey/completion screens run.+ { category: 'server', pattern: /[/\\]packages[/\\]server[/\\]/ },+ {+ category: 'hocuspocus',+ pattern: /[/\\]node_modules[/\\](\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?@hocuspocus[/\\]/,+ },+ // The collaborative CRDT stack (Yjs + its editor bindings). Plain+ // prosemirror/@tiptap markdown-rendering libs are NOT collab and legitimately+ // arrive via core's markdown pipeline, so only the y-* / collaboration bindings+ // are forbidden.+ {+ category: 'crdt',+ pattern: /[/\\]node_modules[/\\](\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?yjs[/\\]/,+ },+ {+ category: 'crdt',+ pattern: /[/\\]node_modules[/\\](\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?y-protocols[/\\]/,+ },+ {+ category: 'crdt',+ pattern: /[/\\]node_modules[/\\](\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?y-prosemirror[/\\]/,+ },+ {+ category: 'crdt',+ pattern:+ /[/\\]node_modules[/\\](\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?y-codemirror\.next[/\\]/,+ },+ {+ category: 'crdt',+ pattern: /[/\\]node_modules[/\\](\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?y-indexeddb[/\\]/,+ },+ {+ category: 'crdt',+ pattern:+ /[/\\]node_modules[/\\](\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?@tiptap[/\\]y-tiptap[/\\]/,+ },+ {+ category: 'crdt',+ pattern:+ /[/\\]node_modules[/\\](\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?@tiptap[/\\]extension-collaboration/,+ },+];++/**+ * Module-count ceiling on the entry's loaded graph — a coarse backstop for a+ * heavy, un-enumerated pull-in the name-based denylist can't foresee (e.g. a new+ * barrel dragging in a server-connected subtree). Sits well above today's real+ * count (~2.7k, dominated by `@inkeep/open-knowledge-core`'s single bundled+ * `dist/index.mjs` loaded — though mostly tree-shaken — for a few feedback+ * constants). An editor/CRDT leak pulls hundreds of modules and trips this even+ * if it somehow slipped the denylist; ordinary dep churn does not.+ */+export const MODULE_GRAPH_BUDGET = 3400;++export interface UninstallModuleGraph {+ /** Absolute paths of every on-disk module reachable from the uninstall entry. */+ readonly moduleIds: readonly string[];+ /** Resolved dynamic-import targets whose importer is an uninstall-source module. */+ readonly dynamicImportsFromUninstallSource: readonly string[];+}++/** Every reachable module matching the forbidden denylist, with its category. */+export function findForbiddenModules(+ moduleIds: readonly string[],+): Array<{ category: string; id: string }> {+ const hits: Array<{ category: string; id: string }> = [];+ for (const id of moduleIds) {+ for (const { category, pattern } of FORBIDDEN_MODULE_PATTERNS) {+ if (pattern.test(id)) hits.push({ category, id });+ }+ }+ return hits;+}++const PROBE_ENTRY = 'virtual:ok-uninstall-graph-probe';+const RESOLVED_PROBE_ENTRY = `\0${PROBE_ENTRY}`;++function probeEntryPlugin(entryImports: readonly string[]): Plugin {+ const code = entryImports.map((specifier) => `import ${JSON.stringify(specifier)};`).join('\n');+ return {+ name: 'ok:uninstall-graph-probe',+ resolveId(id) {+ return id === PROBE_ENTRY ? RESOLVED_PROBE_ENTRY : null;+ },+ load(id) {+ return id === RESOLVED_PROBE_ENTRY ? code : null;+ },+ };+}++/** Strip rollup virtual-module (`\0…`) ids and per-import query suffixes. */+function normalizeModuleId(id: string): string | null {+ if (id.startsWith('\0')) return null;+ const path = id.split('?', 1)[0];+ return path.length > 0 ? path : null;+}++/**+ * @param extraEntryImports Additional specifiers to import alongside the real+ * uninstall entry — used by the planted-positive test to prove the gate fires+ * when a forbidden module (directly or transitively) enters the graph.+ */+export async function buildUninstallModuleGraph(+ extraEntryImports: readonly string[] = [],+): Promise<UninstallModuleGraph> {+ // The Lingui macro resolves `lingui.config.ts` relative to cwd; this test runs+ // from packages/desktop, so point it at the app's config (same fix as+ // electron.vite.config.ts). Without it the Babel macro pass throws.+ process.env.LINGUI_CONFIG ??= fileURLToPath(+ new URL('../../../app/lingui.config.ts', import.meta.url),+ );++ const moduleIds = new Set<string>();+ const dynamicFromUninstall = new Set<string>();++ const capture: Plugin = {+ name: 'ok:uninstall-graph-capture',+ buildEnd() {+ for (const id of this.getModuleIds()) {+ const normalized = normalizeModuleId(id);+ if (normalized !== null) moduleIds.add(normalized);+ if (!id.includes(`${UNINSTALL_SOURCE_DIR}`)) continue;+ const info = this.getModuleInfo(id);+ for (const dynamicId of info?.dynamicallyImportedIds ?? []) {+ const normalized = normalizeModuleId(dynamicId);+ if (normalized !== null) dynamicFromUninstall.add(normalized);+ }+ }+ },+ };++ await build({+ root: APP_ROOT,+ configFile: false,+ logLevel: 'silent',+ plugins: [+ react(),+ await babel(RENDERER_BABEL_OPTIONS),+ probeEntryPlugin([UNINSTALL_ENTRY, ...extraEntryImports]),+ capture,+ ],+ resolve: {+ alias: { '@': fileURLToPath(new URL('../../../app/src', import.meta.url)) },+ dedupe: [...RENDERER_DEDUPE],+ },+ build: {+ write: false,+ rolldownOptions: { input: { uninstall: PROBE_ENTRY } },+ },+ });++ return {+ moduleIds: [...moduleIds],+ dynamicImportsFromUninstallSource: [...dynamicFromUninstall],+ };+}diff --git a/packages/desktop/tests/unit/preload-single-entry.test.ts b/packages/desktop/tests/unit/preload-single-entry.test.tsnew file mode 100644index 000000000..528019ef4--- /dev/null+++ b/packages/desktop/tests/unit/preload-single-entry.test.ts@@ -0,0 +1,56 @@+import { existsSync, readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { describe, expect, test } from 'vitest';++/**+ * A sandboxed preload's `require` is a polyfill over an allowlist of module+ * NAMES (`electron` plus a few node builtins) and cannot resolve a relative+ * path, so every preload bundle must be a single self-contained file.+ *+ * That makes the preload build's entry count load-bearing. A second entry makes+ * rolldown hoist whatever the two share into `chunks/`, and rolldown offers no+ * per-entry inlining knob (`codeSplitting: false` is rejected outright for+ * multi-input builds) — so BOTH preloads then die on the relative `require`,+ * `window.okDesktop` goes undefined, and the editor falls into web mode with no+ * build error to show for it. The self-uninstall window's bridge therefore+ * ships inside the one entry and is selected at exposure time.+ *+ * The smoke (`tests/smoke/uninstall-ipc-bridge.e2e.ts`) catches the same+ * regression at full fidelity but is opt-in and needs a build; this is the+ * always-on tripwire.+ */++const desktopRoot = resolve(fileURLToPath(new URL('../../', import.meta.url)));++interface PreloadBuild {+ rollupOptions?: { input?: Record<string, string> };+}++async function preloadInput(): Promise<Record<string, string>> {+ const config: { preload?: { build?: PreloadBuild } } = (+ await import('../../electron.vite.config')+ ).default;+ const input = config.preload?.build?.rollupOptions?.input;+ if (input === undefined) throw new Error('preload build declares no entry input');+ return input;+}++describe('preload bundle self-containment', () => {+ test('the preload build declares exactly one entry', async () => {+ expect(Object.keys(await preloadInput())).toEqual(['index']);+ });++ test('the built preload requires only module names, never a relative path', () => {+ const built = resolve(desktopRoot, 'out', 'preload', 'index.js');+ if (!existsSync(built)) {+ // Unbuilt tree — the entry-count assertion above still guards the cause.+ return;+ }+ const requires = [...readFileSync(built, 'utf-8').matchAll(/require\(["']([^"']+)["']\)/g)].map(+ (match) => match[1],+ );+ expect(requires.length).toBeGreaterThan(0);+ expect(requires.filter((specifier) => specifier?.startsWith('.'))).toEqual([]);+ });+});diff --git a/packages/desktop/tests/unit/renderer-html-entries.test.ts b/packages/desktop/tests/unit/renderer-html-entries.test.tsnew file mode 100644index 000000000..4e4e00d70--- /dev/null+++ b/packages/desktop/tests/unit/renderer-html-entries.test.ts@@ -0,0 +1,72 @@+import { existsSync } from 'node:fs';+import { dirname, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { describe, expect, test } from 'vitest';+import { RENDERER_HTML_ENTRIES } from '../../../app/vite.entries';++/**+ * The renderer ships from two builds with different consumers: `packages/app`'s+ * own `vite build` produces what a PACKAGED window loads (`dist/` → the CLI's+ * `dist/public/` → `<Resources>/app/`), while `packages/desktop`'s+ * `electron-vite build` produces the unpackaged-dev fallback at+ * `out/renderer/`. An entry declared in only one of them works in dev and 404s+ * in the shipped app, so the entry set is asserted to match across both.+ */+const appRoot = resolve(fileURLToPath(new URL('../../../app/', import.meta.url)));++type EntryInput = Record<string, string>;++/**+ * Both spellings are read because the two configs are mid-migration: Vite 8+ * renamed `rollupOptions` to `rolldownOptions` and the app config has moved+ * while the electron-vite one has not. Reading either keeps this assertion+ * alive across that rename instead of silently going vacuous.+ */+interface RendererBuild {+ rollupOptions?: { input?: EntryInput };+ rolldownOptions?: { input?: EntryInput };+}++function entryInput(build: RendererBuild | undefined): EntryInput {+ const input = build?.rolldownOptions?.input ?? build?.rollupOptions?.input;+ if (input === undefined) throw new Error('renderer build declares no HTML entry input');+ return input;+}++async function appBuildInput(): Promise<EntryInput> {+ const config: { build?: RendererBuild } = (await import('../../../app/vite.config')).default;+ return entryInput(config.build);+}++async function electronRendererInput(): Promise<EntryInput> {+ const config: { renderer?: { build?: RendererBuild } } = (+ await import('../../electron.vite.config')+ ).default;+ return entryInput(config.renderer?.build);+}++describe('renderer HTML entries', () => {+ test('the uninstall window is a build entry, not an inline document', async () => {+ expect(Object.keys(await appBuildInput())).toContain('uninstall');+ expect(Object.keys(await electronRendererInput())).toContain('uninstall');+ });++ test('both renderer builds declare the same entry set', async () => {+ const expected = Object.fromEntries(+ Object.entries(RENDERER_HTML_ENTRIES).map(([name, file]) => [name, resolve(appRoot, file)]),+ );++ expect(await appBuildInput()).toEqual(expected);+ expect(await electronRendererInput()).toEqual(expected);+ });++ test('every declared entry is a flat sibling at the app root', async () => {+ // Vite emits shared chunks to `<outDir>/assets/`, and each entry HTML gets+ // relative `./assets/…` URLs. Nesting one entry a directory deeper would+ // silently break its asset resolution under `file://`.+ for (const [name, entryPath] of Object.entries(await appBuildInput())) {+ expect(dirname(entryPath), `${name} entry must sit at the app root`).toBe(appRoot);+ expect(existsSync(entryPath), `${name} entry is missing on disk`).toBe(true);+ }+ });+});diff --git a/packages/desktop/tests/unit/uninstall-module-graph.test.ts b/packages/desktop/tests/unit/uninstall-module-graph.test.tsnew file mode 100644index 000000000..002489ed8--- /dev/null+++ b/packages/desktop/tests/unit/uninstall-module-graph.test.ts@@ -0,0 +1,101 @@+import { beforeAll, describe, expect, test } from 'vitest';+import {+ buildUninstallModuleGraph,+ findForbiddenModules,+ MODULE_GRAPH_BUDGET,+ type UninstallModuleGraph,+} from '../support/uninstall-module-graph.test-helper';++/**+ * "Connects to nothing" — the PRIMARY gate. The survey and completion screens+ * render after `ok uninstall --yes` has stopped the local Hocuspocus server and+ * removed `~/.ok`, so the uninstall entry's transitive module graph must never+ * reach the editor, the CRDT stack, the provider pool, or the server bootstrap.+ *+ * This asserts over the entry's whole loaded-module set (see the helper), not a+ * single output chunk. The GritQL rule (`no-uninstall-forbidden-import.grit`) is+ * only fast, shallow, first-hop feedback; this graph check is the real gate+ * because it also catches a forbidden module reached indirectly through a shared+ * module.+ */+describe('uninstall entry connects to nothing', () => {+ // Building the real renderer pipeline (React Compiler + Lingui macro) takes a+ // couple of seconds; the planted-positive build pulls the editor + CRDT stack+ // and takes longer.+ const BUILD_TIMEOUT_MS = 120_000;++ describe('the forbidden-module denylist', () => {+ test('flags every editor / CRDT / provider-pool / server category', () => {+ const hits = findForbiddenModules([+ '/repo/packages/app/src/editor/provider-pool.ts',+ '/repo/packages/server/dist/index.mjs',+ '/repo/node_modules/.pnpm/@[email protected]/node_modules/@hocuspocus/provider/dist/index.js',+ '/repo/node_modules/.pnpm/[email protected]/node_modules/yjs/dist/yjs.mjs',+ '/repo/node_modules/.pnpm/[email protected]/node_modules/y-protocols/awareness.js',+ '/repo/node_modules/y-prosemirror/dist/y-prosemirror.js',+ '/repo/node_modules/y-indexeddb/dist/y-indexeddb.js',+ '/repo/node_modules/@tiptap/y-tiptap/dist/index.js',+ '/repo/node_modules/@tiptap/extension-collaboration-cursor/dist/index.js',+ ]);+ expect(new Set(hits.map((h) => h.category))).toEqual(+ new Set(['editor', 'server', 'hocuspocus', 'crdt']),+ );+ expect(hits).toHaveLength(9);+ });++ test('does not flag the allowed shared surface (core, shadcn, markdown-render libs)', () => {+ // The allowed graph legitimately reaches @inkeep/open-knowledge-core (shared+ // types + feedback constants) and, through its markdown pipeline, plain+ // prosemirror / @tiptap rendering libs — none of which connect to anything.+ const hits = findForbiddenModules([+ '/repo/packages/app/src/uninstall/UninstallSurveyScreen.tsx',+ '/repo/packages/app/src/components/ui/button.tsx',+ '/repo/packages/app/src/lib/i18n.ts',+ '/repo/packages/core/dist/index.mjs',+ '/repo/node_modules/.pnpm/@[email protected]/node_modules/@tiptap/core/dist/index.js',+ '/repo/node_modules/.pnpm/[email protected]/node_modules/prosemirror-view/dist/index.js',+ '/repo/node_modules/.pnpm/[email protected]/node_modules/react/index.js',+ ]);+ expect(hits).toEqual([]);+ });+ });++ describe('the real uninstall entry graph', () => {+ let graph: UninstallModuleGraph;++ beforeAll(async () => {+ graph = await buildUninstallModuleGraph();+ }, BUILD_TIMEOUT_MS);++ test('reaches no forbidden module', () => {+ expect(findForbiddenModules(graph.moduleIds)).toEqual([]);+ });++ test('stays within the module-count budget', () => {+ // Lower bound proves the build actually resolved the real tree (not an empty+ // or short-circuited graph that would pass the denylist vacuously).+ expect(graph.moduleIds.length).toBeGreaterThan(200);+ expect(graph.moduleIds.length).toBeLessThanOrEqual(MODULE_GRAPH_BUDGET);+ });++ test('uses no dynamic import in its own source (eager-load invariant)', () => {+ expect(graph.dynamicImportsFromUninstallSource).toEqual([]);+ });+ });++ test(+ 'the gate fires when an editor module enters the graph',+ async () => {+ // Planted positive: import the provider pool, which itself pulls+ // @hocuspocus/provider + yjs. Proves the gate detects both the editor module+ // directly AND the CRDT/server stack it reaches indirectly — the leak shape a+ // first-hop-only check would miss.+ const planted = await buildUninstallModuleGraph(['@/editor/provider-pool']);+ const categories = new Set(findForbiddenModules(planted.moduleIds).map((h) => h.category));++ expect(categories.has('editor')).toBe(true);+ expect(categories.has('crdt') || categories.has('hocuspocus')).toBe(true);+ },+ BUILD_TIMEOUT_MS,+ );+});