Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
feat(open-knowledge): add a setting to disable preview tabs (#3118)
tim-inkeepc2a7e445dd62
diff --git a/.changeset/preview-tabs-toggle.md b/.changeset/preview-tabs-toggle.mdnew file mode 100644index 000000000..08fd7bce8--- /dev/null+++ b/.changeset/preview-tabs-toggle.md@@ -0,0 +1,5 @@+---+"@inkeep/open-knowledge": patch+---++Clicking a file in the Files or Skills sidebar reuses one tab, the way an editor preview tab works. That is still the default, but it is now a setting: turn off **Preview tabs** in Settings (or set `editor.previewTabs: false`) and every sidebar click opens in its own tab instead of replacing the current one. Pinned tabs are never reused either way, and back/forward navigation still reuses the active tab.diff --git a/docs/content/reference/configuration.mdx b/docs/content/reference/configuration.mdxindex 5ef53da39..9b9c5cdce 100644--- a/docs/content/reference/configuration.mdx+++ b/docs/content/reference/configuration.mdx@@ -47,6 +47,7 @@ A key set in a file more specific than its scope (a user-scope key in `.ok/confi| `remote.url` | string | (unset) | project | Public tunnel URL remote clients connect to (e.g. `https://myproject.ngrok.app`); its host is admitted through the Host-header allowlist. Used only when the server is started with `ok start --remote` (config alone never enables remote access, and there is no server-side auth). See [Remote access](/docs/deploy/remote-access). || `remote.port` | number | `24550` | project | Fixed TCP port the server binds when remote access is enabled, so the tunnel's port mapping survives restarts. See [Remote access](/docs/deploy/remote-access). || `editor.wordWrap` | boolean | `true` | user | Soft-wrap long lines in the source-mode CodeMirror editor. A personal preference, not project-shared. Toggle from the Settings pane. |+| `editor.previewTabs` | boolean | `true` | user | Reuse one "preview" tab for single clicks in the Files tree and Skills sidebar, so browsing does not accumulate tabs. Set `false` to open every click in its own tab. A personal preference, not project-shared. Back/forward navigation and rename transitions always reuse the current tab regardless. Toggle from the Settings pane. || `appearance.preview.autoOpen` | boolean | `true` | user | Whether the agent should open or refresh the OpenKnowledge preview when it edits a doc through the MCP. Default `true` lets the agent route the preview by host capability: the host's in-app browser (Cursor preview pane, Codex's built-in browser, Claude Code Desktop) when one exists, the system browser otherwise. Set `false` to keep the agent's hands off your preview window. This is useful when you're already viewing the doc in OK Desktop, a browser tab on a second display, a non-default browser, or any flow where your extensions / accessibility tooling only work in your own browser. The agent then surfaces the URL on request but does not navigate. The change takes effect on the next preview-related tool call. Toggle from **Settings → Preferences → "Open preview when agent edits"**. || `terminal.enabled` | `boolean \| null` | `null` | project-local | Opt-out for the in-app terminal (a real OS shell at full user privilege). On by default; set `false` to disable it for this project on this machine. || `agents.autoApproveOkTools` | boolean | `true` | user | Auto-approve OpenKnowledge's own MCP tools (and the `ok open` command on Claude) for agents launched from the built-in [docked terminal](/docs/features/editor#terminal), so reading and writing the knowledge base runs without a per-call approval prompt. Destructive tools (`delete`, `move`, `share_link`, `install`) still prompt; other shell commands and non-OpenKnowledge file edits are untouched. Per-machine preference; toggle from **Settings → Terminal**. Best-effort per agent — Claude uses an allow/deny list, Codex uses its per-server `approve` mode (and only when its OpenKnowledge entry is already configured). |diff --git a/packages/app/src/components/FileTree.showall-lazy.dom.test.tsx b/packages/app/src/components/FileTree.showall-lazy.dom.test.tsxindex 37a905e58..5069f78d2 100644--- a/packages/app/src/components/FileTree.showall-lazy.dom.test.tsx+++ b/packages/app/src/components/FileTree.showall-lazy.dom.test.tsx@@ -524,6 +524,35 @@ describe('FileTree showAll lazy root seed', () => {expect(window.location.hash).toBe('#/README');});+ // `editor.previewTabs: false` turns off the reuse-one-tab behavior, so a tree+ // click appends its own tab instead of replacing the active one.+ test('with preview tabs disabled, a document click appends a tab', async () => {+ mergedConfig = { appearance: { sidebar: {} }, editor: { previewTabs: false } };+ showAllResponseFactory = () =>+ jsonResponse({+ documents: [docEntry('foo'), docEntry('README')],+ truncated: false,+ });+ const view = render(<FileTree />);++ await waitFor(() => expect(model.items.has('README.md')).toBe(true));+ model.selectedPaths = ['foo.md'];+ view.rerender(<FileTree />);+ fireEvent.click(screen.getByRole('treeitem', { name: 'README.md' }));++ await waitFor(() =>+ expect(openTargetMock).toHaveBeenCalledWith(+ {+ kind: 'doc',+ target: 'README',+ docName: 'README',+ },+ { tabBehavior: 'append' },+ ),+ );+ window.location.hash = '';+ });+test('first click from a document row to a folder opens the folder', async () => {showAllResponseFactory = () =>jsonResponse({diff --git a/packages/app/src/components/FileTree.tsx b/packages/app/src/components/FileTree.tsxindex feba6a454..87f6d0d7a 100644--- a/packages/app/src/components/FileTree.tsx+++ b/packages/app/src/components/FileTree.tsx@@ -1269,13 +1269,13 @@ export function FileTree({if (target.kind === 'doc') {if (target.registerPage) addPage(target.docName);openTarget(navigationTargetForDocument(target.docName, target.size), {- tabBehavior: 'replace-active',+ tabBehavior: openTabBehavior(),});pushHashWithoutNavigation(hashFromDocName(target.docName));} else if (target.kind === 'folder') {openTarget({ kind: 'folder', target: target.folderPath, folderPath: target.folderPath },- { tabBehavior: 'replace-active' },+ { tabBehavior: openTabBehavior() },);pushHashWithoutNavigation(hashFromFolderPath(target.folderPath));} else {@@ -1291,7 +1291,7 @@ export function FileTree({assetPath: target.assetPath,mediaKind: entry?.mediaKind ?? null,},- { tabBehavior: 'replace-active' },+ { tabBehavior: openTabBehavior() },);pushHashWithoutNavigation(hashFromAssetPath(target.assetPath));}@@ -1321,7 +1321,7 @@ export function FileTree({assetPath: action.path,mediaKind: action.mediaKind,},- { tabBehavior: 'replace-active' },+ { tabBehavior: openTabBehavior() },);pushHashWithoutNavigation(action.hash);notifySidebarFileSelected();@@ -1344,7 +1344,7 @@ export function FileTree({docExt: docEntry?.docExt,});if (okTarget?.kind === 'asset') {- openTarget(okTarget, { tabBehavior: 'replace-active' });+ openTarget(okTarget, { tabBehavior: openTabBehavior() });pushHashWithoutNavigation(hashFromAssetPath(okTarget.assetPath));notifySidebarFileSelected();return;@@ -1421,6 +1421,13 @@ export function FileTree({const showHiddenFilesRef = useRef<boolean>(false);const showOnlyMarkdownFilesRef = useRef<boolean>(false);const showOkFoldersRef = useRef<boolean>(false);+ // Preview-tab behavior: on (the default), a tree click reuses the active tab+ // the way an editor preview tab does; off, every click opens its own tab.+ // Same ref treatment as the visibility toggles above — the open closures are+ // created at mount and must read the latest value at click time.+ const previewTabsRef = useRef<boolean>(true);+ const openTabBehavior = (): 'append' | 'replace-active' =>+ previewTabsRef.current ? 'replace-active' : 'append';const treeVisibilityFromRefs = () => ({showHiddenFiles: showHiddenFilesRef.current,showOnlyMarkdownFiles: showOnlyMarkdownFilesRef.current,@@ -1636,6 +1643,7 @@ export function FileTree({const showHiddenFiles = merged?.appearance?.sidebar?.showHiddenFiles ?? false;const showOnlyMarkdownFiles = merged?.appearance?.sidebar?.showOnlyMarkdownFiles ?? false;const showOkFolders = merged?.appearance?.sidebar?.showOkFolders ?? false;+ const previewTabs = merged?.editor?.previewTabs ?? true;const isAvailable = () => busyPathRef.current === null;@@ -3233,6 +3241,7 @@ export function FileTree({showHiddenFilesRef.current = showHiddenFiles;showOnlyMarkdownFilesRef.current = showOnlyMarkdownFiles;showOkFoldersRef.current = showOkFolders;+ previewTabsRef.current = previewTabs;treePathsRef.current = treePaths;folderTreePathsRef.current = folderTreePaths;activeAncestorTreePathsRef.current = activeAncestorTreePaths;diff --git a/packages/app/src/components/SkillsSidebarSection.tsx b/packages/app/src/components/SkillsSidebarSection.tsxindex d94929d0c..28a426879 100644--- a/packages/app/src/components/SkillsSidebarSection.tsx+++ b/packages/app/src/components/SkillsSidebarSection.tsx@@ -60,6 +60,7 @@ import { useCreateBlankSkill } from '@/hooks/use-create-blank-skill';import { useOpenSkill } from '@/hooks/use-open-skill';import { useOpenSkillForEdit } from '@/hooks/use-open-skill-for-edit';import { useSkills } from '@/hooks/use-skills';+import { useConfigContext } from '@/lib/config-provider';import {hashFromDocName,hashFromSkillFile,@@ -222,6 +223,11 @@ export function SkillsSidebarSection({ skillsMode = false }: { skillsMode?: bool* overrides it.*/const stayInSkills = () => setSkillsSidebar(true);+ const { merged } = useConfigContext();+ // Preview tabs off means every sidebar click opens its own tab — same+ // preference the Files tree honors.+ const tabBehavior: 'append' | 'replace-active' =+ (merged?.editor?.previewTabs ?? true) ? 'replace-active' : 'append';const openSkill = useOpenSkill();const openSkillForEdit = useOpenSkillForEdit();const actions = useSkillActions();@@ -357,9 +363,10 @@ export function SkillsSidebarSection({ skillsMode = false }: { skillsMode?: bool// tab, the same preview-tab behavior the Files tree uses on click: clicking// through skills reuses one tab instead of stacking a new one each time (§8.7).// A pinned active tab is preserved (replace-active falls back to append when- // pinned, handled in openTargetWithOptions).+ // pinned, handled in openTargetWithOptions). Users who want a tab per click+ // turn `editor.previewTabs` off, which pins `tabBehavior` to append.const openSkillDoc = (docName: string) => {- openTarget({ kind: 'doc', target: docName, docName }, { tabBehavior: 'replace-active' });+ openTarget({ kind: 'doc', target: docName, docName }, { tabBehavior });pushHashWithoutNavigation(hashFromDocName(docName));stayInSkills();};@@ -407,7 +414,7 @@ export function SkillsSidebarSection({ skillsMode = false }: { skillsMode?: boollevel: target.level,path: target.path,},- { tabBehavior: 'replace-active' },+ { tabBehavior },);pushHashWithoutNavigation(hashFromSkillPreview(target));stayInSkills();@@ -447,7 +454,7 @@ export function SkillsSidebarSection({ skillsMode = false }: { skillsMode?: boolpath: filePath,...(host ? { host } : {}),},- { tabBehavior: 'replace-active' },+ { tabBehavior },);pushHashWithoutNavigation(hashFromSkillFile({@@ -518,7 +525,15 @@ export function SkillsSidebarSection({ skillsMode = false }: { skillsMode?: bool// that autosaves back to the real harness file — "edit without managing":// full WYSIWYG. A bundle file// passes its ext-less `rel`; one registration covers the whole skill dir.- void openSkillForEdit(s.name, source, { replaceActive: true, rel }).then((r) => {+ // Same `tabBehavior` decision as every other open in this sidebar. Hard-+ // coding reuse here left the two halves of this function disagreeing: the+ // plugin branch above already routes through `openPreviewReplacing`, so+ // with `previewTabs` off a detected skill was the one row that still stole+ // the active tab. `replaceActive` maps 1:1 onto the two values — the hook+ // passes `tabBehavior: 'replace-active'` when true, and `openTarget`+ // defaults to `'append'` otherwise.+ const replaceActive = tabBehavior === 'replace-active';+ void openSkillForEdit(s.name, source, { replaceActive, rel }).then((r) => {if (!r.ok) toast.error(t`Couldn't open ${s.name} for editing: ${r.error}`);// Pins after the async open lands, for the same reason as the sync paths.else stayInSkills();diff --git a/packages/app/src/components/settings/settings-fields.ts b/packages/app/src/components/settings/settings-fields.tsindex 09efbcd7f..a1ba51d17 100644--- a/packages/app/src/components/settings/settings-fields.ts+++ b/packages/app/src/components/settings/settings-fields.ts@@ -36,6 +36,11 @@ export const FIELDS_USER_PREFERENCES: FieldDef[] = [label: msg`Word wrap`,description: msg`Wrap long lines in the markdown source editor.`,},+ {+ path: ['editor', 'previewTabs'],+ label: msg`Preview tabs`,+ description: msg`Reuse one tab when clicking through the sidebars. Off opens every click in its own tab.`,+ },{path: ['appearance', 'preview', 'autoOpen'],label: msg`Open preview when agent edits`,diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.jsonindex a1107602d..19035ea3b 100644--- a/packages/app/src/locales/en/messages.json+++ b/packages/app/src/locales/en/messages.json@@ -666,6 +666,9 @@"AB4qw9": ["New terminal"],"ACKMCN": ["Failed to load skill settings: ", ["0"]],"AE7BY3": ["The terminal session ended."],+ "AIC67-": [+ "Reuse one tab when clicking through the sidebars. Off opens every click in its own tab."+ ],"AIVHDc": ["Choose what a new session starts"],"AIn2Yv": [["displayName"], " CLI, ", ["hint"]],"AItsE5": ["Open it there"],@@ -2468,6 +2471,7 @@],"dprWmL": ["Anchor in this page"],"dr1vFs": ["Replace all matches"],+ "drzzZw": ["Preview tabs"],"dw_3cv": ["Rename skill"],"dw_dUJ": ["Failed to duplicate path"],"dx-TwN": ["Running project audit"],diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.poindex bcb80f785..64adbe2ef 100644--- a/packages/app/src/locales/en/messages.po+++ b/packages/app/src/locales/en/messages.po@@ -8093,6 +8093,10 @@ msgstr "Preview browsers can't auto-copy. Use Cmd/Ctrl+C on the URL above, or opmsgid "Preview of the screenshot"msgstr "Preview of the screenshot"+#: src/components/settings/settings-fields.ts+msgid "Preview tabs"+msgstr "Preview tabs"+#: src/components/ConsentDialogBody.tsxmsgid "Preview unavailable: {errorDetail}"msgstr "Preview unavailable: {errorDetail}"@@ -8984,6 +8988,10 @@ msgstr "Retry push"msgid "Retrying"msgstr "Retrying"+#: src/components/settings/settings-fields.ts+msgid "Reuse one tab when clicking through the sidebars. Off opens every click in its own tab."+msgstr "Reuse one tab when clicking through the sidebars. Off opens every click in its own tab."+#: src/components/SeedDialog.tsxmsgid "Reused if it already exists, created if not."msgstr "Reused if it already exists, created if not."diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.jsonindex d998859a8..d5dba07f6 100644--- a/packages/app/src/locales/pseudo/messages.json+++ b/packages/app/src/locales/pseudo/messages.json@@ -666,6 +666,9 @@"AB4qw9": ["Ńēŵ ţēŕḿĩńàĺ"],"ACKMCN": ["Ƒàĩĺēď ţō ĺōàď śķĩĺĺ śēţţĩńĝś: ", ["0"]],"AE7BY3": ["Ţĥē ţēŕḿĩńàĺ śēśśĩōń ēńďēď."],+ "AIC67-": [+ "Ŕēũśē ōńē ţàƀ ŵĥēń ćĺĩćķĩńĝ ţĥŕōũĝĥ ţĥē śĩďēƀàŕś. Ōƒƒ ōƥēńś ēvēŕŷ ćĺĩćķ ĩń ĩţś ōŵń ţàƀ."+ ],"AIVHDc": ["Ćĥōōśē ŵĥàţ à ńēŵ śēśśĩōń śţàŕţś"],"AIn2Yv": [["displayName"], " ĆĹĨ, ", ["hint"]],"AItsE5": ["Ōƥēń ĩţ ţĥēŕē"],@@ -2468,6 +2471,7 @@],"dprWmL": ["Àńćĥōŕ ĩń ţĥĩś ƥàĝē"],"dr1vFs": ["Ŕēƥĺàćē àĺĺ ḿàţćĥēś"],+ "drzzZw": ["Ƥŕēvĩēŵ ţàƀś"],"dw_3cv": ["Ŕēńàḿē śķĩĺĺ"],"dw_dUJ": ["Ƒàĩĺēď ţō ďũƥĺĩćàţē ƥàţĥ"],"dx-TwN": ["Ŕũńńĩńĝ ƥŕōĴēćţ àũďĩţ"],diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.poindex d80a6b437..23be53da2 100644--- a/packages/app/src/locales/pseudo/messages.po+++ b/packages/app/src/locales/pseudo/messages.po@@ -8089,6 +8089,10 @@ msgstr ""msgid "Preview of the screenshot"msgstr ""+#: src/components/settings/settings-fields.ts+msgid "Preview tabs"+msgstr ""+#: src/components/ConsentDialogBody.tsxmsgid "Preview unavailable: {errorDetail}"msgstr ""@@ -8980,6 +8984,10 @@ msgstr ""msgid "Retrying"msgstr ""+#: src/components/settings/settings-fields.ts+msgid "Reuse one tab when clicking through the sidebars. Off opens every click in its own tab."+msgstr ""+#: src/components/SeedDialog.tsxmsgid "Reused if it already exists, created if not."msgstr ""diff --git a/packages/core/src/config/field-registry.test.ts b/packages/core/src/config/field-registry.test.tsindex b284b8e34..9b330e743 100644--- a/packages/core/src/config/field-registry.test.ts+++ b/packages/core/src/config/field-registry.test.ts@@ -143,7 +143,7 @@ describe('ConfigSchema coverage (NR3 — every leaf has fieldRegistry metadata)'expect(allowlisted).toEqual([]);});- test('user-strict fields cover agents.autoApproveOkTools + appearance.{colorTheme,colorThemeEnabled,customTheme.*,preview.autoOpen,theme} + editor.wordWrap', () => {+ test('user-strict fields cover agents.autoApproveOkTools + appearance.{colorTheme,colorThemeEnabled,customTheme.*,preview.autoOpen,theme} + editor.{previewTabs,wordWrap}', () => {const leaves: { path: string[]; schema: unknown }[] = [];walkLeaves(ConfigSchema, [], leaves);const userStrict = leaves@@ -177,6 +177,7 @@ describe('ConfigSchema coverage (NR3 — every leaf has fieldRegistry metadata)''appearance.customTheme.variant','appearance.preview.autoOpen','appearance.theme',+ 'editor.previewTabs','editor.wordWrap',// The one `telemetry` leaf that leaves the machine. USER scope so a// repository cannot decide that its collaborators report to a thirddiff --git a/packages/core/src/config/schema.ts b/packages/core/src/config/schema.tsindex a446af6bc..1afcf7a0f 100644--- a/packages/core/src/config/schema.ts+++ b/packages/core/src/config/schema.ts@@ -379,9 +379,12 @@ export const ConfigSchema = z.looseObject({.optional(),}).default({ preview: { autoOpen: true } }),- // USER-scope: source-editor word wrap is a personal reading/editing- // preference, not project content. Default true preserves the historical- // CodeMirror behavior until a user explicitly disables it.+ // USER-scope throughout: how someone reads and navigates their own editor is a+ // personal preference, not project content, so nothing in this group is+ // committed or agent-settable. Both leaves default true to preserve the+ // behavior each one replaced — CodeMirror's historical soft wrap, and the+ // single reused preview tab — so an existing install notices no change until+ // it opts out.editor: z.looseObject({wordWrap: z@@ -394,8 +397,18 @@ export const ConfigSchema = z.looseObject({'Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).',}).default(true),+ previewTabs: z+ .boolean()+ .register(fieldRegistry, {+ scope: 'user',+ agentSettable: false,+ defaultScope: 'user',+ description:+ 'Reuse one tab when clicking through the Files and Skills sidebars, the way an editor preview tab works. Turn off to open every click in its own tab. Pinned tabs keep their own tab either way. A personal preference (user scope).',+ })+ .default(true),})- .default({ wordWrap: true }),+ .default({ wordWrap: true, previewTabs: true }),// USER-scope: auto-approve OpenKnowledge's OWN MCP tools (and, on Claude, the// `ok open` verb) for agents launched from the docked terminal, so the KB// read/write loop runs without a per-call approval wall. Destructive/exfil OK