The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore(studio): standardise keyboard shortcut UI (#44262)
Danny White8939c97574b5
diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsxindex cf4f32de518..61ccda9e6b0 100644--- a/apps/design-system/__registry__/index.tsx+++ b/apps/design-system/__registry__/index.tsx@@ -1050,6 +1050,39 @@ export const Index: Record<string, any> = {subcategory: "undefined",chunks: []},+ "keyboard-shortcut-demo": {+ name: "keyboard-shortcut-demo",+ type: "components:example",+ registryDependencies: ["button"],+ component: React.lazy(() => import("@/registry/default/example/keyboard-shortcut-demo")),+ source: "",+ files: ["registry/default/example/keyboard-shortcut-demo.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "keyboard-shortcut-pill": {+ name: "keyboard-shortcut-pill",+ type: "components:example",+ registryDependencies: undefined,+ component: React.lazy(() => import("@/registry/default/example/keyboard-shortcut-pill")),+ source: "",+ files: ["registry/default/example/keyboard-shortcut-pill.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },+ "keyboard-shortcut-inline": {+ name: "keyboard-shortcut-inline",+ type: "components:example",+ registryDependencies: ["button"],+ component: React.lazy(() => import("@/registry/default/example/keyboard-shortcut-inline")),+ source: "",+ files: ["registry/default/example/keyboard-shortcut-inline.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },"label-demo": {name: "label-demo",type: "components:example",diff --git a/apps/design-system/config/docs.ts b/apps/design-system/config/docs.tsindex afbaae811b8..ced6685f7aa 100644--- a/apps/design-system/config/docs.ts+++ b/apps/design-system/config/docs.ts@@ -512,6 +512,11 @@ export const docsConfig: DocsConfig = {href: '/docs/components/expanding-textarea',items: [],},+ {+ title: 'Keyboard Shortcut',+ href: '/docs/components/keyboard-shortcut',+ items: [],+ },],},],diff --git a/apps/design-system/content/docs/components/keyboard-shortcut.mdx b/apps/design-system/content/docs/components/keyboard-shortcut.mdxnew file mode 100644index 00000000000..a9e93242ae3--- /dev/null+++ b/apps/design-system/content/docs/components/keyboard-shortcut.mdx@@ -0,0 +1,70 @@+---+title: Keyboard Shortcut+description: Displays a platform-aware keyboard shortcut label for buttons, menus, tooltips, and helper text.+component: true+---++<ComponentPreview name="keyboard-shortcut-demo" align="start" peekCode wide />++`KeyboardShortcut` renders a compact, platform-aware shortcut label from logical key names.++Use it for button accessories, menu shortcuts, tooltips, and helper copy. Avoid placing it directly inside button label text; render it in a right-side accessory slot such as `iconRight` instead.++## Usage++```tsx+import { KeyboardShortcut } from 'ui'+```++```tsx+<KeyboardShortcut keys={['Meta', 'S']} />+```++## Props++### `keys`++An ordered array of logical key names.++```tsx+<KeyboardShortcut keys={['Meta', 'Enter']} />+```++Supported special keys currently include:++- `Meta`+- `Alt`+- `Shift`+- `Enter`+- `Esc` / `Escape`+- `Tab`++Single-character keys are uppercased automatically.++## Variants++### Pill (default)++Use the default pill variant for menus, tooltips, and standalone shortcut chips.++```tsx+<KeyboardShortcut keys={['Shift', 'Meta', 'M']} />+```++### Inline++Use the inline variant when the shortcut needs to sit on the same line as surrounding text or inside a button accessory slot.++```tsx+<Button iconRight={<KeyboardShortcut keys={['Meta', 'Enter']} variant="inline" />}>Apply</Button>+```++## Examples++### Pill++<ComponentPreview name="keyboard-shortcut-pill" align="start" />++### Inline++<ComponentPreview name="keyboard-shortcut-inline" align="start" />diff --git a/apps/design-system/registry/default/example/keyboard-shortcut-demo.tsx b/apps/design-system/registry/default/example/keyboard-shortcut-demo.tsxnew file mode 100644index 00000000000..5d1dc8919ef--- /dev/null+++ b/apps/design-system/registry/default/example/keyboard-shortcut-demo.tsx@@ -0,0 +1,39 @@+import { Button, KeyboardShortcut } from 'ui'++const shortcuts = [+ { label: 'Open command menu', keys: ['Meta', 'K'] },+ { label: 'Prettify SQL', keys: ['Alt', 'Shift', 'F'] },+ { label: 'Download CSV', keys: ['Shift', 'Meta', 'D'] },+]++export default function KeyboardShortcutDemo() {+ return (+ <div className="flex w-full max-w-2xl flex-col gap-6">+ <div className="flex flex-wrap gap-3">+ <Button iconRight={<KeyboardShortcut keys={['Meta', 'S']} variant="inline" />}>Save</Button>+ <Button+ type="default"+ iconRight={<KeyboardShortcut keys={['Meta', 'Enter']} variant="inline" />}+ >+ Run query+ </Button>+ </div>++ <div className="w-full max-w-md rounded-lg border bg-background p-1.5">+ {shortcuts.map((shortcut) => (+ <div+ key={shortcut.label}+ className="flex items-center justify-between rounded-md px-3 py-2 text-sm"+ >+ <span>{shortcut.label}</span>+ <KeyboardShortcut keys={shortcut.keys} />+ </div>+ ))}+ </div>++ <p className="flex items-center gap-1.5 text-xs text-foreground-muted">+ Hit <KeyboardShortcut keys={['Meta', 'K']} variant="inline" /> to open search+ </p>+ </div>+ )+}diff --git a/apps/design-system/registry/default/example/keyboard-shortcut-inline.tsx b/apps/design-system/registry/default/example/keyboard-shortcut-inline.tsxnew file mode 100644index 00000000000..61944f8b3cb--- /dev/null+++ b/apps/design-system/registry/default/example/keyboard-shortcut-inline.tsx@@ -0,0 +1,21 @@+import { Button, KeyboardShortcut } from 'ui'++export default function KeyboardShortcutInline() {+ return (+ <div className="flex w-full max-w-xl flex-col gap-4">+ <div className="flex flex-wrap gap-3">+ <Button iconRight={<KeyboardShortcut keys={['Meta', 'S']} variant="inline" />}>Save</Button>+ <Button+ type="default"+ iconRight={<KeyboardShortcut keys={['Meta', 'Enter']} variant="inline" />}+ >+ Apply+ </Button>+ </div>++ <p className="flex items-center gap-1.5 text-xs text-foreground-muted">+ Hit <KeyboardShortcut keys={['Meta', 'K']} variant="inline" /> to edit with the Assistant+ </p>+ </div>+ )+}diff --git a/apps/design-system/registry/default/example/keyboard-shortcut-pill.tsx b/apps/design-system/registry/default/example/keyboard-shortcut-pill.tsxnew file mode 100644index 00000000000..093b16ac355--- /dev/null+++ b/apps/design-system/registry/default/example/keyboard-shortcut-pill.tsx@@ -0,0 +1,23 @@+import { KeyboardShortcut } from 'ui'++const shortcuts = [+ { label: 'Open command menu', keys: ['Meta', 'K'] },+ { label: 'Prettify SQL', keys: ['Alt', 'Shift', 'F'] },+ { label: 'Download Markdown', keys: ['Shift', 'Meta', 'M'] },+]++export default function KeyboardShortcutPill() {+ return (+ <div className="w-full max-w-md rounded-lg border bg-background p-1.5">+ {shortcuts.map((shortcut) => (+ <div+ key={shortcut.label}+ className="flex items-center justify-between rounded-md px-3 py-2 text-sm"+ >+ <span>{shortcut.label}</span>+ <KeyboardShortcut keys={shortcut.keys} />+ </div>+ ))}+ </div>+ )+}diff --git a/apps/design-system/registry/examples.ts b/apps/design-system/registry/examples.tsindex 40644cb25be..e18429c0951 100644--- a/apps/design-system/registry/examples.ts+++ b/apps/design-system/registry/examples.ts@@ -617,6 +617,23 @@ export const examples: Registry = [registryDependencies: ['input-otp', 'form'],files: ['example/input-otp-form.tsx'],},+ {+ name: 'keyboard-shortcut-demo',+ type: 'components:example',+ registryDependencies: ['button'],+ files: ['example/keyboard-shortcut-demo.tsx'],+ },+ {+ name: 'keyboard-shortcut-pill',+ type: 'components:example',+ files: ['example/keyboard-shortcut-pill.tsx'],+ },+ {+ name: 'keyboard-shortcut-inline',+ type: 'components:example',+ registryDependencies: ['button'],+ files: ['example/keyboard-shortcut-inline.tsx'],+ },{name: 'label-demo',type: 'components:example',diff --git a/apps/studio/components/grid/components/footer/operations/SaveQueueActionBar.tsx b/apps/studio/components/grid/components/footer/operations/SaveQueueActionBar.tsxindex 3c67b9089ef..5320b2c5e38 100644--- a/apps/studio/components/grid/components/footer/operations/SaveQueueActionBar.tsx+++ b/apps/studio/components/grid/components/footer/operations/SaveQueueActionBar.tsx@@ -16,11 +16,9 @@ import { useOperationQueueShortcuts } from '@/components/grid/hooks/useOperationimport { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'import { DiscardChangesConfirmationDialog } from '@/components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'import { useConfirmOnClose } from '@/hooks/ui/useConfirmOnClose'-import { getModKeyLabel } from '@/lib/helpers'import { useTableEditorStateSnapshot } from '@/state/table-editor'export const SaveQueueActionBar = () => {- const modKey = getModKeyLabel()const snap = useTableEditorStateSnapshot()const isQueueOperationsEnabled = useIsQueueOperationsEnabled()const { handleSave, handleCancel } = useOperationQueueActions()@@ -66,9 +64,13 @@ export const SaveQueueActionBar = () => {onClick={handleSave}disabled={isSaving}loading={isSaving}+ iconRight={+ isSaving ? undefined : (+ <KeyboardShortcut keys={['Meta', 's']} variant="inline" />+ )+ }>Save- <span className="text-[10px] text-foreground/40 ml-1.5">{`${modKey}S`}</span></Button><DropdownMenu><DropdownMenuTrigger asChild>diff --git a/apps/studio/components/interfaces/Account/Preferences/HotkeySettings.tsx b/apps/studio/components/interfaces/Account/Preferences/HotkeySettings.tsxindex d7326f2c47e..6f80db6e721 100644--- a/apps/studio/components/interfaces/Account/Preferences/HotkeySettings.tsx+++ b/apps/studio/components/interfaces/Account/Preferences/HotkeySettings.tsx@@ -87,14 +87,14 @@ export const HotkeySettings = () => {form={form}name="aiAssistantEnabled"keys={['Meta', 'i']}- label="AI Assistant Panel"+ label="AI Assistant panel"onToggle={setAiAssistantEnabled}/><HotkeyToggleform={form}name="inlineEditorEnabled"keys={['Meta', 'e']}- label="Inline SQL Editor Panel"+ label="Inline SQL Editor panel"onToggle={setInlineEditorEnabled}/><HotkeyTogglediff --git a/apps/studio/components/interfaces/Account/Preferences/HotkeyToggle.tsx b/apps/studio/components/interfaces/Account/Preferences/HotkeyToggle.tsxindex 5577ed76731..a5a7766c748 100644--- a/apps/studio/components/interfaces/Account/Preferences/HotkeyToggle.tsx+++ b/apps/studio/components/interfaces/Account/Preferences/HotkeyToggle.tsx@@ -25,24 +25,19 @@ export function HotkeyToggle<T extends FieldValues>({control={form.control}name={name}render={({ field }) => (- <FormItemLayout- layout="flex-row-reverse"- label={- <div className="flex items-center gap-x-3">- <KeyboardShortcut keys={keys} />- <span>{label}</span>- </div>- }- >- <FormControl_Shadcn_>- <Switch- checked={field.value}- onCheckedChange={(value) => {- field.onChange(value)- onToggle(value)- }}- />- </FormControl_Shadcn_>+ <FormItemLayout layout="flex-row-reverse" label={label}>+ <div className="flex w-full items-center justify-end gap-x-3">+ <KeyboardShortcut keys={keys} />+ <FormControl_Shadcn_>+ <Switch+ checked={field.value}+ onCheckedChange={(value) => {+ field.onChange(value)+ onToggle(value)+ }}+ />+ </FormControl_Shadcn_>+ </div></FormItemLayout>)}/>diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/RunButton.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/RunButton.tsxindex 954a2769a8b..d85406083a5 100644--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/RunButton.tsx+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/RunButton.tsx@@ -1,7 +1,5 @@-import { Command, CornerDownLeft, Loader2 } from 'lucide-react'-import { Button } from 'ui'--import { detectOS } from '@/lib/helpers'+import { Loader2 } from 'lucide-react'+import { Button, KeyboardShortcut } from 'ui'interface SqlRunButtonProps {isDisabled?: boolean@@ -18,15 +16,9 @@ export const SqlRunButton = ({className,onClick,}: SqlRunButtonProps) => {- const os = detectOS()-- function handleOnClick() {- onClick()- }-return (<Button- onClick={handleOnClick}+ onClick={onClick}disabled={isDisabled}type="primary"size="tiny"@@ -35,14 +27,7 @@ export const SqlRunButton = ({isExecuting ? (<Loader2 className="animate-spin" size={10} strokeWidth={1.5} />) : (- <div className="flex items-center space-x-1">- {os === 'macos' ? (- <Command size={10} strokeWidth={1.5} />- ) : (- <p className="text-xs text-foreground-light">CTRL</p>- )}- <CornerDownLeft size={10} strokeWidth={1.5} />- </div>+ <KeyboardShortcut keys={['Meta', 'Enter']} variant="inline" />)}className={className}diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsxindex 3b3ae4830ae..4545f7e033b 100644--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx@@ -9,6 +9,7 @@ import {DropdownMenuItem,DropdownMenuSeparator,DropdownMenuTrigger,+ KeyboardShortcut,Tooltip,TooltipContent,TooltipTrigger,@@ -113,9 +114,12 @@ const UtilityActions = ({</DropdownMenuItem></>)}- <DropdownMenuItem className="gap-x-2" onClick={prettifyQuery}>- <AlignLeft size={14} strokeWidth={2} className="text-foreground-light" />- Prettify SQL+ <DropdownMenuItem className="justify-between" onClick={prettifyQuery}>+ <span className="flex items-center gap-x-2">+ <AlignLeft size={14} strokeWidth={2} className="text-foreground-light" />+ Prettify SQL+ </span>+ <KeyboardShortcut keys={['Alt', 'Shift', 'f']} /></DropdownMenuItem></DropdownMenuContent></DropdownMenu>@@ -173,7 +177,12 @@ const UtilityActions = ({icon={<AlignLeft strokeWidth={2} className="text-foreground-light" />}/></TooltipTrigger>- <TooltipContent side="bottom">Prettify SQL</TooltipContent>+ <TooltipContent side="bottom" className="p-1 pl-2.5">+ <div className="flex items-center gap-2.5">+ <span>Prettify SQL</span>+ <KeyboardShortcut keys={['Alt', 'Shift', 'f']} />+ </div>+ </TooltipContent></Tooltip></div>@@ -194,7 +203,7 @@ const UtilityActions = ({hasSelection={hasSelection}isDisabled={isDisabled || isExecuting}isExecuting={isExecuting}- className="rounded-l-none min-w-[82px]"+ className="rounded-l-none"onClick={executeQuery}/></div>diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsxindex 3eb397dfc35..b50ed0d54c0 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx@@ -1,9 +1,8 @@import { noop } from 'lodash'-import { PropsWithChildren, useCallback, useMemo, useState } from 'react'-import { Button } from 'ui'+import { PropsWithChildren, useCallback, useState } from 'react'+import { Button, KeyboardShortcut } from 'ui'import { useHotKey } from '@/hooks/ui/useHotKey'-import { getModKeyLabel } from '@/lib/helpers'interface ActionBarProps {loading?: boolean@@ -30,7 +29,6 @@ export const ActionBar = ({visible = true,}: PropsWithChildren<ActionBarProps>) => {const [isRunning, setIsRunning] = useState(false)- const modKeyLabel = useMemo(() => getModKeyLabel(), [])const onSelectApply = useCallback(async () => {const applyCallback = () => new Promise((resolve) => applyFunction?.(resolve))@@ -90,9 +88,13 @@ export const ActionBar = ({onClick={onSelectApply}disabled={disableApply || isRunning || loading}loading={isRunning || loading}+ iconRight={+ isRunning || loading ? undefined : (+ <KeyboardShortcut keys={['Meta', 'Enter']} variant="inline" />+ )+ }>- <span>{applyButtonLabel}</span>- <span className="ml-2 text-xs text-foreground-lighter">{modKeyLabel}↵</span>+ {applyButtonLabel}</Button>) : !hideApply ? (// New solution, when using the Form component, loading is handled by the Form itself@@ -103,9 +105,11 @@ export const ActionBar = ({data-testid="action-bar-save-row"htmlType="submit"form={formId}+ iconRight={+ loading ? undefined : <KeyboardShortcut keys={['Meta', 'Enter']} variant="inline" />+ }>- <span>{applyButtonLabel}</span>- <span className="ml-2 text-xs text-foreground-lighter">{modKeyLabel}↵</span>+ {applyButtonLabel}</Button>) : (<div />diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationQueueSidePanel.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationQueueSidePanel.tsxindex fca06781eab..083b8cb8d19 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationQueueSidePanel.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationQueueSidePanel.tsx@@ -1,5 +1,6 @@import {Button,+ KeyboardShortcut,Sheet,SheetContent,SheetDescription,@@ -13,12 +14,10 @@ import { OperationList } from './OperationList'import { useOperationQueueActions } from '@/components/grid/hooks/useOperationQueueActions'import { DiscardChangesConfirmationDialog } from '@/components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'import { useConfirmOnClose } from '@/hooks/ui/useConfirmOnClose'-import { getModKeyLabel } from '@/lib/helpers'import { useTableEditorStateSnapshot } from '@/state/table-editor'import { QueuedOperation } from '@/state/table-editor-operation-queue.types'export const OperationQueueSidePanel = () => {- const modKey = getModKeyLabel()const snap = useTableEditorStateSnapshot()const visible = snap.sidePanel?.type === 'operation-queue'@@ -53,9 +52,12 @@ export const OperationQueueSidePanel = () => {</SheetSection><SheetFooter className="!justify-between">- <Button type="default" onClick={snap.closeSidePanel}>+ <Button+ type="default"+ onClick={snap.closeSidePanel}+ iconRight={<KeyboardShortcut keys={['Meta', '.']} variant="inline" />}+ >Close- <span className="text-foreground/40 text-[10px] ml-1.5">{modKey}.</span></Button><div className="flex space-x-3"><Button@@ -69,9 +71,11 @@ export const OperationQueueSidePanel = () => {onClick={handleSave}disabled={isSaving || operations.length === 0}loading={isSaving}+ iconRight={+ isSaving ? undefined : <KeyboardShortcut keys={['Meta', 's']} variant="inline" />+ }>Save- <span className="text-foreground/40 text-[10px] ml-1.5">{modKey}S</span></Button></div></SheetFooter>diff --git a/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsxindex fa775bd1aa0..e23dd2f843c 100644--- a/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx+++ b/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx@@ -237,10 +237,11 @@ export const LayoutHeader = ({placeholder="Search..."className={cn('hidden md:flex md:min-w-32 xl:min-w-32 rounded-full bg-transparent',- '[&_.command-shortcut>div]:border-none',- '[&_.command-shortcut>div]:pr-2',- '[&_.command-shortcut>div]:bg-transparent',- '[&_.command-shortcut>div]:text-foreground-lighter'+ '[&_.command-shortcut]:border-none',+ '[&_.command-shortcut]:pr-2',+ '[&_.command-shortcut]:bg-transparent',+ '[&_.command-shortcut]:text-foreground-lighter',+ '[&_.command-shortcut]:shadow-none')}/><HelpButton />@@ -264,10 +265,11 @@ export const LayoutHeader = ({<CommandMenuTriggerInputplaceholder="Search..."className="hidden md:flex md:min-w-32 xl:min-w-32 rounded-full bg-transparent- [&_.command-shortcut>div]:border-none- [&_.command-shortcut>div]:pr-2- [&_.command-shortcut>div]:bg-transparent- [&_.command-shortcut>div]:text-foreground-lighter+ [&_.command-shortcut]:border-none+ [&_.command-shortcut]:pr-2+ [&_.command-shortcut]:bg-transparent+ [&_.command-shortcut]:text-foreground-lighter+ [&_.command-shortcut]:shadow-none"/><HelpButton />diff --git a/apps/studio/components/ui/AIEditor/index.tsx b/apps/studio/components/ui/AIEditor/index.tsxindex 8c7fcfad7b9..eefbec8c2bb 100644--- a/apps/studio/components/ui/AIEditor/index.tsx+++ b/apps/studio/components/ui/AIEditor/index.tsx@@ -1,15 +1,14 @@import Editor, { Monaco, OnMount } from '@monaco-editor/react'import { AnimatePresence, motion } from 'framer-motion'-import { Command } from 'lucide-react'import type { editor as monacoEditor } from 'monaco-editor'import { useCallback, useEffect, useRef, useState } from 'react'import { toast } from 'sonner'+import { KeyboardShortcut } from 'ui'import { DiffEditor } from '../DiffEditor'import ResizableAIWidget from './ResizableAIWidget'import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'import { constructHeaders } from '@/data/fetchers'-import { detectOS } from '@/lib/helpers'import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'interface AIEditorProps {@@ -58,7 +57,6 @@ export const AIEditor = ({executeQuery,onMount,}: AIEditorProps) => {- const os = detectOS()const { toggleSidebar } = useSidebarManagerSnapshot()const editorRef = useRef<monacoEditor.IStandaloneCodeEditor | null>(null)const diffEditorRef = useRef<monacoEditor.IStandaloneDiffEditor | null>(null)@@ -360,11 +358,7 @@ export const AIEditor = ({const handleKeyboard = (event: KeyboardEvent) => {if (event.key === 'Escape') {handleReset()- } else if (- event.key === 'Enter' &&- (os === 'macos' ? event.metaKey : event.ctrlKey) &&- isDiffMode- ) {+ } else if (event.key === 'Enter' && (event.metaKey || event.ctrlKey) && isDiffMode) {event.preventDefault()handleAcceptDiff()}@@ -372,7 +366,7 @@ export const AIEditor = ({window.addEventListener('keydown', handleKeyboard)return () => window.removeEventListener('keydown', handleKeyboard)- }, [os, isDiffMode, handleAcceptDiff, handleReset])+ }, [isDiffMode, handleAcceptDiff, handleReset])return (<div className="flex-1 overflow-hidden flex flex-col h-full relative">@@ -454,7 +448,13 @@ export const AIEditor = ({exit={{ y: 5, opacity: 0 }}className="text-foreground-lighter absolute bottom-4 left-4 z-10 font-mono text-xs flex items-center gap-1">- Hit {os === 'macos' ? <Command size={12} /> : `CTRL+`}K to edit with the Assistant+ Hit{' '}+ <KeyboardShortcut+ keys={['Meta', 'k']}+ variant="inline"+ className="text-xs text-foreground-lighter"+ />{' '}+ to edit with the Assistant</motion.p>)}</AnimatePresence>diff --git a/apps/studio/components/ui/DownloadResultsButton.tsx b/apps/studio/components/ui/DownloadResultsButton.tsxindex 751c03d73d7..6d8eb22be4e 100644--- a/apps/studio/components/ui/DownloadResultsButton.tsx+++ b/apps/studio/components/ui/DownloadResultsButton.tsx@@ -143,7 +143,7 @@ export const DownloadResultsButton = ({)}<DropdownMenuItem onClick={copyAsMarkdown} className="gap-x-2"><Copy size={14} />- <p>Copy as markdown</p>+ <p>Copy as Markdown</p><span className="ml-auto"><KeyboardShortcut keys={['Shift', 'Meta', 'm']} /></span>diff --git a/e2e/studio/features/sql-editor.spec.ts b/e2e/studio/features/sql-editor.spec.tsindex 8f405531a9d..6ab9b744d37 100644--- a/e2e/studio/features/sql-editor.spec.ts+++ b/e2e/studio/features/sql-editor.spec.ts@@ -321,11 +321,11 @@ test.describe('SQL Editor', () => {await page.keyboard.type(`select 'hello world';`)await page.getByTestId('sql-run-button').click()- // export as markdown+ // export as Markdownawait page.getByRole('button', { name: 'Export' }).click()- await page.getByRole('menuitem', { name: 'Copy as markdown' }).click()+ await page.getByRole('menuitem', { name: 'Copy as Markdown' }).click()// Make sure the dropdown has closed otherwise it would make the other assertions unstable- await expect(page.getByRole('menuitem', { name: 'Copy as markdown' })).not.toBeVisible()+ await expect(page.getByRole('menuitem', { name: 'Copy as Markdown' })).not.toBeVisible()await expectClipboardValue({page,value: `| ?column? |diff --git a/packages/ui-patterns/src/CommandMenu/api/CommandMenu.tsx b/packages/ui-patterns/src/CommandMenu/api/CommandMenu.tsxindex b66e1696151..1fb2c962043 100644--- a/packages/ui-patterns/src/CommandMenu/api/CommandMenu.tsx+++ b/packages/ui-patterns/src/CommandMenu/api/CommandMenu.tsx@@ -3,7 +3,7 @@import { VisuallyHidden } from '@radix-ui/react-visually-hidden'import { useBreakpoint } from 'common'import useDragToClose from 'common/hooks/useDragToClose'-import { AlertTriangle, ArrowLeft, Command, Search } from 'lucide-react'+import { AlertTriangle, ArrowLeft, Search } from 'lucide-react'import type { HTMLAttributes, MouseEvent, PropsWithChildren, ReactElement, ReactNode } from 'react'import { Children, cloneElement, forwardRef, isValidElement, useEffect, useMemo } from 'react'import { ErrorBoundary } from 'react-error-boundary'@@ -15,6 +15,7 @@ import {DialogContent,DialogDescription,DialogTitle,+ KeyboardShortcut,} from 'ui'import { useCurrentPage, usePageComponent, usePopPage } from './hooks/pagesHooks'@@ -202,15 +203,12 @@ function CommandMenuTriggerInput({<p className="flex text-xs pr-2 text-foreground-muted">{placeholder}</p></div>{showShortcut && (- <div className="command-shortcut hidden md:flex items-center space-x-1">- <div- aria-hidden="true"- className="md:flex items-center justify-center h-full px-1 border rounded bg-surface-300 gap-0.5"- >- <Command size={12} strokeWidth={1.5} />- <span className="text-[12px]">K</span>- </div>- </div>+ <span aria-hidden="true">+ <KeyboardShortcut+ keys={['Meta', 'k']}+ className="command-shortcut hidden md:inline-flex h-full border border-default bg-surface-300 text-foreground-lighter shadow-xs shadow-background-surface-100"+ />+ </span>)}</button></CommandMenuTrigger>diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/ui/src/components/Button/Button.tsxindex b97c71e9af2..bd645e92f34 100644--- a/packages/ui/src/components/Button/Button.tsx+++ b/packages/ui/src/components/Button/Button.tsx@@ -157,7 +157,7 @@ const buttonVariants = cva(})-const IconContainerVariants = cva('', {+const IconContainerVariants = cva('inline-flex items-center justify-center shrink-0', {variants: {size: {tiny: '[&_svg]:h-[14px] [&_svg]:w-[14px]',diff --git a/packages/ui/src/components/KeyboardShortcut/KeyboardShortcut.tsx b/packages/ui/src/components/KeyboardShortcut/KeyboardShortcut.tsxindex edaae0b754d..449947df7d1 100644--- a/packages/ui/src/components/KeyboardShortcut/KeyboardShortcut.tsx+++ b/packages/ui/src/components/KeyboardShortcut/KeyboardShortcut.tsx@@ -13,25 +13,45 @@ const getIsMac = () => {return false}-export const KeyboardShortcut = ({ keys }: { keys: string[] }) => {+const KEY_SYMBOLS: Record<string, string | ((isMac: boolean) => string)> = {+ Meta: (isMac) => (isMac ? '⌘' : 'Ctrl'),+ Alt: (isMac) => (isMac ? '⌥' : 'Alt'),+ Shift: '⇧',+ Enter: '↵',+ Esc: 'Esc', // ⎋ symbol not recognisable enough+ Escape: 'Esc', // Match above+ Tab: 'Tab', // ⇥ symbol not recognisable enough+}++type KeyboardShortcutProps = {+ keys: string[]+ variant?: 'pill' | 'inline'+ className?: string+}++const resolveKeyLabel = (key: string, isMac: boolean) => {+ const symbol = KEY_SYMBOLS[key]+ const resolvedKey = typeof symbol === 'function' ? symbol(isMac) : (symbol ?? key)++ return resolvedKey.length === 1 ? resolvedKey.toUpperCase() : resolvedKey+}++export const KeyboardShortcut = ({ keys, variant = 'pill', className }: KeyboardShortcutProps) => {const isMac = getIsMac()- const keysWithMeta = keys.map((key) => (key === 'Meta' ? (isMac ? '⌘' : 'Ctrl') : key))- const keysWithMetaAndShift = keysWithMeta.map((key) => (key === 'Shift' ? '⇧' : key))+ const resolvedKeys = keys.map((key) => resolveKeyLabel(key, isMac))+ const shortcutLabel = resolvedKeys.join(' ')return (- <div className="text-xs text-foreground-light flex items-center gap-[3px]">- {keysWithMetaAndShift.map((key) => (- <span- className={cn(- ['Shift', 'Ctrl'].includes(key) ? 'px-1.5 py-0.5' : 'w-[23px] h-[23px]',- 'border border-control',- 'rounded flex items-center justify-center cursor-default'- )}- key={key}- >- {key}- </span>- ))}- </div>+ <span+ className={cn(+ 'inline-flex whitespace-nowrap shrink-0',+ variant === 'pill'+ ? 'items-center text-[11px] leading-none -tracking-[0.05em] text-foreground-light bg-surface-200 dark:bg-surface-100 rounded px-[5px] py-[3px]'+ : 'items-baseline text-[11px] leading-[inherit] text-foreground/40',+ className+ )}+ >+ {shortcutLabel}+ </span>)}