Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Load settings sections independently (#5546)
Nick Gomez144a48623573
diff --git a/.changeset/settings-sections-load-independently.md b/.changeset/settings-sections-load-independently.mdnew file mode 100644index 000000000..8cba7d336--- /dev/null+++ b/.changeset/settings-sections-load-independently.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge": patch+---++Settings sections now appear without waiting for unrelated sections to load.diff --git a/packages/app/src/components/SettingsButton.dom.test.tsx b/packages/app/src/components/SettingsButton.dom.test.tsxindex 1b5098ef8..b59f35a02 100644--- a/packages/app/src/components/SettingsButton.dom.test.tsx+++ b/packages/app/src/components/SettingsButton.dom.test.tsx@@ -2,6 +2,7 @@ import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'import type { ReactNode } from 'react';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';import { TooltipProvider } from '@/components/ui/tooltip';+import { renderSettingsBody } from '@/test-utils/render-settings-body.test-helper';const preloadCalls: string[] = [];@@ -13,11 +14,9 @@ vi.doMock('@lingui/react/macro', () => ({}));vi.doMock('@/components/settings/SettingsDialogBodyLazy', () => ({- SettingsDialogBodyLazy: {- preload: () => {- preloadCalls.push('preload');- return Promise.resolve();- },+ preloadSettingsOnIntent: () => {+ preloadCalls.push('preload');+ return Promise.resolve();},}));@@ -113,3 +112,56 @@ describe('SettingsButton runtime behavior', () => {expect(preloadCalls).toEqual([]);});});++describe('settings body loading on render and on intent', () => {+ const loads: string[] = [];++ beforeEach(() => {+ vi.resetModules();+ vi.doMock('@/components/settings/SettingsDialogBody', () => {+ loads.push('settings-body');+ return {+ SettingsDialogBody: () => <div data-testid="settings-body-probe" />,+ preloadPreferencesSection: () => {+ loads.push('preferences-section');+ return Promise.resolve();+ },+ };+ });+ });++ afterEach(() => {+ cleanup();+ vi.doUnmock('@/components/settings/SettingsDialogBody');+ loads.length = 0;+ });++ const importSettingsDialogBodyLazy = () =>+ vi.importActual<typeof import('@/components/settings/SettingsDialogBodyLazy')>(+ '@/components/settings/SettingsDialogBodyLazy',+ );++ test('rendering the settings body does not start loading the Preferences section', async () => {+ const { SettingsDialogBodyLazy } = await importSettingsDialogBodyLazy();++ await renderSettingsBody(+ <SettingsDialogBodyLazy+ activeId="okignore"+ userBinding={null}+ okignoreBinding={null}+ okignoreSynced={false}+ />,+ );++ expect(screen.queryByTestId('settings-body-probe')).not.toBeNull();+ expect(loads).toEqual(['settings-body']);+ });++ test('the intent prefetch loads the settings body and the Preferences section without a render', async () => {+ const { preloadSettingsOnIntent } = await importSettingsDialogBodyLazy();++ await preloadSettingsOnIntent();++ expect(loads).toEqual(['settings-body', 'preferences-section']);+ });+});diff --git a/packages/app/src/components/SettingsButton.tsx b/packages/app/src/components/SettingsButton.tsxindex 1aaa4eeef..37a849bb8 100644--- a/packages/app/src/components/SettingsButton.tsx+++ b/packages/app/src/components/SettingsButton.tsx@@ -1,7 +1,7 @@import { Trans } from '@lingui/react/macro';import { Settings } from 'lucide-react';import { type FC, useEffect, useRef } from 'react';-import { SettingsDialogBodyLazy } from '@/components/settings/SettingsDialogBodyLazy';+import { preloadSettingsOnIntent } from '@/components/settings/SettingsDialogBodyLazy';import { Button } from '@/components/ui/button';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';import { SETTINGS_OPEN_HASH } from '@/lib/use-settings-route';@@ -15,7 +15,7 @@ export const SettingsButton: FC = () => {if (timerRef.current !== null) return;timerRef.current = setTimeout(() => {timerRef.current = null;- SettingsDialogBodyLazy.preload();+ preloadSettingsOnIntent();}, PREFETCH_INTENT_DELAY_MS);};diff --git a/packages/app/src/components/settings/SettingsDialogBody.dom.test.tsx b/packages/app/src/components/settings/SettingsDialogBody.dom.test.tsxindex d6672e370..54f3b8284 100644--- a/packages/app/src/components/settings/SettingsDialogBody.dom.test.tsx+++ b/packages/app/src/components/settings/SettingsDialogBody.dom.test.tsx@@ -11,7 +11,7 @@ import {SavedThemesListSuccessSchema,} from '@inkeep/open-knowledge-core';import { type Attributes, type Tracer, trace } from '@opentelemetry/api';-import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';+import { act, cleanup, fireEvent, screen, waitFor, within } from '@testing-library/react';import userEvent from '@testing-library/user-event';import { ThemeProvider, useTheme } from 'next-themes';import type { ReactNode } from 'react';@@ -20,6 +20,7 @@ import { TooltipProvider } from '@/components/ui/tooltip';import { ConfigContext, type ConfigContextValue } from '@/lib/config-context';import { emitConfigValidationRejected } from '@/lib/config-validation-events';import { SavedThemesProvider } from '@/lib/saved-themes-client';+import { renderSettingsBody } from '@/test-utils/render-settings-body.test-helper';import { expectVisualClassTokens } from '@/test-utils/visual-contract';import { SettingsDialogBody } from './SettingsDialogBody';@@ -114,8 +115,8 @@ function SettingsContextProvider({);}-function renderPreferences(binding: ConfigBinding) {- return render(+async function renderPreferences(binding: ConfigBinding) {+ return renderSettingsBody(<SettingsContextProvider><TooltipProvider><SettingsDialogBody@@ -129,8 +130,8 @@ function renderPreferences(binding: ConfigBinding) {);}-function renderProjectPreferences() {- return render(+async function renderProjectPreferences() {+ return renderSettingsBody(<SettingsContextProvider><TooltipProvider><SettingsDialogBody@@ -149,9 +150,9 @@ describe('SettingsDialogBody preferences runtime', () => {cleanup();});- test('renders editor.wordWrap in the Preferences section', () => {+ test('renders editor.wordWrap in the Preferences section', async () => {const { binding } = makeBinding();- const { container } = renderPreferences(binding);+ const { container } = await renderPreferences(binding);expect(screen.getByRole('heading', { name: 'Preferences' })).toBeDefined();expect(screen.getByText('Word wrap')).toBeDefined();@@ -218,7 +219,7 @@ describe('SettingsDialogBody preferences runtime', () => {});try {const { binding } = makeBinding();- const { container } = renderPreferences(binding);+ const { container } = await renderPreferences(binding);const row = await screen.findByTestId('settings-spellcheck-row');const languagesRow = await screen.findByTestId('settings-spellcheck-languages-row');@@ -244,7 +245,7 @@ describe('SettingsDialogBody preferences runtime', () => {test('shows no desktop spelling controls without a desktop host', async () => {const { binding } = makeBinding();- renderPreferences(binding);+ await renderPreferences(binding);await screen.findByText('Word wrap');expect(screen.queryByTestId('settings-spelling')).toBeNull();@@ -255,7 +256,7 @@ describe('SettingsDialogBody preferences runtime', () => {test('offers the agent chat browser as a Preferences switch that starts off and writes agents.browserTools', async () => {const user = userEvent.setup();const { binding, patches } = makeBinding();- const { container } = renderPreferences(binding);+ const { container } = await renderPreferences(binding);const field = container.querySelector('[data-field="agents.browserTools"]');expect(field).toBeTruthy();@@ -271,7 +272,7 @@ describe('SettingsDialogBody preferences runtime', () => {test('commits editor.wordWrap changes through binding.patch', async () => {const user = userEvent.setup();const { binding, patches } = makeBinding();- renderPreferences(binding);+ await renderPreferences(binding);const wordWrapSwitch = screen.getByRole('switch', { name: 'Word wrap' });await user.click(wordWrapSwitch);@@ -285,7 +286,7 @@ describe('SettingsDialogBody preferences runtime', () => {test('commits editor.previewTabs changes through binding.patch', async () => {const user = userEvent.setup();const { binding, patches } = makeBinding();- renderPreferences(binding);+ await renderPreferences(binding);const previewTabsSwitch = screen.getByRole('switch', { name: 'Preview tabs' });await user.click(previewTabsSwitch);@@ -299,7 +300,7 @@ describe('SettingsDialogBody preferences runtime', () => {test('commits appearance.preview.autoOpen changes through binding.patch', async () => {const user = userEvent.setup();const { binding, patches } = makeBinding();- renderPreferences(binding);+ await renderPreferences(binding);const autoOpenSwitch = screen.getByRole('switch', { name: 'Open preview when agent edits' });expect(autoOpenSwitch.getAttribute('aria-checked')).toBe('true');@@ -324,7 +325,7 @@ describe('SettingsDialogBody preferences runtime', () => {test('surfaces L3 config-validation rejections on the matching user field', async () => {const { binding } = makeBinding();- const { container } = renderPreferences(binding);+ const { container } = await renderPreferences(binding);const wordWrapField = container.querySelector('[data-field="editor.wordWrap"]');expect(wordWrapField).toBeTruthy();@@ -357,7 +358,7 @@ describe('SettingsDialogBody preferences runtime', () => {});test('surfaces L3 config-validation rejections on the project attachment field', async () => {- const { container } = renderProjectPreferences();+ const { container } = await renderProjectPreferences();const attachmentField = container.querySelector('[data-field="content.attachmentFolderPath"]');expect(attachmentField).toBeTruthy();@@ -404,10 +405,10 @@ describe('SettingsDialogBody language picker', () => {cleanup();});- test('renders a Language row beside Theme, showing the stored preference', () => {+ test('renders a Language row beside Theme, showing the stored preference', async () => {const config = ConfigSchema.parse({ appearance: { language: 'es' } });const { binding } = makeBinding(config);- const { container } = renderPreferences(binding);+ const { container } = await renderPreferences(binding);expect(screen.getByRole('combobox', { name: 'Language' }).textContent).toContain('español');const fields = [...container.querySelectorAll('[data-field]')].map((el) =>@@ -419,7 +420,7 @@ describe('SettingsDialogBody language picker', () => {test('names each language in itself, and offers none that is held back', async () => {const user = userEvent.setup();const { binding } = makeBinding();- renderPreferences(binding);+ await renderPreferences(binding);await openLanguagePicker(user);@@ -437,7 +438,7 @@ describe('SettingsDialogBody language picker', () => {test('derives its locale options from the offered set in core', async () => {const user = userEvent.setup();const { binding } = makeBinding();- renderPreferences(binding);+ await renderPreferences(binding);await openLanguagePicker(user);@@ -450,7 +451,7 @@ describe('SettingsDialogBody language picker', () => {test('commits the picked language through binding.patch', async () => {const user = userEvent.setup();const { binding, patches } = makeBinding();- renderPreferences(binding);+ await renderPreferences(binding);await openLanguagePicker(user);await user.click(screen.getByRole('option', { name: 'español' }));@@ -464,7 +465,7 @@ describe('SettingsDialogBody language picker', () => {const user = userEvent.setup();const config = ConfigSchema.parse({ appearance: { language: 'es' } });const { binding, patches } = makeBinding(config);- renderPreferences(binding);+ await renderPreferences(binding);await openLanguagePicker(user);await user.click(screen.getByRole('option', { name: 'System' }));@@ -499,7 +500,7 @@ describe('SettingsDialogBody language picker', () => {installTracerSpy();const user = userEvent.setup();const { binding } = makeBinding();- renderPreferences(binding);+ await renderPreferences(binding);await openLanguagePicker(user);await user.click(screen.getByRole('option', { name: 'español' }));@@ -518,7 +519,7 @@ describe('SettingsDialogBody language picker', () => {installTracerSpy();const user = userEvent.setup();const { binding } = makeBinding(ConfigSchema.parse({ appearance: { language: 'fr' } }));- renderPreferences(binding);+ await renderPreferences(binding);await openLanguagePicker(user);await user.click(screen.getByRole('option', { name: 'System' }));@@ -535,7 +536,7 @@ describe('SettingsDialogBody language picker', () => {installTracerSpy();const user = userEvent.setup();const { binding } = makeBinding(ConfigSchema.parse({ appearance: { language: 'es' } }));- renderPreferences(binding);+ await renderPreferences(binding);await openLanguagePicker(user);await user.click(screen.getByRole('option', { name: 'System' }));@@ -556,7 +557,7 @@ describe('SettingsDialogBody language picker', () => {const user = userEvent.setup();const config = ConfigSchema.parse({ appearance: { language: 'ar' } });const { binding } = makeBinding(config);- renderPreferences(binding);+ await renderPreferences(binding);expect(screen.getByRole('combobox', { name: 'Language' }).textContent).toContain('العربية');@@ -572,9 +573,9 @@ function ThemeProbe() {return <span data-testid="theme-probe">{theme ?? ''}</span>;}-function renderPreferencesWithTheme(binding: ConfigBinding) {+async function renderPreferencesWithTheme(binding: ConfigBinding) {themeStorageKeySeq += 1;- return render(+ return renderSettingsBody(<ThemeProviderattribute="class"defaultTheme="system"@@ -616,7 +617,7 @@ describe('SettingsDialogBody theme cards — optimistic apply', () => {test('clicking Dark flips next-themes immediately and still persists via binding.patch', async () => {const user = userEvent.setup();const { binding, patches } = makeBinding();- const { container } = renderPreferencesWithTheme(binding);+ const { container } = await renderPreferencesWithTheme(binding);expect(screen.getByTestId('theme-probe').textContent).toBe('system');@@ -631,7 +632,7 @@ describe('SettingsDialogBody theme cards — optimistic apply', () => {test("clicking System forwards 'system' verbatim to next-themes (does not resolve to light/dark)", async () => {const user = userEvent.setup();const { binding, patches } = makeBinding();- const { container } = renderPreferencesWithTheme(binding);+ const { container } = await renderPreferencesWithTheme(binding);await user.click(themeCardItem(container, 'dark'));await waitFor(() => {@@ -649,7 +650,7 @@ describe('SettingsDialogBody theme cards — optimistic apply', () => {test('clicking Light flips to light and records the patch', async () => {const user = userEvent.setup();const { binding, patches } = makeBinding();- const { container } = renderPreferencesWithTheme(binding);+ const { container } = await renderPreferencesWithTheme(binding);await user.click(themeCardItem(container, 'light'));@@ -660,9 +661,9 @@ describe('SettingsDialogBody theme cards — optimistic apply', () => {});});-function renderThemePluginWithTheme(binding: ConfigBinding) {+async function renderThemePluginWithTheme(binding: ConfigBinding) {themeStorageKeySeq += 1;- return render(+ return renderSettingsBody(<ThemeProviderattribute="class"defaultTheme="system"@@ -694,9 +695,9 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()cleanup();});- test('the Themes plugin header shows a User scope badge (user-scope plugin)', () => {+ test('the Themes plugin header shows a User scope badge (user-scope plugin)', async () => {const { binding } = makeBinding();- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);expect(screen.getByTestId('settings-scope-badge-user')).toBeDefined();expect(screen.queryByTestId('settings-scope-badge-project')).toBeNull();});@@ -704,7 +705,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()test('assigning a palette to the mode on screen applies it immediately', async () => {const user = userEvent.setup();const { binding } = makeBinding();- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);expect(screen.getByTestId('theme-probe').textContent).toBe('system');@@ -741,7 +742,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ());const user = userEvent.setup();const { binding, patches } = makeBinding();- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);await user.click(await screen.findByLabelText('Use Ocean as the light theme'));@@ -803,7 +804,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()};const user = userEvent.setup();const { binding } = makeBinding();- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);expect(screen.queryByRole('heading', { name: /Editing/ })).toBeNull();await user.click(screen.getByRole('button', { name: 'Create new theme' }));@@ -887,7 +888,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()};const user = userEvent.setup();const { binding, patches } = makeBinding();- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);await user.click(await screen.findByRole('button', { name: 'Edit Ocean' }));expect(screen.getByRole('heading', { name: 'Editing Ocean' })).toBeDefined();@@ -935,7 +936,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()test('a cross-variant palette in the on-screen slot forces its own mode', async () => {const user = userEvent.setup();const { binding } = makeBinding();- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);expect(screen.getByTestId('theme-probe').textContent).toBe('system');@@ -950,7 +951,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()globalThis.fetch = async () => Response.json({ themes: [], truncated: false });const user = userEvent.setup();const { binding, patches } = makeBinding();- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);await user.click(screen.getByLabelText('Use Dracula as the light theme'));await waitFor(() => {@@ -974,7 +975,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()globalThis.fetch = async () => Response.json({ themes: [], truncated: false });const user = userEvent.setup();const { binding } = makeBinding(ConfigSchema.parse({ appearance: { theme } }));- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);await user.click(screen.getByLabelText(@@ -1000,7 +1001,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()test('assigning a palette to the OTHER mode leaves the current appearance alone', async () => {const user = userEvent.setup();const { binding } = makeBinding();- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);await user.click(screen.getByLabelText('Use Catppuccin Frappé as the dark theme'));@@ -1014,7 +1015,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()const { binding, patches } = makeBinding(ConfigSchema.parse({ appearance: { colorThemeLight: 'dracula' } }),);- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);const resetButton = await screen.findByRole('button', {name: /Reset Color theme to default/i,@@ -1030,7 +1031,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()test('a rejected write surfaces an inline error instead of failing silently', async () => {const user = userEvent.setup();- renderThemePluginWithTheme(makeRejectingBinding());+ await renderThemePluginWithTheme(makeRejectingBinding());expect(document.documentElement.hasAttribute('data-color-theme')).toBe(false);@@ -1044,7 +1045,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()test('a rejected cross-variant pick also reverts the forced light/dark mode', async () => {const user = userEvent.setup();- renderThemePluginWithTheme(makeRejectingBinding());+ await renderThemePluginWithTheme(makeRejectingBinding());expect(screen.getByTestId('theme-probe').textContent).toBe('system');@@ -1062,7 +1063,7 @@ describe('SettingsDialogBody color-palette picker — optimistic mode flip', ()test('one patch writes both slots and retires the pre-pair key', async () => {const user = userEvent.setup();const { binding, patches } = makeBinding();- renderThemePluginWithTheme(binding);+ await renderThemePluginWithTheme(binding);await user.click(screen.getByLabelText('Use Catppuccin Frappé as the dark theme'));diff --git a/packages/app/src/components/settings/SettingsDialogBody.sections.dom.test.tsx b/packages/app/src/components/settings/SettingsDialogBody.sections.dom.test.tsxindex b71e1e2c6..a7cf09cd8 100644--- a/packages/app/src/components/settings/SettingsDialogBody.sections.dom.test.tsx+++ b/packages/app/src/components/settings/SettingsDialogBody.sections.dom.test.tsx@@ -1,9 +1,10 @@-import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';+import { act, cleanup, fireEvent, screen, waitFor, within } from '@testing-library/react';import { createContext, type ReactNode, use, useState } from 'react';import { FormProvider } from 'react-hook-form';import { beforeEach, describe, expect, test, vi } from 'vitest';import { TooltipProvider } from '@/components/ui/tooltip';import { renderLinguiTemplate } from '@/test-utils/lingui-mock';+import { renderSettingsBody } from '@/test-utils/render-settings-body.test-helper';type SyncStatus = {state: string;@@ -346,7 +347,7 @@ async function renderBody(} = { activeId: 'sync' },) {const { SettingsDialogBody } = await import('./SettingsDialogBody');- render(+ return renderSettingsBody(<TooltipProvider><SettingsDialogBodyactiveId={props.activeId}diff --git a/packages/app/src/components/settings/SettingsDialogBody.sync-mode.dom.test.tsx b/packages/app/src/components/settings/SettingsDialogBody.sync-mode.dom.test.tsxindex d0224f73a..347d18c41 100644--- a/packages/app/src/components/settings/SettingsDialogBody.sync-mode.dom.test.tsx+++ b/packages/app/src/components/settings/SettingsDialogBody.sync-mode.dom.test.tsx@@ -1,9 +1,10 @@-import { cleanup, fireEvent, render, screen, within } from '@testing-library/react';+import { cleanup, fireEvent, screen, within } from '@testing-library/react';import userEvent from '@testing-library/user-event';import { createContext, type ReactNode, StrictMode, use } from 'react';import { beforeEach, describe, expect, test, vi } from 'vitest';import { TooltipProvider } from '@/components/ui/tooltip';import { renderLinguiTemplate } from '@/test-utils/lingui-mock';+import { renderSettingsBody } from '@/test-utils/render-settings-body.test-helper';type SyncStatus = {state: string;@@ -228,7 +229,7 @@ async function renderSyncSection({ strict = false }: { strict?: boolean } = {})/></TooltipProvider>);- render(strict ? <StrictMode>{tree}</StrictMode> : tree);+ return renderSettingsBody(strict ? <StrictMode>{tree}</StrictMode> : tree);}describe('Settings Sync section — three-way mode control (real hooks + dialog)', () => {diff --git a/packages/app/src/components/settings/SettingsDialogBody.tsx b/packages/app/src/components/settings/SettingsDialogBody.tsxindex 20e2fe840..608bee990 100644--- a/packages/app/src/components/settings/SettingsDialogBody.tsx+++ b/packages/app/src/components/settings/SettingsDialogBody.tsx@@ -1,35 +1,112 @@import type { ConfigBinding, OkignoreBinding } from '@inkeep/open-knowledge-core';import { Trans, useLingui } from '@lingui/react/macro';-import { SharingSection } from '@/components/settings/SharingSection';-import { AccountSection } from './AccountSection';-import { AgentConnectionsSection } from './AgentConnectionsSection';-import { AttachmentsSection } from './AttachmentsSection';-import { ContentRulesSection } from './ContentRulesSection';-import { SectionSkeleton } from './field-controls';-import { HotkeysSection } from './HotkeysSection';-import { IntegrationsSection } from './IntegrationsSection';-import { LinkPreviewsSection } from './LinkPreviewsSection';-import {- MarkdownlintPluginSection,- ProjectPluginsManageSection,- UserPluginsManageSection,-} from './LintingSection';-import { LINT_PLUGIN_UI } from './lint-plugins';-import { NetworkAccessSection } from './NetworkAccessSection';-import { OkCliPathRow } from './OkCliPathRow';-import { OkignoreSection } from './OkignoreSection';-import { ProjectTemplatesSection } from './ProjectTemplatesSection';-import { SearchSection } from './SearchSection';+import { type ComponentType, lazy } from 'react';+import { lazyWithPreload } from '@/lib/lazy-with-preload';import { SettingsSectionHeader } from './SettingsSectionHeader';-import { SkillsManagerSection } from './SkillsManagerSection';-import { SlidesPluginSection } from './SlidesPluginSection';-import { SpellingSettings } from './SpellingSettings';-import { SyncSection } from './SyncSection';-import { BoundSchemaSection } from './schema-section';import { FIELDS_USER_PREFERENCES } from './settings-fields';import { isTerminalSettingsAvailable } from './settings-host-gates';-import { TerminalSection } from './TerminalSection';-import { ThemePluginSection } from './ThemePluginSection';++function lazySection<Props>(load: () => Promise<ComponentType<Props>>) {+ return lazy(async () => ({ default: await load() }));+}++const SharingSection = lazySection(async () => (await import('./SharingSection')).SharingSection);+const AccountSection = lazySection(async () => (await import('./AccountSection')).AccountSection);+const AgentConnectionsSection = lazySection(+ async () => (await import('./AgentConnectionsSection')).AgentConnectionsSection,+);+const AttachmentsSection = lazySection(+ async () => (await import('./AttachmentsSection')).AttachmentsSection,+);+const ContentRulesSection = lazySection(+ async () => (await import('./ContentRulesSection')).ContentRulesSection,+);+const SectionSkeleton = lazySection(async () => (await import('./field-controls')).SectionSkeleton);+const HotkeysSection = lazySection(async () => (await import('./HotkeysSection')).HotkeysSection);+const IntegrationsSection = lazySection(+ async () => (await import('./IntegrationsSection')).IntegrationsSection,+);+const LinkPreviewsSection = lazySection(+ async () => (await import('./LinkPreviewsSection')).LinkPreviewsSection,+);+const MarkdownlintPluginSection = lazySection(+ async () => (await import('./LintingSection')).MarkdownlintPluginSection,+);+const ProjectPluginsManageSection = lazySection(+ async () => (await import('./LintingSection')).ProjectPluginsManageSection,+);+const UserPluginsManageSection = lazySection(+ async () => (await import('./LintingSection')).UserPluginsManageSection,+);+const NetworkAccessSection = lazySection(+ async () => (await import('./NetworkAccessSection')).NetworkAccessSection,+);+const OkignoreSection = lazySection(+ async () => (await import('./OkignoreSection')).OkignoreSection,+);+const ProjectTemplatesSection = lazySection(+ async () => (await import('./ProjectTemplatesSection')).ProjectTemplatesSection,+);+const SearchSection = lazySection(async () => (await import('./SearchSection')).SearchSection);+const SkillsManagerSection = lazySection(+ async () => (await import('./SkillsManagerSection')).SkillsManagerSection,+);+const SlidesPluginSection = lazySection(+ async () => (await import('./SlidesPluginSection')).SlidesPluginSection,+);+const SyncSection = lazySection(async () => (await import('./SyncSection')).SyncSection);+const TerminalSection = lazySection(+ async () => (await import('./TerminalSection')).TerminalSection,+);+const ThemePluginSection = lazySection(+ async () => (await import('./ThemePluginSection')).ThemePluginSection,+);++const LintPluginSection = lazySection(async () => {+ const { LINT_PLUGIN_UI } = await import('./lint-plugins');+ return function LintPluginSection({ id }: { id: string }) {+ const plugin = LINT_PLUGIN_UI.find((entry) => entry.id === id);+ if (!plugin) return null;+ const PluginSection = plugin.Section;+ return <PluginSection />;+ };+});++const PreferencesSection = lazyWithPreload(async () => {+ const [{ BoundSchemaSection }, { OkCliPathRow }, { SpellingSettings }] = await Promise.all([+ import('./schema-section'),+ import('./OkCliPathRow'),+ import('./SpellingSettings'),+ ]);+ return {+ default: function PreferencesSection({+ title,+ description,+ binding,+ }: {+ title: string;+ description: string;+ binding: ConfigBinding;+ }) {+ return (+ <BoundSchemaSection+ title={title}+ description={description}+ scope="user"+ scopeBadge="user"+ binding={binding}+ fields={FIELDS_USER_PREFERENCES}+ slotsAfter={{+ 'appearance.theme': <OkCliPathRow />,+ 'appearance.language': <SpellingSettings />,+ }}+ />+ );+ },+ };+});++export const preloadPreferencesSection = PreferencesSection.preload;interface SettingsDialogBodyProps {activeId: string;@@ -49,17 +126,10 @@ export function SettingsDialogBody({const { t } = useLingui();if (activeId === 'preferences') {return userBinding ? (- <BoundSchemaSection+ <PreferencesSectiontitle={t`Preferences`}description={t`Customize how the editor looks and behaves.`}- scope="user"- scopeBadge="user"binding={userBinding}- fields={FIELDS_USER_PREFERENCES}- slotsAfter={{- 'appearance.theme': <OkCliPathRow />,- 'appearance.language': <SpellingSettings />,- }}/>) : (<SectionSkeleton />@@ -135,11 +205,7 @@ export function SettingsDialogBody({return <MarkdownlintPluginSection initialRuleQuery={markdownlintRuleQuery ?? null} />;}if (activeId.startsWith('plugin:')) {- const pluginId = activeId.slice('plugin:'.length);- const plugin = LINT_PLUGIN_UI.find((p) => p.id === pluginId);- if (!plugin) return null;- const PluginSection = plugin.Section;- return <PluginSection key={activeId} />;+ return <LintPluginSection key={activeId} id={activeId.slice('plugin:'.length)} />;}if (activeId === 'project-templates') {return <ProjectTemplatesSection />;diff --git a/packages/app/src/components/settings/SettingsDialogBodyLazy.ts b/packages/app/src/components/settings/SettingsDialogBodyLazy.tsindex d5c84ffaa..02fd6c652 100644--- a/packages/app/src/components/settings/SettingsDialogBodyLazy.ts+++ b/packages/app/src/components/settings/SettingsDialogBodyLazy.ts@@ -3,3 +3,10 @@ import { lazyWithPreload } from '@/lib/lazy-with-preload';export const SettingsDialogBodyLazy = lazyWithPreload(() =>import('./SettingsDialogBody').then((m) => ({ default: m.SettingsDialogBody })),);++export async function preloadSettingsOnIntent(): Promise<void> {+ await SettingsDialogBodyLazy.preload()+ .then(() => import('./SettingsDialogBody'))+ .then((m) => m.preloadPreferencesSection())+ .catch(() => {});+}diff --git a/packages/app/src/components/settings/SettingsDialogShell.tsx b/packages/app/src/components/settings/SettingsDialogShell.tsxindex 88731e299..309c5f91d 100644--- a/packages/app/src/components/settings/SettingsDialogShell.tsx+++ b/packages/app/src/components/settings/SettingsDialogShell.tsx@@ -361,7 +361,7 @@ export function SettingsDialogShell({// biome-ignore lint/a11y/noNoninteractiveTabindex: this scrollable content section must be focusable so keyboard users can scroll long settings pages.tabIndex={0}>- <SettingsDialogErrorBoundary>+ <SettingsDialogErrorBoundary key={activeId}><Suspense fallback={<SettingsContentSkeleton />}><SettingsDialogBodyLazyactiveId={activeId}diff --git a/packages/app/src/test-utils/render-settings-body.test-helper.tsx b/packages/app/src/test-utils/render-settings-body.test-helper.tsxnew file mode 100644index 000000000..b87e5167a--- /dev/null+++ b/packages/app/src/test-utils/render-settings-body.test-helper.tsx@@ -0,0 +1,15 @@+import { act, render, waitForElementToBeRemoved } from '@testing-library/react';+import { type ReactNode, Suspense } from 'react';+import { vi } from 'vitest';++export async function renderSettingsBody(content: ReactNode) {+ const view = render(+ <Suspense fallback={<span data-testid="settings-render-pending" />}>{content}</Suspense>,+ );+ await act(async () => {+ await vi.dynamicImportSettled();+ });+ const pending = view.queryByTestId('settings-render-pending');+ if (pending) await waitForElementToBeRemoved(pending);+ return view;+}diff --git a/packages/app/tests/stress/okignore-settings.e2e.ts b/packages/app/tests/stress/okignore-settings.e2e.tsindex bf0dd1684..14858a001 100644--- a/packages/app/tests/stress/okignore-settings.e2e.ts+++ b/packages/app/tests/stress/okignore-settings.e2e.ts@@ -163,7 +163,10 @@ test.describe('Settings — Ignore patterns section (US-007 / US-008 / US-009 /}) => {await page.goto('/#settings');- await expect(page.getByTestId('settings-dialog')).toBeVisible({ timeout: 10_000 });+ const dialog = page.getByTestId('settings-dialog');+ await expect(dialog.getByRole('heading', { name: 'Preferences', exact: true })).toBeVisible({+ timeout: 10_000,+ });await expect(page.getByTestId('settings-okignore-section')).toHaveCount(0);await expect(page.getByTestId('settings-okignore-skeleton')).toHaveCount(0);@@ -452,6 +455,90 @@ test.describe('Settings — Ignore patterns section (US-007 / US-008 / US-009 /});});+test.describe('Settings selected section loading', () => {+ for (const { name, id, panel } of [+ { name: 'Ignore patterns', id: 'okignore', panel: 'settings-okignore-section' },+ { name: 'Hotkeys', id: 'hotkeys', panel: 'settings-hotkeys' },+ ]) {+ test(`${name} mounts while an unselected Themes module is pending`, async ({+ page,+ api,+ }, testInfo) => {+ await api.testReset();++ const themesModule = /\/src\/components\/settings\/ThemePluginSection\.tsx(?:\?|$)/;+ const releaseThemes = Promise.withResolvers<void>();+ await page.route(themesModule, async (route) => {+ await releaseThemes.promise;+ await route.continue();+ });+ const themesRequested = page.waitForRequest(themesModule);++ const section = page.getByTestId(panel);+ try {+ await page.goto('/#settings');+ await page.getByTestId('settings-sidebar-item-plugin:theme').click();+ await themesRequested;++ await page.getByTestId(`settings-sidebar-item-${id}`).click();+ await test.step('panel mounts before Themes delivery resumes', async () => {+ await expect.soft(section).toBeVisible({ timeout: 10_000 });+ });+ } finally {+ releaseThemes.resolve();+ }++ await test.step('panel remains visible after Themes delivery resumes', async () => {+ await expect(section).toBeVisible({ timeout: 10_000 });+ });+ await testInfo.attach('post-release-panel-visible', {+ body: `${name} mounted after Themes delivery resumed`,+ contentType: 'text/plain',+ });+ });+ }++ test('Ignore patterns mounts after an unselected Hotkeys module fails to load', async ({+ page,+ api,+ }) => {+ await api.testReset();+ await page.route(/\/src\/components\/settings\/HotkeysSection\.tsx(?:\?|$)/, (route) =>+ route.abort(),+ );++ const dialog = page.getByTestId('settings-dialog');+ await page.goto('/#settings');+ await page.getByTestId('settings-sidebar-item-hotkeys').click();+ await expect(dialog.getByRole('heading', { name: 'Settings failed to load' })).toBeVisible();++ await page.getByTestId('settings-sidebar-item-okignore').click();+ await expect(page.getByTestId('settings-okignore-section')).toBeVisible();+ });++ test('Hotkeys mounts while every other settings section module is pending', async ({+ page,+ api,+ }) => {+ await api.testReset();++ const otherSectionModules =+ /\/src\/components\/settings\/(?!HotkeysSection\.tsx)[A-Za-z]+Section\.tsx(?:\?|$)/;+ const releaseOtherSections = Promise.withResolvers<void>();+ await page.route(otherSectionModules, async (route) => {+ await releaseOtherSections.promise;+ await route.continue();+ });++ try {+ await page.goto('/#settings/hotkeys');+ await expect(page.getByTestId('settings-hotkeys')).toBeVisible();+ } finally {+ releaseOtherSections.resolve();+ }+ });+});+test.describe('FileTree right-click → Hide this file/folder (US-013)', () => {test('"Hide this file" appends an anchored pattern to __config__/okignore', async ({page,