Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
feat(open-knowledge): Fix all with AI beside the deterministic Auto-fix (#3037)
serafin-garcia3af20cdbe713
diff --git a/.changeset/problems-fix-all-with-ai.md b/.changeset/problems-fix-all-with-ai.mdnew file mode 100644index 000000000..bc7974cd4--- /dev/null+++ b/.changeset/problems-fix-all-with-ai.md@@ -0,0 +1,7 @@+---+"@inkeep/open-knowledge": patch+---++The Problems panel now offers a **Fix all with AI** button beside the deterministic fixer, in both the document and project scopes. It hands the whole scope to your preferred AI agent as one instruction, pointing it at the `audit` tool for the current list of lint violations and broken links and at `lint` with `fix: true` for the mechanically-fixable subset, so the agent reads live truth rather than a snapshot taken when you clicked.++The deterministic button is now labelled **Auto-fix** rather than "Fix all", and both buttons explain themselves on hover. Previously a document whose problems had no automatic fix showed a single disabled "Fix all" with nothing to say for itself, which read as a bug rather than as "these need judgement"; now the AI action sits next to it, enabled, and the disabled Auto-fix says why it is off.diff --git a/packages/app/src/components/DocPanel.dom.test.tsx b/packages/app/src/components/DocPanel.dom.test.tsxindex 90961452b..7635e9d64 100644--- a/packages/app/src/components/DocPanel.dom.test.tsx+++ b/packages/app/src/components/DocPanel.dom.test.tsx@@ -151,7 +151,9 @@ describe('DocPanel — Problems fix/ask-ai wiring', () => {renderPanel('problems');expect(lastProblemsProps?.onAskAi).toBeUndefined();expect(typeof lastProblemsProps?.onFix).toBe('function');- expect(typeof lastProblemsProps?.onFixAll).toBe('function');+ expect(typeof lastProblemsProps?.onAutoFix).toBe('function');+ // Both AI hand-offs need somewhere to send the paste.+ expect(lastProblemsProps?.onFixWithAi).toBeUndefined();});test('desktop host (terminal launch available) passes onAskAi alongside the fix handlers', () => {@@ -159,7 +161,8 @@ describe('DocPanel — Problems fix/ask-ai wiring', () => {terminalLaunchValue = { launchInTerminal: () => {}, installedClis: {} };renderPanel('problems');expect(typeof lastProblemsProps?.onAskAi).toBe('function');- expect(typeof lastProblemsProps?.onFixAll).toBe('function');+ expect(typeof lastProblemsProps?.onAutoFix).toBe('function');+ expect(typeof lastProblemsProps?.onFixWithAi).toBe('function');});test('without a matching provider every fix/ask handler is withheld', () => {@@ -167,8 +170,11 @@ describe('DocPanel — Problems fix/ask-ai wiring', () => {terminalLaunchValue = { launchInTerminal: () => {}, installedClis: {} };renderPanel('problems');expect(lastProblemsProps?.onFix).toBeUndefined();- expect(lastProblemsProps?.onFixAll).toBeUndefined();+ expect(lastProblemsProps?.onAutoFix).toBeUndefined();expect(lastProblemsProps?.onAskAi).toBeUndefined();+ // The bulk hand-off is the exception: it reads nothing off the open doc's+ // CRDT, so a settling provider does not withhold it.+ expect(typeof lastProblemsProps?.onFixWithAi).toBe('function');});});diff --git a/packages/app/src/components/DocPanel.tsx b/packages/app/src/components/DocPanel.tsxindex b4d356bc0..d05e4cc83 100644--- a/packages/app/src/components/DocPanel.tsx+++ b/packages/app/src/components/DocPanel.tsx@@ -2,11 +2,15 @@ import { t } from '@lingui/core/macro';import { Trans, useLingui } from '@lingui/react/macro';import { AlertTriangle, Clock, Link2, ListTree, Network } from 'lucide-react';import { lazy, Suspense, useEffect } from 'react';-import { composeLintFixTerminalPaste } from '@/components/handoff/compose-lint-fix-prompt';+import {+ composeFixAllProblemsTerminalPaste,+ composeLintFixTerminalPaste,+} from '@/components/handoff/compose-lint-fix-prompt';import { useTerminalLaunch } from '@/components/handoff/TerminalLaunchContext';import { requestActiveTerminalInput } from '@/components/handoff/terminal-input-events';import { LinksPanel } from '@/components/LinksPanel';import { OutlinePanel } from '@/components/OutlinePanel';+import type { PanelScope } from '@/components/PanelScopeHeader';import { type DiagnosticLike, ProblemsPanel } from '@/components/ProblemsPanel';import { TimelineContent } from '@/components/TimelinePanel';import { Badge } from '@/components/ui/badge';@@ -125,9 +129,9 @@ export function DocPanel({applyLintFixes(lintProvider, diagnostic.fixes);}};- // Fix-all stays lint-only by construction: only the live lint diagnostics+ // Auto-fix stays lint-only by construction: only the live lint diagnostics// carry deterministic fixes (broken links need content edits).- const handleFixAll = () => {+ const handleAutoFix = () => {if (lintProvider !== null) {applyLintFixes(lintProvider, collectFixes(lintDiagnostics));}@@ -149,6 +153,17 @@ export function DocPanel({submit: true,});};+ // Bulk sibling of the per-row hand-off. Needs no `lintProvider`: the prompt+ // names a scope and the agent reads its own problem list, so nothing is read+ // out of the open doc's CRDT.+ const handleFixWithAi = (scope: PanelScope) => {+ requestActiveTerminalInput(+ composeFixAllProblemsTerminalPaste(scope === 'doc' ? docName : null),+ {+ submit: true,+ },+ );+ };// Single-file `ok <file>` keeps only the Outline + Problems tabs. Links/Graph// need a multi-doc knowledge base, and Timeline is git history — all empty or// inert for a lone git-off file; linting applies to any single file. Coerce a@@ -246,8 +261,9 @@ export function DocPanel({docName={docName}diagnostics={diagnostics}onFix={lintProvider !== null ? handleFix : undefined}- onFixAll={lintProvider !== null ? handleFixAll : undefined}+ onAutoFix={lintProvider !== null ? handleAutoFix : undefined}onAskAi={lintProvider !== null && terminalLaunch !== null ? handleAskAi : undefined}+ onFixWithAi={terminalLaunch !== null ? handleFixWithAi : undefined}/>)}</div>diff --git a/packages/app/src/components/ProblemsPanel.dom.test.tsx b/packages/app/src/components/ProblemsPanel.dom.test.tsxindex 5f4a4774d..c70e57aec 100644--- a/packages/app/src/components/ProblemsPanel.dom.test.tsx+++ b/packages/app/src/components/ProblemsPanel.dom.test.tsx@@ -8,8 +8,8 @@*/import type { LintDiagnostic, ValidationAuditResponse } from '@inkeep/open-knowledge-core';-import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';-import type { ReactNode } from 'react';+import { cleanup, fireEvent, render as rtlRender, screen, waitFor } from '@testing-library/react';+import type { ReactElement, ReactNode } from 'react';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';import { TooltipProvider } from '@/components/ui/tooltip';import { renderLinguiTemplate } from '@/test-utils/lingui-mock';@@ -163,6 +163,15 @@ afterEach(() => {window.location.hash = '';});+/**+ * Production mounts the panel under main.tsx's root TooltipProvider. The action+ * row's Auto-fix / Fix all with AI buttons always carry tooltips, so every+ * render here needs one — Radix throws without an ancestor provider.+ */+function render(ui: ReactElement) {+ return rtlRender(<TooltipProvider>{ui}</TooltipProvider>);+}+describe('ProblemsPanel', () => {test('shows the empty state when there are no diagnostics', () => {render(<ProblemsPanel docName="notes" diagnostics={[]} />);@@ -171,11 +180,7 @@ describe('ProblemsPanel', () => {test('a compact Checked-by line reveals the active plugins in a tooltip', async () => {projectLintConfigData = lintConfigWith({ markdownlint: true, frontmatter: true });- render(- <TooltipProvider>- <ProblemsPanel docName="notes" diagnostics={[]} />- </TooltipProvider>,- );+ render(<ProblemsPanel docName="notes" diagnostics={[]} />);const trigger = screen.getByTestId('problems-active-plugins');// The pill itself carries only the count — names live in the tooltip.expect(trigger.textContent).toContain('2 plugins');@@ -190,11 +195,7 @@ describe('ProblemsPanel', () => {test('only enabled plugins appear in the tooltip', async () => {projectLintConfigData = lintConfigWith({ markdownlint: true, frontmatter: false });- render(- <TooltipProvider>- <ProblemsPanel docName="notes" diagnostics={[]} />- </TooltipProvider>,- );+ render(<ProblemsPanel docName="notes" diagnostics={[]} />);const trigger = screen.getByTestId('problems-active-plugins');expect(trigger.textContent).toContain('1 plugin');fireEvent.focus(trigger);@@ -265,7 +266,7 @@ describe('ProblemsPanel', () => {expect(screen.queryByRole('button', { name: /Fix markdownlint/ })).toBeNull();});- test('doc-scope Fix all renders when onFixAll is provided and calls it on click', () => {+ test('doc-scope Auto-fix renders when onAutoFix is provided and calls it on click', () => {const fixable = diag({code: 'MD010',fixes: [@@ -276,17 +277,17 @@ describe('ProblemsPanel', () => {],});const unfixable = diag({ line: 5, code: 'MD025', message: 'Multiple H1' });- const onFixAll = vi.fn(() => {});+ const onAutoFix = vi.fn(() => {});render(- <ProblemsPanel docName="notes" diagnostics={[fixable, unfixable]} onFixAll={onFixAll} />,+ <ProblemsPanel docName="notes" diagnostics={[fixable, unfixable]} onAutoFix={onAutoFix} />,);- const button = screen.getByTestId('problems-fix-all') as HTMLButtonElement;+ const button = screen.getByTestId('problems-auto-fix') as HTMLButtonElement;expect(button.disabled).toBe(false);// The label sizes the click before it happens: only the fixable diagnostic// counts, not the total problem count.expect(button.textContent).toContain('(1)');button.click();- expect(onFixAll).toHaveBeenCalledTimes(1);+ expect(onAutoFix).toHaveBeenCalledTimes(1);});test('Ask AI renders on fixable AND unfixable rows only when onAskAi is provided', () => {@@ -318,27 +319,143 @@ describe('ProblemsPanel', () => {expect(screen.queryByTestId('problems-ask-ai')).toBeNull();});- test('doc-scope Fix all is disabled when no diagnostic is fixable', () => {- const onFixAll = vi.fn(() => {});+ test('doc-scope Auto-fix is disabled when no diagnostic is fixable', () => {+ const onAutoFix = vi.fn(() => {});render(<ProblemsPaneldocName="notes"diagnostics={[diag({ code: 'MD025', message: 'Multiple H1' })]}- onFixAll={onFixAll}+ onAutoFix={onAutoFix}/>,);- const disabledButton = screen.getByTestId('problems-fix-all') as HTMLButtonElement;+ const disabledButton = screen.getByTestId('problems-auto-fix') as HTMLButtonElement;expect(disabledButton.disabled).toBe(true);expect(disabledButton.textContent).toContain('(0)');});- test('doc-scope Fix all is absent without onFixAll or without diagnostics', () => {+ test('doc-scope Auto-fix is absent without onAutoFix or without diagnostics', () => {const { unmount } = render(<ProblemsPanel docName="notes" diagnostics={[diag({})]} />);- expect(screen.queryByTestId('problems-fix-all')).toBeNull();+ expect(screen.queryByTestId('problems-auto-fix')).toBeNull();unmount();// Empty state renders no action row at all.- render(<ProblemsPanel docName="notes" diagnostics={[]} onFixAll={vi.fn(() => {})} />);- expect(screen.queryByTestId('problems-fix-all')).toBeNull();+ render(<ProblemsPanel docName="notes" diagnostics={[]} onAutoFix={vi.fn(() => {})} />);+ expect(screen.queryByTestId('problems-auto-fix')).toBeNull();+ });++ test('doc-scope Fix all with AI counts every problem, not the unfixable remainder', () => {+ const fixable = diag({+ code: 'MD010',+ fixes: [+ {+ range: { start: { line: 2, character: 0 }, end: { line: 2, character: 1 } },+ newText: ' ',+ },+ ],+ });+ const unfixable = diag({ line: 5, code: 'MD025', message: 'Multiple H1' });+ const onFixWithAi = vi.fn(() => {});+ render(+ <ProblemsPanel+ docName="notes"+ diagnostics={[fixable, unfixable]}+ onAutoFix={vi.fn(() => {})}+ onFixWithAi={onFixWithAi}+ />,+ );+ const aiButton = screen.getByTestId('problems-fix-with-ai') as HTMLButtonElement;+ // The two buttons are "the mechanical subset" (1) and "the whole list" (2),+ // not two halves of a partition.+ expect(screen.getByTestId('problems-auto-fix').textContent).toContain('(1)');+ expect(aiButton.textContent).toContain('(2)');+ expect(aiButton.disabled).toBe(false);+ });++ test('doc-scope Fix all with AI reports its scope and ships no diagnostics', () => {+ const onFixWithAi = vi.fn(() => {});+ render(+ <ProblemsPanel+ docName="nested/notes"+ diagnostics={[diag({ line: 9, code: 'MD025' }), diag({ line: 2, code: 'MD010' })]}+ onFixWithAi={onFixWithAi}+ />,+ );+ screen.getByTestId('problems-fix-with-ai').click();+ // Scope only: the prompt names it and the agent reads its own list, so a+ // stale snapshot never travels with the hand-off.+ expect(onFixWithAi.mock.calls).toEqual([['doc']]);+ });++ test('doc-scope Fix all with AI is withheld on web (no onFixWithAi)', () => {+ render(+ <ProblemsPanel+ docName="notes"+ diagnostics={[diag({})]}+ onAutoFix={vi.fn(() => {})}+ onAskAi={undefined}+ />,+ );+ expect(screen.queryByTestId('problems-fix-with-ai')).toBeNull();+ });++ test('the actions row renders for AI alone when nothing is deterministically fixable', () => {+ render(+ <ProblemsPanel+ docName="notes"+ diagnostics={[diag({ code: 'MD025' })]}+ onFixWithAi={vi.fn(() => {})}+ />,+ );+ // Mike's case inverted: no Auto-fix affordance at all, but the panel still+ // offers an enabled action rather than looking inert.+ expect(screen.queryByTestId('problems-auto-fix')).toBeNull();+ expect((screen.getByTestId('problems-fix-with-ai') as HTMLButtonElement).disabled).toBe(false);+ });++ test('disabled Auto-fix names the reason in its accessible name', () => {+ render(+ <ProblemsPanel+ docName="notes"+ diagnostics={[diag({ code: 'MD025' })]}+ onAutoFix={vi.fn(() => {})}+ onFixWithAi={vi.fn(() => {})}+ />,+ );+ const button = screen.getByTestId('problems-auto-fix') as HTMLButtonElement;+ expect(button.disabled).toBe(true);+ // The tooltip describes the wrapper span (a disabled button emits no+ // pointer events), so the name is all a screen-reader user gets.+ expect(button.getAttribute('aria-label')).toContain('no problems here have an automatic fix');+ });++ test('the nothing-fixable tooltip withholds the AI pointer on web', async () => {+ render(+ <ProblemsPanel+ docName="notes"+ diagnostics={[diag({ code: 'MD025', message: 'Multiple H1' })]}+ onAutoFix={vi.fn(() => {})}+ />,+ );+ // The tooltip hangs off the wrapper span (a disabled button emits no+ // pointer events), so focus it rather than the control.+ fireEvent.focus(screen.getByTestId('problems-auto-fix').parentElement as HTMLElement);+ const tip = await screen.findByTestId('problems-auto-fix-tip');+ expect(tip.textContent).toContain('None of these problems have an automatic fix');+ // Pointing at a button that was never rendered sends the user hunting.+ expect(tip.textContent).not.toMatch(/Fix all with AI/);+ });++ test('the nothing-fixable tooltip keeps the AI pointer when that button exists', async () => {+ render(+ <ProblemsPanel+ docName="notes"+ diagnostics={[diag({ code: 'MD025', message: 'Multiple H1' })]}+ onAutoFix={vi.fn(() => {})}+ onFixWithAi={vi.fn(() => {})}+ />,+ );+ fireEvent.focus(screen.getByTestId('problems-auto-fix').parentElement as HTMLElement);+ const tip = await screen.findByTestId('problems-auto-fix-tip');+ expect(tip.textContent).toContain('Try Fix all with AI');});test('renders a row per diagnostic, sorted by line', () => {@@ -393,12 +510,12 @@ describe('ProblemsPanel', () => {expect(addPageCalls).toEqual(['ghost']);});- test('the create action is never counted by Fix all', () => {+ test('the create action is never counted by Auto-fix', () => {render(- <ProblemsPanel docName="notes" diagnostics={[linkDiag({})]} onFixAll={vi.fn(() => {})} />,+ <ProblemsPanel docName="notes" diagnostics={[linkDiag({})]} onAutoFix={vi.fn(() => {})} />,);- // A dead link is not deterministically fixable — the Fix all label counts 0.- const button = screen.getByTestId('problems-fix-all') as HTMLButtonElement;+ // A dead link is not deterministically fixable — the Auto-fix label counts 0.+ const button = screen.getByTestId('problems-auto-fix') as HTMLButtonElement;expect(button.disabled).toBe(true);expect(button.textContent).toContain('(0)');});@@ -640,7 +757,7 @@ describe('ProblemsPanel — project scope', () => {}});- test('project Fix all sweeps only fixable files, re-audits, and stays quiet on success', async () => {+ test('project Auto-fix sweeps only fixable files, re-audits, and stays quiet on success', async () => {const fixableEdit = {range: { start: { line: 2, character: 0 }, end: { line: 2, character: 1 } },newText: ' ',@@ -659,8 +776,8 @@ describe('ProblemsPanel — project scope', () => {// Counts fixable problems across the audit (a.md + nested/c.md), not files// and not the unfixable b.md diagnostic.- expect(screen.getByTestId('problems-fix-all').textContent).toContain('(2)');- fireEvent.click(screen.getByTestId('problems-fix-all'));+ expect(screen.getByTestId('problems-auto-fix').textContent).toContain('(2)');+ fireEvent.click(screen.getByTestId('problems-auto-fix'));// Only the two files carrying fixable diagnostics are swept, extension-less.await waitFor(() => expect(fixLintDocCalls).toEqual(['a', 'nested/c']));// The sweep ends in a fresh audit fetch (initial activation + re-audit).@@ -668,7 +785,7 @@ describe('ProblemsPanel — project scope', () => {expect(toastError).not.toHaveBeenCalled();});- test('project Fix all continues past per-file failures and surfaces one error toast', async () => {+ test('project Auto-fix continues past per-file failures and surfaces one error toast', async () => {const fixableEdit = {range: { start: { line: 2, character: 0 }, end: { line: 2, character: 1 } },newText: ' ',@@ -686,7 +803,7 @@ describe('ProblemsPanel — project scope', () => {fireEvent.click(screen.getByTestId('panel-scope-project'));await waitFor(() => expect(screen.getByText('bad.md')).toBeTruthy());- fireEvent.click(screen.getByTestId('problems-fix-all'));+ fireEvent.click(screen.getByTestId('problems-auto-fix'));// The failed file does not stop the sweep.await waitFor(() => expect(fixLintDocCalls).toEqual(['bad', 'good']));await waitFor(() => expect(toastError).toHaveBeenCalledTimes(1));@@ -708,14 +825,14 @@ describe('ProblemsPanel — project scope', () => {fireEvent.click(screen.getByTestId('panel-scope-project'));await waitFor(() => expect(screen.getByText('bad.md')).toBeTruthy());- fireEvent.click(screen.getByTestId('problems-fix-all'));+ fireEvent.click(screen.getByTestId('problems-auto-fix'));await waitFor(() => expect(toastError).toHaveBeenCalledTimes(1));// Null detail → just the filename, no ` — ` suffix.const options = toastError.mock.calls[0]?.[1] as { description?: string } | undefined;expect(options?.description).toBe('bad.md');});- test('project Fix all is disabled while loading and when nothing is fixable', async () => {+ test('project Auto-fix is disabled while loading and when nothing is fixable', async () => {runLintAuditImpl = async () =>auditResult({files: [{ file: 'plain.md', diagnostics: [diag({ code: 'MD025' })] }],@@ -724,11 +841,104 @@ describe('ProblemsPanel — project scope', () => {fireEvent.click(screen.getByTestId('panel-scope-project'));await waitFor(() => expect(screen.getByText('plain.md')).toBeTruthy());// Loaded audit with zero fixable files keeps the button disabled.- expect((screen.getByTestId('problems-fix-all') as HTMLButtonElement).disabled).toBe(true);- fireEvent.click(screen.getByTestId('problems-fix-all'));+ expect((screen.getByTestId('problems-auto-fix') as HTMLButtonElement).disabled).toBe(true);+ fireEvent.click(screen.getByTestId('problems-auto-fix'));expect(fixLintDocCalls).toEqual([]);});+ test('project Fix all with AI reports the project scope once the audit loads', async () => {+ runLintAuditImpl = async () =>+ auditResult({+ files: [+ { file: 'a.md', diagnostics: [diag({ line: 1, code: 'MD010' })] },+ {+ file: 'nested/c.md',+ diagnostics: [diag({ line: 4, code: 'MD025' }), diag({ line: 7, code: 'MD013' })],+ },+ ],+ });+ const onFixWithAi = vi.fn(() => {});+ render(<ProblemsPanel docName="notes" diagnostics={[]} onFixWithAi={onFixWithAi} />);+ fireEvent.click(screen.getByTestId('panel-scope-project'));+ await waitFor(() => expect(screen.getByText('a.md')).toBeTruthy());++ // The label still counts every problem across the audit, fixable or not —+ // that number is the panel's own, not something handed to the agent.+ expect(screen.getByTestId('problems-fix-with-ai').textContent).toContain('(3)');+ fireEvent.click(screen.getByTestId('problems-fix-with-ai'));+ expect(onFixWithAi.mock.calls).toEqual([['project']]);+ });++ test('project Fix all with AI stays hidden until the audit has something to describe', async () => {+ runLintAuditImpl = async () => auditResult({ files: [], fileCount: 3 });+ render(<ProblemsPanel docName="notes" diagnostics={[]} onFixWithAi={vi.fn(() => {})} />);+ fireEvent.click(screen.getByTestId('panel-scope-project'));+ await waitFor(() => expect(screen.getByTestId('problems-audit-summary')).toBeTruthy());+ // A clean project has no problems to hand over, so the button is absent+ // rather than an enabled no-op.+ expect(screen.queryByTestId('problems-fix-with-ai')).toBeNull();+ });++ test('a clean project audit makes no claim about problems lacking an automatic fix', async () => {+ runLintAuditImpl = async () => auditResult({ files: [], fileCount: 3 });+ render(<ProblemsPanel docName="notes" diagnostics={[]} />);+ fireEvent.click(screen.getByTestId('panel-scope-project'));+ await waitFor(() => expect(screen.getByText('No problems across 3 documents.')).toBeTruthy());++ const button = screen.getByTestId('problems-auto-fix');+ fireEvent.focus(button.parentElement as HTMLElement);+ const tip = await screen.findByTestId('problems-auto-fix-tip');+ // Zero problems means neither claim is true: nothing lacks a fix, and there+ // is no AI hand-off to point at.+ expect(tip.textContent).not.toMatch(/None of these problems/);+ expect(tip.textContent).not.toMatch(/Fix all with AI/);+ expect(button.getAttribute('aria-label')).not.toContain(+ 'no problems here have an automatic fix',+ );+ // Pin the positive value too: the negative assertions above would also pass+ // on an empty or drifted label, so they cannot tell "correct" from "gone".+ expect(button.getAttribute('aria-label')).toBe('Auto-fix — nothing to fix');+ });++ test('project Fix all with AI is disabled mid-sweep and usable again once it ends', async () => {+ const fixableEdit = {+ range: { start: { line: 2, character: 0 }, end: { line: 2, character: 1 } },+ newText: ' ',+ };+ runLintAuditImpl = async () =>+ auditResult({ files: [{ file: 'a.md', diagnostics: [diag({ fixes: [fixableEdit] })] }] });+ let releaseFix: (() => void) | undefined;+ fixLintDocImpl = async () => {+ await new Promise<void>((resolve) => {+ releaseFix = resolve;+ });+ return { ok: true };+ };+ render(<ProblemsPanel docName="notes" diagnostics={[]} onFixWithAi={vi.fn(() => {})} />);+ fireEvent.click(screen.getByTestId('panel-scope-project'));+ await waitFor(() => expect(screen.getByText('a.md')).toBeTruthy());++ fireEvent.click(screen.getByTestId('problems-auto-fix'));+ await waitFor(() =>+ expect((screen.getByTestId('problems-fix-with-ai') as HTMLButtonElement).disabled).toBe(true),+ );++ // A finished sweep has to hand both affordances back, or the panel stays+ // permanently inert after one auto-fix. `waitFor` is load-bearing rather+ // than stylistic: the sweep closes with a re-audit, and during that reload+ // the AI button is absent (its handler is withheld until the audit loads).+ releaseFix?.();+ await waitFor(() =>+ expect((screen.getByTestId('problems-fix-with-ai') as HTMLButtonElement).disabled).toBe(+ false,+ ),+ );+ const autoFix = screen.getByTestId('problems-auto-fix') as HTMLButtonElement;+ expect(autoFix.disabled).toBe(false);+ expect(autoFix.textContent).not.toContain('Fixing');+ expect(autoFix.textContent).toContain('(1)');+ });+test('doc-scope content and count stay doc-scoped while project scope is active', async () => {runLintAuditImpl = async () =>auditResult({ files: [{ file: 'other.md', diagnostics: [diag({}), diag({ line: 9 })] }] });diff --git a/packages/app/src/components/ProblemsPanel.tsx b/packages/app/src/components/ProblemsPanel.tsxindex f3e6c3696..7b7d56d9d 100644--- a/packages/app/src/components/ProblemsPanel.tsx+++ b/packages/app/src/components/ProblemsPanel.tsx@@ -169,38 +169,146 @@ function CreatePageButton({);}-/** "Fix all" action shared by both scopes — same look, same position in the- * actions row; only the click handler's blast radius differs. The label- * carries the deterministically-fixable problem count so the click's effect- * is sized before it happens; `children` overrides it (sweep progress). */-function FixAllButton({+/**+ * Wraps a possibly-disabled action in a tooltip. A disabled button emits no+ * pointer events, so the trigger hangs off a wrapper span that still receives+ * hover — the whole point here is explaining why Auto-fix is greyed out, which+ * is exactly when the button itself cannot report it. Keyboard users get the+ * same reason from the button's own `aria-label`, since the tooltip describes+ * the span rather than the control.+ */+function ActionTooltip({+ tip,+ testId,+ children,+}: {+ tip: ReactNode;+ testId: string;+ children: ReactNode;+}) {+ return (+ <Tooltip>+ <TooltipTrigger asChild>+ {/* `shrink-0` rides the span, not the button: the span is what the+ actions row lays out, so without it a narrow rail squeezes the+ wrapper and truncates the label the count lives in. */}+ <span className="inline-flex shrink-0">{children}</span>+ </TooltipTrigger>+ <TooltipContent data-testid={testId}>{tip}</TooltipContent>+ </Tooltip>+ );+}++/** Deterministic-fix action shared by both scopes — same look, same position in+ * the actions row; only the click handler's blast radius differs. "Auto-fix"+ * names the mechanism, so it reads as distinct from the AI action beside it+ * rather than as a smaller version of it; the count sizes the click before it+ * happens. `children` overrides the label (sweep progress). */+function AutoFixButton({count,+ problemCount,+ aiAvailable,disabled,onClick,children,}: {count: number;+ problemCount: number;+ aiAvailable: boolean;disabled: boolean;onClick: () => void;children?: ReactNode;}) {const { t } = useLingui();return (- <Button- size="sm"- variant="ghost"- className="h-6 shrink-0 px-2 text-xs"- disabled={disabled}- onClick={onClick}- // When `children` is present (project sweep: "Fixing 3/10"), drop the- // static label so the visible progress text is the accessible name —- // otherwise the aria-label would override it and freeze the announcement.- aria-label={children === undefined ? t`Fix all ${count} fixable problems` : undefined}- data-testid="problems-fix-all"+ <ActionTooltip+ testId="problems-auto-fix-tip"+ tip={+ count > 0 ? (+ <Plural+ value={count}+ one="Instantly fixes the # problem that has a known automatic fix."+ other="Instantly fixes the # problems that have a known automatic fix."+ />+ ) : problemCount === 0 ? (+ // Deliberately state-agnostic: the project scope also reports zero+ // problems while its audit is loading, idle, or failed, so this must+ // hold without claiming the list is clean.+ <Trans>Auto-fix applies only to problems with a known mechanical fix.</Trans>+ ) : aiAvailable ? (+ <Trans>None of these problems have an automatic fix. Try Fix all with AI.</Trans>+ ) : (+ <Trans>None of these problems have an automatic fix.</Trans>+ )+ }>- <Wrench aria-hidden="true" className="size-3" />- {children ?? <Trans>Fix all ({count})</Trans>}- </Button>+ <Button+ size="sm"+ variant="ghost"+ className="h-6 shrink-0 px-2 text-xs"+ disabled={disabled}+ onClick={onClick}+ // When `children` is present (project sweep: "Fixing 3/10"), drop the+ // static label so the visible progress text is the accessible name —+ // otherwise the aria-label would override it and freeze the announcement.+ // A disabled button spells its reason out instead: the tooltip describes+ // the wrapper span, so the name is all a screen-reader user gets from+ // the control. Everything else falls back to the visible label.+ aria-label={+ children !== undefined+ ? undefined+ : problemCount === 0+ ? t`Auto-fix — nothing to fix`+ : count === 0+ ? t`Auto-fix — no problems here have an automatic fix`+ : undefined+ }+ data-testid="problems-auto-fix"+ >+ <Wrench aria-hidden="true" className="size-3" />+ {children ?? <Trans>Auto-fix ({count})</Trans>}+ </Button>+ </ActionTooltip>+ );+}++/** Bulk AI hand-off beside Auto-fix. Counts EVERY problem, not the complement+ * of the auto-fixable ones: the two buttons are "the mechanical subset" and+ * "the whole list", so the user picks a lane instead of reasoning about which+ * problems fall in which set. Clicking Auto-fix first simply leaves this one+ * pointed at what survived. */+function FixWithAiButton({+ count,+ disabled,+ onClick,+}: {+ count: number;+ disabled: boolean;+ onClick: () => void;+}) {+ return (+ <ActionTooltip+ testId="problems-fix-with-ai-tip"+ tip={+ <Plural+ value={count}+ one="Hands the # problem to your AI agent, including what has no automatic fix."+ other="Hands all # problems to your AI agent, including what has no automatic fix."+ />+ }+ >+ <Button+ size="sm"+ variant="ghost"+ className="h-6 shrink-0 px-2 text-xs"+ disabled={disabled}+ onClick={onClick}+ data-testid="problems-fix-with-ai"+ >+ <Sparkles aria-hidden="true" className="size-3" />+ <Trans>Fix all with AI ({count})</Trans>+ </Button>+ </ActionTooltip>);}@@ -219,8 +327,9 @@ export function ProblemsPanel({docName,diagnostics,onFix,- onFixAll,+ onAutoFix,onAskAi,+ onFixWithAi,}: {docName: string;/** Live lint diagnostics for the open doc PLUS its broken-link findings —@@ -230,13 +339,18 @@ export function ProblemsPanel({* (e.g. unit harness), fixable rows render no Fix button. */onFix?: (diagnostic: DiagnosticLike) => void;/** Apply every fixable diagnostic's auto-fix in this doc. When absent, the- * doc-scope Fix all button is not rendered. */- onFixAll?: () => void;+ * doc-scope Auto-fix button is not rendered. */+ onAutoFix?: () => void;/** Hand one diagnostic to the docked terminal's agent as a grounded fix* prompt. Desktop-only — absent on web, where rows render no Ask AI button.* Offered on every row, fixable or not: AI is most useful exactly where no* deterministic fix exists. */onAskAi?: (diagnostic: DiagnosticLike) => void;+ /** Hand this scope's problems to the agent in one prompt. Passes only the+ * scope: the prompt names it and the agent reads its own list, so the panel+ * ships no diagnostics. The caller composes and dispatches, so the panel+ * needs no opinion about which agent receives it. Desktop-only, as `onAskAi`. */+ onFixWithAi?: (scope: PanelScope) => void;}) {const { t } = useLingui();const [scope, setScope] = useState<PanelScope>('doc');@@ -269,6 +383,7 @@ export function ProblemsPanel({}, []);const sorted = [...diagnostics].sort(compareDiagnostics);+ const docFixableCount = countFixable(sorted);/*** One-shot fix for a dead link: create the missing target page (the same@@ -454,15 +569,29 @@ export function ProblemsPanel({)) : (<>- {onFixAll !== undefined && (- <div className="flex items-center justify-end gap-2 px-2 pb-1">- <FixAllButton- count={countFixable(sorted)}- disabled={countFixable(sorted) === 0}- onClick={onFixAll}- />+ {onAutoFix !== undefined || onFixWithAi !== undefined ? (+ // Wraps rather than clips: the buttons are `shrink-0` so their+ // counts stay readable, which in a hand-narrowed rail means the+ // second one drops to its own right-aligned line.+ <div className="flex flex-wrap items-center justify-end gap-1 px-2 pb-1">+ {onAutoFix !== undefined && (+ <AutoFixButton+ count={docFixableCount}+ problemCount={sorted.length}+ aiAvailable={onFixWithAi !== undefined}+ disabled={docFixableCount === 0}+ onClick={onAutoFix}+ />+ )}+ {onFixWithAi !== undefined && (+ <FixWithAiButton+ count={sorted.length}+ disabled={false}+ onClick={() => onFixWithAi('doc')}+ />+ )}</div>- )}+ ) : null}<ul aria-label={t`Problems`} className="flex flex-col gap-0.5">{sorted.map((diagnostic) => {const displayLine = diagnostic.range.start.line + 1;@@ -541,8 +670,18 @@ export function ProblemsPanel({onRefresh={() => void loadAudit()}onNavigate={handleProjectNav}fixableCount={projectFixableFiles.reduce((n, f) => n + countFixable(f.diagnostics), 0)}+ problemCount={+ audit.status === 'loaded'+ ? audit.result.files.reduce((n, f) => n + f.diagnostics.length, 0)+ : 0+ }fixing={projectFixing}- onFixAll={() => void fixAllProjectFiles()}+ onAutoFix={() => void fixAllProjectFiles()}+ onFixWithAi={+ onFixWithAi === undefined || audit.status !== 'loaded'+ ? undefined+ : () => onFixWithAi('project')+ }onCreateTarget={pageList !== null ? (d) => void createLinkTarget(d) : undefined}creatingTarget={creatingTarget}/>@@ -556,8 +695,10 @@ function ProjectAuditBody({onRefresh,onNavigate,fixableCount,+ problemCount,fixing,- onFixAll,+ onAutoFix,+ onFixWithAi,onCreateTarget,creatingTarget,}: {@@ -565,11 +706,16 @@ function ProjectAuditBody({onRefresh: () => void;onNavigate: (filePath: string, diagnostic: DiagnosticLike) => void;/** Auto-fixable diagnostics across the loaded audit (same unit the doc- * scope's Fix all counts — problems, not files). */+ * scope's Auto-fix counts — problems, not files). */fixableCount: number;- /** Sweep progress while a project Fix all is running, else null. */+ /** Every diagnostic across the loaded audit, fixable or not. */+ problemCount: number;+ /** Sweep progress while a project auto-fix is running, else null. */fixing: { done: number; total: number } | null;- onFixAll: () => void;+ onAutoFix: () => void;+ /** Hand the whole audit to the agent; absent on web and until the audit+ * loads (there is nothing to describe before then). */+ onFixWithAi?: () => void;/** Create a dead-link row's missing target page; absent in bare harnesses. */onCreateTarget?: (diagnostic: DiagnosticLike) => void;creatingTarget: string | null;@@ -578,18 +724,40 @@ function ProjectAuditBody({const loading = audit.status === 'loading' || audit.status === 'idle';return (<PanelBody className="px-2 py-2" data-testid="problems-project-scope">- <div className="flex items-center justify-between gap-2 px-2 pb-1">- <p className="text-xs text-muted-foreground" data-testid="problems-audit-summary">- {audit.status === 'loaded' && (- <>- <Plural value={audit.result.errorCount} one="# error" other="# errors" />- {' · '}- <Plural value={audit.result.warningCount} one="# warning" other="# warnings" />- </>- )}- </p>- <div className="flex shrink-0 items-center gap-1">- {/* The Fix all button is disabled during a sweep, so AT can't focus it+ {/* Two rows, not one: the count summary plus two labelled actions plus+ refresh need ~400px, and the rail is narrower than that — on one row+ the buttons (deliberately `shrink-0`, so a count is never truncated)+ squeezed the summary into a three-line wrap mid-phrase. Refresh rides+ with the summary because both concern the audit data rather than the+ problems, which also leaves the action row matching the doc scope's. */}+ <div className="flex flex-col gap-1 px-2 pb-1">+ <div className="flex items-center justify-between gap-2">+ <p+ className="min-w-0 truncate text-xs text-muted-foreground"+ data-testid="problems-audit-summary"+ >+ {audit.status === 'loaded' && (+ <>+ <Plural value={audit.result.errorCount} one="# error" other="# errors" />+ {' · '}+ <Plural value={audit.result.warningCount} one="# warning" other="# warnings" />+ </>+ )}+ </p>+ <Button+ variant="ghost"+ size="icon"+ className="size-6 shrink-0 text-muted-foreground"+ aria-label={t`Refresh audit`}+ data-testid="problems-audit-refresh"+ disabled={loading || fixing !== null}+ onClick={onRefresh}+ >+ <RefreshCw aria-hidden="true" className="size-3.5" />+ </Button>+ </div>+ <div className="flex flex-wrap items-center justify-end gap-1">+ {/* The Auto-fix button is disabled during a sweep, so AT can't focus itto hear the "Fixing N/M" progress — announce it from a live regioninstead. Rendered only while sweeping so it never coexists with theloading skeleton's own role="status". */}@@ -598,28 +766,28 @@ function ProjectAuditBody({{t`Fixing ${fixing.done} of ${fixing.total} files`}</span>) : null}- <FixAllButton+ <AutoFixButtoncount={fixableCount}+ problemCount={problemCount}+ aiAvailable={onFixWithAi !== undefined}disabled={loading || fixing !== null || fixableCount === 0}- onClick={onFixAll}+ onClick={onAutoFix}>{fixing !== null ? (<Trans>Fixing {fixing.done}/{fixing.total}</Trans>) : undefined}- </FixAllButton>- <Button- variant="ghost"- size="icon"- className="size-6 shrink-0 text-muted-foreground"- aria-label={t`Refresh audit`}- data-testid="problems-audit-refresh"- disabled={loading || fixing !== null}- onClick={onRefresh}- >- <RefreshCw aria-hidden="true" className="size-3.5" />- </Button>+ </AutoFixButton>+ {onFixWithAi !== undefined && problemCount > 0 ? (+ <FixWithAiButton+ count={problemCount}+ // The sweep rewrites the same files this would hand over, so a+ // mid-sweep hand-off would describe problems that are already gone.+ disabled={fixing !== null}+ onClick={onFixWithAi}+ />+ ) : null}</div></div>diff --git a/packages/app/src/components/handoff/compose-lint-fix-prompt.test.ts b/packages/app/src/components/handoff/compose-lint-fix-prompt.test.tsindex 6202fbc74..8a229c9f4 100644--- a/packages/app/src/components/handoff/compose-lint-fix-prompt.test.ts+++ b/packages/app/src/components/handoff/compose-lint-fix-prompt.test.ts@@ -1,6 +1,9 @@import type { LintDiagnostic } from '@inkeep/open-knowledge-core';import { describe, expect, test } from 'vitest';-import { composeLintFixTerminalPaste } from './compose-lint-fix-prompt.ts';+import {+ composeFixAllProblemsTerminalPaste,+ composeLintFixTerminalPaste,+} from './compose-lint-fix-prompt.ts';function diag(over: Partial<LintDiagnostic> = {}): LintDiagnostic {return {@@ -37,3 +40,18 @@ describe('composeLintFixTerminalPaste', () => {expect(paste).not.toContain('FM001 (');});});++describe('composeFixAllProblemsTerminalPaste', () => {+ test('maps an extension-less docName to its path for the doc scope', () => {+ const paste = composeFixAllProblemsTerminalPaste('guides/setup');+ expect(paste).toContain('@guides/setup.md');+ expect(paste).not.toContain('setup.md.md');+ expect(paste).toContain('Run the `audit` tool scoped to it');+ });++ test('null docName asks for the whole project and mentions no doc', () => {+ const paste = composeFixAllProblemsTerminalPaste(null);+ expect(paste).toContain("across this project's documents");+ expect(paste).not.toContain('@');+ });+});diff --git a/packages/app/src/components/handoff/compose-lint-fix-prompt.ts b/packages/app/src/components/handoff/compose-lint-fix-prompt.tsindex 3a5e71555..b6a8ce53f 100644--- a/packages/app/src/components/handoff/compose-lint-fix-prompt.ts+++ b/packages/app/src/components/handoff/compose-lint-fix-prompt.ts@@ -1,4 +1,5 @@import {+ composeFixAllProblemsPrompt,composeLintFixPrompt,type LintDiagnostic,MARKDOWNLINT_RULE_CATALOG,@@ -7,6 +8,18 @@ import { docNameToRelativePath } from '@/lib/workspace-paths';const ALIAS_BY_CODE = new Map(MARKDOWNLINT_RULE_CATALOG.map((rule) => [rule.id, rule.alias]));+/** The diagnostic fields both composers read. Structural over the wire shape:+ * the unified Problems panel hands diagnostics whose `source` is any validator+ * id, not the in-process lint-plugin literal union. */+type ComposableDiagnostic = Pick<LintDiagnostic, 'code' | 'message' | 'range'> & {+ readonly source: string;+};++/** Rule alias, when the diagnostic came from markdownlint and the code is known. */+function aliasOf(diagnostic: ComposableDiagnostic): string | undefined {+ return diagnostic.source === 'markdownlint' ? ALIAS_BY_CODE.get(diagnostic.code) : undefined;+}+/*** Grounded lint-fix paste for a terminal CLI: the doc named as an `@`-mention,* one diagnostic located precisely (rule, line, column, message, offending@@ -19,21 +32,29 @@ const ALIAS_BY_CODE = new Map(MARKDOWNLINT_RULE_CATALOG.map((rule) => [rule.id,*/export function composeLintFixTerminalPaste(docName: string,- // Structural over the fields actually read: the unified Problems panel- // hands wire-shape diagnostics whose `source` is any validator id, not the- // in-process lint-plugin literal union. `LintDiagnostic` remains assignable.- diagnostic: Pick<LintDiagnostic, 'code' | 'message' | 'range'> & { source: string },+ diagnostic: ComposableDiagnostic,lineText: string | undefined,): string {return composeLintFixPrompt({relativePath: docNameToRelativePath(docName),source: diagnostic.source,code: diagnostic.code,- ruleAlias:- diagnostic.source === 'markdownlint' ? ALIAS_BY_CODE.get(diagnostic.code) : undefined,+ ruleAlias: aliasOf(diagnostic),message: diagnostic.message,line: diagnostic.range.start.line + 1,column: diagnostic.range.start.character + 1,lineText,});}++/**+ * Bulk sibling of {@link composeLintFixTerminalPaste} for the Problems panel's+ * "Fix all with AI" button. `docName` names the open doc (doc scope) or is null+ * for the whole project; only the doc case needs the docName-to-path mapping.+ *+ * Carries no diagnostics — see `composeFixAllProblemsPrompt` for why the agent+ * reads its own list instead.+ */+export function composeFixAllProblemsTerminalPaste(docName: string | null): string {+ return composeFixAllProblemsPrompt(docName === null ? null : docNameToRelativePath(docName));+}diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.jsonindex dbb0d4ea5..18d4f9595 100644--- a/packages/app/src/locales/en/messages.json+++ b/packages/app/src/locales/en/messages.json@@ -263,6 +263,7 @@"4hJhzz": ["Table"],"4ieVh2": ["Pick “Custom” above to use this palette."],"4jDd0j": ["Anyone can see"],+ "4m-xuX": ["Auto-fix — nothing to fix"],"4mLBx9": ["Subscriptions aren't available right now."],"4niEzY": ["Sandboxed HTML embed — write HTML, see the rendered preview live."],"4nj6n8": ["/api/config returned HTTP ", ["code"]],@@ -313,7 +314,6 @@"5Y17qa": ["Applies to (globs — leading ! excludes; empty means every doc)"],"5ZB7XC": ["File drop zone"],"5ZbJFS": ["Your current version is saved first, so this is reversible."],- "5_8TCr": ["Fix all (", ["count"], ")"],"5_j-DA": ["Kill Terminal"],"5aahsI": ["nothing (", ["0"], " is not a valid pattern)"],"5e1Dri": ["The menu label agents pick this template by (required)."],@@ -1031,7 +1031,6 @@"ItxGi3": ["Attachments must total under 3 MB."],"Ix0K8o": ["Hide external URL nodes"],"IxyZXD": ["Screenshot"],- "Izb10l": ["Fix all ", ["count"], " fixable problems"],"J2Mv98": ["Name (e.g. ", ["login"], ")"],"J2_JuX": ["nothing (", ["0"], " cannot match a doc)"],"J2eKUI": ["File"],@@ -1479,6 +1478,7 @@"RXEbZy": ["In app"],"RXNu_r": ["Shared via git with everyone working on this project."],"RY6Bq1": ["Open shared ", ["targetNoun"]],+ "RZXTlY": ["Auto-fix (", ["count"], ")"],"R_U_A4": ["Add file or folder pattern, e.g. guides/**/*"],"RaPMZv": ["Keyboard shortcuts available in the editor and workspace."],"Rah7yq": ["What should the AI do? (optional)"],@@ -1546,6 +1546,7 @@"Skr_7L": ["Search worktrees"],"SlfejT": ["Error"],"Sq8lf2": ["Editors to install skills into"],+ "SqIoy_": ["Auto-fix — no problems here have an automatic fix"],"SrOuyg": ["Document panels"],"SvBFYA": ["No recent projects"],"Sxx_Zz": [@@ -1745,6 +1746,7 @@"WyXG7w": ["Close all"],"Wyxs0x": ["Path cannot contain \"..\""],"X0ttSN": ["No tags match \"", ["tagListQuery"], "\"."],+ "X3MMeA": ["None of these problems have an automatic fix."],"X7u0xR": [["0"], " templates available"],"X8kjQX": ["Re-authenticate with GitHub"],"X9VpsP": ["Loading folder contents"],@@ -2269,6 +2271,7 @@"> failed to render (likely a bad prop). Copy the source to see what went wrong, or delete the block."],"g85bAo": ["Synced ", ["lastSyncedRelative"]],+ "gAhHu7": ["Auto-fix applies only to problems with a known mechanical fix."],"gBbxn_": ["Checking sign-in status"],"gGVP4q": ["Click <0>+</0> <1/> <2>Create skill</2> <3/> <4>Upload skill</4>."],"gHSAWT": ["Create worktree <0>“<1>", ["typedName"], "</1>”</0>"],@@ -2309,6 +2312,7 @@],"gwEcOD": ["Your local copy is behind."],"gwykHF": ["This doc hasn't synced to GitHub yet. The link will work after the next sync."],+ "gyHDWC": ["Fix all with AI (", ["count"], ")"],"h-AdvS": ["The folders and templates are already here, so there's nothing to add."],"h06R3C": ["No pages are missing outgoing graph links."],"h16FyT": ["Lists"],@@ -2629,6 +2633,24 @@"mdzKSV": [["nodeCount", "plural", { "one": ["#", " node"], "other": ["#", " nodes"] }]],"mf37rL": ["Retrying"],"mg0YGL": ["Source multi-cursor and multi-select"],+ "mgDKWS": [+ [+ "count",+ "plural",+ {+ "one": [+ "Hands the ",+ "#",+ " problem to your AI agent, including what has no automatic fix."+ ],+ "other": [+ "Hands all ",+ "#",+ " problems to your AI agent, including what has no automatic fix."+ ]+ }+ ]+ ],"mk2poV": ["e.g. server.ts"],"mmpzAq": ["Wrap long lines in the markdown source editor."],"mo22UP": ["Toggle inline code formatting."],@@ -3107,6 +3129,16 @@"</0> to copy the link below, or open OK in the desktop app."],"vja0Dg": ["Open session dock"],+ "vjwsDi": [+ [+ "count",+ "plural",+ {+ "one": ["Instantly fixes the ", "#", " problem that has a known automatic fix."],+ "other": ["Instantly fixes the ", "#", " problems that have a known automatic fix."]+ }+ ]+ ],"vppAju": ["Where newly added attachments are placed."],"vv7kpg": ["Cancelled"],"vvWZnu": ["Diff unavailable"],@@ -3290,6 +3322,7 @@"z60Lgn": ["Saves the file to <0>~/Downloads/openknowledge.skill</0> and opens the Claude Desktop App. Requires Node.js or Bun on your PATH."],+ "zA9zRL": ["None of these problems have an automatic fix. Try Fix all with AI."],"zAJzIg": ["Problems in ", ["0"]],"zAsDLY": ["Graph visualization of document links"],"zBUqvf": ["Set up OpenKnowledge integrations…"],diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.poindex 73565bf00..88b32ab59 100644--- a/packages/app/src/locales/en/messages.po+++ b/packages/app/src/locales/en/messages.po@@ -354,6 +354,14 @@ msgstr "{count, plural, one {# more cross-doc participant} other {# more cross-dmsgid "{count, plural, one {# more participant} other {# more participants}}"msgstr "{count, plural, one {# more participant} other {# more participants}}"+#: src/components/ProblemsPanel.tsx+msgid "{count, plural, one {Hands the # problem to your AI agent, including what has no automatic fix.} other {Hands all # problems to your AI agent, including what has no automatic fix.}}"+msgstr "{count, plural, one {Hands the # problem to your AI agent, including what has no automatic fix.} other {Hands all # problems to your AI agent, including what has no automatic fix.}}"++#: src/components/ProblemsPanel.tsx+msgid "{count, plural, one {Instantly fixes the # problem that has a known automatic fix.} other {Instantly fixes the # problems that have a known automatic fix.}}"+msgstr "{count, plural, one {Instantly fixes the # problem that has a known automatic fix.} other {Instantly fixes the # problems that have a known automatic fix.}}"+#: src/components/settings/OkignoreSection.tsxmsgid "{count, plural, one {matches # file} other {matches # files}}"msgstr "{count, plural, one {matches # file} other {matches # files}}"@@ -1310,6 +1318,22 @@ msgstr "Auto-approved"msgid "Auto-denied"msgstr "Auto-denied"+#: src/components/ProblemsPanel.tsx+msgid "Auto-fix — no problems here have an automatic fix"+msgstr "Auto-fix — no problems here have an automatic fix"++#: src/components/ProblemsPanel.tsx+msgid "Auto-fix — nothing to fix"+msgstr "Auto-fix — nothing to fix"++#: src/components/ProblemsPanel.tsx+msgid "Auto-fix ({count})"+msgstr "Auto-fix ({count})"++#: src/components/ProblemsPanel.tsx+msgid "Auto-fix applies only to problems with a known mechanical fix."+msgstr "Auto-fix applies only to problems with a known mechanical fix."+#: src/components/FolderTimelineCard.tsx#: src/components/TimelinePanel.tsxmsgid "Auto-save"@@ -4285,12 +4309,8 @@ msgid "Fix {flatId}"msgstr "Fix {flatId}"#: src/components/ProblemsPanel.tsx-msgid "Fix all ({count})"-msgstr "Fix all ({count})"--#: src/components/ProblemsPanel.tsx-msgid "Fix all {count} fixable problems"-msgstr "Fix all {count} fixable problems"+msgid "Fix all with AI ({count})"+msgstr "Fix all with AI ({count})"#: src/components/settings/AttachmentsSection.tsxmsgid "Fixed folder in content root"@@ -6285,6 +6305,14 @@ msgstr "No workspace"msgid "None"msgstr "None"+#: src/components/ProblemsPanel.tsx+msgid "None of these problems have an automatic fix."+msgstr "None of these problems have an automatic fix."++#: src/components/ProblemsPanel.tsx+msgid "None of these problems have an automatic fix. Try Fix all with AI."+msgstr "None of these problems have an automatic fix. Try Fix all with AI."+#: src/components/acp/ThreadView.tsxmsgid "Not answered"msgstr "Not answered"diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.jsonindex 008a18929..1a8b61561 100644--- a/packages/app/src/locales/pseudo/messages.json+++ b/packages/app/src/locales/pseudo/messages.json@@ -263,6 +263,7 @@"4hJhzz": ["Ţàƀĺē"],"4ieVh2": ["Ƥĩćķ “Ćũśţōḿ” àƀōvē ţō ũśē ţĥĩś ƥàĺēţţē."],"4jDd0j": ["Àńŷōńē ćàń śēē"],+ "4m-xuX": ["Àũţō-ƒĩx — ńōţĥĩńĝ ţō ƒĩx"],"4mLBx9": ["Śũƀśćŕĩƥţĩōńś àŕēń'ţ àvàĩĺàƀĺē ŕĩĝĥţ ńōŵ."],"4niEzY": ["Śàńďƀōxēď ĤŢḾĹ ēḿƀēď — ŵŕĩţē ĤŢḾĹ, śēē ţĥē ŕēńďēŕēď ƥŕēvĩēŵ ĺĩvē."],"4nj6n8": ["/àƥĩ/ćōńƒĩĝ ŕēţũŕńēď ĤŢŢƤ ", ["code"]],@@ -313,7 +314,6 @@"5Y17qa": ["Àƥƥĺĩēś ţō (ĝĺōƀś — ĺēàďĩńĝ ! ēxćĺũďēś; ēḿƥţŷ ḿēàńś ēvēŕŷ ďōć)"],"5ZB7XC": ["Ƒĩĺē ďŕōƥ źōńē"],"5ZbJFS": ["Ŷōũŕ ćũŕŕēńţ vēŕśĩōń ĩś śàvēď ƒĩŕśţ, śō ţĥĩś ĩś ŕēvēŕśĩƀĺē."],- "5_8TCr": ["Ƒĩx àĺĺ (", ["count"], ")"],"5_j-DA": ["Ķĩĺĺ Ţēŕḿĩńàĺ"],"5aahsI": ["ńōţĥĩńĝ (", ["0"], " ĩś ńōţ à vàĺĩď ƥàţţēŕń)"],"5e1Dri": ["Ţĥē ḿēńũ ĺàƀēĺ àĝēńţś ƥĩćķ ţĥĩś ţēḿƥĺàţē ƀŷ (ŕēǫũĩŕēď)."],@@ -1031,7 +1031,6 @@"ItxGi3": ["Àţţàćĥḿēńţś ḿũśţ ţōţàĺ ũńďēŕ 3 Ḿß."],"Ix0K8o": ["Ĥĩďē ēxţēŕńàĺ ŨŔĹ ńōďēś"],"IxyZXD": ["Śćŕēēńśĥōţ"],- "Izb10l": ["Ƒĩx àĺĺ ", ["count"], " ƒĩxàƀĺē ƥŕōƀĺēḿś"],"J2Mv98": ["Ńàḿē (ē.ĝ. ", ["login"], ")"],"J2_JuX": ["ńōţĥĩńĝ (", ["0"], " ćàńńōţ ḿàţćĥ à ďōć)"],"J2eKUI": ["Ƒĩĺē"],@@ -1479,6 +1478,7 @@"RXEbZy": ["Ĩń àƥƥ"],"RXNu_r": ["Śĥàŕēď vĩà ĝĩţ ŵĩţĥ ēvēŕŷōńē ŵōŕķĩńĝ ōń ţĥĩś ƥŕōĴēćţ."],"RY6Bq1": ["Ōƥēń śĥàŕēď ", ["targetNoun"]],+ "RZXTlY": ["Àũţō-ƒĩx (", ["count"], ")"],"R_U_A4": ["Àďď ƒĩĺē ōŕ ƒōĺďēŕ ƥàţţēŕń, ē.ĝ. ĝũĩďēś/**/*"],"RaPMZv": ["Ķēŷƀōàŕď śĥōŕţćũţś àvàĩĺàƀĺē ĩń ţĥē ēďĩţōŕ àńď ŵōŕķśƥàćē."],"Rah7yq": ["Ŵĥàţ śĥōũĺď ţĥē ÀĨ ďō? (ōƥţĩōńàĺ)"],@@ -1546,6 +1546,7 @@"Skr_7L": ["Śēàŕćĥ ŵōŕķţŕēēś"],"SlfejT": ["Ēŕŕōŕ"],"Sq8lf2": ["Ēďĩţōŕś ţō ĩńśţàĺĺ śķĩĺĺś ĩńţō"],+ "SqIoy_": ["Àũţō-ƒĩx — ńō ƥŕōƀĺēḿś ĥēŕē ĥàvē àń àũţōḿàţĩć ƒĩx"],"SrOuyg": ["Ďōćũḿēńţ ƥàńēĺś"],"SvBFYA": ["Ńō ŕēćēńţ ƥŕōĴēćţś"],"Sxx_Zz": [@@ -1745,6 +1746,7 @@"WyXG7w": ["Ćĺōśē àĺĺ"],"Wyxs0x": ["Ƥàţĥ ćàńńōţ ćōńţàĩń \"..\""],"X0ttSN": ["Ńō ţàĝś ḿàţćĥ \"", ["tagListQuery"], "\"."],+ "X3MMeA": ["Ńōńē ōƒ ţĥēśē ƥŕōƀĺēḿś ĥàvē àń àũţōḿàţĩć ƒĩx."],"X7u0xR": [["0"], " ţēḿƥĺàţēś àvàĩĺàƀĺē"],"X8kjQX": ["Ŕē-àũţĥēńţĩćàţē ŵĩţĥ ĜĩţĤũƀ"],"X9VpsP": ["Ĺōàďĩńĝ ƒōĺďēŕ ćōńţēńţś"],@@ -2269,6 +2271,7 @@"> ƒàĩĺēď ţō ŕēńďēŕ (ĺĩķēĺŷ à ƀàď ƥŕōƥ). Ćōƥŷ ţĥē śōũŕćē ţō śēē ŵĥàţ ŵēńţ ŵŕōńĝ, ōŕ ďēĺēţē ţĥē ƀĺōćķ."],"g85bAo": ["Śŷńćēď ", ["lastSyncedRelative"]],+ "gAhHu7": ["Àũţō-ƒĩx àƥƥĺĩēś ōńĺŷ ţō ƥŕōƀĺēḿś ŵĩţĥ à ķńōŵń ḿēćĥàńĩćàĺ ƒĩx."],"gBbxn_": ["Ćĥēćķĩńĝ śĩĝń-ĩń śţàţũś"],"gGVP4q": ["Ćĺĩćķ <0>+</0> <1/> <2>Ćŕēàţē śķĩĺĺ</2> <3/> <4>Ũƥĺōàď śķĩĺĺ</4>."],"gHSAWT": ["Ćŕēàţē ŵōŕķţŕēē <0>“<1>", ["typedName"], "</1>”</0>"],@@ -2309,6 +2312,7 @@],"gwEcOD": ["Ŷōũŕ ĺōćàĺ ćōƥŷ ĩś ƀēĥĩńď."],"gwykHF": ["Ţĥĩś ďōć ĥàśń'ţ śŷńćēď ţō ĜĩţĤũƀ ŷēţ. Ţĥē ĺĩńķ ŵĩĺĺ ŵōŕķ àƒţēŕ ţĥē ńēxţ śŷńć."],+ "gyHDWC": ["Ƒĩx àĺĺ ŵĩţĥ ÀĨ (", ["count"], ")"],"h-AdvS": ["Ţĥē ƒōĺďēŕś àńď ţēḿƥĺàţēś àŕē àĺŕēàďŷ ĥēŕē, śō ţĥēŕē'ś ńōţĥĩńĝ ţō àďď."],"h06R3C": ["Ńō ƥàĝēś àŕē ḿĩśśĩńĝ ōũţĝōĩńĝ ĝŕàƥĥ ĺĩńķś."],"h16FyT": ["Ĺĩśţś"],@@ -2629,6 +2633,24 @@"mdzKSV": [["nodeCount", "plural", { "one": ["#", " ńōďē"], "other": ["#", " ńōďēś"] }]],"mf37rL": ["Ŕēţŕŷĩńĝ"],"mg0YGL": ["Śōũŕćē ḿũĺţĩ-ćũŕśōŕ àńď ḿũĺţĩ-śēĺēćţ"],+ "mgDKWS": [+ [+ "count",+ "plural",+ {+ "one": [+ "Ĥàńďś ţĥē ",+ "#",+ " ƥŕōƀĺēḿ ţō ŷōũŕ ÀĨ àĝēńţ, ĩńćĺũďĩńĝ ŵĥàţ ĥàś ńō àũţōḿàţĩć ƒĩx."+ ],+ "other": [+ "Ĥàńďś àĺĺ ",+ "#",+ " ƥŕōƀĺēḿś ţō ŷōũŕ ÀĨ àĝēńţ, ĩńćĺũďĩńĝ ŵĥàţ ĥàś ńō àũţōḿàţĩć ƒĩx."+ ]+ }+ ]+ ],"mk2poV": ["ē.ĝ. śēŕvēŕ.ţś"],"mmpzAq": ["Ŵŕàƥ ĺōńĝ ĺĩńēś ĩń ţĥē ḿàŕķďōŵń śōũŕćē ēďĩţōŕ."],"mo22UP": ["Ţōĝĝĺē ĩńĺĩńē ćōďē ƒōŕḿàţţĩńĝ."],@@ -3107,6 +3129,16 @@"</0> ţō ćōƥŷ ţĥē ĺĩńķ ƀēĺōŵ, ōŕ ōƥēń ŌĶ ĩń ţĥē ďēśķţōƥ àƥƥ."],"vja0Dg": ["Ōƥēń śēśśĩōń ďōćķ"],+ "vjwsDi": [+ [+ "count",+ "plural",+ {+ "one": ["Ĩńśţàńţĺŷ ƒĩxēś ţĥē ", "#", " ƥŕōƀĺēḿ ţĥàţ ĥàś à ķńōŵń àũţōḿàţĩć ƒĩx."],+ "other": ["Ĩńśţàńţĺŷ ƒĩxēś ţĥē ", "#", " ƥŕōƀĺēḿś ţĥàţ ĥàvē à ķńōŵń àũţōḿàţĩć ƒĩx."]+ }+ ]+ ],"vppAju": ["Ŵĥēŕē ńēŵĺŷ àďďēď àţţàćĥḿēńţś àŕē ƥĺàćēď."],"vv7kpg": ["Ćàńćēĺĺēď"],"vvWZnu": ["Ďĩƒƒ ũńàvàĩĺàƀĺē"],@@ -3290,6 +3322,7 @@"z60Lgn": ["Śàvēś ţĥē ƒĩĺē ţō <0>~/Ďōŵńĺōàďś/ōƥēńķńōŵĺēďĝē.śķĩĺĺ</0> àńď ōƥēńś ţĥē Ćĺàũďē Ďēśķţōƥ Àƥƥ. Ŕēǫũĩŕēś Ńōďē.Ĵś ōŕ ßũń ōń ŷōũŕ ƤÀŢĤ."],+ "zA9zRL": ["Ńōńē ōƒ ţĥēśē ƥŕōƀĺēḿś ĥàvē àń àũţōḿàţĩć ƒĩx. Ţŕŷ Ƒĩx àĺĺ ŵĩţĥ ÀĨ."],"zAJzIg": ["Ƥŕōƀĺēḿś ĩń ", ["0"]],"zAsDLY": ["Ĝŕàƥĥ vĩśũàĺĩźàţĩōń ōƒ ďōćũḿēńţ ĺĩńķś"],"zBUqvf": ["Śēţ ũƥ ŌƥēńĶńōŵĺēďĝē ĩńţēĝŕàţĩōńś…"],diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.poindex 04f5e4355..955ef7ec3 100644--- a/packages/app/src/locales/pseudo/messages.po+++ b/packages/app/src/locales/pseudo/messages.po@@ -354,6 +354,14 @@ msgstr ""msgid "{count, plural, one {# more participant} other {# more participants}}"msgstr ""+#: src/components/ProblemsPanel.tsx+msgid "{count, plural, one {Hands the # problem to your AI agent, including what has no automatic fix.} other {Hands all # problems to your AI agent, including what has no automatic fix.}}"+msgstr ""++#: src/components/ProblemsPanel.tsx+msgid "{count, plural, one {Instantly fixes the # problem that has a known automatic fix.} other {Instantly fixes the # problems that have a known automatic fix.}}"+msgstr ""+#: src/components/settings/OkignoreSection.tsxmsgid "{count, plural, one {matches # file} other {matches # files}}"msgstr ""@@ -1306,6 +1314,22 @@ msgstr ""msgid "Auto-denied"msgstr ""+#: src/components/ProblemsPanel.tsx+msgid "Auto-fix — no problems here have an automatic fix"+msgstr ""++#: src/components/ProblemsPanel.tsx+msgid "Auto-fix — nothing to fix"+msgstr ""++#: src/components/ProblemsPanel.tsx+msgid "Auto-fix ({count})"+msgstr ""++#: src/components/ProblemsPanel.tsx+msgid "Auto-fix applies only to problems with a known mechanical fix."+msgstr ""+#: src/components/FolderTimelineCard.tsx#: src/components/TimelinePanel.tsxmsgid "Auto-save"@@ -4281,11 +4305,7 @@ msgid "Fix {flatId}"msgstr ""#: src/components/ProblemsPanel.tsx-msgid "Fix all ({count})"-msgstr ""--#: src/components/ProblemsPanel.tsx-msgid "Fix all {count} fixable problems"+msgid "Fix all with AI ({count})"msgstr ""#: src/components/settings/AttachmentsSection.tsx@@ -6281,6 +6301,14 @@ msgstr ""msgid "None"msgstr ""+#: src/components/ProblemsPanel.tsx+msgid "None of these problems have an automatic fix."+msgstr ""++#: src/components/ProblemsPanel.tsx+msgid "None of these problems have an automatic fix. Try Fix all with AI."+msgstr ""+#: src/components/acp/ThreadView.tsxmsgid "Not answered"msgstr ""diff --git a/packages/core/src/handoff/index.ts b/packages/core/src/handoff/index.tsindex 06feebbe6..68e90c411 100644--- a/packages/core/src/handoff/index.ts+++ b/packages/core/src/handoff/index.ts@@ -19,6 +19,7 @@ export {composeCreatePrompt,composeEmptySpacePrompt,composeFilePrompt,+ composeFixAllProblemsPrompt,composeFolderPrompt,composeLintFixPrompt,composeSelectionPrompt,diff --git a/packages/core/src/handoff/prompt-composer.test.ts b/packages/core/src/handoff/prompt-composer.test.tsindex 8c08b9d5f..478b22047 100644--- a/packages/core/src/handoff/prompt-composer.test.ts+++ b/packages/core/src/handoff/prompt-composer.test.ts@@ -9,6 +9,7 @@ import {composeCreatePrompt,composeEmptySpacePrompt,composeFilePrompt,+ composeFixAllProblemsPrompt,composeFolderPrompt,composeLintFixPrompt,composeSelectionPrompt,@@ -1667,3 +1668,45 @@ test('composeLintFixPrompt sanitizes the @-mention path like the selection compo// Whitespace + zero-width bytes collapse so the mention stays one token.expect(prompt).toContain('@my_docs/note_.md');});++// --- composeFixAllProblemsPrompt ---------------------------------------------++test('composeFixAllProblemsPrompt names the doc scope and points at audit', () => {+ const prompt = composeFixAllProblemsPrompt('guides/setup.md');+ expect(prompt).toContain('Fix every problem in @guides/setup.md using OpenKnowledge.');+ expect(prompt).toContain('Run the `audit` tool scoped to it');+ expect(prompt).toContain('lint violations and broken links');+ expect(prompt).toContain('re-audit @guides/setup.md until it reports no problems');+ // The mechanically-fixable subset is a tool call, not hand-editing.+ expect(prompt).toContain('`lint` tool with `fix: true`');+});++test('composeFixAllProblemsPrompt names the project scope with no doc mention', () => {+ const prompt = composeFixAllProblemsPrompt(null);+ expect(prompt).toContain(+ "Fix every problem across this project's documents using OpenKnowledge.",+ );+ expect(prompt).toContain('Run the `audit` tool for the current list');+ // `lint` rejects fix:true without a document, so the project variant must not+ // imply one bulk autofix call.+ expect(prompt).toContain('work file by file');+ expect(prompt).toContain("clears one document's mechanically-fixable problems at a time");+ expect(prompt).not.toContain('@');+});++test('composeFixAllProblemsPrompt enumerates no diagnostics in either scope', () => {+ for (const prompt of [composeFixAllProblemsPrompt('a.md'), composeFixAllProblemsPrompt(null)]) {+ // No per-problem lines, so no doc-derived text reaches the instruction plane+ // and no truncation bound is needed.+ expect(prompt).not.toContain('>');+ expect(prompt).not.toMatch(/line \d+, column \d+/);+ // Small enough that the terminal argv budget is not in play at all.+ expect(quotedByteLength(prompt)).toBeLessThan(1000);+ }+});++test('composeFixAllProblemsPrompt sanitizes the @-mention path', () => {+ const prompt = composeFixAllProblemsPrompt('my docs/note\u200b.md');+ expect(prompt).toContain('@my_docs/note_.md');+ expect(prompt).not.toContain('@my docs/');+});diff --git a/packages/core/src/handoff/prompt-composer.ts b/packages/core/src/handoff/prompt-composer.tsindex 867d63619..dff545fd1 100644--- a/packages/core/src/handoff/prompt-composer.ts+++ b/packages/core/src/handoff/prompt-composer.ts@@ -1275,3 +1275,36 @@ export function composeLintFixPrompt(input: LintFixPromptInput): string {);return lines.join('\n');}++/**+ * Bulk problem-fix composer for the Problems panel's "Fix all with AI" button.+ * `relativePath` names the open document (doc scope) or is null for the whole+ * project. Unlike `composeLintFixPrompt` this enumerates nothing: it names a+ * SCOPE and points at the tool that reads it.+ *+ * Deliberately no diagnostic list. OK's `audit` tool returns exactly what the+ * panel shows — every lint violation plus every broken internal link, by file+ * with lines — for one doc or the whole project, so an embedded list would be+ * redundant with a call the agent makes anyway, and staler: the paste waits in+ * a live session until the user submits it, and anything fixed in between makes+ * a baked-in list wrong. Enumerating also piped doc-derived lint messages into+ * the instruction plane, which this shape removes entirely.+ *+ * `lint`'s `fix: true` is per-document (it rejects a project-wide call), so the+ * project variant says file-by-file rather than implying one bulk autofix.+ */+export function composeFixAllProblemsPrompt(relativePath: string | null): string {+ if (relativePath === null) {+ return [+ "Fix every problem across this project's documents using OpenKnowledge.",+ '',+ "Run the `audit` tool for the current list of lint violations and broken links, then work file by file — the `lint` tool with `fix: true` clears one document's mechanically-fixable problems at a time — and re-audit until it reports no problems.",+ ].join('\n');+ }+ const safePath = sanitizePathForAtMention(relativePath);+ return [+ `Fix every problem in @${safePath} using OpenKnowledge.`,+ '',+ `Run the \`audit\` tool scoped to it for the current list of lint violations and broken links, then fix each one — the \`lint\` tool with \`fix: true\` clears the mechanically-fixable ones — and re-audit @${safePath} until it reports no problems.`,+ ].join('\n');+}diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 888f0bcc5..9de4d7f63 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -462,6 +462,7 @@ export {composeCreatePrompt,composeEmptySpacePrompt,composeFilePrompt,+ composeFixAllProblemsPrompt,composeFolderPrompt,composeLintFixPrompt,composeSelectionPrompt,