Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

feat(ok): collapse missing external apps in agent settings (#4364)

sarahadc7bcc49c63
diff --git a/.changeset/external-apps-show-more.md b/.changeset/external-apps-show-more.md
new file mode 100644
index 000000000..72cce21e2
--- /dev/null
+++ b/.changeset/external-apps-show-more.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Missing external apps now appear behind “Show N more” in Agent connections settings, including enabled apps and apps with setup to remove. Detected and unknown apps stay visible; all apps appear when none would remain visible or while searching. All three sections announce their expanded state and retain keyboard focus within the group when a focused disclosure disappears.
diff --git a/packages/app/src/components/settings/AgentConnectionsSection.dom.test.tsx b/packages/app/src/components/settings/AgentConnectionsSection.dom.test.tsx
index e5edcb228..49a11ea65 100644
--- a/packages/app/src/components/settings/AgentConnectionsSection.dom.test.tsx
+++ b/packages/app/src/components/settings/AgentConnectionsSection.dom.test.tsx
@@ -235,6 +235,10 @@ async function expandInApp(): Promise<void> {
fireEvent.click(await screen.findByTestId('configure-agents-in-app-show-more'));
}
+async function expandDesktop(): Promise<void> {
+ fireEvent.click(await screen.findByTestId('configure-agents-desktop-show-more'));
+}
+
function groupOrder(): string[] {
return screen.getAllByRole('heading', { level: 4 }).map((h) => h.textContent?.trim() ?? '');
}
@@ -303,9 +307,11 @@ describe('AgentConnectionsSection', () => {
expect(screen.queryByText('Cline')).toBeNull();
const toggle = screen.getByTestId('configure-agents-in-app-show-more');
expect(toggle.textContent).toContain('Show 3 more');
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
fireEvent.click(toggle);
+ expect(toggle.getAttribute('aria-expanded')).toBe('true');
expect(screen.getByText('Cline')).toBeTruthy();
expect(screen.getByText('ACP wrapper for Cursor')).toBeTruthy();
expect(toggle.textContent).toContain('Show less');
@@ -457,14 +463,26 @@ describe('AgentConnectionsSection', () => {
test('a detected external app is on with no override; a missing one is off', async () => {
renderSection();
const detected = await screen.findByTestId('configure-agents-desktop-claude-code');
+ expect(screen.queryByTestId('configure-agents-desktop-codex')).toBeNull();
+ expect(screen.getByTestId('configure-agents-desktop-cursor')).toBeTruthy();
+ const fold = screen.getByTestId('configure-agents-desktop-show-more');
+ expect(fold.textContent).toBe('Show 1 more');
+ expect(fold.getAttribute('aria-expanded')).toBe('false');
+ await expandDesktop();
const missing = await screen.findByTestId('configure-agents-desktop-codex');
expect(overrides()['desktop:claude-code']).toBeUndefined();
expect(detected.getAttribute('aria-checked')).toBe('true');
expect(missing.getAttribute('aria-checked')).toBe('false');
+ expect(fold.textContent).toBe('Show less');
+ expect(fold.getAttribute('aria-expanded')).toBe('true');
+ fireEvent.click(fold);
+ expect(screen.queryByTestId('configure-agents-desktop-codex')).toBeNull();
+ expect(screen.getByTestId('configure-agents-desktop-claude-code')).toBe(detected);
});
test('an absent external app cannot be switched on, and offers to install instead', async () => {
renderSection();
+ await expandDesktop();
const toggle = await screen.findByTestId('configure-agents-desktop-codex');
expect(toggle.getAttribute('aria-checked')).toBe('false');
expect(toggle.getAttribute('data-disabled')).toBe('');
@@ -489,9 +507,83 @@ describe('AgentConnectionsSection', () => {
fireEvent.change(screen.getByTestId('configure-agents-search'), { target: { value: 'codex' } });
await waitFor(() => expect(screen.queryByText('Claude Agent')).toBeNull());
expect(screen.getByTestId('configure-agents-desktop-codex')).toBeTruthy();
+ expect(screen.queryByTestId('configure-agents-desktop-show-more')).toBeNull();
expect(screen.queryByTestId('configure-agents-no-results')).toBeNull();
});
+ test.each([false, true])(
+ 'search preserves external expansion %s with mixed matches',
+ async (expanded) => {
+ renderSection();
+ await screen.findByText('Claude Agent');
+ if (expanded) await expandDesktop();
+ const search = screen.getByTestId('configure-agents-search');
+ fireEvent.change(search, { target: { value: 'desktop' } });
+ expect(screen.getByTestId('configure-agents-desktop-codex')).toBeTruthy();
+ expect(screen.getByTestId('configure-agents-desktop-claude-code')).toBeTruthy();
+ expect(screen.queryByTestId('configure-agents-desktop-show-more')).toBeNull();
+ fireEvent.change(search, { target: { value: '' } });
+ expect(
+ screen.getByTestId('configure-agents-desktop-show-more').getAttribute('aria-expanded'),
+ ).toBe(String(expanded));
+ expect(screen.queryByTestId('configure-agents-desktop-codex') !== null).toBe(expanded);
+ },
+ );
+
+ test('all absent external apps stay visible without a disclosure', async () => {
+ states = {};
+ const snapshot = { ...snapshotWith(), detection: { detected: [], probed: true } };
+ renderSection(async () => result(snapshot));
+ await screen.findByText('Claude Agent');
+ await waitFor(() =>
+ expect(screen.getByTestId('agent-connection-lm-studio').textContent).toContain(
+ 'Not detected',
+ ),
+ );
+ expect(screen.getByTestId('configure-agents-desktop-claude-code')).toBeTruthy();
+ expect(screen.getByTestId('configure-agents-desktop-codex')).toBeTruthy();
+ expect(screen.getByTestId('configure-agents-desktop-cursor')).toBeTruthy();
+ expect(screen.queryByTestId('configure-agents-desktop-show-more')).toBeNull();
+ });
+
+ test('enabled but absent external apps remain behind the disclosure', async () => {
+ localStorage.setItem(STORAGE_KEY, JSON.stringify({ 'desktop:codex': true }));
+ reloadEnabledAgentsFromStorage();
+ renderSection();
+ await screen.findByText('Claude Agent');
+ expect(screen.queryByTestId('configure-agents-desktop-codex')).toBeNull();
+ await expandDesktop();
+ expect(screen.getByTestId('configure-agents-desktop-codex').getAttribute('aria-checked')).toBe(
+ 'true',
+ );
+ });
+
+ test('resolved presence keeps newly revealed desktop targets after visible targets', async () => {
+ states = {
+ 'claude-code': { installed: null },
+ codex: { installed: null },
+ cursor: { installed: true },
+ } as Record<string, InstallState>;
+ renderSection(async () =>
+ result({ ...snapshotWith(), detection: { detected: [], probed: true } }),
+ );
+ await waitFor(() => expect(screen.queryByTestId('configure-agents-desktop-codex')).toBeNull());
+ await expandDesktop();
+ const rows = screen.getAllByTestId(/^configure-agents-desktop-row-/);
+ expect(rows[0].getAttribute('data-testid')).toBe('configure-agents-desktop-row-cursor');
+ });
+
+ test('focus returns to the group when detection removes its disclosure', async () => {
+ renderSection();
+ await screen.findByText('Claude Agent');
+ const fold = screen.getByTestId('configure-agents-desktop-show-more');
+ fold.focus();
+ states = { ...states, codex: { installed: true } };
+ fireEvent.click(fold);
+ expect(screen.queryByTestId('configure-agents-desktop-show-more')).toBeNull();
+ expect(document.activeElement).toBe(screen.getByRole('heading', { name: 'External apps' }));
+ });
+
test('a query matching nothing shows the no-results line', async () => {
renderSection();
await screen.findByText('Claude Agent');
@@ -527,10 +619,12 @@ describe('AgentConnectionsSection — Terminal group (docked terminal present)',
test('Terminal sorts installed CLIs first and folds the not-installed ones', async () => {
renderSection();
const fold = await screen.findByTestId('configure-agents-terminal-show-more');
+ expect(fold.getAttribute('aria-expanded')).toBe('false');
expect(screen.queryByTestId('configure-agents-terminal-codex')).toBeNull();
expect(screen.getByTestId('configure-agents-terminal-claude')).toBeTruthy();
fireEvent.click(fold);
+ expect(fold.getAttribute('aria-expanded')).toBe('true');
expect(screen.getByTestId('configure-agents-terminal-codex')).toBeTruthy();
expect(fold.textContent).toContain('Show less');
});
@@ -688,6 +782,7 @@ describe('AgentConnectionsSection — connection status and action', () => {
renderSection(async () => result(snapshotWith([])));
await screen.findByTestId('configure-agents-terminal-claude');
+ await expandDesktop();
await waitFor(() => expect(screen.getByTestId('agent-connection-lm-studio')).toBeTruthy());
expect(within(terminalRow('claude')).queryByRole('button')).toBeNull();
expect(within(terminalRow('claude')).getByRole('switch')).toBeTruthy();
@@ -757,6 +852,7 @@ describe('AgentConnectionsSection — connect dialog on switch press', () => {
renderSection(async () => result(snapshotWith([])));
const toggle = await screen.findByTestId('configure-agents-terminal-claude');
+ await expandDesktop();
await waitFor(() => expect(screen.getByTestId('agent-connection-lm-studio')).toBeTruthy());
expect(toggle.getAttribute('aria-checked')).toBe('false');
@@ -772,6 +868,7 @@ describe('AgentConnectionsSection — connect dialog on switch press', () => {
renderSection(async () => result(snapshotWith([])));
const toggle = await screen.findByTestId('configure-agents-terminal-claude');
+ await expandDesktop();
await waitFor(() => expect(screen.getByTestId('agent-connection-lm-studio')).toBeTruthy());
fireEvent.click(toggle);
const dialog = await screen.findByRole('dialog');
@@ -799,6 +896,7 @@ describe('AgentConnectionsSection — connect dialog on switch press', () => {
});
const toggle = await screen.findByTestId('configure-agents-terminal-claude');
+ await expandDesktop();
await waitFor(() => expect(screen.getByTestId('agent-connection-lm-studio')).toBeTruthy());
fireEvent.click(toggle);
const dialog = await screen.findByRole('dialog');
@@ -864,6 +962,7 @@ describe('AgentConnectionsSection — an agent nothing can open', () => {
renderSection(async () => result(snapshotWith([])));
await screen.findByText('External apps');
+ await expandDesktop();
expect(screen.getByTestId('agent-connection-lm-studio')).toBeTruthy();
expect(screen.queryByText('Connect only')).toBeNull();
});
@@ -871,6 +970,7 @@ describe('AgentConnectionsSection — an agent nothing can open', () => {
test('its row carries no switch, having no launcher entry to control', async () => {
renderSection(async () => result(snapshotWith([])));
+ await expandDesktop();
const row = await screen.findByTestId('agent-connection-lm-studio');
expect(within(row).queryByRole('switch')).toBeNull();
});
@@ -878,6 +978,7 @@ describe('AgentConnectionsSection — an agent nothing can open', () => {
test('removal is reachable from the row once its setup is on disk', async () => {
renderSection(async () => result(snapshotWith(diskSatisfierIds('lm-studio'))));
+ await expandDesktop();
const row = await screen.findByTestId('agent-connection-lm-studio');
await waitFor(() =>
expect(within(row).getByRole('button', { name: /^Remove\b/ })).toBeTruthy(),
@@ -893,6 +994,7 @@ describe('AgentConnectionsSection — an agent nothing can open', () => {
});
await waitFor(() => expect(screen.getByTestId('agent-connection-lm-studio')).toBeTruthy());
+ expect(screen.queryByTestId('configure-agents-desktop-show-more')).toBeNull();
expect(screen.queryByText('Terminal')).toBeNull();
});
@@ -943,6 +1045,7 @@ describe('AgentConnectionsSection — no connection row lost on any host', () =>
fireEvent.click(await screen.findByTestId('configure-agents-terminal-show-more'));
expect(connectionRowFor('opencode')).not.toBeNull();
+ await expandDesktop();
expect(CONNECTION_ROW_AGENT_IDS.length).toBeGreaterThanOrEqual(10);
for (const agentId of CONNECTION_ROW_AGENT_IDS) {
expect(
@@ -959,6 +1062,7 @@ describe('AgentConnectionsSection — no connection row lost on any host', () =>
await screen.findByText('External apps');
expect(screen.getByText('Terminal')).toBeTruthy();
+ await expandDesktop();
expect(CONNECTION_ROW_AGENT_IDS.length).toBeGreaterThanOrEqual(10);
for (const agentId of CONNECTION_ROW_AGENT_IDS) {
expect(connectionRowFor(agentId), `no connection row for ${agentId} on web`).not.toBeNull();
@@ -1090,6 +1194,7 @@ describe('AgentConnectionsSection — degraded install-state read', () => {
test('an External-apps row wires its hint to its switch', async () => {
renderSection();
+ await expandDesktop();
const toggle = await screen.findByTestId('configure-agents-desktop-codex');
const row = screen.getByTestId('configure-agents-desktop-row-codex');
diff --git a/packages/app/src/components/settings/AgentConnectionsSection.tsx b/packages/app/src/components/settings/AgentConnectionsSection.tsx
index 491bf108e..74b4700ee 100644
--- a/packages/app/src/components/settings/AgentConnectionsSection.tsx
+++ b/packages/app/src/components/settings/AgentConnectionsSection.tsx
@@ -6,6 +6,7 @@ import {
agentIdForHandoffTarget,
agentIdForTerminalCli,
CONNECTION_ROW_AGENT_IDS,
+ type HandoffTarget,
type HostSnapshot,
TERMINAL_CLI_IDS,
TERMINAL_CLIS,
@@ -160,6 +161,7 @@ function AgentGroup({
<div className="mb-2">
<h4
id={labelId}
+ tabIndex={-1}
className="flex items-center gap-1.5 font-mono text-muted-foreground text-xs uppercase tracking-wide"
>
{label}
@@ -172,6 +174,43 @@ function AgentGroup({
);
}
+function restoreGroupFocusOnRemoval(button: HTMLButtonElement | null) {
+ if (!button) return;
+ return () => {
+ if (button.ownerDocument.activeElement === button) {
+ button.closest('section')?.querySelector('h4')?.focus();
+ }
+ };
+}
+
+function FoldToggleButton({
+ hiddenCount,
+ expanded,
+ onToggle,
+ testId,
+}: {
+ hiddenCount: number;
+ expanded: boolean;
+ onToggle: () => void;
+ testId: string;
+}): ReactNode {
+ const { t } = useLingui();
+ if (hiddenCount <= 0) return null;
+ return (
+ <Button
+ ref={restoreGroupFocusOnRemoval}
+ type="button"
+ variant="ghost"
+ onClick={onToggle}
+ aria-expanded={expanded}
+ className="w-full justify-center rounded-none font-normal text-1sm text-muted-foreground"
+ data-testid={testId}
+ >
+ {expanded ? t`Show less` : t`Show ${hiddenCount} more`}
+ </Button>
+ );
+}
+
function ConnectionStatusLine({
status,
enabled,
@@ -317,7 +356,6 @@ export function AgentConnectionsSection({
applyConnections?: ApplyConnections;
} = {}): ReactNode {
const { t } = useLingui();
- const showMoreLabel = (hiddenCount: number): string => t`Show ${hiddenCount} more`;
const overrides = useEnabledOverrides();
const registered = useRegisteredAgents();
const { states, refresh } = useInstalledAgents();
@@ -325,6 +363,7 @@ export function AgentConnectionsSection({
const [query, setQuery] = useState('');
const [showInAppOverflow, setShowInAppOverflow] = useState(false);
const [showTerminalOverflow, setShowTerminalOverflow] = useState(false);
+ const [showDesktopOverflow, setShowDesktopOverflow] = useState(false);
const [snapshot, setSnapshot] = useState<HostSnapshot | null>(null);
const [readFailed, setReadFailed] = useState(false);
const [readOnly, setReadOnly] = useState(false);
@@ -502,11 +541,14 @@ export function AgentConnectionsSection({
Number(cliPresent(b)) - Number(cliPresent(a)) ||
TERMINAL_CLIS[a].displayName.localeCompare(TERMINAL_CLIS[b].displayName),
);
+ const desktopPresence = (id: HandoffTarget) =>
+ rowPresence(agentIdForHandoffTarget(id), states[id]?.installed ?? null);
const desktopTargets = VISIBLE_TARGETS.filter((target) => {
const { displayName } = target;
return matches(t`${displayName} Desktop`) || matches(target.id);
}).sort(
- (a, b) => Number(states[a.id]?.installed === false) - Number(states[b.id]?.installed === false),
+ (a, b) =>
+ Number(desktopPresence(a.id) === 'absent') - Number(desktopPresence(b.id) === 'absent'),
);
const canLaunchTerminal = terminalLaunch !== null;
@@ -556,6 +598,20 @@ export function AgentConnectionsSection({
const terminalHiddenCount =
terminalFoldable && !searching ? terminalClis.length - terminalPrimary.length : 0;
+ const desktopPrimary = desktopTargets.filter((target) => desktopPresence(target.id) !== 'absent');
+ const unlaunchablePrimary = unlaunchableIds.filter(
+ (id) =>
+ rowPresence(id, connections.find((c) => c.id === id)?.row.detected ?? null) !== 'absent',
+ );
+ const desktopPrimaryCount = desktopPrimary.length + unlaunchablePrimary.length;
+ const desktopTotalCount = desktopTargets.length + unlaunchableIds.length;
+ const desktopFoldable = desktopPrimaryCount > 0 && desktopPrimaryCount < desktopTotalCount;
+ const desktopExpanded = !desktopFoldable || searching || showDesktopOverflow;
+ const desktopShown = desktopExpanded ? desktopTargets : desktopPrimary;
+ const unlaunchableShown = desktopExpanded ? unlaunchableIds : unlaunchablePrimary;
+ const desktopHiddenCount =
+ desktopFoldable && !searching ? desktopTotalCount - desktopPrimaryCount : 0;
+
const inAppHasDetected = !catalogReady || inAppAgents.some(isHarnessDetected);
const terminalHasPresent = canLaunchTerminal && terminalClis.some(cliPresent);
const desktopHasPresent = desktopTargets.some((tg) => states[tg.id]?.installed === true);
@@ -625,17 +681,12 @@ export function AgentConnectionsSection({
/>
);
})}
- {inAppHiddenCount > 0 ? (
- <Button
- type="button"
- variant="ghost"
- onClick={() => setShowInAppOverflow((v) => !v)}
- className="w-full justify-center rounded-none font-normal text-1sm text-muted-foreground"
- data-testid="configure-agents-in-app-show-more"
- >
- {showInAppOverflow ? t`Show less` : showMoreLabel(inAppHiddenCount)}
- </Button>
- ) : null}
+ <FoldToggleButton
+ hiddenCount={inAppHiddenCount}
+ expanded={showInAppOverflow}
+ onToggle={() => setShowInAppOverflow((v) => !v)}
+ testId="configure-agents-in-app-show-more"
+ />
</>
)}
</AgentGroup>
@@ -688,17 +739,12 @@ export function AgentConnectionsSection({
/>
);
})}
- {terminalHiddenCount > 0 ? (
- <Button
- type="button"
- variant="ghost"
- onClick={() => setShowTerminalOverflow((v) => !v)}
- className="w-full justify-center rounded-none font-normal text-1sm text-muted-foreground"
- data-testid="configure-agents-terminal-show-more"
- >
- {showTerminalOverflow ? t`Show less` : showMoreLabel(terminalHiddenCount)}
- </Button>
- ) : null}
+ <FoldToggleButton
+ hiddenCount={terminalHiddenCount}
+ expanded={showTerminalOverflow}
+ onToggle={() => setShowTerminalOverflow((v) => !v)}
+ testId="configure-agents-terminal-show-more"
+ />
</AgentGroup>
) : null;
@@ -709,7 +755,7 @@ export function AgentConnectionsSection({
labelId="settings-configure-agents-desktop"
labelIcon={<ArrowUpRight aria-hidden="true" className="size-3" />}
>
- {desktopTargets.map((target) => {
+ {desktopShown.map((target) => {
const installed = states[target.id]?.installed ?? null;
const { displayName } = target;
const enabled = isDesktopTargetEnabled(overrides, target.id, installed);
@@ -750,7 +796,7 @@ export function AgentConnectionsSection({
/>
);
})}
- {unlaunchableIds.map((agentId) => {
+ {unlaunchableShown.map((agentId) => {
const connection = connections.find((c) => c.id === agentId) ?? null;
const detected = connection?.row.detected ?? null;
const label = connectionLabel(agentId);
@@ -785,6 +831,12 @@ export function AgentConnectionsSection({
/>
);
})}
+ <FoldToggleButton
+ hiddenCount={desktopHiddenCount}
+ expanded={showDesktopOverflow}
+ onToggle={() => setShowDesktopOverflow((v) => !v)}
+ testId="configure-agents-desktop-show-more"
+ />
</AgentGroup>
) : null;
diff --git a/packages/app/tests/stress/agents-settings-accessible-names.e2e.ts b/packages/app/tests/stress/agents-settings-accessible-names.e2e.ts
index 66f729d67..6c9824e19 100644
--- a/packages/app/tests/stress/agents-settings-accessible-names.e2e.ts
+++ b/packages/app/tests/stress/agents-settings-accessible-names.e2e.ts
@@ -46,6 +46,13 @@ const CATALOG_BODY = {
};
async function openAgentsSettings(page: Page): Promise<Locator> {
+ await page.route('**/api/installed-agents', (route) =>
+ route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({ claude: true }),
+ }),
+ );
await page.route('**/api/agent-integrations/apply', (route) =>
route.fulfill({
status: 200,
@@ -67,6 +74,9 @@ async function openAgentsSettings(page: Page): Promise<Locator> {
await expect(page.getByTestId('agent-connection-lm-studio')).toBeVisible({
timeout: 15_000,
});
+ const desktopOverflow = section.getByTestId('configure-agents-desktop-show-more');
+ await desktopOverflow.click();
+ await expect(section.getByTestId('configure-agents-desktop-codex')).toBeVisible();
return section;
}
@@ -84,7 +94,7 @@ async function controlsMissingAccessibleName(section: Locator): Promise<number>
return missing;
}
-test.describe('merged Agents settings — every control keeps a readable label', () => {
+test.describe('merged Agents settings — accessible controls and focus', () => {
test('every switch and button on the page has a non-empty accessible name', async ({ page }) => {
const section = await openAgentsSettings(page);
@@ -94,6 +104,24 @@ test.describe('merged Agents settings — every control keeps a readable label',
expect(await controlsMissingAccessibleName(section)).toBe(0);
});
+ test('focus stays in External apps when detection removes the disclosure', async ({ page }) => {
+ await page.clock.install();
+ const section = await openAgentsSettings(page);
+ const fold = section.getByTestId('configure-agents-desktop-show-more');
+ await fold.focus();
+ await page.route('**/api/installed-agents', (route) =>
+ route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({ claude: true, codex: true, cursor: true }),
+ }),
+ );
+ await page.clock.fastForward(11_000);
+ await page.evaluate(() => window.dispatchEvent(new Event('focus')));
+ await expect(fold).toHaveCount(0);
+ await expect(section.getByRole('heading', { name: 'External apps' })).toBeFocused();
+ });
+
test('the sweep goes red when a control label is blanked', async ({ page }) => {
const section = await openAgentsSettings(page);
expect(await controlsMissingAccessibleName(section)).toBe(0);