From e412bebbecbfc01d481a190cde272c8a42238b0d Mon Sep 17 00:00:00 2001 From: broisnees Date: Tue, 24 Nov 2026 11:58:48 +0000 Subject: [PATCH] Add a Labs option to open the connection page as a tab Settings > Labs > Connection page in a tab, off by default. ConnectionModal gains an inline mode: the same page drawn in place of the dialog, with props to hide its saved-connections rail, gate its global chords on the tab being active, start over on a reset key, and put the shell's tab strip where the dialog's title row was. showConnectionModal stays the one request for the page, so none of its fifteen-odd callers change. With the option on, the dialog never opens: connected, the request opens or focuses a singleton Connect tab, kept mounted while it is open so a form or provider sign-in survives a tab switch; with nothing connected, the window shows the page inline with its rail as the only list under a one-tab strip, in place of the launcher. The tab closes when the page closes itself, is left out of parked sessions and of the reopened-tabs list, and goes away if the option is turned off. --- .changeset/connect-in-tab.md | 2 + src/lib/components/ConnectionModal.svelte | 156 ++++++++++++++-------- src/lib/components/SettingsDialog.svelte | 8 ++ src/lib/components/StudioShell.svelte | 141 ++++++++++++++++++- src/lib/components/TabBar.svelte | 1 + src/lib/stores/settings.js | 10 +- src/lib/studio-tabs.js | 7 +- src/lib/studio-tabs.test.js | 8 ++ 8 files changed, 271 insertions(+), 62 deletions(-) create mode 100644 .changeset/connect-in-tab.md diff --git a/.changeset/connect-in-tab.md b/.changeset/connect-in-tab.md new file mode 100644 index 00000000..cde7f71b --- /dev/null +++ b/.changeset/connect-in-tab.md @@ -0,0 +1,2 @@ +### Changes +- **Connection page in a tab (Labs, off by default)** - Settings > Labs > Connection page in a tab. Adding or editing a connection opens a Connect tab beside your tables and queries, with the sidebar's own list of connections next to it; a half-filled form or a provider sign-in like Neon stays put while you look at another tab. With nothing connected, the window shows your saved connections and the connect page in one view under a Connect tab, instead of the first-run page and a dialog over it. diff --git a/src/lib/components/ConnectionModal.svelte b/src/lib/components/ConnectionModal.svelte index e086b256..03ba8b22 100644 --- a/src/lib/components/ConnectionModal.svelte +++ b/src/lib/components/ConnectionModal.svelte @@ -137,7 +137,29 @@ ondisconnect = () => {}, /** A saved connection was deleted here; the shell ends its session if open. */ onremoved = (/** @type {string} */ id) => {}, + /** + * Labs, connection page in a tab: drawn in place (a tab's pane, or the + * window when nothing is connected) instead of as a dialog over the app. + */ + inline = false, + /** Inline only: show the saved-connections rail. Off in a tab, where the + * studio's own sidebar lists the connections. */ + showRail = true, + /** Inline only: whether this view is the one on screen (its tab is the + * active one). The page's keyboard and mouse chords only act when it is. */ + active = true, + /** Inline only: bumped by the shell to start over (a new "Edit…" or + * engine request) while the view stays open. */ + resetKey = 0, + /** Inline only: drawn above the form, in place of the dialog's title row + * (the shell's tab strip when nothing is connected). */ + top = undefined, } = $props(); + // Inline the app's own title bar is above, so nothing makes room for the + // traffic lights. + const macChrome = $derived(isMacChrome && !inline); + // The page's global chords act only while it is open and on screen. + const live = $derived(open && (!inline || active)); /** The logos on the New connection button. */ const NEW_CONN_STACK = ["postgres", "mysql", "mongodb", "sqlite"]; @@ -1060,7 +1082,7 @@ // when there is nowhere to go - left alone the webview walks its own document // history, which in a Tauri window navigates away from the app. $effect(() => { - if (!open) return; + if (!live) return; /** @param {MouseEvent} e */ function onMouseNav(e) { if (e.button !== 3 && e.button !== 4) return; @@ -1068,7 +1090,7 @@ e.stopPropagation(); if (e.button !== 3) return; // nothing to go forward to if (step === "form") backToPick(); - else requestClose(); + else if (!inline) requestClose(); } /** Swallow the paired auxclick/mouseup so the webview cannot act on them. */ function swallowAux(/** @type {MouseEvent} */ e) { @@ -2326,6 +2348,7 @@ $effect(() => { if (!open) return; + void resetKey; untrack(() => { // The first provider call pays DNS + TCP + TLS; start those now, while // the dialog is still being read, so a listing or connect doesn't. @@ -2591,6 +2614,8 @@ const _rail = loadRail(); let railWidth = $state(_rail.width); let railOpen = $state(_rail.open); + // The rail as drawn: a tab never shows it. + const railShown = $derived(inline ? showRail : railOpen); function saveRail() { try { localStorage.setItem( @@ -2620,7 +2645,7 @@ * @param {KeyboardEvent} e */ function onRefreshKey(e) { - if (!open) return; + if (!live) return; if (!(e.ctrlKey || e.metaKey) || e.altKey) return; const key = e.key.toLowerCase(); /** @param {() => void} run */ @@ -2644,6 +2669,8 @@ } else if (key === "n") { take(() => newConnectionForm()); } else if (key === "f") { + // In a tab the studio's sidebar is the list: its own Mod+F finds there. + if (inline && !showRail) return; take(() => { if (!railOpen) { railOpen = true; saveRail(); } void tick().then(() => { savedSearchEl?.focus(); savedSearchEl?.select?.(); }); @@ -3438,7 +3465,7 @@ { - if (!open) return; + if (!live || inline) return; if ( (e.ctrlKey || e.metaKey) && !e.altKey && @@ -3951,57 +3978,15 @@ {/snippet} - - - - { - // Start in the connection filter. Left to the dialog, focus went to - // its first button, the rail's Hide toggle, and opened from the - // keyboard it drew a focus box around that icon in the header. - if (!savedSearchEl) return; - e.preventDefault(); - savedSearchEl.focus(); - }} - onEscapeKeydown={(e) => { - if (isDirty && !isBusy) { - e.preventDefault(); - confirmDiscardOpen = true; - } - }} - onFocusOutside={(e) => { - // Never let focus leaving the content dismiss the modal. Starting a native - // window drag/resize from the titlebar makes the webview lose focus, which - // bits-ui treats as focus-outside and closes the dialog. The modal is only - // meant to close via ×, Escape, or a genuine outside pointer interaction - // (handled below) - not because the OS took focus for a window drag. - e.preventDefault(); - }} - onInteractOutside={(e) => { - // Nothing outside the content dismisses this dialog. It is inset to leave - // the titlebar and status bar usable, so "outside" is window chrome: - // dragging the window to move or resize it, or a stray click on the tab - // bar, would otherwise throw away a half-filled connection form. Closing - // is deliberate only - the × button, Escape, or a successful connect. - e.preventDefault(); - }} - > - Connections +{#snippet panelBody()}
- {#if !railOpen} + {#if !railShown}
{:else} @@ -4030,9 +4015,12 @@ the rail's far end, and in a 48px row against the panel's 40px, it jumped across and down on every collapse. -->
+ + {#if !inline} + {/if}

Connections

@@ -4356,8 +4345,13 @@ lights sit in it; 40px elsewhere), so its buttons share the lights' centre line instead of floating at an offset. It is also the window's drag area here. --> + {#if inline} + + {#if top}{@render top()}{/if} + {:else}
{#if !railOpen} @@ -4386,7 +4380,8 @@
- {#if dialing} @@ -6392,7 +6387,7 @@ {saved.length === 0 ? "Everything stays on this machine" - : railOpen + : railOpen || inline ? "Or pick a saved connection on the left" : "Saved connections are hidden - reopen them from the top left"} @@ -6679,9 +6674,64 @@
{/if} +{/snippet} + +{#if inline} + + {#if open} +
+ {@render panelBody()} +
+ {/if} +{:else} + + + + { + // Start in the connection filter. Left to the dialog, focus went to + // its first button, the rail's Hide toggle, and opened from the + // keyboard it drew a focus box around that icon in the header. + if (!savedSearchEl) return; + e.preventDefault(); + savedSearchEl.focus(); + }} + onEscapeKeydown={(e) => { + if (isDirty && !isBusy) { + e.preventDefault(); + confirmDiscardOpen = true; + } + }} + onFocusOutside={(e) => { + // Never let focus leaving the content dismiss the modal. Starting a native + // window drag/resize from the titlebar makes the webview lose focus, which + // bits-ui treats as focus-outside and closes the dialog. The modal is only + // meant to close via ×, Escape, or a genuine outside pointer interaction + // (handled below) - not because the OS took focus for a window drag. + e.preventDefault(); + }} + onInteractOutside={(e) => { + // Nothing outside the content dismisses this dialog. It is inset to leave + // the titlebar and status bar usable, so "outside" is window chrome: + // dragging the window to move or resize it, or a stray click on the tab + // bar, would otherwise throw away a half-filled connection form. Closing + // is deliberate only - the × button, Escape, or a successful connect. + e.preventDefault(); + }} + > + Connections + {@render panelBody()} +{/if} { settings = updateSettings({ treeFocusOnSwitch: settings.treeFocusOnSwitch !== true }) }, )} {/if} + {#if show('Connection page in a tab', 'Labs, open new connections and edits as a tab, and start in the app instead of a separate connection page')} + {@render switchRow( + 'Connection page in a tab', + 'Adding or editing a connection opens a Connect tab beside your tables and queries. With nothing connected, the window shows your saved connections and the connect page in one view instead of a separate first page.', + settings.connectInTab === true, + () => { settings = updateSettings({ connectInTab: settings.connectInTab !== true }) }, + )} + {/if} {#if show('Boring connection bar', 'Labs, group saved connections into a folder per database kind')} {@render switchRow( 'Boring connection bar', diff --git a/src/lib/components/StudioShell.svelte b/src/lib/components/StudioShell.svelte index a0187d6b..543ac9fd 100644 --- a/src/lib/components/StudioShell.svelte +++ b/src/lib/components/StudioShell.svelte @@ -44,7 +44,7 @@ import { isTypingTarget } from '$lib/focus-search.js' import { slashFocusTarget } from '$lib/slash-focus.js' import QuitHint from './QuitHint.svelte' - import { appRelationColumns, appFkAutoExpandJson, cycleTheme, restorePreviousTheme, isCurrentThemeDark, loadSettings, appPaginationMode, appVimMode, appAutoSaveQueries, appStreamResults, appSqlUndo, appSqlEditor, appAiInTab, increaseZoom, decreaseZoom, resetZoom, updateSettings } from '$lib/stores/settings.js' + import { appRelationColumns, appFkAutoExpandJson, cycleTheme, restorePreviousTheme, isCurrentThemeDark, loadSettings, appPaginationMode, appVimMode, appAutoSaveQueries, appStreamResults, appSqlUndo, appSqlEditor, appAiInTab, appConnectInTab, increaseZoom, decreaseZoom, resetZoom, updateSettings } from '$lib/stores/settings.js' import { requireUnlock } from '$lib/stores/app-lock.js' import { isTextEntryTarget, setVimSubMode } from '$lib/vim/vim.js' import { normalizeColumn, columnType } from '$lib/column.js' @@ -227,6 +227,8 @@ createMigrationsTab, findMigrationsTab, createLicenseTab, + createConnectTab, + findConnectTab, createAiTab, findAiTab, findLicenseTab, @@ -685,6 +687,14 @@ let objectsFocusSearch = $state(/** @type {() => void} */ (() => {})) let dbSearchFocusInput = $state(/** @type {() => void} */ (() => {})) let showConnectionModal = $state(false) + // Labs, connection page in a tab (connectInTab). `showConnectionModal` stays + // the one way to ask for the page; with the option on, the request opens the + // Connect tab instead (or, with nothing connected, resets the page the window + // already shows), so the dialog never opens and none of its callers change. + // The inline page's own open flag: it clears it to close itself. + let connectInlineOpen = $state(true) + // Bumped to start the page over (a new Edit… or engine request) in place. + let connectResetKey = $state(0) /** Engine chosen on the welcome screen - the modal opens straight into its form. */ let connectionModalEngine = $state('') /** A saved connection the dialog opens into its form (sidebar Edit…). */ @@ -886,7 +896,7 @@ if (importDataOpen) dialogMounted.importData = true if ($shareRequest) dialogMounted.share = true if (showDockerModal) dialogMounted.docker = true - if (showConnectionModal) dialogMounted.connection = true + if (showConnectionModal && !$appConnectInTab) dialogMounted.connection = true if (showOnboarding) dialogMounted.onboarding = true if (showCreateDbDialog) dialogMounted.createDb = true if (generateSqlOpen) dialogMounted.generateSql = true @@ -3481,7 +3491,7 @@ let rowSearch = $state('') // `sqlLoading` true (only the owning tab's state is patched), and the next // snapshot of ANY sql tab would then capture that stale true as its own. if (tab.kind !== 'sql') sqlLoading = false - if (tab.kind === 'welcome' || tab.kind === 'ai' || tab.kind === 'schema' || tab.kind === 'orm' || tab.kind === 'ddl') { + if (tab.kind === 'welcome' || tab.kind === 'ai' || tab.kind === 'schema' || tab.kind === 'orm' || tab.kind === 'ddl' || tab.kind === 'connect') { clearTableEditor() return } @@ -5259,6 +5269,58 @@ let rowSearch = $state('') openSingletonTab({ find: findSchemaTab, create: createSchemaTab, capability: () => hasSchemaExplorer }) } + /** + * Labs, connection page in a tab: open the Connect tab (or bring it forward) + * and start its page over, picking up any engine or Edit… request. Free, like + * the dialog it stands in for, so no Pro gate. + */ + function openConnectTab() { + if (aiMode) exitAiMode() + connectInlineOpen = true + connectResetKey += 1 + const existing = findConnectTab(tabs) + if (existing) { void activateTab(existing.id); return } + saveActiveTabState() + dropWelcomeTabs() + const tab = createConnectTab() + tabs = [...tabs, tab] + activeTabId = tab.id + clearTableEditor() + } + + // A request for the connection page, with the Labs option on: never the + // dialog. Connected, it is the Connect tab; with nothing connected the window + // already shows the page, which starts over to take the request. + $effect(() => { + if (!showConnectionModal || !$appConnectInTab) return + untrack(() => { + showConnectionModal = false + if (connection) openConnectTab() + else { connectInlineOpen = true; connectResetKey += 1 } + }) + }) + + // The option turned off with a Connect tab open: the tab has nothing to draw. + $effect(() => { + if ($appConnectInTab) return + untrack(() => { + const tab = findConnectTab(tabs) + if (tab) void closeTab(tab.id) + }) + }) + + // The inline page closed itself (its hand-over after a connect, or a Cancel): + // its tab goes with it. With nothing connected the page is the window, so it + // simply stays. + $effect(() => { + if (connectInlineOpen) return + untrack(() => { + connectInlineOpen = true + const tab = connection ? findConnectTab(tabs) : null + if (tab) void closeTab(tab.id) + }) + }) + function openOrmTab() { openSingletonTab({ find: findOrmTab, create: createOrmTab }) } @@ -9665,7 +9727,8 @@ let rowSearch = $state('') label: sessionLabel(connection), // The tab on screen keeps its rows, so coming back to it is instant; // the others refetch when shown, so a kept database costs little. - tabs: tabs.map((t) => { + // The Connect tab belongs to the window, not to this database. + tabs: tabs.filter((t) => t.kind !== 'connect').map((t) => { if (!(t.kind === 'table' && t.state && t.id !== activeTabId)) return t _liveRowsByTab.delete(t.id) return { ...t, state: { ...t.state, rows: [], selected: new Set(), windowedHead: false, windowedLoaded: [], windowCount: 0, loadingRows: false, evicted: true } } @@ -10903,7 +10966,7 @@ let rowSearch = $state('') {#if dialogMounted.connection} {#await lazyDialogs.connection() then { default: ConnectionModal }} showConnectionModal && !$appConnectInTab, (v) => (showConnectionModal = v)} bind:initialEngine={connectionModalEngine} bind:initialEditId={connectionModalEditId} bind:initialUri={connectionModalUri} @@ -11478,6 +11541,18 @@ let rowSearch = $state('') {/await} {/if} + {#snippet connectStrip()} + +
+ +
+ {/snippet} + {#snippet tabError(/** @type {unknown} */ error, /** @type {() => void} */ reset)}
@@ -11497,7 +11572,28 @@ let rowSearch = $state('')
{/snippet} - {#if !connection} + {#if !connection && $appConnectInTab} + + {#await lazyDialogs.connection() then { default: ConnectionModal }} + onConnected(conn, id)} + maxConnections={$hasPro ? Infinity : FREE_CONNECTION_LIMIT} + activeConnectionName="" + ondisconnect={requestDisconnect} + onremoved={handleConnectionRemoved} + top={connectStrip} + /> + {/await} + {:else if !connection} + {:else if activeTab?.kind === 'connect'} + {:else if activeTab?.kind === 'schema'} {#await import('./SchemaPage.svelte')}{:then { default: SchemaPage }} @@ -11679,6 +11777,37 @@ let rowSearch = $state('') {/if} + + {#if $appConnectInTab && tabs.some((t) => t.kind === 'connect')} +
+ + {#await lazyDialogs.connection()}{:then { default: ConnectionModal }} + onConnected(conn, id)} + maxConnections={$hasPro ? Infinity : FREE_CONNECTION_LIMIT} + activeConnectionName={connection ? (connection.name || connection.database || connection.host || connection.filePath || 'Connected') : ''} + ondisconnect={requestDisconnect} + onremoved={handleConnectionRemoved} + /> + {/await} + +
+ {/if} + {#if aiTabEverOpened && $appAiInTab} diff --git a/src/lib/components/TabBar.svelte b/src/lib/components/TabBar.svelte index a2710d9c..76b1013a 100644 --- a/src/lib/components/TabBar.svelte +++ b/src/lib/components/TabBar.svelte @@ -164,6 +164,7 @@ if (tab.kind === 'map') return 'globe' if (tab.kind === 'search') return 'search' if (tab.kind === 'license') return 'key-round' + if (tab.kind === 'connect') return 'plug' if (tab.kind === 'shortcuts') return 'keyboard' if (tab.kind === 'shares') return 'share-2' if (tab.kind === 'queries') return 'history' diff --git a/src/lib/stores/settings.js b/src/lib/stores/settings.js index 18fa0f84..061ebc02 100644 --- a/src/lib/stores/settings.js +++ b/src/lib/stores/settings.js @@ -134,7 +134,7 @@ function pushProxySettings(proxy) { .catch((e) => { _proxySent = ''; console.warn('proxy settings not applied:', e) }) } -/** @typedef {{ theme: ThemeId, zoom: number, font: FontId, iconStyle: IconStyleId, iconSet: IconSetId, tableStyle: TableStyleId, jsonTheme: JsonThemeId, editorTheme: import('$lib/themes/editor-themes.js').EditorThemeId, mcpAutoStart: boolean, launchAtLogin: boolean, autoUpdate: boolean, autoReconnectOnStartup: boolean, previewDmlBeforeApply: boolean, defaultDataView: string, paginationMode: string, maxQueryHistory: number, connectTimeoutMs: number, socketTimeoutMs: number, maxAllowedPacket: number, sessionTimezone: string, displayTimezone: string, vimMode: boolean, cmdkAiEnabled: boolean, liveModeEnabled: boolean, sidebarStyle: SidebarStyleId, aiInTab: boolean, lazyWideColumns: boolean, nullSortOrder: string, agentChatFontSize: number, agentCodeFontSize: number, agentThinkingStyle: string, agentShowQueryCards: boolean, agentWebAccess: boolean, tableTextAlign: string, telemetry: boolean, jsonWordWrap: boolean, nativeScroll: boolean, rowSpacing: RowSpacingId, motion: MotionId, animatePanels: boolean, quitGuard: boolean, reopenTabs: boolean, multiConnection: boolean, studioShare: boolean, treeFocusOnSwitch: boolean, boringConnectionBar: boolean, zebraRows: boolean, showRowNumbers: boolean, showRelationColumns: boolean, showMenuBar: boolean, numberGrouping: boolean, imagePreview: boolean, openUrlsOnClick: boolean, highlightActiveRow: boolean, fkAutoExpandJson: boolean, gridFontSize: number, autoSaveQueries: boolean, streamResults: boolean, sqlUndo: boolean, sidebarComments: boolean, sidebarRememberGroups: boolean, sqlFormat: import('$lib/sql-format-options.js').SqlFormatOptions, sqlEditor: import('$lib/sql-editor-options.js').SqlEditorOptions, shareDefaults: Record | null, proxy: ProxySettings, fonts: import('$lib/fonts.js').FontSettings }} AppSettings */ +/** @typedef {{ theme: ThemeId, zoom: number, font: FontId, iconStyle: IconStyleId, iconSet: IconSetId, tableStyle: TableStyleId, jsonTheme: JsonThemeId, editorTheme: import('$lib/themes/editor-themes.js').EditorThemeId, mcpAutoStart: boolean, launchAtLogin: boolean, autoUpdate: boolean, autoReconnectOnStartup: boolean, previewDmlBeforeApply: boolean, defaultDataView: string, paginationMode: string, maxQueryHistory: number, connectTimeoutMs: number, socketTimeoutMs: number, maxAllowedPacket: number, sessionTimezone: string, displayTimezone: string, vimMode: boolean, cmdkAiEnabled: boolean, liveModeEnabled: boolean, sidebarStyle: SidebarStyleId, aiInTab: boolean, connectInTab: boolean, lazyWideColumns: boolean, nullSortOrder: string, agentChatFontSize: number, agentCodeFontSize: number, agentThinkingStyle: string, agentShowQueryCards: boolean, agentWebAccess: boolean, tableTextAlign: string, telemetry: boolean, jsonWordWrap: boolean, nativeScroll: boolean, rowSpacing: RowSpacingId, motion: MotionId, animatePanels: boolean, quitGuard: boolean, reopenTabs: boolean, multiConnection: boolean, studioShare: boolean, treeFocusOnSwitch: boolean, boringConnectionBar: boolean, zebraRows: boolean, showRowNumbers: boolean, showRelationColumns: boolean, showMenuBar: boolean, numberGrouping: boolean, imagePreview: boolean, openUrlsOnClick: boolean, highlightActiveRow: boolean, fkAutoExpandJson: boolean, gridFontSize: number, autoSaveQueries: boolean, streamResults: boolean, sqlUndo: boolean, sidebarComments: boolean, sidebarRememberGroups: boolean, sqlFormat: import('$lib/sql-format-options.js').SqlFormatOptions, sqlEditor: import('$lib/sql-editor-options.js').SqlEditorOptions, shareDefaults: Record | null, proxy: ProxySettings, fonts: import('$lib/fonts.js').FontSettings }} AppSettings */ /** * UI type scale in design pixels: `[step, font-size, line-height?]`, matching @@ -618,6 +618,8 @@ export const DEFAULT_SETTINGS = { // Labs: a database switch folds the tree to the new database's tables. treeFocusOnSwitch: false, boringConnectionBar: false, + // Labs: the connection page opens as a tab, and replaces the first-run page. + connectInTab: false, // SQL formatter preferences. Defaults live with the formatter (format-sql.js) // so there is one source for what a valid option set is. sqlFormat: { ...SQL_FORMAT_DEFAULTS }, @@ -795,6 +797,8 @@ export const appSidebarStyle = writable(/** @type {SidebarStyleId} */ ('classic' export const appAiInTab = writable(false) /** Labs: saved connections in one folder per database kind. */ export const appBoringConnectionBar = writable(false) +/** Labs: the connection page as a tab (connectInTab). */ +export const appConnectInTab = writable(false) /** Whether the agent transcript shows a card per executed query. */ export const appAgentQueryCards = writable(false) @@ -1031,6 +1035,7 @@ export function loadSettings() { const studioShare = parsed.studioShare === true const treeFocusOnSwitch = parsed.treeFocusOnSwitch === true const boringConnectionBar = parsed.boringConnectionBar === true + const connectInTab = parsed.connectInTab === true const sqlFormat = normalizeSqlFormat(parsed.sqlFormat) const sqlEditor = normalizeSqlEditor(parsed.sqlEditor) const proxy = normalizeProxy(parsed.proxy) @@ -1077,7 +1082,7 @@ export function loadSettings() { const agentShowQueryCards = parsed.agentShowQueryCards === true const agentWebAccess = parsed.agentWebAccess === true const tableTextAlign = TABLE_ALIGN_IDS.includes(parsed.tableTextAlign) ? parsed.tableTextAlign : DEFAULT_TABLE_ALIGN - _settingsCache = { theme, zoom, font, iconStyle, iconSet, tableStyle, jsonTheme, editorTheme, mcpAutoStart, launchAtLogin, autoUpdate, autoReconnectOnStartup, previewDmlBeforeApply, defaultDataView, paginationMode, maxQueryHistory, connectTimeoutMs, socketTimeoutMs, maxAllowedPacket, sessionTimezone, displayTimezone, vimMode, cmdkAiEnabled, liveModeEnabled, sidebarStyle, aiInTab, lazyWideColumns, nullSortOrder, agentChatFontSize, agentCodeFontSize, agentThinkingStyle, agentShowQueryCards, agentWebAccess, tableTextAlign, telemetry, jsonWordWrap, nativeScroll, rowSpacing, motion, animatePanels, quitGuard, reopenTabs, multiConnection, studioShare, treeFocusOnSwitch, boringConnectionBar, zebraRows, showRowNumbers, showRelationColumns, showMenuBar, numberGrouping, imagePreview, openUrlsOnClick, highlightActiveRow, fkAutoExpandJson, gridFontSize, autoSaveQueries, streamResults, sqlUndo, sidebarComments, sidebarRememberGroups, sqlFormat, sqlEditor, shareDefaults, proxy, fonts } + _settingsCache = { theme, zoom, font, iconStyle, iconSet, tableStyle, jsonTheme, editorTheme, mcpAutoStart, launchAtLogin, autoUpdate, autoReconnectOnStartup, previewDmlBeforeApply, defaultDataView, paginationMode, maxQueryHistory, connectTimeoutMs, socketTimeoutMs, maxAllowedPacket, sessionTimezone, displayTimezone, vimMode, cmdkAiEnabled, liveModeEnabled, sidebarStyle, aiInTab, connectInTab, lazyWideColumns, nullSortOrder, agentChatFontSize, agentCodeFontSize, agentThinkingStyle, agentShowQueryCards, agentWebAccess, tableTextAlign, telemetry, jsonWordWrap, nativeScroll, rowSpacing, motion, animatePanels, quitGuard, reopenTabs, multiConnection, studioShare, treeFocusOnSwitch, boringConnectionBar, zebraRows, showRowNumbers, showRelationColumns, showMenuBar, numberGrouping, imagePreview, openUrlsOnClick, highlightActiveRow, fkAutoExpandJson, gridFontSize, autoSaveQueries, streamResults, sqlUndo, sidebarComments, sidebarRememberGroups, sqlFormat, sqlEditor, shareDefaults, proxy, fonts } // A migrated value is saved at once, or the next launch reads the old one. if (settingsMigrated) { try { localStorage.setItem(STORAGE_KEY, JSON.stringify(_settingsCache)) } catch {} @@ -1427,6 +1432,7 @@ function applySettingsNow(settings, root, theme, zoom, dark) { setStore(appSidebarStyle, settings.sidebarStyle === 'tree' ? 'tree' : 'classic') setStore(appAiInTab, settings.aiInTab === true) setStore(appBoringConnectionBar, settings.boringConnectionBar === true) + setStore(appConnectInTab, settings.connectInTab === true) setStore(appAgentQueryCards, settings.agentShowQueryCards === true) setStore(appAgentWebAccess, settings.agentWebAccess === true) setStore(appTableAlign, TABLE_ALIGN_IDS.includes(settings.tableTextAlign) ? settings.tableTextAlign : DEFAULT_TABLE_ALIGN) diff --git a/src/lib/studio-tabs.js b/src/lib/studio-tabs.js index 5b9b1d2f..ea6275eb 100644 --- a/src/lib/studio-tabs.js +++ b/src/lib/studio-tabs.js @@ -1,4 +1,4 @@ -/** @typedef {'table' | 'sql' | 'ddl' | 'welcome' | 'ai' | 'schema' | 'orm' | 'security' | 'logs' | 'extensions' | 'extension-detail' | 'backup' | 'json' | 'charts' | 'dashboard' | 'erd' | 'reltree' | 'diagrams' | 'search' | 'notebook' | 'schema-timeline' | 'data-diff' | 'migrations' | 'insights' | 'objects' | 'redis' | 'dynamodb' | 'docs' | 'license' | 'orm-schema' | 'map' | 'advisor' | 'golf' | 'terminal' | 'shortcuts' | 'shares' | 'queries'} StudioTabKind */ +/** @typedef {'table' | 'sql' | 'ddl' | 'welcome' | 'ai' | 'schema' | 'orm' | 'security' | 'logs' | 'extensions' | 'extension-detail' | 'backup' | 'json' | 'charts' | 'dashboard' | 'erd' | 'reltree' | 'diagrams' | 'search' | 'notebook' | 'schema-timeline' | 'data-diff' | 'migrations' | 'insights' | 'objects' | 'redis' | 'dynamodb' | 'docs' | 'license' | 'orm-schema' | 'map' | 'advisor' | 'golf' | 'terminal' | 'shortcuts' | 'shares' | 'queries' | 'connect'} StudioTabKind */ import { loadDefaultPageSize } from '$lib/table-query.js' @@ -245,6 +245,8 @@ const SINGLETON_TAB_TITLES = { shortcuts: 'Keyboard shortcuts', shares: 'Shared links', queries: 'Queries', + // Labs, connection page in a tab. + connect: 'Connect', } /** @param {StudioTabKind} kind */ @@ -286,6 +288,7 @@ export const createRelTreeTab = () => createKindTab('reltree') export const createDiagramsTab = () => createKindTab('diagrams') export const createErdTab = () => createKindTab('erd') export const createLicenseTab = () => createKindTab('license') +export const createConnectTab = () => createKindTab('connect') export const createSearchTab = () => createKindTab('search') export const createSchemaTimelineTab = () => createKindTab('schema-timeline') export const createDataDiffTab = () => createKindTab('data-diff') @@ -345,6 +348,8 @@ export const findDiagramsTab = (tabs) => findTabByKind(tabs, 'diagrams') export const findErdTab = (tabs) => findTabByKind(tabs, 'erd') /** @type {(tabs: StudioTab[]) => StudioTab | null} */ export const findLicenseTab = (tabs) => findTabByKind(tabs, 'license') +/** @param {StudioTab[]} tabs */ +export const findConnectTab = (tabs) => findTabByKind(tabs, 'connect') /** @type {(tabs: StudioTab[]) => StudioTab | null} */ export const findShortcutsTab = (tabs) => findTabByKind(tabs, 'shortcuts') /** @type {(tabs: StudioTab[]) => StudioTab | null} */ diff --git a/src/lib/studio-tabs.test.js b/src/lib/studio-tabs.test.js index 80284564..98089dda 100644 --- a/src/lib/studio-tabs.test.js +++ b/src/lib/studio-tabs.test.js @@ -8,6 +8,8 @@ import { cloneTableTabState, cloneSqlTabState, createAiTab, + createConnectTab, + findConnectTab, createSchemaTab, findAiTab, findSchemaTab, @@ -94,6 +96,12 @@ describe('find helpers', () => { expect(findSchemaTab(tabs)?.kind).toBe('schema') expect(findAiTab([createSqlTab('SELECT 1;')])).toBeNull() }) + it('find the Labs Connect tab, titled for what it does', () => { + const connect = createConnectTab() + expect(connect.title).toBe('Connect') + expect(findConnectTab([createSqlTab('SELECT 1;'), connect])?.id).toBe(connect.id) + expect(findConnectTab([createAiTab()])).toBeNull() + }) }) describe('cloneSqlTabState', () => {