Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Detect AI tools in project settings (#3692)

mike-inkeep9997284d68cd
diff --git a/.changeset/project-ai-tools-detection.md b/.changeset/project-ai-tools-detection.md
new file mode 100644
index 000000000..a73bd6fe5
--- /dev/null
+++ b/.changeset/project-ai-tools-detection.md
@@ -0,0 +1,5 @@
+---
+'@inkeep/open-knowledge': patch
+---
+
+Project AI tools now puts integrations already wired or detected on this machine first and folds the rest behind a disclosure. Detection uses the machine's login-shell PATH and registered URL handlers, never MCP config folders, and failed probes quietly under-claim instead of guessing.
diff --git a/packages/app/src/components/settings/AiToolsSection.dom.test.tsx b/packages/app/src/components/settings/AiToolsSection.dom.test.tsx
index e557f0bc8..9c299a240 100644
--- a/packages/app/src/components/settings/AiToolsSection.dom.test.tsx
+++ b/packages/app/src/components/settings/AiToolsSection.dom.test.tsx
@@ -241,6 +241,23 @@ describe('AiToolsSection', () => {
expect(status.textContent).toContain('How to set up');
});
+ test('the editor disclosure exposes its expand and collapse state', async () => {
+ installBridge();
+ renderSection();
+
+ const disclosure = await screen.findByTestId('ai-tools-editors-show-more');
+ expect(disclosure.getAttribute('aria-expanded')).toBe('false');
+
+ const user = userEvent.setup();
+ await user.click(disclosure);
+ expect(disclosure.getAttribute('aria-expanded')).toBe('true');
+ expect(screen.getByTestId('ai-tools-editor-checkbox-cursor')).toBeTruthy();
+
+ await user.click(disclosure);
+ expect(disclosure.getAttribute('aria-expanded')).toBe('false');
+ expect(screen.queryByTestId('ai-tools-editor-checkbox-cursor')).toBeNull();
+ });
+
test('clicking a checkbox sends the matching install/uninstall and re-renders from the result', async () => {
const flipped: OkIntegrationsStatus = {
...baseStatus,
diff --git a/packages/app/src/components/settings/AiToolsSection.tsx b/packages/app/src/components/settings/AiToolsSection.tsx
index a4ecf96f9..4833bd4f2 100644
--- a/packages/app/src/components/settings/AiToolsSection.tsx
+++ b/packages/app/src/components/settings/AiToolsSection.tsx
@@ -30,6 +30,7 @@ import { Skeleton } from '@/components/ui/skeleton';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import type { OkIntegrationsSetRequest, OkIntegrationsStatus } from '@/lib/desktop-bridge-types';
import { dispatchExternalLinkClick } from '@/lib/external-link';
+import { foldEditorsByPrimary, ShowMoreRow } from './editor-list-fold';
import { SettingsSectionHeader } from './SettingsSectionHeader';
type ComponentRef = OkIntegrationsSetRequest['component'];
@@ -112,34 +113,9 @@ export function AiToolsSection() {
setPending(null);
}
- // Yours first, the rest folded. A row is primary when OK has WIRED it
- // (`installed`, `foreign`, or `unmanageable` — its config file exists, which is
- // what makes the tool real), or when the editor is detected.
- //
- // Detection ORDERS but never CLAIMS. That is one rule across every agent list:
- // the external-apps group lets its probe pick a row's default, this one lets
- // the probe pick a row's position, and neither prints an assertion of presence
- // on the row. No surface prints `Detected on this machine`, precisely so the
- // signal can stay useful for ranking without being read as a fact.
- //
- // The signal is a probe of the machine — a CLI on the login-shell PATH, or the
- // app the OS says owns the URL scheme — and it answers "is this tool here",
- // not "did the user set it up with us". Those are different questions, so
- // ranking is the most it earns. A row it lifts still shows `How to set up`,
- // never a presence claim.
- const editors = status?.editors ?? [];
- const isPrimaryEditor = (e: (typeof editors)[number]): boolean =>
- e.state !== 'not-installed' || e.detected;
- const primaryEditors = editors.filter(isPrimaryEditor);
- // Nothing configured and nothing detected would otherwise fold the entire list
- // away and leave an empty box under the heading. A fold that hides everything
- // is not a fold.
- const foldable = primaryEditors.length > 0 && primaryEditors.length < editors.length;
- const shownEditors =
- !foldable || showAllEditors
- ? [...editors].sort((a, b) => Number(isPrimaryEditor(b)) - Number(isPrimaryEditor(a)))
- : primaryEditors;
- const hiddenCount = foldable ? editors.length - primaryEditors.length : 0;
+ // Yours first, the rest folded — the ranking contract lives in
+ // `foldEditorsByPrimary`, shared with the project-scope section.
+ const { shownEditors, hiddenCount } = foldEditorsByPrimary(status?.editors ?? [], showAllEditors);
const header = (
<SettingsSectionHeader
@@ -350,26 +326,12 @@ export function AiToolsSection() {
</li>
);
})}
- {hiddenCount > 0 ? (
- <li>
- <Button
- type="button"
- variant="ghost"
- onClick={() => setShowAllEditors((v) => !v)}
- className="w-full justify-center rounded-none font-normal text-muted-foreground text-xs"
- data-testid="ai-tools-editors-show-more"
- >
- {/* Never names what the probe thinks of the hidden rows: an
- "N not found" label would reassert the same unbacked detection
- claim this surface removed, one line lower. The noun is left off
- to reuse the
- Configure agents msgid verbatim — a counted noun would need
- plural forms in every locale to buy a word the "MCP
- connections" heading above already supplies. */}
- {showAllEditors ? t`Show less` : t`Show ${hiddenCount} more`}
- </Button>
- </li>
- ) : null}
+ <ShowMoreRow
+ hiddenCount={hiddenCount}
+ expanded={showAllEditors}
+ onToggle={() => setShowAllEditors((v) => !v)}
+ testId="ai-tools-editors-show-more"
+ />
</ul>
</div>
diff --git a/packages/app/src/components/settings/ProjectAiToolsSection.dom.test.tsx b/packages/app/src/components/settings/ProjectAiToolsSection.dom.test.tsx
index 1de645652..2739c4866 100644
--- a/packages/app/src/components/settings/ProjectAiToolsSection.dom.test.tsx
+++ b/packages/app/src/components/settings/ProjectAiToolsSection.dom.test.tsx
@@ -40,6 +40,7 @@ const baseStatus: OkProjectIntegrationsStatus = {
{
id: 'claude',
label: 'Claude Code',
+ detected: true,
state: 'installed',
configPath: '.mcp.json',
entryLocator: 'mcpServers.open-knowledge',
@@ -48,6 +49,7 @@ const baseStatus: OkProjectIntegrationsStatus = {
{
id: 'cursor',
label: 'Cursor',
+ detected: false,
state: 'not-installed',
configPath: '.cursor/mcp.json',
entryLocator: 'mcpServers.open-knowledge',
@@ -56,6 +58,7 @@ const baseStatus: OkProjectIntegrationsStatus = {
{
id: 'codex',
label: 'Codex',
+ detected: true,
state: 'foreign',
configPath: '.codex/config.toml',
entryLocator: '[mcp_servers.open-knowledge]',
@@ -94,6 +97,10 @@ function installBridge({ status = baseStatus, setResult }: HarnessOpts = {}) {
return { setCalls };
}
+async function expandEditors(): Promise<void> {
+ await userEvent.click(await screen.findByTestId('project-ai-tools-editors-show-more'));
+}
+
afterEach(() => {
cleanup();
toastError.mockClear();
@@ -136,8 +143,10 @@ describe('ProjectAiToolsSection', () => {
await waitFor(() => {
expect(screen.getByTestId('project-ai-tools-editor-checkbox-claude')).toBeTruthy();
});
- expect(screen.getByTestId('project-ai-tools-editor-checkbox-cursor')).toBeTruthy();
+ expect(screen.queryByTestId('project-ai-tools-editor-checkbox-cursor')).toBeNull();
expect(screen.getByTestId('project-ai-tools-editor-checkbox-codex')).toBeTruthy();
+ await expandEditors();
+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-cursor')).toBeTruthy();
// The project skill moved to Skills Studio; this page names where.
expect(screen.queryByTestId('project-ai-tools-skill-uninstall')).toBeNull();
expect(screen.getByTestId('project-ai-tools-skills-moved').textContent).toContain(
@@ -155,6 +164,7 @@ describe('ProjectAiToolsSection', () => {
expect(
screen.getByTestId('project-ai-tools-editor-checkbox-claude').getAttribute('aria-checked'),
).toBe('true');
+ await expandEditors();
expect(
screen.getByTestId('project-ai-tools-editor-checkbox-cursor').getAttribute('aria-checked'),
).toBe('false');
@@ -172,6 +182,7 @@ describe('ProjectAiToolsSection', () => {
// Foreign row (checked) also carries its follow-up.
expect(screen.getByTestId('project-ai-tools-editor-followup-codex')).toBeTruthy();
// not-installed cursor row has no follow-up yet.
+ await expandEditors();
expect(screen.queryByTestId('project-ai-tools-editor-followup-cursor')).toBeNull();
});
@@ -179,9 +190,7 @@ describe('ProjectAiToolsSection', () => {
const { setCalls } = installBridge();
renderSection();
const user = userEvent.setup();
- await waitFor(() => {
- expect(screen.getByTestId('project-ai-tools-editor-checkbox-cursor')).toBeTruthy();
- });
+ await expandEditors();
await user.click(screen.getByTestId('project-ai-tools-editor-checkbox-cursor'));
await waitFor(() => expect(setCalls.length).toBe(1));
expect(setCalls[0]).toEqual({ component: { kind: 'editor', id: 'cursor' }, enabled: true });
@@ -197,9 +206,7 @@ describe('ProjectAiToolsSection', () => {
});
renderSection();
const user = userEvent.setup();
- await waitFor(() => {
- expect(screen.getByTestId('project-ai-tools-editor-checkbox-cursor')).toBeTruthy();
- });
+ await expandEditors();
await user.click(screen.getByTestId('project-ai-tools-editor-checkbox-cursor'));
await waitFor(() => expect(toastError).toHaveBeenCalledWith('guest config — left unchanged'));
});
@@ -222,4 +229,57 @@ describe('ProjectAiToolsSection', () => {
expect(screen.getByTestId('project-ai-tools-read-only')).toBeTruthy();
});
});
+
+ test('detection keeps an unwired editor above the fold without claiming presence', async () => {
+ installBridge({
+ status: {
+ ...baseStatus,
+ editors: baseStatus.editors.map((editor) =>
+ editor.id === 'cursor' ? { ...editor, detected: true } : editor,
+ ),
+ },
+ });
+ renderSection();
+
+ await screen.findByTestId('project-ai-tools-editor-checkbox-cursor');
+ expect(screen.queryByTestId('project-ai-tools-editors-show-more')).toBeNull();
+ expect(document.body.textContent).not.toContain('Detected on this machine');
+ });
+
+ test('the editor disclosure expands and collapses the hidden rows', async () => {
+ installBridge();
+ renderSection();
+
+ const disclosure = await screen.findByTestId('project-ai-tools-editors-show-more');
+ expect(disclosure.getAttribute('aria-expanded')).toBe('false');
+ expect(screen.queryByTestId('project-ai-tools-editor-checkbox-cursor')).toBeNull();
+
+ const user = userEvent.setup();
+ await user.click(disclosure);
+ expect(disclosure.getAttribute('aria-expanded')).toBe('true');
+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-cursor')).toBeTruthy();
+
+ await user.click(disclosure);
+ expect(disclosure.getAttribute('aria-expanded')).toBe('false');
+ expect(screen.queryByTestId('project-ai-tools-editor-checkbox-cursor')).toBeNull();
+ });
+
+ test('shows the full list when nothing is configured or detected', async () => {
+ installBridge({
+ status: {
+ ...baseStatus,
+ editors: baseStatus.editors.map((editor) => ({
+ ...editor,
+ detected: false,
+ state: 'not-installed' as const,
+ })),
+ },
+ });
+ renderSection();
+
+ await screen.findByTestId('project-ai-tools-editor-checkbox-cursor');
+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-claude')).toBeTruthy();
+ expect(screen.getByTestId('project-ai-tools-editor-checkbox-codex')).toBeTruthy();
+ expect(screen.queryByTestId('project-ai-tools-editors-show-more')).toBeNull();
+ });
});
diff --git a/packages/app/src/components/settings/ProjectAiToolsSection.tsx b/packages/app/src/components/settings/ProjectAiToolsSection.tsx
index 4d1e9eced..af3e3fd26 100644
--- a/packages/app/src/components/settings/ProjectAiToolsSection.tsx
+++ b/packages/app/src/components/settings/ProjectAiToolsSection.tsx
@@ -41,6 +41,7 @@ import type {
OkProjectIntegrationsSetRequest,
OkProjectIntegrationsStatus,
} from '@/lib/desktop-bridge-types';
+import { foldEditorsByPrimary, ShowMoreRow } from './editor-list-fold';
import { SettingsSectionHeader } from './SettingsSectionHeader';
type EditorRow = OkProjectIntegrationsStatus['editors'][number];
@@ -119,6 +120,7 @@ export function ProjectAiToolsSection() {
const [status, setStatus] = useState<OkProjectIntegrationsStatus | null>(null);
const [loadFailed, setLoadFailed] = useState(false);
const [pending, setPending] = useState<string | null>(null);
+ const [showAllEditors, setShowAllEditors] = useState(false);
useEffect(() => {
if (!bridge) return;
@@ -153,6 +155,10 @@ export function ProjectAiToolsSection() {
setPending(null);
}
+ // Same ranking contract as the user-global list, by construction — both
+ // sections consume `foldEditorsByPrimary`.
+ const { shownEditors, hiddenCount } = foldEditorsByPrimary(status?.editors ?? [], showAllEditors);
+
const header = (
<SettingsSectionHeader
titleId="settings-project-ai-tools-title"
@@ -224,7 +230,7 @@ export function ProjectAiToolsSection() {
</Trans>
</span>
<ul className="rounded-md border border-border bg-card/50 divide-y divide-border overflow-hidden">
- {status.editors.map((editor) => (
+ {shownEditors.map((editor) => (
<EditorRowItem
key={editor.id}
editor={editor}
@@ -232,6 +238,12 @@ export function ProjectAiToolsSection() {
onToggle={(enabled) => void applyToggle({ kind: 'editor', id: editor.id }, enabled)}
/>
))}
+ <ShowMoreRow
+ hiddenCount={hiddenCount}
+ expanded={showAllEditors}
+ onToggle={() => setShowAllEditors((value) => !value)}
+ testId="project-ai-tools-editors-show-more"
+ />
</ul>
</div>
diff --git a/packages/app/src/components/settings/editor-list-fold.test.ts b/packages/app/src/components/settings/editor-list-fold.test.ts
new file mode 100644
index 000000000..924c77b21
--- /dev/null
+++ b/packages/app/src/components/settings/editor-list-fold.test.ts
@@ -0,0 +1,29 @@
+import { describe, expect, test } from 'vitest';
+import { foldEditorsByPrimary } from './editor-list-fold';
+
+type Editor = {
+ id: string;
+ state: 'installed' | 'not-installed';
+ detected: boolean;
+};
+
+describe('foldEditorsByPrimary', () => {
+ test('orders primary editors first without changing order within either group', () => {
+ const editors: Editor[] = [
+ { id: 'secondary-a', state: 'not-installed', detected: false },
+ { id: 'wired', state: 'installed', detected: false },
+ { id: 'secondary-b', state: 'not-installed', detected: false },
+ { id: 'detected', state: 'not-installed', detected: true },
+ ];
+
+ const { shownEditors, hiddenCount } = foldEditorsByPrimary(editors, true);
+
+ expect(shownEditors.map((editor) => editor.id)).toEqual([
+ 'wired',
+ 'detected',
+ 'secondary-a',
+ 'secondary-b',
+ ]);
+ expect(hiddenCount).toBe(2);
+ });
+});
diff --git a/packages/app/src/components/settings/editor-list-fold.tsx b/packages/app/src/components/settings/editor-list-fold.tsx
new file mode 100644
index 000000000..8b199ebae
--- /dev/null
+++ b/packages/app/src/components/settings/editor-list-fold.tsx
@@ -0,0 +1,77 @@
+/**
+ * The one ranking contract for Settings editor lists — user-global
+ * (`AiToolsSection`) and project (`ProjectAiToolsSection`) consume the same
+ * fold so the two scopes can never rank the same machine differently.
+ *
+ * Yours first, the rest folded. A row is primary when OK has WIRED it
+ * (`installed`, `foreign`, or `unmanageable` — its config file exists, which is
+ * what makes the tool real), or when the editor is detected.
+ *
+ * Detection ORDERS but never CLAIMS. That is one rule across every agent list:
+ * the external-apps group lets its probe pick a row's default, these lists let
+ * the probe pick a row's position, and neither prints an assertion of presence
+ * on the row. No surface prints `Detected on this machine`, precisely so the
+ * signal can stay useful for ranking without being read as a fact.
+ *
+ * The signal is a probe of the machine — a CLI on the login-shell PATH, or the
+ * app the OS says owns the URL scheme — and it answers "is this tool here",
+ * not "did the user set it up with us". Those are different questions, so
+ * ranking is the most it earns. A row it lifts still shows `How to set up`,
+ * never a presence claim.
+ */
+
+import { useLingui } from '@lingui/react/macro';
+import { Button } from '@/components/ui/button';
+
+export function foldEditorsByPrimary<T extends { state: string; detected: boolean }>(
+ editors: readonly T[],
+ showAll: boolean,
+): { shownEditors: T[]; hiddenCount: number } {
+ const isPrimary = (editor: T): boolean => editor.state !== 'not-installed' || editor.detected;
+ const primaryEditors = editors.filter(isPrimary);
+ // Nothing configured and nothing detected would otherwise fold the entire list
+ // away and leave an empty box under the heading. A fold that hides everything
+ // is not a fold.
+ const foldable = primaryEditors.length > 0 && primaryEditors.length < editors.length;
+ const shownEditors =
+ !foldable || showAll
+ ? [...editors].sort((a, b) => Number(isPrimary(b)) - Number(isPrimary(a)))
+ : primaryEditors;
+ return { shownEditors, hiddenCount: foldable ? editors.length - primaryEditors.length : 0 };
+}
+
+/** The fold's disclosure row. Renders nothing when the list isn't foldable. */
+export function ShowMoreRow({
+ hiddenCount,
+ expanded,
+ onToggle,
+ testId,
+}: {
+ hiddenCount: number;
+ expanded: boolean;
+ onToggle: () => void;
+ testId: string;
+}) {
+ const { t } = useLingui();
+ if (hiddenCount === 0) return null;
+ return (
+ <li>
+ <Button
+ type="button"
+ variant="ghost"
+ aria-expanded={expanded}
+ onClick={onToggle}
+ className="w-full justify-center rounded-none font-normal text-muted-foreground text-xs"
+ data-testid={testId}
+ >
+ {/* Never names what the probe thinks of the hidden rows: an
+ "N not found" label would reassert the same unbacked detection
+ claim this surface removed, one line lower. The noun is left off
+ to reuse the Configure agents msgid verbatim — a counted noun
+ would need plural forms in every locale to buy a word the "MCP
+ connections" heading above already supplies. */}
+ {expanded ? t`Show less` : t`Show ${hiddenCount} more`}
+ </Button>
+ </li>
+ );
+}
diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.po
index b15c8a468..c85b897b8 100644
--- a/packages/app/src/locales/ar/messages.po
+++ b/packages/app/src/locales/ar/messages.po
@@ -11562,8 +11562,8 @@ msgstr "إظهار {0} إضافية"
msgid "Show {hidden} more"
msgstr "إظهار {hidden} إضافية"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "إظهار {hiddenCount} إضافية"
@@ -11629,8 +11629,8 @@ msgid "Show in Explorer"
msgstr "الإظهار في المستعرض"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "إظهار أقل"
diff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.po
index 39161b90f..d7064a69b 100644
--- a/packages/app/src/locales/bn/messages.po
+++ b/packages/app/src/locales/bn/messages.po
@@ -11558,8 +11558,8 @@ msgstr "আরও {0}টি দেখান"
msgid "Show {hidden} more"
msgstr "আরও {hidden}টি দেখান"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "আরও {hiddenCount}টি দেখান"
@@ -11625,8 +11625,8 @@ msgid "Show in Explorer"
msgstr "Explorer-এ দেখান"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "কম দেখান"
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index f201fc964..437f35aaa 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -11562,8 +11562,8 @@ msgstr "Show {0} more"
msgid "Show {hidden} more"
msgstr "Show {hidden} more"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "Show {hiddenCount} more"
@@ -11629,8 +11629,8 @@ msgid "Show in Explorer"
msgstr "Show in Explorer"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "Show less"
diff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.po
index 4aad6613f..27e5cb6ed 100644
--- a/packages/app/src/locales/es/messages.po
+++ b/packages/app/src/locales/es/messages.po
@@ -11562,8 +11562,8 @@ msgstr "Mostrar {0} más"
msgid "Show {hidden} more"
msgstr "Mostrar {hidden} más"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "Mostrar {hiddenCount} más"
@@ -11629,8 +11629,8 @@ msgid "Show in Explorer"
msgstr "Mostrar en el Explorador"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "Mostrar menos"
diff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.po
index 40e1fb252..b5cfb0193 100644
--- a/packages/app/src/locales/fr/messages.po
+++ b/packages/app/src/locales/fr/messages.po
@@ -11562,8 +11562,8 @@ msgstr "Afficher {0} de plus"
msgid "Show {hidden} more"
msgstr "Afficher {hidden} de plus"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "Afficher {hiddenCount} de plus"
@@ -11629,8 +11629,8 @@ msgid "Show in Explorer"
msgstr "Afficher dans l'Explorateur"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "Afficher moins"
diff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.po
index 0c3b1fce9..bc943b6cc 100644
--- a/packages/app/src/locales/hi/messages.po
+++ b/packages/app/src/locales/hi/messages.po
@@ -11558,8 +11558,8 @@ msgstr "{0} और दिखाएँ"
msgid "Show {hidden} more"
msgstr "{hidden} और दिखाएँ"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "{hiddenCount} और दिखाएँ"
@@ -11625,8 +11625,8 @@ msgid "Show in Explorer"
msgstr "Explorer में दिखाएँ"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "कम दिखाएँ"
diff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.po
index b4d505a54..20f70274e 100644
--- a/packages/app/src/locales/id/messages.po
+++ b/packages/app/src/locales/id/messages.po
@@ -11558,8 +11558,8 @@ msgstr "Tampilkan {0} lagi"
msgid "Show {hidden} more"
msgstr "Tampilkan {hidden} lagi"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "Tampilkan {hiddenCount} lagi"
@@ -11625,8 +11625,8 @@ msgid "Show in Explorer"
msgstr "Tampilkan di Explorer"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "Tampilkan lebih sedikit"
diff --git a/packages/app/src/locales/ko/messages.po b/packages/app/src/locales/ko/messages.po
index 10161e9b8..31499a3dc 100644
--- a/packages/app/src/locales/ko/messages.po
+++ b/packages/app/src/locales/ko/messages.po
@@ -11562,8 +11562,8 @@ msgstr "{0}개 더 보기"
msgid "Show {hidden} more"
msgstr "{hidden}개 더 보기"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "{hiddenCount}개 더 보기"
@@ -11629,8 +11629,8 @@ msgid "Show in Explorer"
msgstr "탐색기에서 보기"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "적게 보기"
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 8fa54ddbc..01e373140 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -11558,8 +11558,8 @@ msgstr ""
msgid "Show {hidden} more"
msgstr ""
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr ""
@@ -11625,8 +11625,8 @@ msgid "Show in Explorer"
msgstr ""
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr ""
diff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.po
index 08c7adb73..bc5d122c3 100644
--- a/packages/app/src/locales/pt-BR/messages.po
+++ b/packages/app/src/locales/pt-BR/messages.po
@@ -11558,8 +11558,8 @@ msgstr "Mostrar mais {0}"
msgid "Show {hidden} more"
msgstr "Mostrar mais {hidden}"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "Mostrar mais {hiddenCount}"
@@ -11625,8 +11625,8 @@ msgid "Show in Explorer"
msgstr "Mostrar no Explorador"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "Mostrar menos"
diff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.po
index f5f3d6733..3347d58ef 100644
--- a/packages/app/src/locales/ur/messages.po
+++ b/packages/app/src/locales/ur/messages.po
@@ -11562,8 +11562,8 @@ msgstr "{0} مزید دکھائیں"
msgid "Show {hidden} more"
msgstr "{hidden} مزید دکھائیں"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "{hiddenCount} مزید دکھائیں"
@@ -11629,8 +11629,8 @@ msgid "Show in Explorer"
msgstr "ایکسپلورر میں دکھائیں"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "کم دکھائیں"
diff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.po
index ca0d659ee..78cdfd7e3 100644
--- a/packages/app/src/locales/zh-Hans/messages.po
+++ b/packages/app/src/locales/zh-Hans/messages.po
@@ -11562,8 +11562,8 @@ msgstr "再显示 {0} 个"
msgid "Show {hidden} more"
msgstr "再显示 {hidden} 个"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "再显示 {hiddenCount} 个"
@@ -11629,8 +11629,8 @@ msgid "Show in Explorer"
msgstr "在资源管理器中显示"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "收起"
diff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.po
index b3e843ae4..bdd87a840 100644
--- a/packages/app/src/locales/zh-Hant/messages.po
+++ b/packages/app/src/locales/zh-Hant/messages.po
@@ -11562,8 +11562,8 @@ msgstr "再顯示 {0} 個"
msgid "Show {hidden} more"
msgstr "再顯示 {hidden} 個"
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show {hiddenCount} more"
msgstr "再顯示 {hiddenCount} 個"
@@ -11629,8 +11629,8 @@ msgid "Show in Explorer"
msgstr "在檔案總管中顯示"
#: src/components/PackCardGrid.tsx
-#: src/components/settings/AiToolsSection.tsx
#: src/components/settings/ConfigureAgentsSection.tsx
+#: src/components/settings/editor-list-fold.tsx
msgid "Show less"
msgstr "收合"
diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.ts
index 7484e4d4d..68a2133a4 100644
--- a/packages/core/src/desktop-bridge.ts
+++ b/packages/core/src/desktop-bridge.ts
@@ -687,6 +687,8 @@ export interface OkProjectIntegrationsStatus {
readonly editors: readonly {
readonly id: OkMcpWiringEditorId;
readonly label: string;
+ /** Machine-level presence from CLI / URL-scheme probes. Ranking only. */
+ readonly detected: boolean;
readonly state: OkIntegrationsEditorState;
readonly configPath: string;
readonly entryLocator: string;
diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.ts
index d0f253117..0c92f51a0 100644
--- a/packages/desktop/src/main/index.ts
+++ b/packages/desktop/src/main/index.ts
@@ -271,7 +271,10 @@ import { readCanonicalGitHubRemoteUrl } from './git-remote.ts';
import { classifyInstallShape } from './install-shape.ts';
import { formatInstanceAppName, resolveInstanceLabel } from './instance-identity.ts';
import { deriveInstanceUserDataDir } from './instance-isolation.ts';
-import { registerIntegrationsSettings } from './integrations-settings.ts';
+import {
+ type EditorPresenceProbes,
+ registerIntegrationsSettings,
+} from './integrations-settings.ts';
import {
type BugReportScreenshotEntry,
handleBugReportCaptureScreenshot,
@@ -6729,6 +6732,62 @@ function registerIpcHandlers() {
registerProjectIntegrationsSettingsIpc();
}
+/**
+ * Machine-level editor presence shared by both Settings integration scopes,
+ * cached ~60s as one in-flight Promise. Both scopes await a fresh pass on
+ * every status fetch AND inside every toggle acknowledgment (behind the
+ * mutation mutex), and the scheme-handler probes are subprocess-backed on
+ * Linux (`xdg-mime` per scheme, 2s timeout each) — uncached, a checkbox click
+ * would block its own acknowledgment on OS queries whose answer the mutation
+ * cannot change (detection is ranking-only). Same TTL rationale and
+ * promise-sharing shape as `resolveTerminalCliInstalledMap`, which caches the
+ * CLI half independently.
+ */
+const EDITOR_PRESENCE_TTL_MS = 60_000;
+let editorPresenceCache: { at: number; value: Promise<EditorPresenceProbes> } | null = null;
+
+function probeEditorPresence(): Promise<EditorPresenceProbes> {
+ const now = Date.now();
+ if (editorPresenceCache && now - editorPresenceCache.at < EDITOR_PRESENCE_TTL_MS) {
+ return editorPresenceCache.value;
+ }
+ const value = probeEditorPresenceUncached().catch((err) => {
+ // Every sub-probe already degrades in place, so this shouldn't fire — but a
+ // rejection must not stay cached for the full TTL; the next call retries.
+ editorPresenceCache = null;
+ throw err;
+ });
+ editorPresenceCache = { at: now, value };
+ return value;
+}
+
+async function probeEditorPresenceUncached(): Promise<EditorPresenceProbes> {
+ const [cliOnPath, ...schemes] = await Promise.all([
+ resolveTerminalCliInstalledMap().catch(() => ({}) as Record<TerminalCli, boolean>),
+ ...(['claude', 'codex', 'cursor'] as const).map((scheme) =>
+ detectProtocolImpl(
+ {
+ platform: process.platform,
+ getApplicationInfoForProtocol: (url) => app.getApplicationInfoForProtocol(url),
+ },
+ scheme,
+ )
+ .then((r) => r.installed)
+ .catch(() => false),
+ ),
+ ]);
+ return {
+ cliOnPath,
+ // `claude-code` is the handoff-target id for the Claude desktop app; the
+ // other two share their scheme name with their target id.
+ schemeHandler: {
+ 'claude-code': schemes[0] ?? false,
+ codex: schemes[1] ?? false,
+ cursor: schemes[2] ?? false,
+ },
+ };
+}
+
/**
* Settings → AI tools: persistent status/toggle IPC over the same install
* actors as the first-launch consent dialog (`createMcpWiringOpts`) and the
@@ -6774,35 +6833,10 @@ function registerIntegrationsSettingsIpc(): void {
removeUserMcpEntry: (editorId) =>
removeOwnMcpEntry(EDITOR_TARGETS[editorId], '', osHomedir()),
},
- // Reuses the probes the launcher surfaces already run and cache (~60s), so
- // opening Settings costs no extra shell spawns and every surface answers the
- // same question the same way.
- probeEditorPresence: async () => {
- const [cliOnPath, ...schemes] = await Promise.all([
- resolveTerminalCliInstalledMap().catch(() => ({}) as Record<TerminalCli, boolean>),
- ...(['claude', 'codex', 'cursor'] as const).map((scheme) =>
- detectProtocolImpl(
- {
- platform: process.platform,
- getApplicationInfoForProtocol: (url) => app.getApplicationInfoForProtocol(url),
- },
- scheme,
- )
- .then((r) => r.installed)
- .catch(() => false),
- ),
- ]);
- return {
- cliOnPath,
- // `claude-code` is the handoff-target id for the Claude desktop app; the
- // other two share their scheme name with their target id.
- schemeHandler: {
- 'claude-code': schemes[0] ?? false,
- codex: schemes[1] ?? false,
- cursor: schemes[2] ?? false,
- },
- };
- },
+ // Cached ~60s (see probeEditorPresence), so opening Settings or toggling a
+ // row costs no extra shell spawns and every surface answers the same
+ // question the same way.
+ probeEditorPresence,
path: {
computeStatus: () => {
const descriptor = computePathInstallDescriptor({
@@ -7045,6 +7079,7 @@ function registerProjectIntegrationsSettingsIpc(): void {
available,
ipcMain,
cli,
+ probeEditorPresence,
resolveProjectDir: (event) => {
const win = BrowserWindow.fromWebContents(event.sender);
if (!win) return null;
diff --git a/packages/desktop/src/main/integrations-settings.ts b/packages/desktop/src/main/integrations-settings.ts
index 432fdc9f2..a1a3e85ae 100644
--- a/packages/desktop/src/main/integrations-settings.ts
+++ b/packages/desktop/src/main/integrations-settings.ts
@@ -215,6 +215,24 @@ export function detectedEditorsFromProbes(probes: EditorPresenceProbes): Set<Mcp
return detected;
}
+/**
+ * `detectedEditorsFromProbes` with the shared failure policy: a failed probe is
+ * unknown, not empty-and-not-installed — but unknown must not claim, and an
+ * empty set under-claims, which is the safe direction on every surface that
+ * reads this (detection is ranking-only). One function so the user-global and
+ * project Settings scopes can never rank the same machine differently on
+ * failure.
+ */
+export async function safeDetectedEditors(
+ probeEditorPresence: () => Promise<EditorPresenceProbes>,
+): Promise<Set<McpWiringEditorId>> {
+ try {
+ return detectedEditorsFromProbes(await probeEditorPresence());
+ } catch {
+ return new Set();
+ }
+}
+
export function registerIntegrationsSettings(
opts: RegisterIntegrationsSettingsOpts,
): IntegrationsSettingsHandle {
@@ -240,23 +258,15 @@ export function registerIntegrationsSettings(
* filtered to user-global targets, while this set must stay honest about
* project-scope-only ones (Pi) too.
*/
- async function computeDetectedEditors(): Promise<Set<McpWiringEditorId>> {
- try {
- return detectedEditorsFromProbes(await probeEditorPresence());
- } catch {
- // A failed probe is unknown, not empty-and-not-installed — but unknown
- // must not claim, and an empty set under-claims, which is the safe
- // direction on every surface that reads this.
- return new Set();
- }
- }
+ const computeDetectedEditors = (): Promise<Set<McpWiringEditorId>> =>
+ safeDetectedEditors(probeEditorPresence);
/**
* `detected` is optional so a caller that has already probed can pass its set
- * in rather than paying a second pass. `probeEditorPresence` is not cached —
- * each call re-runs the login-shell lookups and the OS scheme-handler
- * queries — and two passes can straddle an install or removal, which is
- * exactly the drift the status snapshot must not show.
+ * in rather than paying a second pass. Whether `probeEditorPresence` caches
+ * is the injector's business (main's does, ~60s), so two passes here could
+ * still straddle an install or removal — exactly the drift the status
+ * snapshot must not show.
*/
async function computeEditorStatuses(
detected?: Set<McpWiringEditorId>,
diff --git a/packages/desktop/src/main/project-integrations-settings.test.ts b/packages/desktop/src/main/project-integrations-settings.test.ts
index 9d956c91a..0037286ab 100644
--- a/packages/desktop/src/main/project-integrations-settings.test.ts
+++ b/packages/desktop/src/main/project-integrations-settings.test.ts
@@ -119,13 +119,21 @@ function makeCli(overrides: CliOverrides = {}): ProjectIntegrationsCliSurface &
function register(
cli: ProjectIntegrationsCliSurface,
- opts: { available?: boolean; projectDir?: string | null } = {},
+ opts: {
+ available?: boolean;
+ projectDir?: string | null;
+ probeEditorPresence?: Parameters<
+ typeof registerProjectIntegrationsSettings
+ >[0]['probeEditorPresence'];
+ } = {},
) {
const ipcMain = fakeIpcMain();
const handle = registerProjectIntegrationsSettings({
available: opts.available ?? true,
ipcMain,
cli,
+ probeEditorPresence:
+ opts.probeEditorPresence ?? (async () => ({ cliOnPath: {}, schemeHandler: {} })),
resolveProjectDir: () => (opts.projectDir === undefined ? PROJECT : opts.projectDir),
tildify: (p) => p,
});
@@ -150,10 +158,36 @@ describe('registerProjectIntegrationsSettings — status', () => {
expect(s.editors.map((e) => e.id)).toEqual(['claude', 'codex']);
const claude = s.editors.find((e) => e.id === 'claude');
expect(claude?.configPath).toBe('.mcp.json');
+ expect(claude?.detected).toBe(false);
expect(claude?.followUp).toBe('approve-once');
expect(s.editors.find((e) => e.id === 'codex')?.followUp).toBe('auto-connect');
});
+ test('marks project rows detected from the shared machine-level probes', async () => {
+ const { status } = register(makeCli(), {
+ probeEditorPresence: async () => ({
+ cliOnPath: { codex: true },
+ schemeHandler: { 'claude-code': true },
+ }),
+ });
+ const s = await status();
+ expect(s.editors.map(({ id, detected }) => [id, detected])).toEqual([
+ ['claude', true],
+ ['codex', true],
+ ]);
+ });
+
+ test('probe failure safely leaves project rows undetected', async () => {
+ const { status } = register(makeCli(), {
+ probeEditorPresence: async () => {
+ throw new Error('probe unavailable');
+ },
+ });
+ const s = await status();
+ expect(s.editors.length).toBeGreaterThan(0);
+ expect(s.editors.every((editor) => !editor.detected)).toBe(true);
+ });
+
test('classifies own entry as installed, foreign as foreign, decline as unmanageable', async () => {
const { status } = register(
makeCli({
diff --git a/packages/desktop/src/main/project-integrations-settings.ts b/packages/desktop/src/main/project-integrations-settings.ts
index 8da8859d6..74d15b131 100644
--- a/packages/desktop/src/main/project-integrations-settings.ts
+++ b/packages/desktop/src/main/project-integrations-settings.ts
@@ -48,7 +48,11 @@ import type {
SkillCostTiers,
} from '../shared/ipc-channels.ts';
import { createHandler } from '../shared/ipc-handler.ts';
-import { classifyEditorState } from './integrations-settings.ts';
+import {
+ classifyEditorState,
+ type EditorPresenceProbes,
+ safeDetectedEditors,
+} from './integrations-settings.ts';
import { logIpcError } from './ipc-log.ts';
/**
@@ -153,6 +157,8 @@ export interface RegisterProjectIntegrationsSettingsOpts {
available: boolean;
ipcMain: IpcMainLike;
cli: ProjectIntegrationsCliSurface;
+ /** Same machine-level probes as the user-global integrations surface. */
+ probeEditorPresence: () => Promise<EditorPresenceProbes>;
/** Resolve the sender window's project dir (main maps webContents →
* ProjectContext). Null when the sender isn't bound to a project. */
resolveProjectDir(event: IpcMainInvokeEvent): string | null;
@@ -172,6 +178,7 @@ export function registerProjectIntegrationsSettings(
available,
ipcMain,
cli,
+ probeEditorPresence,
resolveProjectDir,
tildify = (p) => p,
logger = DEFAULT_LOGGER,
@@ -182,7 +189,10 @@ export function registerProjectIntegrationsSettings(
return cli.allEditorIds.filter((id) => cli.projectSkillPath(id, projectDir) !== null);
}
- function computeEditorStatuses(projectDir: string): ProjectIntegrationsEditorStatus[] {
+ function computeEditorStatuses(
+ projectDir: string,
+ detected: ReadonlySet<McpWiringEditorId>,
+ ): ProjectIntegrationsEditorStatus[] {
const statuses: ProjectIntegrationsEditorStatus[] = [];
for (const id of cli.allEditorIds) {
const projectPath = cli.projectConfigPath(id, projectDir);
@@ -206,6 +216,7 @@ export function registerProjectIntegrationsSettings(
statuses.push({
id,
label: cli.editorLabel(id),
+ detected: detected.has(id),
state,
configPath: relative(projectDir, projectPath),
entryLocator: cli.entryLocator(id),
@@ -215,13 +226,13 @@ export function registerProjectIntegrationsSettings(
return statuses;
}
- function computeStatus(projectDir: string | null): ProjectIntegrationsStatus {
+ async function computeStatus(projectDir: string | null): Promise<ProjectIntegrationsStatus> {
if (projectDir === null) {
return { available, hasProject: false, projectDir: null, editors: [], skill: null };
}
let editors: ProjectIntegrationsEditorStatus[];
try {
- editors = computeEditorStatuses(projectDir);
+ editors = computeEditorStatuses(projectDir, await safeDetectedEditors(probeEditorPresence));
} catch (err) {
logger.warn('project editor statuses failed', {
projectDir,
@@ -420,9 +431,9 @@ export function registerProjectIntegrationsSettings(
handler: 'projectIntegrationsDispatch',
cause: { component: request?.component?.kind ?? 'unknown', error: result.error },
});
- return { ok: false, error: result.error, status: computeStatus(projectDir) };
+ return { ok: false, error: result.error, status: await computeStatus(projectDir) };
}
- return { ok: true, status: computeStatus(projectDir) };
+ return { ok: true, status: await computeStatus(projectDir) };
});
mutationChain = run.catch(() => {});
return run;
diff --git a/packages/desktop/src/shared/ipc-channels.ts b/packages/desktop/src/shared/ipc-channels.ts
index 0a7955784..f9339d96a 100644
--- a/packages/desktop/src/shared/ipc-channels.ts
+++ b/packages/desktop/src/shared/ipc-channels.ts
@@ -663,6 +663,9 @@ export type ProjectIntegrationsFollowUp =
export interface ProjectIntegrationsEditorStatus {
readonly id: McpWiringEditorId;
readonly label: string;
+ /** Machine-level presence from CLI / URL-scheme probes. Used only to order
+ * and fold rows; the renderer never presents it as a setup claim. */
+ readonly detected: boolean;
readonly state: IntegrationsEditorState;
readonly configPath: string;
readonly entryLocator: string;