Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(app): wire settings title and coalesce auth status (#2420)

Dimitri POSTOLOVb14423ba9693
diff --git a/.changeset/still-pandas-connect.md b/.changeset/still-pandas-connect.md
new file mode 100644
index 000000000..72a8b093a
--- /dev/null
+++ b/.changeset/still-pandas-connect.md
@@ -0,0 +1,7 @@
+---
+"@inkeep/open-knowledge-app": patch
+---
+
+Fix the Settings dialog's hidden title wiring so Radix can associate `DialogContent` with its `DialogTitle` for screen reader users.
+
+Coalesce overlapping GitHub auth-status checks in the HTTP transport so opening multiple auth-aware surfaces at once does not trip the local operation concurrency guard.
diff --git a/packages/app/src/components/settings/SettingsDialogShell.dom.test.tsx b/packages/app/src/components/settings/SettingsDialogShell.dom.test.tsx
index 701934eff..bf661dd1d 100644
--- a/packages/app/src/components/settings/SettingsDialogShell.dom.test.tsx
+++ b/packages/app/src/components/settings/SettingsDialogShell.dom.test.tsx
@@ -209,11 +209,15 @@ describe('SettingsDialogShell userBinding gating (Tier-3 mount)', () => {
});
test('renders the dialog frame, navigation landmark, and default Preferences section immediately', () => {
- render(<SettingsDialogShell open={true} onOpenChange={() => {}} />);
+ render(<SettingsDialogShell open onOpenChange={() => {}} />);
expect(screen.getByTestId('settings-dialog')).toBeTruthy();
- expect(screen.getByRole('dialog')).toBeTruthy();
+ const dialog = screen.getByRole('dialog');
+ const labelledBy = dialog.getAttribute('aria-labelledby');
+ expect(labelledBy).toBeTruthy();
+ expect(document.getElementById(labelledBy ?? '')?.textContent).toBe('Settings');
expect(screen.getByRole('heading', { name: 'Settings' })).toBeTruthy();
+ expect(screen.getByRole('region', { name: 'Settings content' })).toBeTruthy();
expect(screen.getByRole('navigation', { name: 'Settings sections' })).toBeTruthy();
expect(screen.getByText('User')).toBeTruthy();
expect(screen.getByText('This project')).toBeTruthy();
diff --git a/packages/app/src/components/settings/SettingsDialogShell.tsx b/packages/app/src/components/settings/SettingsDialogShell.tsx
index c2208a221..f9f4f8fd9 100644
--- a/packages/app/src/components/settings/SettingsDialogShell.tsx
+++ b/packages/app/src/components/settings/SettingsDialogShell.tsx
@@ -76,11 +76,10 @@ export function SettingsDialogShell({ open, onOpenChange }: SettingsDialogShellP
const { collabUrl } = useDocumentContext();
const { userBinding, userSynced, okignoreBinding, okignoreSynced } = useConfigContext();
const { desktopPresent } = useClaudeDesktopIntegration();
- const titleId = 'settings-dialog-title';
// Always default to USER → Preferences on each fresh open. No
// in-session memory of last-viewed section.
- const [activeId, setActiveId] = useState<string>('preferences');
+ const [activeId, setActiveId] = useState('preferences');
useEffect(() => {
if (open) setActiveId('preferences');
}, [open]);
@@ -139,7 +138,7 @@ export function SettingsDialogShell({ open, onOpenChange }: SettingsDialogShellP
className="flex h-[700px] max-h-[calc(100dvh-4rem)] w-[900px] max-w-[calc(100%-2rem)] flex-col gap-0 overflow-hidden p-0 sm:grid sm:grid-cols-[220px_1fr] sm:max-w-[min(900px,calc(100%-2rem))]"
data-testid="settings-dialog"
>
- <DialogTitle className="sr-only" id={titleId}>
+ <DialogTitle className="sr-only">
<Trans>Settings</Trans>
</DialogTitle>
<DialogDescription className="sr-only">
@@ -147,7 +146,7 @@ export function SettingsDialogShell({ open, onOpenChange }: SettingsDialogShellP
</DialogDescription>
<SettingsSidebar groups={groups} activeId={activeId} onSelect={setActiveId} />
<section
- aria-labelledby={titleId}
+ aria-label={t`Settings content`}
className="min-h-0 flex-1 overflow-y-auto overscroll-contain subtle-scrollbar p-6"
// biome-ignore lint/a11y/noNoninteractiveTabindex: this scrollable content section must be focusable so keyboard users can scroll long settings pages.
tabIndex={0}
diff --git a/packages/app/src/lib/transports/auth-query-transport.test.ts b/packages/app/src/lib/transports/auth-query-transport.test.ts
index a56b1d4fe..dfdfdd0ed 100644
--- a/packages/app/src/lib/transports/auth-query-transport.test.ts
+++ b/packages/app/src/lib/transports/auth-query-transport.test.ts
@@ -12,22 +12,121 @@ type FetchFn = typeof globalThis.fetch;
let originalFetch: FetchFn;
let lastCall: { url: string; init: Parameters<FetchFn>[1] } | null;
+let fetchCalls: Array<{ url: string; init: Parameters<FetchFn>[1] }>;
-function stubFetch(make: () => Response): void {
+function stubFetch(make: () => Response | Promise<Response>): void {
globalThis.fetch = (async (input: Parameters<FetchFn>[0], init?: Parameters<FetchFn>[1]) => {
lastCall = { url: typeof input === 'string' ? input : String(input), init };
- return make();
+ fetchCalls.push(lastCall);
+ return await make();
}) as FetchFn;
}
beforeEach(() => {
originalFetch = globalThis.fetch;
lastCall = null;
+ fetchCalls = [];
});
afterEach(() => {
globalThis.fetch = originalFetch;
});
+describe('httpAuthQueryTransport().status', () => {
+ it('coalesces concurrent same-host checks across transport instances', async () => {
+ let resolveFetch: ((response: Response) => void) | undefined;
+ const pendingResponse = new Promise<Response>((resolve) => {
+ resolveFetch = resolve;
+ });
+ stubFetch(() => pendingResponse);
+
+ const a = httpAuthQueryTransport().status();
+ const b = httpAuthQueryTransport().status({ host: 'github.com' });
+
+ expect(fetchCalls).toHaveLength(1);
+ expect(fetchCalls[0]?.url).toBe('/api/local-op/auth/status');
+
+ resolveFetch?.(
+ new Response(JSON.stringify({ authenticated: true, host: 'github.com', login: 'octocat' }), {
+ status: 200,
+ }),
+ );
+
+ const [resA, resB] = await Promise.all([a, b]);
+ expect(resA).toEqual({ authenticated: true, host: 'github.com', login: 'octocat' });
+ expect(resB).toEqual(resA);
+ });
+
+ it('keeps concurrent different-host checks isolated', async () => {
+ let resolveGithub: ((response: Response) => void) | undefined;
+ let resolveGitlab: ((response: Response) => void) | undefined;
+ const pendingResponses = [
+ new Promise<Response>((resolve) => {
+ resolveGithub = resolve;
+ }),
+ new Promise<Response>((resolve) => {
+ resolveGitlab = resolve;
+ }),
+ ];
+ stubFetch(() => {
+ const response = pendingResponses.shift();
+ if (!response) throw new Error('unexpected extra fetch');
+ return response;
+ });
+
+ const githubStatus = httpAuthQueryTransport().status({ host: 'github.com' });
+ const gitlabStatus = httpAuthQueryTransport().status({ host: 'gitlab.com' });
+
+ expect(fetchCalls).toHaveLength(2);
+ expect(fetchCalls.map((call) => JSON.parse(String(call.init?.body)).host)).toEqual([
+ 'github.com',
+ 'gitlab.com',
+ ]);
+
+ resolveGithub?.(
+ new Response(JSON.stringify({ authenticated: true, host: 'github.com', login: 'octocat' })),
+ );
+ resolveGitlab?.(new Response(JSON.stringify({ authenticated: false, host: 'gitlab.com' })));
+
+ await expect(githubStatus).resolves.toEqual({
+ authenticated: true,
+ host: 'github.com',
+ login: 'octocat',
+ });
+ await expect(gitlabStatus).resolves.toEqual({
+ authenticated: false,
+ host: 'gitlab.com',
+ });
+ });
+
+ it('clears the coalescing slot after the status check settles', async () => {
+ stubFetch(() => new Response(JSON.stringify({ authenticated: false, host: 'github.com' })));
+ const transport = httpAuthQueryTransport();
+
+ await transport.status();
+ await transport.status();
+
+ expect(fetchCalls).toHaveLength(2);
+ });
+
+ it('clears the coalescing slot after the status check rejects', async () => {
+ let callCount = 0;
+ stubFetch(() => {
+ callCount += 1;
+ if (callCount === 1) throw new Error('network down');
+ return new Response(JSON.stringify({ authenticated: false, host: 'github.com' }));
+ });
+ const transport = httpAuthQueryTransport();
+
+ await expect(transport.status()).rejects.toThrow('network down');
+ await expect(transport.status()).resolves.toEqual({
+ authenticated: false,
+ host: 'github.com',
+ });
+
+ expect(fetchCalls).toHaveLength(2);
+ });
+});
+
describe('httpAuthQueryTransport().signout', () => {
it('POSTs to the signout endpoint and resolves ok on a 200 empty body', async () => {
stubFetch(() => new Response('{}', { status: 200 }));
diff --git a/packages/app/src/lib/transports/auth-query-transport.ts b/packages/app/src/lib/transports/auth-query-transport.ts
index 4ffb3e3b2..370dbb1f2 100644
--- a/packages/app/src/lib/transports/auth-query-transport.ts
+++ b/packages/app/src/lib/transports/auth-query-transport.ts
@@ -22,6 +22,11 @@ import type {
OkLocalOpAuthStatusResponse,
} from '@/lib/desktop-bridge-types';
+const DEFAULT_AUTH_QUERY_HOST = 'github.com';
+// Default HTTP transports are created per component; keep status single-flight
+// at module scope so overlapping callers share one local-op request.
+const authStatusInFlight = new Map<string, Promise<OkLocalOpAuthStatusResponse>>();
+
/**
* Extract the RFC 9457 problem+json title from a pre-stream error body for
* surfacing the typed reason (rate limit, origin rejection, auth failure)
@@ -55,6 +60,53 @@ async function postJson(path: string, body: unknown): Promise<Response> {
});
}
+async function requestAuthStatus(request?: {
+ host?: string;
+}): Promise<OkLocalOpAuthStatusResponse> {
+ const host = request?.host ?? DEFAULT_AUTH_QUERY_HOST;
+ const res = await postJson('/api/local-op/auth/status', request);
+ if (!res.ok) {
+ // Surface the typed RFC 9457 title (e.g. "Origin not allowed.",
+ // "Loopback required.") instead of dropping the structured
+ // diagnosis. Sibling transports do the same.
+ const error = await extractProblemTitle(res);
+ return { authenticated: false, host, error };
+ }
+ const data = (await res.json()) as Record<string, unknown>;
+ const h = typeof data.host === 'string' ? data.host : host;
+ if (data.authenticated === true && typeof data.login === 'string') {
+ // Mirror the whitelist in auth-query.ts so the HTTP and IPC paths
+ // surface `tier` consistently — without this, only IPC carries it.
+ const tier =
+ data.tier === 'A' || data.tier === 'B' || data.tier === 'C' ? data.tier : undefined;
+ return {
+ authenticated: true,
+ host: h,
+ login: data.login,
+ tier,
+ name: typeof data.name === 'string' ? data.name : undefined,
+ email: typeof data.email === 'string' ? data.email : undefined,
+ };
+ }
+ return {
+ authenticated: false,
+ host: h,
+ error: typeof data.error === 'string' ? data.error : undefined,
+ };
+}
+
+function coalescedAuthStatus(request?: { host?: string }): Promise<OkLocalOpAuthStatusResponse> {
+ const host = request?.host ?? DEFAULT_AUTH_QUERY_HOST;
+ const existing = authStatusInFlight.get(host);
+ if (existing) return existing;
+
+ const promise = requestAuthStatus(request).finally(() => {
+ authStatusInFlight.delete(host);
+ });
+ authStatusInFlight.set(host, promise);
+ return promise;
+}
+
/**
* Pull the last parseable JSON line out of an NDJSON-ish body. The HTTP
* relays for status / repos emit one structured line; older builds may
@@ -78,38 +130,7 @@ function lastJsonLine(text: string): Record<string, unknown> | null {
/** HTTP transport — wraps the `/api/local-op/auth/{status,repos}` endpoints. */
export function httpAuthQueryTransport(): AuthQueryTransport {
return {
- async status(request) {
- const host = request?.host ?? 'github.com';
- const res = await postJson('/api/local-op/auth/status', request);
- if (!res.ok) {
- // Surface the typed RFC 9457 title (e.g. "Origin not allowed.",
- // "Loopback required.") instead of dropping the structured
- // diagnosis. Sibling transports do the same.
- const error = await extractProblemTitle(res);
- return { authenticated: false, host, error };
- }
- const data = (await res.json()) as Record<string, unknown>;
- const h = typeof data.host === 'string' ? data.host : host;
- if (data.authenticated === true && typeof data.login === 'string') {
- // Mirror the whitelist in auth-query.ts so the HTTP and IPC paths
- // surface `tier` consistently — without this, only IPC carries it.
- const tier =
- data.tier === 'A' || data.tier === 'B' || data.tier === 'C' ? data.tier : undefined;
- return {
- authenticated: true,
- host: h,
- login: data.login,
- tier,
- name: typeof data.name === 'string' ? data.name : undefined,
- email: typeof data.email === 'string' ? data.email : undefined,
- };
- }
- return {
- authenticated: false,
- host: h,
- error: typeof data.error === 'string' ? data.error : undefined,
- };
- },
+ status: coalescedAuthStatus,
async repos(request) {
const host = request?.host ?? 'github.com';
const res = await postJson('/api/local-op/auth/repos', request);
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index a76f9ece4..83a7958a1 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -954,6 +954,7 @@
"OTF92M": ["Label <0>(optional display text)</0>"],
"OVjNeX": ["Terminal ", ["0"]],
"OX2Neh": ["Inline code"],
+ "OXb_Df": ["Settings content"],
"OYnx7O": ["Path cannot start with \"/\""],
"OdmsFg": ["Failed to delete item"],
"OeAl1e": ["e.g. assets/uploads"],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index a0a34cfad..f061f92ef 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -5919,6 +5919,10 @@ msgstr "Setting up"
msgid "Settings"
msgstr "Settings"
+#: src/components/settings/SettingsDialogShell.tsx
+msgid "Settings content"
+msgstr "Settings content"
+
#: src/components/settings/SettingsDialogErrorBoundary.tsx
msgid "Settings failed to load"
msgstr "Settings failed to load"
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index 7278d1947..4dc6d109f 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -954,6 +954,7 @@
"OTF92M": ["Ĺàƀēĺ <0>(ōƥţĩōńàĺ ďĩśƥĺàŷ ţēxţ)</0>"],
"OVjNeX": ["Ţēŕḿĩńàĺ ", ["0"]],
"OX2Neh": ["Ĩńĺĩńē ćōďē"],
+ "OXb_Df": ["Śēţţĩńĝś ćōńţēńţ"],
"OYnx7O": ["Ƥàţĥ ćàńńōţ śţàŕţ ŵĩţĥ \"/\""],
"OdmsFg": ["Ƒàĩĺēď ţō ďēĺēţē ĩţēḿ"],
"OeAl1e": ["ē.ĝ. àśśēţś/ũƥĺōàďś"],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 0ecede831..94d93c2c3 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -5914,6 +5914,10 @@ msgstr ""
msgid "Settings"
msgstr ""
+#: src/components/settings/SettingsDialogShell.tsx
+msgid "Settings content"
+msgstr ""
+
#: src/components/settings/SettingsDialogErrorBoundary.tsx
msgid "Settings failed to load"
msgstr ""