Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(ok): let the setup screen close when the user opened it (#3738)
sarah255aa8ce2c83
diff --git a/.changeset/setup-dialog-dismissible-when-user-opened.md b/.changeset/setup-dialog-dismissible-when-user-opened.mdnew file mode 100644index 000000000..1090925f8--- /dev/null+++ b/.changeset/setup-dialog-dismissible-when-user-opened.md@@ -0,0 +1,7 @@+---+"@inkeep/open-knowledge": patch+---++The first-launch setup screen now closes the way you'd expect when you opened it yourself. Reopening it — from the command palette, the menu bar, the File menu, or the "Connect tools" button on the Claude Code banner — gives you a close button, a Cancel action, and click-outside-to-close, exactly like every other dialog in the app. Its first, unprompted appearance is unchanged: that one still asks for a real decision and offers "Skip for now" rather than a way to wave it away. Closing a reopened one now leaves your setup exactly as it was — no marker is written at all, so a completed setup stays completed with its original date intact.++Confirmation dialogs no longer freeze the window in place. Because they can't be dismissed by clicking outside, their backdrop was suppressing the title-bar drag region underneath it, so the window couldn't be moved until the dialog was answered — including on that first-run setup screen.diff --git a/knip.config.ts b/knip.config.tsindex b61debe5e..8ad68f996 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -124,7 +124,9 @@ export default {'packages/server': {entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],project: 'src/**',- ignoreDependencies: ['@types/shell-quote'],+ ignoreDependencies: [+ '@types/shell-quote',+ ],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],diff --git a/packages/app/src/components/McpConsentDialog.dom.test.tsx b/packages/app/src/components/McpConsentDialog.dom.test.tsxindex 9004ac728..c3e486be3 100644--- a/packages/app/src/components/McpConsentDialog.dom.test.tsx+++ b/packages/app/src/components/McpConsentDialog.dom.test.tsx@@ -1,5 +1,5 @@import * as actualLinguiMacro from '@lingui/react/macro';-import { cleanup, render, screen, waitFor } from '@testing-library/react';+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';import userEvent from '@testing-library/user-event';import type { ReactNode } from 'react';import { afterEach, describe, expect, test, vi } from 'vitest';@@ -40,6 +40,7 @@ const DISCOVERY_SKILL = {};const payload: OkMcpWiringShowPayload = {+ origin: 'first-run',detectedEditors: [{id: 'claude',@@ -83,6 +84,7 @@ const payload: OkMcpWiringShowPayload = {* none created. No agent tool on the machine ⇒ nowhere to install.*/const noneDetectedPayload: OkMcpWiringShowPayload = {+ origin: 'first-run',detectedEditors: [{id: 'codex',@@ -129,6 +131,7 @@ function makeHarness({} = {}) {const confirmCalls: RecordedConfirm[] = [];const skipCalls: string[] = [];+ const dismissCalls: string[] = [];const toastErrors: string[] = [];const toastMessages: string[] = [];const store: McpConsentStore = {@@ -140,7 +143,9 @@ function makeHarness({});return confirmResult(request.editorIds);},- dismiss: () => {},+ dismiss: () => {+ dismissCalls.push('dismiss');+ },getSnapshot: () => snapshot,install: () => undefined,skip: async () => {@@ -156,6 +161,7 @@ function makeHarness({return {confirmCalls,skipCalls,+ dismissCalls,store,toast,toastErrors,@@ -719,6 +725,293 @@ describe('McpConsentDialog dismissal', () => {});});+describe('McpConsentDialog surface by origin', () => {+ afterEach(() => cleanup());++ const reconfigureHarness = () => makeHarness({ snapshot: { ...payload, origin: 'reconfigure' } });++ /**+ * Radix registers its outside-pointerdown listener inside a zero-delay+ * timeout, so a gesture dispatched before that tick reaches no listener and+ * every "did not dismiss" assertion downstream passes for the wrong reason.+ */+ async function armOutsideDismissal() {+ await act(async () => {+ await new Promise((resolve) => setTimeout(resolve, 0));+ });+ }++ /** `userEvent` refuses to click <body> — Radix sets `pointer-events: none` on+ * it while a modal is open — so the gesture is dispatched directly. */+ function clickOutside() {+ fireEvent.pointerDown(document.body);+ fireEvent.click(document.body);+ }++ test('first-run is an alertdialog that an outside click cannot dismiss', async () => {+ const harness = await renderDialog();++ expect(screen.getByRole('alertdialog')).toBeTruthy();+ // No close X: the footer's two choices are the whole decision surface.+ expect(screen.queryByRole('button', { name: 'Close' })).toBeNull();++ await armOutsideDismissal();+ clickOutside();++ // Asserted as "no decision recorded" rather than "still mounted": the store+ // is what a dismissal would touch, and it stays untouched.+ expect(harness.skipCalls).toEqual([]);+ expect(harness.confirmCalls).toEqual([]);+ });++ test('a user-opened one is an ordinary dialog with a close X', async () => {+ await renderDialog(reconfigureHarness());++ expect(screen.getByRole('dialog')).toBeTruthy();+ expect(screen.queryByRole('alertdialog')).toBeNull();+ expect(screen.getByRole('button', { name: 'Close' })).toBeTruthy();+ });++ test('the footer action reads Cancel when the user opened it, Skip when it opened itself', async () => {+ await renderDialog();+ expect(screen.getByTestId('mcp-consent-skip').textContent).toBe('Skip for now');++ cleanup();++ await renderDialog(reconfigureHarness());+ expect(screen.getByTestId('mcp-consent-skip').textContent).toBe('Cancel');+ });++ test.each([+ ['the close X', async () => userEvent.click(screen.getByRole('button', { name: 'Close' }))],+ [+ 'an outside click',+ async () => {+ await armOutsideDismissal();+ clickOutside();+ },+ ],+ ['the footer Cancel', async () => userEvent.click(screen.getByTestId('mcp-consent-skip'))],+ ['Escape', async () => userEvent.keyboard('{Escape}')],+ ])('%s leaves a finished setup untouched', async (_label, dismiss) => {+ const harness = await renderDialog(reconfigureHarness());++ await dismiss();++ await waitFor(() => {+ expect(harness.dismissCalls).toEqual(['dismiss']);+ });+ // The point of routing these to dismiss rather than skip: `skip` writes+ // `{ configured: false, skippedAt }` unconditionally, so a user who already+ // finished setup and then closed a screen they opened out of curiosity+ // would have had that marker downgraded and their real `configuredAt` lost.+ expect(harness.skipCalls).toEqual([]);+ expect(harness.confirmCalls).toEqual([]);+ // No toast either — a "configure this in Settings" pointer after Cancel+ // implies something was recorded, and the user just came from that surface.+ expect(harness.toastMessages).toEqual([]);+ });++ test('first-run still writes the skip marker — dismiss is the reopen path only', async () => {+ // The control for the block above. Without it, "skip was not called" would+ // pass just as happily if skip had stopped working everywhere.+ const harness = await renderDialog();++ await userEvent.click(screen.getByTestId('mcp-consent-skip'));++ await waitFor(() => {+ expect(harness.skipCalls).toEqual(['skip']);+ });+ expect(harness.dismissCalls).toEqual([]);+ });++ test('the footer Cancel dismisses once per click, not twice', async () => {+ // The two shells close by opposite routes — the alert shell's Cancel closes+ // the dialog and lets `onOpenChange` act, the plain Button calls the handler+ // directly. Wiring both on one element double-fires.+ const harness = await renderDialog(reconfigureHarness());++ await userEvent.click(screen.getByTestId('mcp-consent-skip'));++ await waitFor(() => {+ expect(harness.dismissCalls).toEqual(['dismiss']);+ });+ });++ test('no dismiss surface can fire while a request is in flight', async () => {+ // The reopen shell adds two dismiss routes that did not exist before (close+ // X, outside-click), which makes `onOpenChange`'s `busy` guard reachable in+ // ways it was not. Without the guard a dismiss could race a pending+ // confirm — both `store.confirm` and `store.dismiss` dispatching for one+ // decision, and `busy` left stuck.+ const pending = deferredResult();+ const harness = await renderDialog(+ makeHarness({+ snapshot: { ...payload, origin: 'reconfigure' },+ confirmResult: async () => pending.promise,+ }),+ );++ await userEvent.click(screen.getByTestId('mcp-consent-add'));+ await waitFor(() => {+ expect((screen.getByTestId('mcp-consent-add') as HTMLButtonElement).disabled).toBe(true);+ });++ await userEvent.keyboard('{Escape}');+ await armOutsideDismissal();+ clickOutside();+ await userEvent.click(screen.getByTestId('mcp-consent-skip'));++ pending.resolve({ ok: true });+ await waitFor(() => {+ expect(harness.confirmCalls.length).toBe(1);+ });+ expect(harness.dismissCalls).toEqual([]);+ expect(harness.skipCalls).toEqual([]);+ });++ test('the close X is visibly inert while a request is in flight', async () => {+ // The guard above makes it a no-op; this makes it look like one. Every other+ // control greys out via `disabled={busy}`, but the X belongs to DialogContent.+ const pending = deferredResult();+ await renderDialog(+ makeHarness({+ snapshot: { ...payload, origin: 'reconfigure' },+ confirmResult: async () => pending.promise,+ }),+ );++ const content = screen.getByRole('dialog');+ expect(content.className).not.toContain('[&_[data-slot=dialog-close]]:pointer-events-none');++ await userEvent.click(screen.getByTestId('mcp-consent-add'));++ await waitFor(() => {+ expect(content.className).toContain('[&_[data-slot=dialog-close]]:pointer-events-none');+ });+ expect(content.className).toContain('[&_[data-slot=dialog-close]]:opacity-50');+ pending.resolve({ ok: true });+ });++ test('a user-opened one still offers Finish setup', async () => {+ // Dismissibility is the only difference; the decision itself is unchanged.+ const harness = await renderDialog(reconfigureHarness());++ await userEvent.click(screen.getByTestId('mcp-consent-add'));++ await waitFor(() => {+ expect(harness.confirmCalls.length).toBe(1);+ });+ expect(harness.skipCalls).toEqual([]);+ });+});++/**+ * These drive a REAL `createMcpConsentStore()` rather than the harness stub, so+ * the `useSyncExternalStore` subscription is actually exercised. Every other+ * test passes `payload=` directly, which short-circuits that path — the very+ * code that fixes the replacement race would be dead in the suite otherwise, and+ * a revert to a bare `getSnapshot()` read would stay green.+ */+describe('McpConsentDialog payload replacement', () => {+ afterEach(() => cleanup());++ function makeStoreBridge() {+ let handler: ((next: OkMcpWiringShowPayload) => void) | null = null;+ const confirm = vi.fn(() => Promise.resolve({ ok: true as const }));+ const bridge = {+ mcpWiring: {+ onShow: (cb: (next: OkMcpWiringShowPayload) => void) => {+ handler = cb;+ return () => {+ handler = null;+ };+ },+ signalReady: () => {},+ confirm,+ skip: () => Promise.resolve({ ok: true as const }),+ },+ };+ return {+ bridge,+ confirm,+ fireShow: (next: OkMcpWiringShowPayload) => handler?.(next),+ };+ }++ async function renderAgainstStore(harnessBridge: ReturnType<typeof makeStoreBridge>) {+ const { McpConsentDialogBody } = await import('./McpConsentDialogBody');+ const { createMcpConsentStore } = await import('@/lib/mcp-consent-store');+ const { TooltipProvider } = await import('@/components/ui/tooltip');+ const store = createMcpConsentStore();+ store.install({ bridge: harnessBridge.bridge as never });+ const toastMessages: string[] = [];+ render(+ <TooltipProvider>+ <McpConsentDialogBody+ store={store}+ toast={{ error: (m) => toastMessages.push(m), message: (m) => toastMessages.push(m) }}+ />+ </TooltipProvider>,+ );+ return { store, toastMessages };+ }++ test('a reconfigure arriving over an open first-run swaps the shell', async () => {+ const b = makeStoreBridge();+ await renderAgainstStore(b);++ act(() => b.fireShow({ ...payload, origin: 'first-run' }));+ await waitFor(() => {+ expect(screen.getByRole('alertdialog')).toBeTruthy();+ });++ // Reachable on macOS: the native File menu stays clickable behind a web modal.+ act(() => b.fireShow({ ...payload, origin: 'reconfigure' }));++ await waitFor(() => {+ expect(screen.getByRole('dialog')).toBeTruthy();+ });+ expect(screen.queryByRole('alertdialog')).toBeNull();+ expect(screen.getByTestId('mcp-consent-skip').textContent).toBe('Cancel');+ });++ test('a replacement remounts the form rather than inheriting its state', async () => {+ // The acute case: a confirm in flight when the replacement lands. Reconciled+ // rather than remounted, the new dialog inherits `busy` and renders fully+ // disabled with no exit, then unmounts under the user when the first confirm+ // settles and clears the store.+ const b = makeStoreBridge();+ let releaseConfirm!: () => void;+ b.confirm.mockImplementation(+ () =>+ new Promise((resolve) => {+ releaseConfirm = () => resolve({ ok: true });+ }),+ );+ await renderAgainstStore(b);++ act(() => b.fireShow({ ...payload, origin: 'first-run' }));+ await waitFor(() => {+ expect(screen.getByTestId('mcp-consent-add')).toBeTruthy();+ });+ await userEvent.click(screen.getByTestId('mcp-consent-add'));+ await waitFor(() => {+ expect((screen.getByTestId('mcp-consent-add') as HTMLButtonElement).disabled).toBe(true);+ });++ act(() => b.fireShow({ ...payload, origin: 'reconfigure' }));++ // The freshly-opened dialog must be usable, not a disabled husk.+ await waitFor(() => {+ expect((screen.getByTestId('mcp-consent-add') as HTMLButtonElement).disabled).toBe(false);+ });+ expect((screen.getByTestId('mcp-consent-skip') as HTMLButtonElement).disabled).toBe(false);++ releaseConfirm();+ });+});+describe('McpConsentDialog theme picker', () => {afterEach(() => {cleanup();diff --git a/packages/app/src/components/McpConsentDialogBody.tsx b/packages/app/src/components/McpConsentDialogBody.tsxindex 7cb8f745a..7f7e4a21f 100644--- a/packages/app/src/components/McpConsentDialogBody.tsx+++ b/packages/app/src/components/McpConsentDialogBody.tsx@@ -46,7 +46,7 @@import { i18n } from '@lingui/core';import { Trans, useLingui } from '@lingui/react/macro';import { useTheme } from 'next-themes';-import { useId, useState } from 'react';+import { type ComponentType, type ReactNode, useId, useState, useSyncExternalStore } from 'react';import { toast as sonnerToast } from 'sonner';import { OkIcon } from '@/components/icons/ok';import { RowDisclosure } from '@/components/RowDisclosure';@@ -63,6 +63,15 @@ import {} from '@/components/ui/alert-dialog';import { Button } from '@/components/ui/button';import { Checkbox } from '@/components/ui/checkbox';+import {+ Dialog,+ DialogBody,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@/components/ui/dialog';import { Label } from '@/components/ui/label';import { useConfigContextOptional } from '@/lib/config-context';import type { OkMcpWiringShowPayload } from '@/lib/desktop-bridge-types';@@ -105,6 +114,56 @@ export function connectableEditors(return editors.filter((e) => e.detected);}+/**+ * The two shells this screen renders in. ONLY the shell differs — the heading,+ * every row of the form, and the primary action are authored once below and+ * mount into whichever is selected, so the two entry points cannot drift apart.+ *+ * first-run is the unsolicited showing, and the only one that earns a surface+ * the user cannot wave away: Radix preventDefaults outside-pointer dismissal on+ * an alert dialog and moves initial focus onto its cancel element, which is why+ * the footer keeps an `AlertDialogCancel` in that mode specifically.+ *+ * Every other entry point is the user asking for this screen, and gets the+ * ordinary dialog treatment — close X, click-outside, Escape — because a screen+ * you deliberately opened should close the way every other one does. That shell+ * is stock `Dialog`, with no per-call-site deviation: the whole point is that it+ * behaves like every other dialog in the app.+ */+interface ConsentSurface {+ Root: ComponentType<{+ open: boolean;+ onOpenChange: (open: boolean) => void;+ children: ReactNode;+ }>;+ Content: ComponentType<{ className?: string; 'aria-busy'?: boolean; children: ReactNode }>;+ Header: ComponentType<{ children: ReactNode }>;+ Title: ComponentType<{ className?: string; children: ReactNode }>;+ Description: ComponentType<{ className?: string; children: ReactNode }>;+ Body: ComponentType<{ className?: string; children: ReactNode }>;+ Footer: ComponentType<{ className?: string; children: ReactNode }>;+}++const FIRST_RUN_SURFACE: ConsentSurface = {+ Root: AlertDialog,+ Content: AlertDialogContent,+ Header: AlertDialogHeader,+ Title: AlertDialogTitle,+ Description: AlertDialogDescription,+ Body: AlertDialogBody,+ Footer: AlertDialogFooter,+};++const DISMISSIBLE_SURFACE: ConsentSurface = {+ Root: Dialog,+ Content: DialogContent,+ Header: DialogHeader,+ Title: DialogTitle,+ Description: DialogDescription,+ Body: DialogBody,+ Footer: DialogFooter,+};+/*** Test-injectable store + toast — production consumers use the default* exports. Exposed as props so the tests don't need to reset module@@ -144,13 +203,44 @@ export function McpConsentDialogBody({toast = defaultToast,payload,}: McpConsentDialogBodyProps = {}) {- // In production the lazy wrapper only mounts us when the snapshot is non-- // null; we still read from the store here so React subscribes (and we- // unmount cleanly when clearCurrent fires on success). The `payload` prop- // override is test-only.- const snapshot = payload ?? store.getSnapshot();+ // Subscribed, not a bare read. The lazy wrapper above subscribes with a+ // derived boolean (`getSnapshot() !== null`), so a payload REPLACEMENT —+ // non-null to non-null — bails out of its `Object.is` check and never+ // re-renders. That was harmless while both payloads rendered the same shell;+ // now that `origin` picks the shell, a 'reconfigure' arriving over an open+ // first-run dialog would leave the locked one on screen. Reachable on macOS:+ // the native File menu is OS-level and stays clickable behind a web modal.+ // The `payload` prop override is test-only and skips the subscription.+ const subscribed = useSyncExternalStore(store.subscribe, store.getSnapshot, () => null);+ const snapshot = payload ?? subscribed;++ /**+ * A replacement must REMOUNT the form, not reconcile it.+ *+ * Every piece of the form's answer lives in `useState` — `busy`, and the three+ * checkboxes. Without a changing key React keeps all of it across a swap, so+ * the incoming request inherits the outgoing one's state. The acute case is+ * `busy`: a confirm in flight when a reconfigure arrives hands the user a+ * freshly-opened dialog that is entirely disabled with no exit, and then+ * unmounts it under them when the original confirm resolves and clears the+ * store. Carrying checkbox answers across two different requests is wrong on+ * its own — a new showing asks the question again.+ *+ * Counted rather than keyed off payload contents: two successive reconfigures+ * can be structurally identical, and a content-derived key would collide on+ * exactly the repeat case. This is React's documented "adjust state when a+ * prop changes" shape — the extra render happens before children commit, so+ * the stale form never paints.+ */+ const [seenSnapshot, setSeenSnapshot] = useState(snapshot);+ const [requestKey, setRequestKey] = useState(0);+ if (snapshot !== seenSnapshot) {+ setSeenSnapshot(snapshot);+ if (snapshot !== null) setRequestKey((n) => n + 1);+ }+if (!snapshot) return null;- return <McpConsentDialogForm payload={snapshot} store={store} toast={toast} />;+ return <McpConsentDialogForm key={requestKey} payload={snapshot} store={store} toast={toast} />;}interface McpConsentDialogFormProps {@@ -261,6 +351,30 @@ function McpConsentDialogForm({ payload, store, toast }: McpConsentDialogFormPro}}+ // first-run is the only unsolicited showing; everything else is the user+ // asking for this screen. See FIRST_RUN_SURFACE.+ const firstRun = payload.origin === 'first-run';+ const Surface = firstRun ? FIRST_RUN_SURFACE : DISMISSIBLE_SURFACE;++ /**+ * Leaving a screen you opened yourself must not rewrite what you already+ * decided. `skip()` writes `{ configured: false, skippedAt }` unconditionally,+ * so routing a reopen's exits there would downgrade a finished setup's+ * `{ configured: true, configuredAt, editors }` marker to a skip and lose the+ * real `configuredAt` — a control labelled Cancel writing state is the+ * opposite of what the label promises. `dismiss()` closes the dialog and+ * touches nothing, which is the whole meaning of cancelling here: the marker's+ * only job is the first-launch gate, and a reopen cannot change that answer.+ *+ * No toast either. Skip's "configure this in Settings" pointer exists because+ * a first-run user may never find the surface again; someone who just opened+ * it from the palette or the menu bar knows exactly where it lives, and a+ * toast after Cancel would imply something was recorded.+ */+ function onDismiss(): void {+ store.dismiss();+ }+async function onSkip() {setBusy(true);const result = await store.skip();@@ -275,16 +389,20 @@ function McpConsentDialogForm({ payload, store, toast }: McpConsentDialogFormPro}function onOpenChange(open: boolean) {- // Two routes in: ESC, and the footer's Skip button (an `AlertDialogCancel`,- // which closes rather than calling `onSkip` itself). Outside-click is not one- // of them — `AlertDialog` preventDefaults it — and the content renders no X.- // Either way no decision was made, so this is a skip (marker only), not a- // decline.- if (!open && !busy) void onSkip();+ // Every close route lands here, and none of them made a decision — but the+ // two shells record that differently. First run (ESC, the footer's cancel+ // element) writes the skip marker, which is what stops the dialog firing+ // again next launch. A reopen (close X, outside-click, ESC) records nothing+ // at all; see onDismiss. The dismissible footer's Cancel calls `onDismiss`+ // directly instead — it is a plain Button, so nothing closes the dialog out+ // from under it and this handler never sees that click.+ if (open || busy) return;+ if (firstRun) void onSkip();+ else onDismiss();}return (- <AlertDialog open onOpenChange={onOpenChange}>+ <Surface.Root open onOpenChange={onOpenChange}>{/** Radix Dialog auto-wires `aria-labelledby` / `aria-describedby` on* `DialogContent` from `DialogTitle` / `DialogDescription` via context@@ -295,9 +413,20 @@ function McpConsentDialogForm({ payload, store, toast }: McpConsentDialogFormPro* screen readers to either announce the label twice or drop the* association.*/}- <AlertDialogContent className="sm:max-w-2xl md:max-w-3xl" aria-busy={busy}>- <AlertDialogHeader>- <AlertDialogTitle className="flex flex-col gap-8 text-2xl tracking-tighter">+ <Surface.Content+ className={cn(+ 'sm:max-w-2xl md:max-w-3xl',+ // Every control in the form carries `disabled={busy}`; the close X+ // belongs to DialogContent and cannot, so it would sit fully lit while+ // `onOpenChange` silently no-ops on it. Match the others rather than+ // leave the one control that lies about its state.+ busy &&+ '[&_[data-slot=dialog-close]]:pointer-events-none [&_[data-slot=dialog-close]]:opacity-50',+ )}+ aria-busy={busy}+ >+ <Surface.Header>+ <Surface.Title className="flex flex-col gap-8 text-2xl tracking-tighter">{/* Brand mark, not an information-bearing image — the headingbelow already names OpenKnowledge, so announcing the logo toowould just repeat it. `aria-hidden` overrides the icon's own@@ -311,13 +440,13 @@ function McpConsentDialogForm({ payload, store, toast }: McpConsentDialogFormPro</span><Trans>Let's get set up.</Trans></span>- </AlertDialogTitle>- <AlertDialogDescription className="sr-only">+ </Surface.Title>+ <Surface.Description className="sr-only"><Trans>Customize your OpenKnowledge experience.</Trans>- </AlertDialogDescription>- </AlertDialogHeader>+ </Surface.Description>+ </Surface.Header>- <AlertDialogBody className="flex flex-col gap-6 min-h-0">+ <Surface.Body className="flex flex-col gap-6 min-h-0">{/** Shell-PATH consent section — rendered first inside the scrollable* DialogBody, above the AI-tools row. Distinct from the AI-tools@@ -633,39 +762,61 @@ function McpConsentDialogForm({ payload, store, toast }: McpConsentDialogFormProaria-label={t`Choose your theme`}/></div>- </AlertDialogBody>- <AlertDialogFooter className="sm:justify-between">+ </Surface.Body>+ <Surface.Footer className="sm:justify-between">{/* Skip and an all-unchecked Finish are NOT the same outcome, so bothare offered: skip writes the marker and nothing else, while Finishrecords an explicit decline for every offered target. Skip staysvisually quiet so it reads as "not now" rather than "no". ESC routeshere too. */}- {/* An `AlertDialogCancel`, not a plain Button: Radix moves initial focus- onto the cancel element and suppresses its own auto-focus when there- isn't one, which would leave focus stranded on <body> with the trap- inert (see the header of `alert-dialog.tsx`). Skip IS the cancel- action, so the semantic element is also the right one.+ {/* The one element that genuinely differs per shell, for two reasons.+ Semantics: on first run this IS the cancel action, and Radix moves+ initial focus onto `AlertDialogCancel` — with no such element in the+ tree it suppresses its own auto-focus and strands focus on <body>+ with the trap inert (see the header of `alert-dialog.tsx`). Wording:+ "Skip for now" answers a question the user did not ask for, while a+ screen they deliberately opened is one they cancel out of.- `variant` goes on the component rather than an inner `<Button asChild>`:- the component already renders a Button (defaulting to `outline`) around- the Radix Cancel, so wrapping one adds a third Slot and merges the- outline classes onto the final element. It also applies `font-mono- uppercase` itself. `-ms-2.5` offsets the size default's `px-2.5` so the- focus ring keeps even padding while the label stays on the content edge.+ `variant` goes on `AlertDialogCancel` rather than an inner `<Button+ asChild>`: it already renders a Button (defaulting to `outline`)+ around the Radix Cancel, so wrapping one adds a third Slot and merges+ the outline classes onto the final element. It also applies+ `font-mono uppercase` itself, which the plain Button has to restate.+ `-ms-2.5` offsets the size default's `px-2.5` so the focus ring keeps+ even padding while the label stays on the content edge.- No `onClick` here on purpose: Cancel closes the dialog, which fires- `onOpenChange(false)`, which is already the skip path. Calling- `onSkip` from both ran it twice per click. */}- <AlertDialogCancel- variant="link-muted"- disabled={busy}- className="-ms-2.5 tracking-wide"- data-testid="mcp-consent-skip"- >- <Trans comment="Secondary footer action that dismisses first-launch setup without writing any config">- Skip for now- </Trans>- </AlertDialogCancel>+ No `onClick` on the Cancel on purpose: it closes the dialog, which+ fires `onOpenChange(false)`, which is already the skip path — calling+ `onSkip` from both ran it twice per click. The plain Button is the+ mirror image: nothing closes the dialog for it, so it must call+ `onDismiss` itself. */}+ {firstRun ? (+ <AlertDialogCancel+ variant="link-muted"+ disabled={busy}+ className="-ms-2.5 tracking-wide"+ data-testid="mcp-consent-skip"+ >+ <Trans comment="Secondary footer action that dismisses first-launch setup without writing any config">+ Skip for now+ </Trans>+ </AlertDialogCancel>+ ) : (+ <Button+ variant="link-muted"+ disabled={busy}+ className="-ms-2.5 tracking-wide font-mono uppercase"+ data-testid="mcp-consent-skip"+ onClick={onDismiss}+ >+ {/* No `comment` here: this msgid is the shared "Cancel" that ~20+ other components resolve to, and an extracted note would attach+ setup-screen guidance to every one of their catalog entries.+ The "Skip for now" comment above is safe — that msgid is unique+ to this file. */}+ <Trans>Cancel</Trans>+ </Button>+ )}{/* The default variant already carries `font-mono uppercase`. */}<Button onClick={() => void onContinue()} disabled={busy} data-testid="mcp-consent-add">{busy ? (@@ -676,9 +827,9 @@ function McpConsentDialogForm({ payload, store, toast }: McpConsentDialogFormPro</Trans>)}</Button>- </AlertDialogFooter>- </AlertDialogContent>- </AlertDialog>+ </Surface.Footer>+ </Surface.Content>+ </Surface.Root>);}diff --git a/packages/app/src/components/ui/alert-dialog.dom.test.tsx b/packages/app/src/components/ui/alert-dialog.dom.test.tsxindex 4be3df440..a7fc5f14e 100644--- a/packages/app/src/components/ui/alert-dialog.dom.test.tsx+++ b/packages/app/src/components/ui/alert-dialog.dom.test.tsx@@ -291,6 +291,39 @@ describe('AlertDialog surface classes', () => {]);});+ test('renders no drag strip off the desktop host', () => {+ renderAlert();++ expect(screen.queryByTestId('alert-dialog-drag-strip')).toBeNull();+ });++ test('restores the title-bar drag band, between the overlay and the dialog', () => {+ vi.stubGlobal('okDesktop', {});+ try {+ renderAlert();++ const strip = screen.getByTestId('alert-dialog-drag-strip');+ const overlay = document.querySelector('[data-slot="alert-dialog-overlay"]');+ const content = screen.getByRole('alertdialog');++ expectVisualClassTokens(strip.getAttribute('class'), [+ '[-webkit-app-region:drag]',+ 'pointer-events-none',+ 'z-50',+ ]);+ // The ordering IS the contract: after the overlay so it beats the no-drag+ // blanket, before the content so a viewport-tall dialog's own close X and+ // heading stay clickable rather than becoming drag region.+ expect(overlay?.compareDocumentPosition(strip)).toBe(Node.DOCUMENT_POSITION_FOLLOWING);+ expect(content.compareDocumentPosition(strip)).toBe(Node.DOCUMENT_POSITION_PRECEDING);+ // Opts into the globals.css rule that suspends drag under an open popper.+ expect(strip.hasAttribute('data-electron-drag')).toBe(true);+ expect(strip.getAttribute('aria-hidden')).toBe('true');+ } finally {+ vi.unstubAllGlobals();+ }+ });+test('caller className composes with the base classes rather than replacing them', () => {render(<AlertDialog open>diff --git a/packages/app/src/components/ui/alert-dialog.tsx b/packages/app/src/components/ui/alert-dialog.tsxindex e86fb909a..9216f89a4 100644--- a/packages/app/src/components/ui/alert-dialog.tsx+++ b/packages/app/src/components/ui/alert-dialog.tsx@@ -70,6 +70,46 @@ function AlertDialogOverlay({);}+/**+ * Hands the title-bar band back to the window while an alert dialog is open.+ *+ * `AlertDialogOverlay` blankets the viewport with `-webkit-app-region: no-drag`,+ * which also neutralizes the chrome-row drag regions underneath it — so an open+ * alert dialog leaves an Electron window immovable until it is answered.+ * Painting a `drag` strip over that band restores it.+ *+ * MUST stay between the overlay and the content, at the same z-index as both.+ * App-region resolves topmost-first and equal-z positioned elements paint in DOM+ * order, so that one position is what lets the strip beat the overlay while+ * still losing to the dialog itself. Moved above the content, it would turn the+ * top of a viewport-tall dialog — its heading, any header control — into a drag+ * region and swallow those clicks, which is the exact failure `no-drag` on the+ * content exists to prevent.+ *+ * `pointer-events-none` keeps the strip out of DOM hit-testing while+ * `-webkit-app-region` still resolves at the compositor — the same pairing the+ * editor-window chrome strip uses. `data-electron-drag` opts it into the+ * `globals.css` rule that suspends drag while a popper floater is open, so a+ * menu opened from inside the dialog stays dismissable by clicking the band.+ *+ * Deliberately not offered on plain `Dialog`, which dismisses on outside click:+ * a drag region swallows that gesture for the pixels it covers, and dialogs that+ * dismiss differently depending on which one you opened is a worse trade than a+ * window you cannot move. An alert dialog has no outside-click dismissal to lose+ * (Radix preventDefaults it), so the strip costs it nothing.+ */+function AlertDialogDragStrip() {+ if (typeof window === 'undefined' || window.okDesktop == null) return null;+ return (+ <div+ aria-hidden="true"+ data-testid="alert-dialog-drag-strip"+ data-electron-drag=""+ className="pointer-events-none fixed inset-x-0 top-0 z-50 h-12 [-webkit-app-region:drag]"+ />+ );+}+function AlertDialogContent({className,...props@@ -77,6 +117,8 @@ function AlertDialogContent({return (<AlertDialogPortal><AlertDialogOverlay />+ {/* Between overlay and content, deliberately — see AlertDialogDragStrip. */}+ <AlertDialogDragStrip /><AlertDialogPrimitive.Contentdata-slot="alert-dialog-content"// No close affordance in the corner, by design: an alert dialog offersdiff --git a/packages/app/src/lib/mcp-consent-store.test.ts b/packages/app/src/lib/mcp-consent-store.test.tsindex c4b07f012..99e8bd512 100644--- a/packages/app/src/lib/mcp-consent-store.test.ts+++ b/packages/app/src/lib/mcp-consent-store.test.ts@@ -67,6 +67,7 @@ function makeBridge(}const sampleShowPayload: OkMcpWiringShowPayload = {+ origin: 'first-run',detectedEditors: [{id: 'claude',diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.poindex 11f3ed4b8..ae1bf605f 100644--- a/packages/app/src/locales/ar/messages.po+++ b/packages/app/src/locales/ar/messages.po@@ -2280,6 +2280,7 @@ msgstr "تعذّرت مشاركة هذا المسار."#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.poindex 96762d272..494e22959 100644--- a/packages/app/src/locales/bn/messages.po+++ b/packages/app/src/locales/bn/messages.po@@ -2276,6 +2276,7 @@ msgstr "এই পাথ শেয়ার করা যাচ্ছে না#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.poindex 5f0011d51..e7db88cda 100644--- a/packages/app/src/locales/en/messages.po+++ b/packages/app/src/locales/en/messages.po@@ -2280,6 +2280,7 @@ msgstr "Can't share this path."#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.poindex 66a5bc0e1..b6091311c 100644--- a/packages/app/src/locales/es/messages.po+++ b/packages/app/src/locales/es/messages.po@@ -2280,6 +2280,7 @@ msgstr "No se puede compartir esta ruta."#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.poindex d2041160b..e0a0bd330 100644--- a/packages/app/src/locales/fr/messages.po+++ b/packages/app/src/locales/fr/messages.po@@ -2280,6 +2280,7 @@ msgstr "Impossible de partager ce chemin."#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.poindex 3238c2372..30b7e4b85 100644--- a/packages/app/src/locales/hi/messages.po+++ b/packages/app/src/locales/hi/messages.po@@ -2276,6 +2276,7 @@ msgstr "यह पथ साझा नहीं किया जा सकता#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.poindex 3c622cadc..d915f245f 100644--- a/packages/app/src/locales/id/messages.po+++ b/packages/app/src/locales/id/messages.po@@ -2276,6 +2276,7 @@ msgstr "Tidak dapat membagikan jalur ini."#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/ko/messages.po b/packages/app/src/locales/ko/messages.poindex 616530909..0d62f8aa1 100644--- a/packages/app/src/locales/ko/messages.po+++ b/packages/app/src/locales/ko/messages.po@@ -2280,6 +2280,7 @@ msgstr "이 경로는 공유할 수 없습니다."#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.poindex 5391f2fe6..a731fc195 100644--- a/packages/app/src/locales/pseudo/messages.po+++ b/packages/app/src/locales/pseudo/messages.po@@ -2276,6 +2276,7 @@ msgstr ""#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.poindex 13ba330d2..165e6f5a9 100644--- a/packages/app/src/locales/pt-BR/messages.po+++ b/packages/app/src/locales/pt-BR/messages.po@@ -2276,6 +2276,7 @@ msgstr "Não é possível compartilhar este caminho."#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.poindex acead80d9..94a80b884 100644--- a/packages/app/src/locales/ur/messages.po+++ b/packages/app/src/locales/ur/messages.po@@ -2280,6 +2280,7 @@ msgstr "یہ راستہ شیئر نہیں کیا جا سکتا۔"#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.poindex 0be967a79..b61efdd8c 100644--- a/packages/app/src/locales/zh-Hans/messages.po+++ b/packages/app/src/locales/zh-Hans/messages.po@@ -2280,6 +2280,7 @@ msgstr "无法共享此路径。"#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.poindex 9daf83ec7..39fa31f28 100644--- a/packages/app/src/locales/zh-Hant/messages.po+++ b/packages/app/src/locales/zh-Hant/messages.po@@ -2280,6 +2280,7 @@ msgstr "無法分享這個路徑。"#: src/components/FrontmatterRow.tsx#: src/components/ImportSkillForm.tsx#: src/components/InstallInClaudeDesktopDialog.tsx+#: src/components/McpConsentDialogBody.tsx#: src/components/MountStalledAffordance.tsx#: src/components/NewItemDialog.tsx#: src/components/NewSkillDialog.tsxdiff --git a/packages/core/src/bridge/bind-frontmatter-doc.ts b/packages/core/src/bridge/bind-frontmatter-doc.tsindex d7a845280..dfd95ef49 100644--- a/packages/core/src/bridge/bind-frontmatter-doc.ts+++ b/packages/core/src/bridge/bind-frontmatter-doc.ts@@ -1,3 +1,4 @@+import type * as Y from 'yjs';import type { Err, Ok, Result } from '../config/result.ts';import { type FrontmatterValidationError, toFrontmatterIssue } from '../frontmatter/errors.ts';diff --git a/packages/core/src/bridge/bridge-invariant.ts b/packages/core/src/bridge/bridge-invariant.tsindex 005627195..8bfdb40cd 100644--- a/packages/core/src/bridge/bridge-invariant.ts+++ b/packages/core/src/bridge/bridge-invariant.ts@@ -1,3 +1,4 @@+import { fnv1aDigest } from './hash-util.ts';export type BridgeInvariantSite = 'observer-b' | 'persistence' | 'test-harness';diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex f4cc8a286..2a597ec3d 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,3 +1,4 @@+import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/divergence-locate.ts b/packages/core/src/bridge/divergence-locate.tsindex 6b505314d..d979f4b39 100644--- a/packages/core/src/bridge/divergence-locate.ts+++ b/packages/core/src/bridge/divergence-locate.ts@@ -1,3 +1,4 @@+import { findFirstDivergenceIndex } from './tolerance-telemetry.ts';export const BRIDGE_LINE_KINDS = [diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex 8fb428b90..01ef76a9f 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,3 +1,4 @@+import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/bridge/growth-detect.ts b/packages/core/src/bridge/growth-detect.tsindex 9d9c244b0..463e89595 100644--- a/packages/core/src/bridge/growth-detect.ts+++ b/packages/core/src/bridge/growth-detect.ts@@ -1,3 +1,4 @@+const DEFAULT_MIN_SUBSTANTIVE_LINE_LENGTH = 16;export const DUPLICATION_GATE_MIN_LINE_LENGTH = 8;diff --git a/packages/core/src/bridge/intraline-predicate.ts b/packages/core/src/bridge/intraline-predicate.tsindex c43fdd7e7..0939885bb 100644--- a/packages/core/src/bridge/intraline-predicate.ts+++ b/packages/core/src/bridge/intraline-predicate.ts@@ -1,3 +1,4 @@+export function rawLineCounts(doc: string): Map<string, number> {const counts = new Map<string, number>();for (const line of doc.split('\n')) {diff --git a/packages/core/src/bridge/merge-three-way.ts b/packages/core/src/bridge/merge-three-way.tsindex 251560a35..c0dc65705 100644--- a/packages/core/src/bridge/merge-three-way.ts+++ b/packages/core/src/bridge/merge-three-way.ts@@ -65,6 +65,7 @@ export function tryLineLevelCombine(return { clean: true, merged };}+export type BridgeMergeContentLossSide = 'user' | 'agent';export type BridgeMergeContentLossWhich = 'substring' | 'order' | 'growth';diff --git a/packages/core/src/bridge/normalize.ts b/packages/core/src/bridge/normalize.tsindex 01ac80099..dcc5b0690 100644--- a/packages/core/src/bridge/normalize.ts+++ b/packages/core/src/bridge/normalize.ts@@ -1,3 +1,4 @@+import { stripFrontmatter } from '../extensions/frontmatter.ts';import { bodyEdgeEmpties } from './doc-boundary-space.ts';diff --git a/packages/core/src/bridge/pm-structural-equivalence.ts b/packages/core/src/bridge/pm-structural-equivalence.tsindex 754dc5cc2..0be5203e4 100644--- a/packages/core/src/bridge/pm-structural-equivalence.ts+++ b/packages/core/src/bridge/pm-structural-equivalence.ts@@ -32,6 +32,7 @@ const BR_SENTINEL: PmStructuralNode = { type: '__br__' };const BR_LITERAL_RE = /^<br\s*\/?>$/i;+interface DegradeEntry {readonly label: string;readonly severity: ToleranceClassSeverity;@@ -127,6 +128,7 @@ export interface ComparePmStructuralOptions {ignoreAttrs?: (attrKey: string) => boolean;}+/** Rebuild a node with `fn` applied to each child; identity when childless.* Shared by the degrade canonicalizers so none re-implements the walk. */function mapChildren(@@ -248,6 +250,7 @@ function applyDegrades(tree: PmStructuralNode): {return { normalized: current, fired };}+export function comparePmStructural(expected: PmStructuralNode,actual: PmStructuralNode,diff --git a/packages/core/src/bridge/subsequence.ts b/packages/core/src/bridge/subsequence.tsindex af20de1e2..dca644141 100644--- a/packages/core/src/bridge/subsequence.ts+++ b/packages/core/src/bridge/subsequence.ts@@ -1,3 +1,4 @@+/** True when `needle` is a subsequence of `haystack` (two-pointer, O(n+m)):* insertions in `haystack` are free; any dropped or substituted `needle` byte* fails. */diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.tsindex b5f97051f..6e98a33dc 100644--- a/packages/core/src/desktop-bridge.ts+++ b/packages/core/src/desktop-bridge.ts@@ -533,6 +533,16 @@ export type OkMcpWiringEditorId = EditorId;* would edit.*/export interface OkMcpWiringShowPayload {+ /**+ * Which of the two situations this showing is. `'first-run'` is the+ * unsolicited one — the app raised the dialog by itself because no decision+ * has ever been recorded — and it is the only one that warrants a dialog the+ * user cannot wave away. Every other entry point (command palette, in-app+ * menu bar, native File menu, the Claude readiness banner's "Connect tools")+ * is the user asking for this screen, and reports `'reconfigure'`, which the+ * dialog renders as an ordinary dismissible surface.+ */+ readonly origin: 'first-run' | 'reconfigure';readonly detectedEditors: readonly {readonly id: OkMcpWiringEditorId;readonly label: string;diff --git a/packages/core/src/markdown/callout-transformer.ts b/packages/core/src/markdown/callout-transformer.tsindex 83d47404a..a363dfd54 100644--- a/packages/core/src/markdown/callout-transformer.ts+++ b/packages/core/src/markdown/callout-transformer.ts@@ -1,3 +1,4 @@+import type { Blockquote, Paragraph, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/code-fence.ts b/packages/core/src/markdown/code-fence.tsindex 9807a7e82..4499dbc92 100644--- a/packages/core/src/markdown/code-fence.ts+++ b/packages/core/src/markdown/code-fence.ts@@ -1,3 +1,4 @@+export function selectFenceChar(info: string): '`' | '~' {return info.includes('`') ? '~' : '`';}diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex 7415c474a..34704165b 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/dedent-block-jsx-close.ts b/packages/core/src/markdown/dedent-block-jsx-close.tsindex ece5c02a1..b6299a948 100644--- a/packages/core/src/markdown/dedent-block-jsx-close.ts+++ b/packages/core/src/markdown/dedent-block-jsx-close.ts@@ -1,3 +1,4 @@+import { findFencedRegions, isInsideFence } from './fence-regions.ts';const INDENTED_BLOCK_JSX_CLOSE_RE = /^([ ]{1,3})(<\/[A-Z][A-Za-z0-9_]*\s*>)([ \t]*)$/gm;diff --git a/packages/core/src/markdown/details-accordion-promoter.ts b/packages/core/src/markdown/details-accordion-promoter.tsindex 54774764a..acd398aa6 100644--- a/packages/core/src/markdown/details-accordion-promoter.ts+++ b/packages/core/src/markdown/details-accordion-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/div-align-promoter.ts b/packages/core/src/markdown/div-align-promoter.tsindex 43ecdc709..ba9b56384 100644--- a/packages/core/src/markdown/div-align-promoter.ts+++ b/packages/core/src/markdown/div-align-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, Parent, Root, Text } from 'mdast';import type { MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/fence-regions.ts b/packages/core/src/markdown/fence-regions.tsindex 6d3f3643e..4513da9bb 100644--- a/packages/core/src/markdown/fence-regions.ts+++ b/packages/core/src/markdown/fence-regions.ts@@ -1,3 +1,4 @@+const FENCE_RE = /^(`{3,}|~{3,})/gm;export function findFencedRegions(src: string): Array<[number, number]> {diff --git a/packages/core/src/markdown/fixtures/index.ts b/packages/core/src/markdown/fixtures/index.tsindex 00f5771ee..6931623c7 100644--- a/packages/core/src/markdown/fixtures/index.ts+++ b/packages/core/src/markdown/fixtures/index.ts@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -8,6 +9,7 @@ function fixturePath(...segments: string[]): string {return resolve(FIXTURES_DIR, ...segments);}+interface GfmExample {section: string;markdown: string;@@ -17,6 +19,7 @@ export function loadGfmExamples(): GfmExample[] {return JSON.parse(readFileSync(fixturePath('gfm', 'examples.json'), 'utf8')) as GfmExample[];}+interface MdxCrashEntry {id: string;input: string;@@ -68,6 +71,7 @@ export function loadLargeEmbedFixtures(): LargeEmbedFixture[] {) as LargeEmbedFixture[];}+export function loadPrd6955Before(): string {return readFileSync(fixturePath('regression', 'prd-6955-before.md'), 'utf8');}@@ -76,6 +80,7 @@ export function loadPrd6955CorruptedTriplicated(): string {return readFileSync(fixturePath('regression', 'prd-6955-corrupted-triplicated.md'), 'utf8');}+export interface NgPinnedCase {id: string;name: string;@@ -92,6 +97,7 @@ export function loadNgPinnedCases(): NgPinnedCase[] {) as NgPinnedCase[];}+export function loadLargeRealistic(): string {return readFileSync(fixturePath('perf', 'large-realistic.md'), 'utf8');}diff --git a/packages/core/src/markdown/fixtures/perf/generate.ts b/packages/core/src/markdown/fixtures/perf/generate.tsindex 8b1eb8519..daa3ef82b 100644--- a/packages/core/src/markdown/fixtures/perf/generate.ts+++ b/packages/core/src/markdown/fixtures/perf/generate.ts@@ -1,3 +1,4 @@+import { writeFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';@@ -10,6 +11,7 @@ const BASELINE_ONLY_COUNTS = [500, 2500] as const;const SEED = 0xf1de1117;+function mulberry32(seed: number): () => number {let a = seed >>> 0;return () => {@@ -36,6 +38,7 @@ function pickWeighted<T>(rand: () => number, items: readonly [T, number][]): T {return items[items.length - 1][0];}+const WORDS = ['lorem','ipsum',@@ -153,6 +156,7 @@ function mdxBlock(rand: () => number): string {return `<${name}>\n\n${sentence(rand)}\n\n</${name}>`;}+type BlockKind = 'paragraph' | 'heading' | 'list' | 'code' | 'table' | 'mdx';const MIX: readonly [BlockKind, number][] = [@@ -191,6 +195,7 @@ function generateDocument(blockCount: number, seed: number): string {return `${blocks.join('\n\n')}\n`;}+function main(): void {for (const count of [...BLOCK_COUNTS, ...BASELINE_ONLY_COUNTS]) {const doc = generateDocument(count, SEED);diff --git a/packages/core/src/markdown/guard-flanking-matrix.ts b/packages/core/src/markdown/guard-flanking-matrix.tsindex 420dc0fe5..32c055c5b 100644--- a/packages/core/src/markdown/guard-flanking-matrix.ts+++ b/packages/core/src/markdown/guard-flanking-matrix.ts@@ -7,6 +7,7 @@ import {import { BACKSLASH_GUARD_SUBSTITUTIONS, encodeBackslashEscapes } from './backslash-escape-guard.ts';import { ENTITY_REF_GUARD_SUBSTITUTIONS, encodeEntityRefs } from './entity-ref-guard.ts';+export const ATTENTION_DELIMITERS = ['*', '_', '**', '~~', '=='] as const;export type FlankClass = 'whitespace' | 'punctuation' | 'other';diff --git a/packages/core/src/markdown/handler-shadow-audit.ts b/packages/core/src/markdown/handler-shadow-audit.tsindex 2653473da..283913255 100644--- a/packages/core/src/markdown/handler-shadow-audit.ts+++ b/packages/core/src/markdown/handler-shadow-audit.ts@@ -1,3 +1,4 @@+export interface HandlerShadowWitness {input: string;expect: 'byte' | 'byte-and-reparse-type';diff --git a/packages/core/src/markdown/highlight-promoter.ts b/packages/core/src/markdown/highlight-promoter.tsindex da0a81d23..5d1000cc4 100644--- a/packages/core/src/markdown/highlight-promoter.ts+++ b/packages/core/src/markdown/highlight-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, PhrasingContent, Root, Text } from 'mdast';import type { MdxJsxTextElement } from 'mdast-util-mdx';import { SKIP, visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/html-to-mdast.ts b/packages/core/src/markdown/html-to-mdast.tsindex 787315157..9681c0056 100644--- a/packages/core/src/markdown/html-to-mdast.ts+++ b/packages/core/src/markdown/html-to-mdast.ts@@ -1,3 +1,4 @@+import type { Element as HastElement, Root as HastRoot } from 'hast';import type { List, Nodes as MdastNodes, Root as MdastRoot } from 'mdast';import rehypeParse from 'rehype-parse';@@ -128,7 +129,8 @@ export function htmlToMdast(html: string, options?: HtmlToMdastOptions): MdastRothrow new HtmlPayloadTooLargeError(html.length, maxBytes);}- const processor = unified().use(rehypeParse, { fragment: true });+ const processor = unified()+ .use(rehypeParse, { fragment: true });for (const plugin of cleanupPlugins) {processor.use(plugin);diff --git a/packages/core/src/markdown/image-promoter.ts b/packages/core/src/markdown/image-promoter.tsindex 706fa9afb..994eb6917 100644--- a/packages/core/src/markdown/image-promoter.ts+++ b/packages/core/src/markdown/image-promoter.ts@@ -1,3 +1,4 @@+import type { Image, Paragraph, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/index.ts b/packages/core/src/markdown/index.tsindex 779e27500..ec1ac1b7e 100644--- a/packages/core/src/markdown/index.ts+++ b/packages/core/src/markdown/index.ts@@ -1,3 +1,4 @@+import {type FromProseMirrorOptions,fromPmMark,@@ -206,6 +207,7 @@ export class MarkdownManager {}}+const registry = createRegistry();function destructureAttrs(@@ -254,6 +256,7 @@ function destructureAttrs(return result;}+function hasDirtyDescendant(node: PmNode): boolean {let found = false;node.descendants((child) => {@@ -276,6 +279,7 @@ function effectiveDirty(node: PmNode, freshnessChecker?: StructuralFreshnessChecreturn freshnessChecker ? freshnessChecker.isDiverged(node.toJSON()) : false;}+function isEmptyMdastParagraph(node: MdastNodes): boolean {if (node.type !== 'paragraph') return false;const children = node.children ?? [];@@ -344,6 +348,7 @@ function extractTextFromMdastNodes(nodes: MdastNodes[]): string {return out;}+import {AUDIO_EXTENSIONS,FILE_ATTACHMENT_EXTENSIONS,@@ -596,6 +601,7 @@ function buildMdastToPmHandlers(}));}+if (m.emphasis) {handlers.emphasis = toPmMark(m.emphasis, (node: Emphasis) => ({sourceDelimiter: node.data?.sourceDelimiter ?? '*',@@ -676,6 +682,7 @@ function buildMdastToPmHandlers(}));}+if (m.link) {const sourceLiteralMark = m.sourceLiteral;handlers.link = (node: Link, _parent: MdastParent, state: MdastToPmState) => {@@ -973,6 +980,7 @@ function buildMdastToPmHandlers(};}+const blockUnknownHandler = (node: {type: string;position?: { start: { offset: number }; end: { offset: number } };@@ -1098,6 +1106,7 @@ function buildMdastToPmHandlers(return handlers as RemarkProseMirrorOptions['handlers'];}+function buildPmToMdastHandlers(schema: Schema,freshness: FreshnessCheckerHolder,diff --git a/packages/core/src/markdown/lint/applies-to.ts b/packages/core/src/markdown/lint/applies-to.tsindex fa0be9e86..b79e9aef7 100644--- a/packages/core/src/markdown/lint/applies-to.ts+++ b/packages/core/src/markdown/lint/applies-to.ts@@ -1,3 +1,4 @@+import picomatch from 'picomatch';import { SUPPORTED_DOC_EXTENSIONS } from '../../constants/doc-extensions.ts';diff --git a/packages/core/src/markdown/lint/config-files.ts b/packages/core/src/markdown/lint/config-files.tsindex 312c9c74b..94b34dee1 100644--- a/packages/core/src/markdown/lint/config-files.ts+++ b/packages/core/src/markdown/lint/config-files.ts@@ -1,3 +1,4 @@+const MARKDOWNLINT_JSON_CONFIG_FILES: ReadonlySet<string> = new Set(['.markdownlint.json','.markdownlint.jsonc',diff --git a/packages/core/src/markdown/lint/config-schemas.ts b/packages/core/src/markdown/lint/config-schemas.tsindex 1a81aa524..fbbd309df 100644--- a/packages/core/src/markdown/lint/config-schemas.ts+++ b/packages/core/src/markdown/lint/config-schemas.ts@@ -52,6 +52,7 @@ const fullPluginShape = Object.fromEntries(LINT_PLUGINS.map((plugin) => [plugin.id, plugin.sliceSchema]),) as z.ZodRawShape;+export const LinterConfigSchema = z.object({enabled: z.boolean(),plugins: z.object(fullPluginShape),diff --git a/packages/core/src/markdown/lint/default-config.ts b/packages/core/src/markdown/lint/default-config.tsindex d48eea5e4..a51f2ffb0 100644--- a/packages/core/src/markdown/lint/default-config.ts+++ b/packages/core/src/markdown/lint/default-config.ts@@ -6,6 +6,7 @@ export const DEFAULT_MARKDOWNLINT_CONFIG: Record<string, MarkdownlintRuleSettingMD013: false,};+export function resolveMarkdownlintConfig(rules: Record<string, MarkdownlintRuleSetting> | undefined,): Configuration {diff --git a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts b/packages/core/src/markdown/lint/frontmatter-schema-edit.tsindex ef478e268..9c9542661 100644--- a/packages/core/src/markdown/lint/frontmatter-schema-edit.ts+++ b/packages/core/src/markdown/lint/frontmatter-schema-edit.ts@@ -1,3 +1,4 @@+import { CANONICAL_SCHEMA_DIALECT_URIS, DEFAULT_SCHEMA_DIALECT } from './frontmatter-validate.ts';export interface FrontmatterFieldConstraint {diff --git a/packages/core/src/markdown/lint/frontmatter-validate.ts b/packages/core/src/markdown/lint/frontmatter-validate.tsindex 5f953d667..b0e7833fd 100644--- a/packages/core/src/markdown/lint/frontmatter-validate.ts+++ b/packages/core/src/markdown/lint/frontmatter-validate.ts@@ -1,3 +1,4 @@+import Ajv, { type ValidateFunction } from 'ajv';import Ajv2019 from 'ajv/dist/2019.js';import Ajv2020 from 'ajv/dist/2020.js';diff --git a/packages/core/src/markdown/lint/index.ts b/packages/core/src/markdown/lint/index.tsindex 11b5abdfd..ffd277a90 100644--- a/packages/core/src/markdown/lint/index.ts+++ b/packages/core/src/markdown/lint/index.ts@@ -1,3 +1,4 @@+import { LINT_PLUGINS, type LinterConfig } from './plugins.ts';import type { LintDiagnostic } from './types.ts';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts b/packages/core/src/markdown/lint/okf-frontmatter/materialize.tsindex 7a5af097e..f438f1b16 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/materialize.ts@@ -1,3 +1,4 @@+import type { OkfRuleId } from '../okf-rule-meta.ts';import { fileNameFor, OKF_SCHEMA_DIR, okfSchemaPathFor } from './paths.ts';import { OKF_FRONTMATTER_REGISTRY } from './registry.ts';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/paths.ts b/packages/core/src/markdown/lint/okf-frontmatter/paths.tsindex 1ee913527..c290b6878 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/paths.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/paths.ts@@ -1,3 +1,4 @@+import type { OkfRuleId } from '../okf-rule-meta.ts';export const OKF_SCHEMA_DIR = '.ok/okf';diff --git a/packages/core/src/markdown/lint/okf-frontmatter/registry.ts b/packages/core/src/markdown/lint/okf-frontmatter/registry.tsindex f325fbbb4..53ecb619d 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/registry.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/registry.ts@@ -1,3 +1,4 @@+import { compileAppliesTo } from '../applies-to.ts';import { validateFrontmatterSource } from '../frontmatter-validate.ts';import {diff --git a/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts b/packages/core/src/markdown/lint/okf-frontmatter/schemas.tsindex f1c37671b..89845d3d5 100644--- a/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts+++ b/packages/core/src/markdown/lint/okf-frontmatter/schemas.ts@@ -1,3 +1,4 @@+// file-level form is deliberate: the sibling `biome-ignore` must sit on the line// oxlint-disable unicorn/no-thenablediff --git a/packages/core/src/markdown/lint/okf-project/rules.ts b/packages/core/src/markdown/lint/okf-project/rules.tsindex 6d691ae2b..8b476332e 100644--- a/packages/core/src/markdown/lint/okf-project/rules.ts+++ b/packages/core/src/markdown/lint/okf-project/rules.ts@@ -1,3 +1,4 @@+import { SUPPORTED_DOC_EXTENSIONS } from '../../../constants/doc-extensions.ts';import { isOkfRuleEnabled, type OkfRuleId, type OkfRuleToggles } from '../okf-rule-meta.ts';diff --git a/packages/core/src/markdown/lint/okf-rule-meta.ts b/packages/core/src/markdown/lint/okf-rule-meta.tsindex 4de50d79f..44913a9dc 100644--- a/packages/core/src/markdown/lint/okf-rule-meta.ts+++ b/packages/core/src/markdown/lint/okf-rule-meta.ts@@ -1,3 +1,4 @@+export const OKF_RULE_IDS = ['no-wiki-links','log-shape',diff --git a/packages/core/src/markdown/lint/okf-rules.ts b/packages/core/src/markdown/lint/okf-rules.tsindex 1d5538421..d0999b62e 100644--- a/packages/core/src/markdown/lint/okf-rules.ts+++ b/packages/core/src/markdown/lint/okf-rules.ts@@ -1,3 +1,4 @@+import { isOkfRuleEnabled, type OkfRuleId, type OkfRuleToggles } from './okf-rule-meta.ts';import type { OkfRule } from './okf-runner.ts';import { indexShape } from './rules/index-shape.ts';diff --git a/packages/core/src/markdown/lint/okf-runner.ts b/packages/core/src/markdown/lint/okf-runner.tsindex de130e3f4..fabb08d6e 100644--- a/packages/core/src/markdown/lint/okf-runner.ts+++ b/packages/core/src/markdown/lint/okf-runner.ts@@ -1,3 +1,4 @@+import type { Root } from 'mdast';import remarkFrontmatter from 'remark-frontmatter';import remarkGfm from 'remark-gfm';diff --git a/packages/core/src/markdown/lint/plugins.ts b/packages/core/src/markdown/lint/plugins.tsindex 09c8450ee..0a089990e 100644--- a/packages/core/src/markdown/lint/plugins.ts+++ b/packages/core/src/markdown/lint/plugins.ts@@ -1,3 +1,4 @@+import { z } from 'zod';import { DEFAULT_MARKDOWNLINT_CONFIG, resolveMarkdownlintConfig } from './default-config.ts';import {@@ -23,6 +24,7 @@ import {type OkfSlice,} from './types.ts';+const MarkdownlintRuleSettingSchema = z.union([z.boolean(),z.enum(MARKDOWNLINT_RULE_SEVERITIES),diff --git a/packages/core/src/markdown/lint/rules/index-shape.ts b/packages/core/src/markdown/lint/rules/index-shape.tsindex 59fe9b87d..fcbb1b56c 100644--- a/packages/core/src/markdown/lint/rules/index-shape.ts+++ b/packages/core/src/markdown/lint/rules/index-shape.ts@@ -1,3 +1,4 @@+import type { List, ListItem } from 'mdast';import { EXIT, visit } from 'unist-util-visit';import { defineScopedOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/rules/log-shape.ts b/packages/core/src/markdown/lint/rules/log-shape.tsindex e0159519f..431e4e9c8 100644--- a/packages/core/src/markdown/lint/rules/log-shape.ts+++ b/packages/core/src/markdown/lint/rules/log-shape.ts@@ -1,3 +1,4 @@+import type { Heading } from 'mdast';import { toString as headingText } from 'mdast-util-to-string';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/lint/rules/no-wiki-links.ts b/packages/core/src/markdown/lint/rules/no-wiki-links.tsindex 2123e977f..f75a04d15 100644--- a/packages/core/src/markdown/lint/rules/no-wiki-links.ts+++ b/packages/core/src/markdown/lint/rules/no-wiki-links.ts@@ -1,3 +1,4 @@+import type { Point } from 'unist';import { visit } from 'unist-util-visit';import { defineOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/rules/reserved-casing.ts b/packages/core/src/markdown/lint/rules/reserved-casing.tsindex 89ef3e4a9..c8b4d8f28 100644--- a/packages/core/src/markdown/lint/rules/reserved-casing.ts+++ b/packages/core/src/markdown/lint/rules/reserved-casing.ts@@ -1,3 +1,4 @@+import { SUPPORTED_DOC_EXTENSIONS } from '../../../constants/doc-extensions.ts';import { defineOkfRule } from '../okf-runner.ts';diff --git a/packages/core/src/markdown/lint/types.ts b/packages/core/src/markdown/lint/types.tsindex 6836b962d..c04fa4de0 100644--- a/packages/core/src/markdown/lint/types.ts+++ b/packages/core/src/markdown/lint/types.ts@@ -1,3 +1,4 @@+import type { BrokenLinkReason } from '../../schemas/api/agent-write.ts';import type { OkfRuleId } from './okf-rule-meta.ts';@@ -112,6 +113,7 @@ export interface OkfSlice {generate?: { index?: boolean };}+interface RuleOptionSpecBase {key: string;description: string;diff --git a/packages/core/src/markdown/lint/validation-counts.ts b/packages/core/src/markdown/lint/validation-counts.tsindex 98238656e..437cc539a 100644--- a/packages/core/src/markdown/lint/validation-counts.ts+++ b/packages/core/src/markdown/lint/validation-counts.ts@@ -1,3 +1,4 @@+export interface ValidationSourceCounts {errorCount: number;warningCount: number;diff --git a/packages/core/src/markdown/math-promoter.ts b/packages/core/src/markdown/math-promoter.tsindex a5b511f25..bd79424c7 100644--- a/packages/core/src/markdown/math-promoter.ts+++ b/packages/core/src/markdown/math-promoter.ts@@ -1,3 +1,4 @@+import type { Code, Root } from 'mdast';import type { Math as MdastMath } from 'mdast-util-math';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';diff --git a/packages/core/src/markdown/mdast-to-hast-handlers.ts b/packages/core/src/markdown/mdast-to-hast-handlers.tsindex ed89371d0..00fbc0035 100644--- a/packages/core/src/markdown/mdast-to-hast-handlers.ts+++ b/packages/core/src/markdown/mdast-to-hast-handlers.ts@@ -1,3 +1,4 @@+import type { Comment, Element, ElementContent, Properties } from 'hast';import type { FootnoteDefinition, FootnoteReference } from 'mdast';import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx';diff --git a/packages/core/src/markdown/mdast-to-html.ts b/packages/core/src/markdown/mdast-to-html.tsindex 8ce2b2492..df788a80d 100644--- a/packages/core/src/markdown/mdast-to-html.ts+++ b/packages/core/src/markdown/mdast-to-html.ts@@ -1,3 +1,4 @@+import type { Element, Root as HastRoot, Text as HastText } from 'hast';import type { Root as MdastRoot, Text as MdastText } from 'mdast';import type { Handler } from 'mdast-util-to-hast';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex bfd7e3109..fa3cfcd86 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/mermaid-promoter.ts b/packages/core/src/markdown/mermaid-promoter.tsindex 1a897fca8..17ed2b829 100644--- a/packages/core/src/markdown/mermaid-promoter.ts+++ b/packages/core/src/markdown/mermaid-promoter.ts@@ -1,3 +1,4 @@+import type { Code, Root } from 'mdast';import type { MdxJsxAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/parse-with-fallback.ts b/packages/core/src/markdown/parse-with-fallback.tsindex d988f4b8b..4aa0490c4 100644--- a/packages/core/src/markdown/parse-with-fallback.ts+++ b/packages/core/src/markdown/parse-with-fallback.ts@@ -168,6 +168,7 @@ export function parseRecursive(}}+interface VFilePlace {offset?: number;start?: { offset?: number };@@ -186,6 +187,7 @@ function extractErrorOffset(err: unknown): number | undefined {return undefined;}+interface Region {start: number;end: number;@@ -209,6 +211,7 @@ function nearestBlankLineAfter(src: string, offset: number): number | null {return null;}+export interface TagEvent {kind: 'open' | 'close' | 'self-close';name: string;@@ -355,6 +358,7 @@ function findFallbackRegion(src: string, errorOffset: number): Region {return { start: blockStart, end: blockEnd };}+interface SourceBlock {src: string;start: number;@@ -452,6 +456,7 @@ function tryPerBlockFallback(};}+function wholeDocRawText(source: string): JSONContent {return {type: 'doc',diff --git a/packages/core/src/markdown/parser-drop-closure.ts b/packages/core/src/markdown/parser-drop-closure.tsindex e6ab4fd57..43d420187 100644--- a/packages/core/src/markdown/parser-drop-closure.ts+++ b/packages/core/src/markdown/parser-drop-closure.ts@@ -1,3 +1,4 @@+export type DroppedTokenAdjudication =| {kind: 'format-dof-axis';diff --git a/packages/core/src/markdown/pipeline.ts b/packages/core/src/markdown/pipeline.tsindex 0e3224206..55736041c 100644--- a/packages/core/src/markdown/pipeline.ts+++ b/packages/core/src/markdown/pipeline.ts@@ -1,3 +1,4 @@+import {type FromProseMirrorOptions,fromProseMirror,diff --git a/packages/core/src/markdown/position-aware-join.ts b/packages/core/src/markdown/position-aware-join.tsindex 91cdf658f..ccf06e94d 100644--- a/packages/core/src/markdown/position-aware-join.ts+++ b/packages/core/src/markdown/position-aware-join.ts@@ -1,3 +1,4 @@+import type { Join } from 'mdast-util-to-markdown';import type { Position } from 'unist';import { isBlankLineParagraph } from './zero-emission-blocks.ts';diff --git a/packages/core/src/markdown/position-slice.ts b/packages/core/src/markdown/position-slice.tsindex 0f399d34c..e5b4c9eba 100644--- a/packages/core/src/markdown/position-slice.ts+++ b/packages/core/src/markdown/position-slice.ts@@ -1,3 +1,4 @@+import type { Nodes, Root } from 'mdast';import { visit } from 'unist-util-visit';import type { VFile } from 'vfile';@@ -476,7 +477,8 @@ export function applyPositionSliceToNode(const first = source[startOff];if (first !== '[' && first !== '<' && !node.title) {node.data.sourceStyle = 'gfm-autolink';- } else if (first === '[') {+ }+ else if (first === '[') {const slice = source.slice(startOff, endOff);const closeBracketIdx = slice.lastIndexOf('](');if (closeBracketIdx !== -1) {diff --git a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.tsindex db10fa54b..ca225ce9b 100644--- a/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts+++ b/packages/core/src/markdown/rehype-plugins/skip-notion-whitespace.ts@@ -1,3 +1,4 @@+import type { Comment, Element, Root, Text } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.tsindex 34068d103..3a2524a9a 100644--- a/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-cocoa-meta.ts@@ -1,3 +1,4 @@+import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.tsindex 93151d43b..2279a0189 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gdocs-wrapper.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.tsindex 188f02d83..a0f467c42 100644--- a/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-github-hovercard.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.tsindex 4ba2c3418..4e8542a21 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gmail-classes.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.tsindex 1a74b1272..a3c96b24a 100644--- a/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-gsheets-wrapper.ts@@ -1,3 +1,4 @@+import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.tsindex de35e7b79..e95cf43d6 100644--- a/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-mso-styles.ts@@ -1,3 +1,4 @@+import type { Comment, Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.tsindex b4be1b2ea..ffdb4d5b5 100644--- a/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-slack-classes.ts@@ -1,3 +1,4 @@+import type { Element, ElementContent, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.tsindex 3c8d88b7c..e2a96d1a7 100644--- a/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts+++ b/packages/core/src/markdown/rehype-plugins/strip-vscode-spans.ts@@ -1,3 +1,4 @@+import type { Element, Root } from 'hast';import type { Plugin } from 'unified';diff --git a/packages/core/src/markdown/resolve-image-url.ts b/packages/core/src/markdown/resolve-image-url.tsindex cf2c9da8e..0389575ac 100644--- a/packages/core/src/markdown/resolve-image-url.ts+++ b/packages/core/src/markdown/resolve-image-url.ts@@ -1,3 +1,4 @@+import { isRelativeUrl } from './safe-url.ts';function isDevDiagnosticContext(): boolean {diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 4d3250d3a..8be632ba4 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,3 +1,4 @@+export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');diff --git a/packages/core/src/markdown/serialize-fidelity.test-helper.ts b/packages/core/src/markdown/serialize-fidelity.test-helper.tsindex 0dd54070e..96304e7a5 100644--- a/packages/core/src/markdown/serialize-fidelity.test-helper.ts+++ b/packages/core/src/markdown/serialize-fidelity.test-helper.ts@@ -1,3 +1,4 @@+import type { JSONContent } from '@tiptap/core';import type { Nodes } from 'mdast';import { expect } from 'vitest';diff --git a/packages/core/src/markdown/serialize-helpers.ts b/packages/core/src/markdown/serialize-helpers.tsindex 7cac5b042..93798cf83 100644--- a/packages/core/src/markdown/serialize-helpers.ts+++ b/packages/core/src/markdown/serialize-helpers.ts@@ -1,3 +1,4 @@+import type { Node as PmNode } from '@tiptap/pm/model';import type {MdxJsxAttribute,diff --git a/packages/core/src/markdown/single-dollar-math-promoter.ts b/packages/core/src/markdown/single-dollar-math-promoter.tsindex b012a5aff..8c08b7a04 100644--- a/packages/core/src/markdown/single-dollar-math-promoter.ts+++ b/packages/core/src/markdown/single-dollar-math-promoter.ts@@ -1,3 +1,4 @@+import type { PhrasingContent, Root, Text } from 'mdast';import type { InlineMath } from 'mdast-util-math';import { SKIP, visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/to-markdown-handlers.ts b/packages/core/src/markdown/to-markdown-handlers.tsindex 3e79f8cb6..959cc0bd2 100644--- a/packages/core/src/markdown/to-markdown-handlers.ts+++ b/packages/core/src/markdown/to-markdown-handlers.ts@@ -1,3 +1,4 @@+import type { Nodes, Parents } from 'mdast';import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxFlowElement } from 'mdast-util-mdx';import type { Handle, Info, State } from 'mdast-util-to-markdown';diff --git a/packages/core/src/markdown/underline-promoter.ts b/packages/core/src/markdown/underline-promoter.tsindex 0f1b0f27d..6e6d73400 100644--- a/packages/core/src/markdown/underline-promoter.ts+++ b/packages/core/src/markdown/underline-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, Root } from 'mdast';import type { MdxJsxTextElement } from 'mdast-util-mdx';import { visit } from 'unist-util-visit';diff --git a/packages/core/src/markdown/unknown-mdast-guard.ts b/packages/core/src/markdown/unknown-mdast-guard.tsindex 1a082bda7..932d7d2a8 100644--- a/packages/core/src/markdown/unknown-mdast-guard.ts+++ b/packages/core/src/markdown/unknown-mdast-guard.ts@@ -1,3 +1,4 @@+import type { Root as MdastRoot } from 'mdast';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/whitespace-char-ref.ts b/packages/core/src/markdown/whitespace-char-ref.tsindex d578476a7..ac9f5239b 100644--- a/packages/core/src/markdown/whitespace-char-ref.ts+++ b/packages/core/src/markdown/whitespace-char-ref.ts@@ -1,3 +1,4 @@+const INLINE_WHITESPACE_BY_CODE: ReadonlyMap<number, string> = new Map([[0x20, ' '],[0x09, '\t'],diff --git a/packages/core/src/markdown/wiki-link-micromark.ts b/packages/core/src/markdown/wiki-link-micromark.tsindex 6dad26200..afd9936fe 100644--- a/packages/core/src/markdown/wiki-link-micromark.ts+++ b/packages/core/src/markdown/wiki-link-micromark.ts@@ -17,6 +17,7 @@ declare module 'micromark-util-types' {}}+const CODE_BANG = 33; // !const CODE_LBRACKET = 91; // [const CODE_RBRACKET = 93; // ]@@ -260,6 +261,7 @@ export function wikiLinkSyntax(): Extension {};}+function enterWikiLink(this: CompileContext, token: Token) {this.enter({@@ -385,6 +387,7 @@ export const wikiLinkToMarkdown: {unsafe: [{ character: '[', inConstruct: ['phrasing'] }],};+const MICROMARK_EXT = wikiLinkSyntax();export function remarkWikiLink(this: Processor) {diff --git a/packages/desktop/src/main/mcp-wiring.test.ts b/packages/desktop/src/main/mcp-wiring.test.tsindex 3cd66625b..35128f34f 100644--- a/packages/desktop/src/main/mcp-wiring.test.ts+++ b/packages/desktop/src/main/mcp-wiring.test.ts@@ -884,6 +884,7 @@ describe('runMcpWiringOnFirstLaunch — mid-session immediate dispatch', () => {{channel: 'ok:mcp-wiring:show',payload: {+ origin: 'first-run',detectedEditors: [{id: 'claude',@@ -1085,6 +1086,32 @@ describe('runMcpWiringOnFirstLaunch — mid-session immediate dispatch', () => {});});+ test('forceShow marks the payload as user-initiated, the boot path as first-run', () => {+ // The renderer decides whether the dialog may be dismissed off this single+ // field, and `forceShow` is set by every user-initiated entry point and only+ // by those — so the two must not drift.+ const forced = fakeWebContents(31);+ runMcpWiringOnFirstLaunch(+ buildWiringOpts({+ ipcMain: stubIpcMain(),+ fs: memoryFs(),+ forceShow: true,+ immediateDispatchTarget: forced,+ }),+ );+ expect(forced.sent[0]?.payload).toMatchObject({ origin: 'reconfigure' });++ const booted = fakeWebContents(32);+ runMcpWiringOnFirstLaunch(+ buildWiringOpts({+ ipcMain: stubIpcMain(),+ fs: memoryFs(),+ immediateDispatchTarget: booted,+ }),+ );+ expect(booted.sent[0]?.payload).toMatchObject({ origin: 'first-run' });+ });+test('no immediate target preserves the boot-path mount-ack behavior', () => {const ipcMain = stubIpcMain();runMcpWiringOnFirstLaunch(buildWiringOpts({ ipcMain }));diff --git a/packages/desktop/src/main/mcp-wiring.ts b/packages/desktop/src/main/mcp-wiring.tsindex 4998872d4..f07874109 100644--- a/packages/desktop/src/main/mcp-wiring.ts+++ b/packages/desktop/src/main/mcp-wiring.ts@@ -1148,6 +1148,10 @@ export function runMcpWiringOnFirstLaunch(opts: RunMcpWiringFirstLaunchOpts): Ruconst dispatchShowAndBind = (target: McpWiringDispatchTarget): boolean => {try {sendToRenderer(target, 'ok:mcp-wiring:show', {+ // `forceShow` is set by every user-initiated entry point and only by+ // those, so it is exactly the first-run/reconfigure distinction the+ // dialog needs to decide whether it may be dismissed.+ origin: forceShow ? 'reconfigure' : 'first-run',detectedEditors: detections,pathInstall: pathDescriptor,globalSkills: skillDescriptors,diff --git a/packages/desktop/src/shared/ipc-events.ts b/packages/desktop/src/shared/ipc-events.tsindex 8b6d65ba9..7db86c580 100644--- a/packages/desktop/src/shared/ipc-events.ts+++ b/packages/desktop/src/shared/ipc-events.ts@@ -170,6 +170,10 @@ export interface EventChannels {*/'ok:mcp-wiring:show': {payload: {+ /** `'first-run'` only when the app raised this itself; every user-initiated+ * entry point reports `'reconfigure'`. Drives whether the dialog renders+ * as a locked alert or a dismissible one. */+ origin: 'first-run' | 'reconfigure';detectedEditors: readonly McpWiringEditorDetection[];pathInstall: McpWiringPathInstallDescriptor;globalSkills: readonly McpWiringGlobalSkillDescriptor[];