Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Keep Settings open on every repeated open request (PRD-9310) (#6158)

Andrew Mikofalvy578c11b431b5
diff --git a/docs/content/features/editor.mdx b/docs/content/features/editor.mdx
index fa0118baa..bba5b8142 100644
--- a/docs/content/features/editor.mdx
+++ b/docs/content/features/editor.mdx
@@ -367,6 +367,8 @@ Inside an AI editor's embedded view, the **Open with AI** menus, the bottom Ask
The OpenKnowledge desktop app keeps its menu bar in sync with the active editor target: File menu items enable / disable based on whether a doc, folder, or nothing is currently selected. On macOS this is the system menu bar; on Windows and Linux the same menus live in the app window's title bar, with `Ctrl` in place of `Cmd`.
+On Windows and Linux, an open dialog such as Settings blocks the title-bar menus until you close it, the way a dialog blocks its window's menus in other Windows and Linux apps. Pressing `Ctrl+,` while Settings is open keeps it open on the page you were viewing; close it with the X button or `Esc`.
+
### File menu
Alongside the project items (Recent project, New project…, Switch Project… `Cmd+Shift+P`, Open Folder… `Cmd+O`), the worktree pair (New worktree…, Switch worktree…), **Set up OpenKnowledge integrations…** (re-runs the first-launch integrations setup), and Close tab, the File menu surfaces the most-used sidebar affordances so they're reachable from the keyboard:
diff --git a/knip.config.ts b/knip.config.ts
index 69344114d..0004a763a 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -149,11 +149,15 @@ export default {
'packages/server': {
entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],
project: 'src/**',
- ignoreDependencies: ['@types/shell-quote'],
+ ignoreDependencies: [
+ '@types/shell-quote',
+ ],
},
'packages/cli': {
entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],
- ignoreDependencies: ['yjs'],
+ ignoreDependencies: [
+ 'yjs',
+ ],
},
'packages/desktop': {
entry: [
diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx
index 320be1ec2..f5eb24955 100644
--- a/packages/app/src/App.tsx
+++ b/packages/app/src/App.tsx
@@ -69,11 +69,7 @@ import { mark, ProfilerBoundary } from '@/lib/perf';
import { SingleFileModeProvider, useSingleFileMode } from '@/lib/single-file-mode';
import { consumeHashNavigationSuppression } from '@/lib/tab-session-restore-suppression';
import { useServerKeepalive } from '@/lib/use-server-keepalive';
-import {
- isSettingsHashOpen,
- isSettingsShortcut,
- SETTINGS_OPEN_HASH,
-} from '@/lib/use-settings-route';
+import { isSettingsHashOpen, isSettingsShortcut, openSettings } from '@/lib/use-settings-route';
const ShareBranchSwitchDialog = lazy(() =>
import('@/components/ShareBranchSwitchDialog').then((m) => ({
@@ -405,9 +401,7 @@ function SettingsShortcutHandler() {
})
) {
e.preventDefault();
- if (window.location.hash !== SETTINGS_OPEN_HASH) {
- window.location.hash = SETTINGS_OPEN_HASH;
- }
+ openSettings();
}
}
diff --git a/packages/app/src/components/SettingsButton.tsx b/packages/app/src/components/SettingsButton.tsx
index 37a849bb8..e770eb514 100644
--- a/packages/app/src/components/SettingsButton.tsx
+++ b/packages/app/src/components/SettingsButton.tsx
@@ -4,7 +4,7 @@ import { type FC, useEffect, useRef } from 'react';
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';
+import { openSettings } from '@/lib/use-settings-route';
const PREFETCH_INTENT_DELAY_MS = 50;
@@ -26,11 +26,9 @@ export const SettingsButton: FC = () => {
}
};
- const openSettings = () => {
+ const handleClick = () => {
cancelPreload();
- if (window.location.hash !== SETTINGS_OPEN_HASH) {
- window.location.hash = SETTINGS_OPEN_HASH;
- }
+ openSettings();
};
useEffect(
@@ -54,7 +52,7 @@ export const SettingsButton: FC = () => {
onMouseLeave={cancelPreload}
onFocus={schedulePreload}
onBlur={cancelPreload}
- onClick={openSettings}
+ onClick={handleClick}
>
<Settings className="size-4" />
<span className="sr-only">
diff --git a/packages/app/src/components/command-palette-commands.ts b/packages/app/src/components/command-palette-commands.ts
index 66cc7b782..73d812860 100644
--- a/packages/app/src/components/command-palette-commands.ts
+++ b/packages/app/src/components/command-palette-commands.ts
@@ -58,7 +58,7 @@ import type { OkDesktopBridge, OkMenuAction } from '@/lib/desktop-bridge-types';
import { i18n } from '@/lib/i18n';
import type { KeyboardShortcutId } from '@/lib/keyboard-shortcuts';
import { openDocInNoteWindow } from '@/lib/open-note-window';
-import { SETTINGS_OPEN_HASH } from '@/lib/use-settings-route';
+import { openSettings } from '@/lib/use-settings-route';
import type { ViewMenuState } from '@/lib/view-menu-state-store';
export type ContextualTargetKind = 'doc' | 'folder' | 'asset' | 'none';
@@ -314,9 +314,7 @@ const COMMAND_DISPATCH: Record<string, (ctx: PaletteCommandContext) => void> = {
},
settings: (ctx) => {
ctx.closePalette();
- if (window.location.hash !== SETTINGS_OPEN_HASH) {
- window.location.hash = SETTINGS_OPEN_HASH;
- }
+ openSettings();
},
'install-claude-desktop': (ctx) => {
ctx.closePalette();
diff --git a/packages/app/src/lib/use-settings-route.dom.test.tsx b/packages/app/src/lib/use-settings-route.dom.test.tsx
index afa0fe830..812b9e082 100644
--- a/packages/app/src/lib/use-settings-route.dom.test.tsx
+++ b/packages/app/src/lib/use-settings-route.dom.test.tsx
@@ -68,4 +68,29 @@ describe('useSettingsRoute runtime routing', () => {
expect(await screen.findByText('open')).toBeTruthy();
});
+
+ test('opening Settings while it is already open on a section keeps it open on that section', async () => {
+ window.history.replaceState(null, '', '/');
+ await renderProbe();
+ window.location.hash = '#settings/about';
+ fireEvent(window, new Event('hashchange'));
+ expect(screen.getByTestId('settings-open').textContent).toBe('open');
+ const { openSettings } = await import('./use-settings-route');
+ const historyLength = window.history.length;
+
+ for (let attempt = 0; attempt < 10; attempt += 1) openSettings();
+
+ expect(window.location.hash).toBe('#settings/about');
+ expect(window.history.length).toBe(historyLength);
+ expect(screen.getByTestId('settings-open').textContent).toBe('open');
+ });
+
+ test('opening Settings from a closed state routes to the Settings hash', async () => {
+ window.history.replaceState(null, '', '/');
+ const { openSettings } = await import('./use-settings-route');
+
+ openSettings();
+
+ expect(window.location.hash).toBe('#settings');
+ });
});
diff --git a/packages/app/src/lib/use-settings-route.ts b/packages/app/src/lib/use-settings-route.ts
index 2b6d67541..c1e67838b 100644
--- a/packages/app/src/lib/use-settings-route.ts
+++ b/packages/app/src/lib/use-settings-route.ts
@@ -34,6 +34,11 @@ function openSettingsSection(sectionId: string): void {
if (window.location.hash !== target) window.location.hash = target;
}
+export function openSettings(): void {
+ if (typeof window === 'undefined') return;
+ if (!isSettingsHashOpen(window.location.hash)) window.location.hash = SETTINGS_OPEN_HASH;
+}
+
const AGENT_SETTINGS_SECTION = 'agent-connections';
export function openAgentSettings(): void {
diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
index a50b00123..4549c74b3 100644
--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
@@ -1,3 +1,4 @@
+
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
index 6fcdc23f2..4fc2c11f9 100644
--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
@@ -1,3 +1,4 @@
+
import { setTimeout as wait } from 'node:timers/promises';
import { normalizeBridge } from '@inkeep/open-knowledge-core';
import { updateYFragment } from '@tiptap/y-tiptap';
diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.ts
index 40b5cdfd6..9f2f6feb6 100644
--- a/packages/app/tests/integration/interior-edit-freshness.test.ts
+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts
@@ -1,3 +1,4 @@
+
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
index 93666af70..2a085742b 100644
--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
@@ -1,3 +1,4 @@
+
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.ts
index 867598d34..878d5196b 100644
--- a/packages/app/tests/integration/producer-guard-wiring.test.ts
+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts
@@ -1,3 +1,4 @@
+
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
index 0970ac12f..4ada3cf26 100644
--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
@@ -1,3 +1,4 @@
+
import { randomUUID } from 'node:crypto';
import { afterEach, describe, expect, test } from 'vitest';
import { agentWriteMd, createTestServer, type TestServer } from './test-harness';
diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
index b632185e1..cbe2b705f 100644
--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
@@ -1,3 +1,4 @@
+
import { execFileSync } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { join } from 'node:path';
diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
index c530ce4ba..89bc9b4d9 100644
--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
@@ -1,3 +1,4 @@
+
import { randomUUID } from 'node:crypto';
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';
import type * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.ts
index d3767adc9..a78aeb0e4 100644
--- a/packages/app/tests/integration/undo-after-rollback.test.ts
+++ b/packages/app/tests/integration/undo-after-rollback.test.ts
@@ -1,3 +1,4 @@
+
import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.ts
index b076f955c..e7cc69c3f 100644
--- a/packages/app/tests/integration/undo-recycle-reset.test.ts
+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts
@@ -1,3 +1,4 @@
+
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.ts
index 7935e35f8..9ddcd0730 100644
--- a/packages/app/tests/integration/undo-rederive-survival.test.ts
+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts
@@ -1,3 +1,4 @@
+
import { prependFrontmatter } from '@inkeep/open-knowledge-core';
import { Plugin, PluginKey } from '@tiptap/pm/state';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
diff --git a/packages/app/tests/stress/settings-close-button.e2e.ts b/packages/app/tests/stress/settings-close-button.e2e.ts
index a98656512..27a8df45f 100644
--- a/packages/app/tests/stress/settings-close-button.e2e.ts
+++ b/packages/app/tests/stress/settings-close-button.e2e.ts
@@ -98,6 +98,52 @@ test.describe('Settings close button', () => {
await closeWithX(page);
});
+ const reopenEntryPoints: ReadonlyArray<{
+ name: string;
+ open: (page: Page) => Promise<void>;
+ hash: RegExp;
+ }> = [
+ {
+ name: 'header gear',
+ open: (page) => page.getByTestId('header-settings-button').click(),
+ hash: /#settings$/,
+ },
+ {
+ name: 'keyboard shortcut',
+ open: (page) => page.locator('body').press('ControlOrMeta+,'),
+ hash: /#settings$/,
+ },
+ {
+ name: 'About & updates page',
+ open: async (page) => {
+ await page.evaluate(() => {
+ window.location.hash = '#settings/about';
+ });
+ },
+ hash: /#settings\/about$/,
+ },
+ ];
+
+ for (const entry of reopenEntryPoints) {
+ test(`repeated Settings requests over Settings opened from the ${entry.name} keep it open`, async ({
+ page,
+ }) => {
+ await openApp(page);
+ await entry.open(page);
+ await expectSettingsOpen(page);
+ await expect(page).toHaveURL(entry.hash);
+
+ for (let attempt = 0; attempt < 10; attempt += 1) {
+ await page.keyboard.press('ControlOrMeta+,');
+ await page.evaluate(settingsHashScript());
+ await expectSettingsOpen(page);
+ await expect(page).toHaveURL(entry.hash);
+ }
+
+ await closeWithX(page);
+ });
+ }
+
test('a native-menu section request over open Settings switches page without stacking history', async ({
page,
}) => {
diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.ts
index f4cc8a286..2a597ec3d 100644
--- a/packages/core/src/bridge/compose.ts
+++ b/packages/core/src/bridge/compose.ts
@@ -1,3 +1,4 @@
+
import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';
export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';
diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index e7e63f43d..ffd8fce06 100644
--- a/packages/core/src/bridge/doc-boundary-space.ts
+++ b/packages/core/src/bridge/doc-boundary-space.ts
@@ -1,3 +1,4 @@
+
import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';
import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index fc267cbea..fb0ba5a7c 100644
--- a/packages/core/src/markdown/comment-promoter.ts
+++ b/packages/core/src/markdown/comment-promoter.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.ts
index bfd7e3109..fa3cfcd86 100644
--- a/packages/core/src/markdown/merged-walker.ts
+++ b/packages/core/src/markdown/merged-walker.ts
@@ -1,3 +1,4 @@
+
import type { Nodes, Parent, Root } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.ts
index 4d3250d3a..8be632ba4 100644
--- a/packages/core/src/markdown/safe-url.ts
+++ b/packages/core/src/markdown/safe-url.ts
@@ -1,3 +1,4 @@
+
export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;
const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');