Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): keyboard shortcuts for observability pages (#46277)

Ali Waseem42c0cb717117
diff --git a/apps/studio/components/interfaces/Observability/ObservabilityOverview.tsx b/apps/studio/components/interfaces/Observability/ObservabilityOverview.tsx
index 749f04cdf61..b358ec29eba 100644
--- a/apps/studio/components/interfaces/Observability/ObservabilityOverview.tsx
+++ b/apps/studio/components/interfaces/Observability/ObservabilityOverview.tsx
@@ -15,9 +15,12 @@ import ReportHeader from '@/components/interfaces/Reports/ReportHeader'
import ReportPadding from '@/components/interfaces/Reports/ReportPadding'
import { ChartIntervalDropdown } from '@/components/ui/Logs/ChartIntervalDropdown'
import { CHART_INTERVALS } from '@/components/ui/Logs/logs.utils'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import { useIsDataApiEnabled } from '@/hooks/misc/useIsDataApiEnabled'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
type ChartIntervalKey = '1hr' | '1day' | '7day'
@@ -33,6 +36,7 @@ export const ObservabilityOverview = () => {
const DEFAULT_INTERVAL: ChartIntervalKey = '1day'
const [interval, setInterval] = useState<ChartIntervalKey>(DEFAULT_INTERVAL)
const [refreshKey, setRefreshKey] = useState(0)
+ const [showIntervalDropdown, setShowIntervalDropdown] = useState(false)
const selectedInterval = CHART_INTERVALS.find((i) => i.key === interval) || CHART_INTERVALS[1]
@@ -56,6 +60,11 @@ export const ObservabilityOverview = () => {
queryClient.invalidateQueries({ queryKey: ['max-connections'] })
}, [queryClient, projectRef])
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_REFRESH, handleRefresh)
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER, () => {
+ setShowIntervalDropdown((open) => !open)
+ })
+
const serviceBase = useMemo(
() => [
{
@@ -154,15 +163,23 @@ export const ObservabilityOverview = () => {
</Tooltip>
</div>
<div className="flex items-center gap-2">
- <Button type="outline" icon={<RefreshCw size={14} />} onClick={handleRefresh}>
- Refresh
- </Button>
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
+ label="Refresh report"
+ side="bottom"
+ >
+ <Button type="outline" icon={<RefreshCw size={14} />} onClick={handleRefresh}>
+ Refresh
+ </Button>
+ </ShortcutTooltip>
<ChartIntervalDropdown
value={interval}
onChange={(interval) => setInterval(interval as ChartIntervalKey)}
organizationSlug={organization?.slug}
dropdownAlign="end"
tooltipSide="left"
+ open={showIntervalDropdown}
+ onOpenChange={setShowIntervalDropdown}
/>
</div>
</div>
diff --git a/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceFilterBar.tsx b/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceFilterBar.tsx
index a3efa5404ab..9d7c6158b18 100644
--- a/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceFilterBar.tsx
+++ b/apps/studio/components/interfaces/QueryPerformance/QueryPerformanceFilterBar.tsx
@@ -1,5 +1,5 @@
import { parseAsArrayOf, parseAsJson, parseAsString, useQueryStates } from 'nuqs'
-import { ReactNode, useEffect, useState } from 'react'
+import { ReactNode, useCallback, useEffect, useState } from 'react'
import { FilterInput } from './components/FilterInput'
import { FilterPill } from './components/FilterPill'
@@ -14,6 +14,8 @@ import {
ReportsNumericFilter,
} from '@/components/interfaces/Reports/v2/ReportsNumericFilter'
import { useDebouncedValue } from '@/hooks/misc/useDebouncedValue'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
export const QueryPerformanceFilterBar = ({
actions,
@@ -84,6 +86,45 @@ export const QueryPerformanceFilterBar = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [debouncedInputValue])
+ const hasActiveFilters = Boolean(
+ inputValue ||
+ filters.roles.length > 0 ||
+ filters.sources.length > 0 ||
+ callsFilter ||
+ totalTimeFilter ||
+ indexAdvisor === 'true' ||
+ sort
+ )
+
+ const handleResetFilters = useCallback(() => {
+ setInputValue('')
+ setFilters({ roles: [], sources: [] })
+ setSearchParams({
+ search: '',
+ roles: [],
+ sources: [],
+ callsFilter: null,
+ totalTimeFilter: null,
+ indexAdvisor: 'false',
+ })
+ clearSort()
+ }, [setSearchParams, clearSort])
+
+ useShortcut(
+ SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
+ () => {
+ const el = document.getElementById('keyword')
+ if (el instanceof HTMLInputElement) {
+ el.focus()
+ el.select()
+ }
+ },
+ { label: 'Search queries' }
+ )
+ useShortcut(SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS, handleResetFilters, {
+ enabled: hasActiveFilters,
+ })
+
const getCallsFilterDisplay = () => {
if (!callsFilter) return null
return `${callsFilter.operator} ${callsFilter.value}`
diff --git a/apps/studio/components/interfaces/QueryPerformance/WithStatements/WithStatements.tsx b/apps/studio/components/interfaces/QueryPerformance/WithStatements/WithStatements.tsx
index bf085c8b8ae..346658e68c0 100644
--- a/apps/studio/components/interfaces/QueryPerformance/WithStatements/WithStatements.tsx
+++ b/apps/studio/components/interfaces/QueryPerformance/WithStatements/WithStatements.tsx
@@ -16,8 +16,8 @@ import { QueryPerformanceMetrics } from '../QueryPerformanceMetrics'
import { QueryPerformanceInfiniteHook } from '../useQueryPerformanceQuery'
import { transformStatementDataToRows } from './WithStatements.utils'
import { PresetHookResult } from '@/components/interfaces/Reports/Reports.utils'
-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { DownloadResultsButton } from '@/components/ui/DownloadResultsButton'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
import { formatDatabaseID } from '@/data/read-replicas/replicas.utils'
import { executeSql } from '@/data/sql/execute-sql-query'
@@ -27,6 +27,8 @@ import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL, IS_PLATFORM } from '@/lib/constants'
import { getErrorMessage } from '@/lib/get-error-message'
import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
interface WithStatementsProps {
queryHitRate: PresetHookResult
@@ -76,6 +78,13 @@ export const WithStatements = ({
queryMetrics.runQuery()
}
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_REFRESH, handleRefresh, {
+ enabled: !isRefetching,
+ })
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_RESET_REPORT, () => {
+ setShowResetgPgStatStatements(true)
+ })
+
const processedData = useMemo(() => {
return transformStatementDataToRows(data || [], indexAdvisor === 'true')
}, [data, indexAdvisor])
@@ -195,22 +204,32 @@ export const WithStatements = ({
showSourceFilter
actions={
<>
- <ButtonTooltip
- type="default"
- size="tiny"
- icon={<RefreshCw />}
- onClick={handleRefresh}
- tooltip={{ content: { side: 'top', text: 'Refresh' } }}
- className="w-[26px]"
- />
- <ButtonTooltip
- type="default"
- size="tiny"
- icon={<RotateCcw />}
- onClick={() => setShowResetgPgStatStatements(true)}
- tooltip={{ content: { side: 'top', text: 'Reset report' } }}
- className="w-[26px]"
- />
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
+ label="Refresh"
+ side="top"
+ >
+ <Button
+ type="default"
+ size="tiny"
+ icon={<RefreshCw />}
+ onClick={handleRefresh}
+ className="w-[26px]"
+ />
+ </ShortcutTooltip>
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_RESET_REPORT}
+ label="Reset report"
+ side="top"
+ >
+ <Button
+ type="default"
+ size="tiny"
+ icon={<RotateCcw />}
+ onClick={() => setShowResetgPgStatStatements(true)}
+ className="w-[26px]"
+ />
+ </ShortcutTooltip>
<DownloadResultsButton
results={processedData}
diff --git a/apps/studio/components/interfaces/QueryPerformance/components/FilterInput.tsx b/apps/studio/components/interfaces/QueryPerformance/components/FilterInput.tsx
index 3e3b6079876..bc53077d6e9 100644
--- a/apps/studio/components/interfaces/QueryPerformance/components/FilterInput.tsx
+++ b/apps/studio/components/interfaces/QueryPerformance/components/FilterInput.tsx
@@ -2,6 +2,8 @@ import { Search, X } from 'lucide-react'
import { Button } from 'ui'
import { Input } from 'ui-patterns/DataInputs/Input'
+import { onSearchInputEscape } from '@/lib/keyboard'
+
interface FilterInputProps {
value: string
onChange: (value: string) => void
@@ -17,6 +19,7 @@ export const FilterInput = ({ value, onChange, placeholder, className }: FilterI
icon={<Search />}
value={value}
onChange={(e) => onChange(e.target.value)}
+ onKeyDown={onSearchInputEscape(value, onChange)}
name="keyword"
id="keyword"
placeholder={placeholder || 'Filter by query'}
diff --git a/apps/studio/components/interfaces/Reports/ReportFilterBar.tsx b/apps/studio/components/interfaces/Reports/ReportFilterBar.tsx
index 2cf6e9fd91f..a7aea4479c6 100644
--- a/apps/studio/components/interfaces/Reports/ReportFilterBar.tsx
+++ b/apps/studio/components/interfaces/Reports/ReportFilterBar.tsx
@@ -2,7 +2,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '@ui/components/shadcn/u
import { useParams } from 'common'
import { Auth, Realtime, Storage } from 'icons'
import { ChevronDown, Database, Network, Plus, RefreshCw, X } from 'lucide-react'
-import { ComponentProps, useEffect, useState } from 'react'
+import { ComponentProps, useCallback, useEffect, useState } from 'react'
import SVG from 'react-inlinesvg'
import {
Button,
@@ -25,10 +25,12 @@ import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { DatePickerValue, LogsDatePicker } from '../Settings/Logs/Logs.DatePickers'
import { REPORTS_DATEPICKER_HELPERS } from './Reports.constants'
import type { ReportFilterItem } from './Reports.types'
-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { DatabaseSelector } from '@/components/ui/DatabaseSelector'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import { useLoadBalancersQuery } from '@/data/read-replicas/load-balancers-query'
import { BASE_PATH } from '@/lib/constants'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
interface ReportFilterBarProps {
filters: ReportFilterItem[]
@@ -111,6 +113,8 @@ const ReportFilterBar = ({
'response.status_code',
]
const [showAdder, setShowAdder] = useState(false)
+ const [showDatePicker, setShowDatePicker] = useState(false)
+ const [showProductFilter, setShowProductFilter] = useState(false)
const [currentProductFilter, setCurrentProductFilter] = useState<
null | (typeof PRODUCT_FILTERS)[number]
>(null)
@@ -161,6 +165,45 @@ const ReportFilterBar = ({
}
}, [])
+ const customFilters = filters.filter(
+ (filter) =>
+ filter.value !== currentProductFilter?.filterValue ||
+ filter.key !== currentProductFilter?.filterKey
+ )
+
+ const handleClearFilters = useCallback(() => {
+ if (customFilters.length === 0) return
+ onRemoveFilters(customFilters)
+ }, [customFilters, onRemoveFilters])
+
+ useShortcut(
+ SHORTCUT_IDS.OBSERVABILITY_REFRESH,
+ () => {
+ onRefresh?.()
+ },
+ { enabled: Boolean(onRefresh) && !isLoading }
+ )
+ useShortcut(
+ SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER,
+ () => {
+ setShowDatePicker((open) => !open)
+ },
+ { enabled: !hideDatepicker }
+ )
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_FOCUS_FILTER, () => {
+ setShowAdder(true)
+ })
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_RESET_FILTERS, handleClearFilters, {
+ enabled: customFilters.length > 0,
+ })
+ useShortcut(
+ SHORTCUT_IDS.OBSERVABILITY_FILTER_REQUESTS,
+ () => {
+ setShowProductFilter((open) => !open)
+ },
+ { enabled: !selectedProduct }
+ )
+
const getInitialDatePickerValue = () => {
if (initialDatePickerValue) {
return initialDatePickerValue
@@ -187,35 +230,49 @@ const ReportFilterBar = ({
<div className={cn('flex items-center justify-between', className)}>
<div className="flex flex-row justify-start items-center flex-wrap gap-2">
{onRefresh && (
- <ButtonTooltip
- type="default"
- disabled={isLoading}
- icon={<RefreshCw className={isLoading ? 'animate-spin' : ''} />}
- className="w-7"
- tooltip={{ content: { side: 'bottom', text: 'Refresh report' } }}
- onClick={() => onRefresh()}
- />
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
+ label="Refresh report"
+ side="bottom"
+ >
+ <Button
+ type="default"
+ disabled={isLoading}
+ icon={<RefreshCw className={isLoading ? 'animate-spin' : ''} />}
+ className="w-7"
+ onClick={() => onRefresh()}
+ />
+ </ShortcutTooltip>
)}
{!hideDatepicker && (
<LogsDatePicker
onSubmit={handleDatepickerChange}
value={selectedRange}
helpers={datepickerHelpers}
+ open={showDatePicker}
+ onOpenChange={setShowDatePicker}
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER}
/>
)}
{!selectedProduct && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- type="default"
- className="inline-flex flex-row gap-2"
- iconRight={<ChevronDown size={14} />}
- >
- <span>
- {currentProductFilter === null ? 'All Requests' : currentProductFilter.label}
- </span>
- </Button>
- </DropdownMenuTrigger>
+ <DropdownMenu open={showProductFilter} onOpenChange={setShowProductFilter}>
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_FILTER_REQUESTS}
+ side="bottom"
+ open={showProductFilter ? false : undefined}
+ >
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="default"
+ className="inline-flex flex-row gap-2"
+ iconRight={<ChevronDown size={14} />}
+ >
+ <span>
+ {currentProductFilter === null ? 'All Requests' : currentProductFilter.label}
+ </span>
+ </Button>
+ </DropdownMenuTrigger>
+ </ShortcutTooltip>
<DropdownMenuContent side="bottom" align="start">
<DropdownMenuItem onClick={() => handleProductFilterChange(null)}>
<Network size={14} strokeWidth={1.5} className="mr-2" />
@@ -259,42 +316,41 @@ const ReportFilterBar = ({
</DropdownMenuContent>
</DropdownMenu>
)}
- {filters
- .filter(
- (filter) =>
- filter.value !== currentProductFilter?.filterValue ||
- filter.key !== currentProductFilter?.filterKey
- )
- .map((filter) => (
- <div
- key={`${filter.key}-${filter.compare}-${filter.value}`}
- className="text-xs rounded-md font-mono bg-surface-300 px-2 h-[26px] flex flex-row justify-center gap-1 items-center"
+ {customFilters.map((filter) => (
+ <div
+ key={`${filter.key}-${filter.compare}-${filter.value}`}
+ className="text-xs rounded-md font-mono bg-surface-300 px-2 h-[26px] flex flex-row justify-center gap-1 items-center"
+ >
+ <span className="">{filter.key}</span>
+ <span className="text-foreground-lighter">{filter.compare}</span>
+ <span className="">{filter.value}</span>
+ <Button
+ type="text"
+ size="tiny"
+ className="p-0! space-x-0!"
+ onClick={() => onRemoveFilters([filter])}
+ icon={<X className="text-foreground-light" />}
>
- <span className="">{filter.key}</span>
- <span className="text-foreground-lighter">{filter.compare}</span>
- <span className="">{filter.value}</span>
+ <span className="sr-only">Remove</span>
+ </Button>
+ </div>
+ ))}
+ <Popover open={showAdder} onOpenChange={(openValue) => setShowAdder(openValue)}>
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_FOCUS_FILTER}
+ side="bottom"
+ open={showAdder ? false : undefined}
+ >
+ <PopoverTrigger asChild>
<Button
- type="text"
+ type="default"
size="tiny"
- className="p-0! space-x-0!"
- onClick={() => onRemoveFilters([filter])}
- icon={<X className="text-foreground-light" />}
+ icon={<Plus className={`text-foreground-light `} />}
>
- <span className="sr-only">Remove</span>
+ Add filter
</Button>
- </div>
- ))}
- <Popover open={showAdder} onOpenChange={(openValue) => setShowAdder(openValue)}>
- <PopoverTrigger>
- <Button
- asChild
- type="default"
- size="tiny"
- icon={<Plus className={`text-foreground-light `} />}
- >
- <span>Add filter</span>
- </Button>
- </PopoverTrigger>
+ </PopoverTrigger>
+ </ShortcutTooltip>
<PopoverContent align={filters.length > 0 ? 'end' : 'start'} className="p-0 w-60">
<div className="flex flex-col gap-3 p-3">
<FormItemLayout
diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx b/apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx
index 1fed416743e..a2c8ddf55de 100644
--- a/apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx
+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.DatePickers.tsx
@@ -20,7 +20,9 @@ import { LOGS_LARGE_DATE_RANGE_DAYS_THRESHOLD } from './Logs.constants'
import type { DatetimeHelper } from './Logs.types'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { TimeSplitInput } from '@/components/ui/DatePicker/TimeSplitInput'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
+import type { ShortcutId } from '@/state/shortcuts/registry'
type Unit = 'minute' | 'hour' | 'day'
@@ -98,6 +100,12 @@ interface LogsDatePickerProps {
align?: 'start' | 'end' | 'center'
open?: boolean
onOpenChange?: (open: boolean) => void
+ /**
+ * Registered shortcut id whose hotkey is shown in a tooltip on the trigger
+ * button. The tooltip hides while the popover is open so it doesn't sit on
+ * top of the picker. Leave undefined to render no tooltip.
+ */
+ shortcutId?: ShortcutId
}
export const LogsDatePicker = ({
@@ -110,6 +118,7 @@ export const LogsDatePicker = ({
align = 'end',
open: openProp,
onOpenChange,
+ shortcutId,
}: PropsWithChildren<LogsDatePickerProps>) => {
const [internalOpen, setInternalOpen] = useState(false)
const isControlled = openProp !== undefined
@@ -326,15 +335,25 @@ export const LogsDatePicker = ({
return true
}
+ const triggerButton = (
+ <PopoverTrigger asChild>
+ <Button type="default" icon={<Clock size={12} />} {...buttonTriggerProps}>
+ {value.isHelper
+ ? value.text
+ : `${dayjs(value.from).format('DD MMM, HH:mm')} - ${dayjs(value.to || new Date()).format('DD MMM, HH:mm')}`}
+ </Button>
+ </PopoverTrigger>
+ )
+
return (
<Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger asChild>
- <Button type="default" icon={<Clock size={12} />} {...buttonTriggerProps}>
- {value.isHelper
- ? value.text
- : `${dayjs(value.from).format('DD MMM, HH:mm')} - ${dayjs(value.to || new Date()).format('DD MMM, HH:mm')}`}
- </Button>
- </PopoverTrigger>
+ {shortcutId ? (
+ <ShortcutTooltip shortcutId={shortcutId} side="bottom" open={open ? false : undefined}>
+ {triggerButton}
+ </ShortcutTooltip>
+ ) : (
+ triggerButton
+ )}
<PopoverContent
className="flex w-full p-0"
side="bottom"
diff --git a/apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.tsx b/apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.tsx
index 50881e72cea..a9087d161f9 100644
--- a/apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.tsx
+++ b/apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.tsx
@@ -17,12 +17,15 @@ import { CreateReportModal } from '@/components/interfaces/Reports/CreateReportM
import { UpdateCustomReportModal } from '@/components/interfaces/Reports/UpdateModal'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { ProductMenu } from '@/components/ui/ProductMenu'
+import { ProductMenuShortcuts } from '@/components/ui/ProductMenu/ProductMenuShortcuts'
import { useContentDeleteMutation } from '@/data/content/content-delete-mutation'
import { Content, ContentBase, useContentQuery } from '@/data/content/content-query'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { IS_PLATFORM } from '@/lib/constants'
import { useProfile } from '@/lib/profile'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
import type { Dashboards } from '@/types'
const ObservabilityMenu = () => {
@@ -133,8 +136,17 @@ const ObservabilityMenu = () => {
isPlatform: IS_PLATFORM,
})
+ useShortcut(
+ SHORTCUT_IDS.OBSERVABILITY_NEW_REPORT,
+ () => {
+ setShowNewReportModal(true)
+ },
+ { enabled: IS_PLATFORM && canCreateCustomReport }
+ )
+
return (
<div>
+ <ProductMenuShortcuts menu={menuItems} />
{isLoading ? (
<div className="px-5 my-4 space-y-2">
<ShimmeringLoader />
diff --git a/apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx b/apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx
index 62f26186a09..59b90083bcb 100644
--- a/apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx
+++ b/apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx
@@ -1,9 +1,11 @@
import { IS_PLATFORM } from '@/lib/constants'
+import { SHORTCUT_IDS, type ShortcutId } from '@/state/shortcuts/registry'
interface ObservabilityMenuItem {
name: string
key: string
url: string
+ shortcutId?: ShortcutId
}
export interface ObservabilityMenuSection {
@@ -40,6 +42,7 @@ export function generateObservabilityMenuItems(
name: 'Overview',
key: 'observability',
url: `/project/${ref}/observability${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_OVERVIEW,
},
]
: []),
@@ -49,6 +52,7 @@ export function generateObservabilityMenuItems(
name: 'Query Insights',
key: 'query-insights',
url: `/project/${ref}/observability/query-insights${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_QUERY_PERFORMANCE,
},
]
: [
@@ -56,6 +60,7 @@ export function generateObservabilityMenuItems(
name: 'Query Performance',
key: 'query-performance',
url: `/project/${ref}/observability/query-performance${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_QUERY_PERFORMANCE,
},
]),
...(isPlatform
@@ -64,6 +69,7 @@ export function generateObservabilityMenuItems(
name: 'API Gateway',
key: 'api-overview',
url: `/project/${ref}/observability/api-overview${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_API_GATEWAY,
},
]
: []),
@@ -74,21 +80,25 @@ export function generateObservabilityMenuItems(
name: 'Database',
key: 'database',
url: `/project/${ref}/observability/database${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_DATABASE,
},
{
name: 'Data API',
key: 'postgrest',
url: `/project/${ref}/observability/postgrest${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_DATA_API,
},
{
name: 'Auth',
key: 'auth',
url: `/project/${ref}/observability/auth${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_AUTH,
},
{
name: 'Edge Functions',
key: 'edge-functions',
url: `/project/${ref}/observability/edge-functions${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_FUNCTIONS,
},
...(storageSupported
? [
@@ -96,6 +106,7 @@ export function generateObservabilityMenuItems(
name: 'Storage',
key: 'storage',
url: `/project/${ref}/observability/storage${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_STORAGE,
},
]
: []),
@@ -103,6 +114,7 @@ export function generateObservabilityMenuItems(
name: 'Realtime',
key: 'realtime',
url: `/project/${ref}/observability/realtime${preservedQueryParams}`,
+ shortcutId: SHORTCUT_IDS.NAV_OBSERVABILITY_REALTIME,
},
]
diff --git a/apps/studio/components/ui/Logs/ChartIntervalDropdown.tsx b/apps/studio/components/ui/Logs/ChartIntervalDropdown.tsx
index 97be9defa6e..10baeacf701 100644
--- a/apps/studio/components/ui/Logs/ChartIntervalDropdown.tsx
+++ b/apps/studio/components/ui/Logs/ChartIntervalDropdown.tsx
@@ -27,6 +27,8 @@ interface ChartIntervalDropdownProps {
organizationSlug?: string
dropdownAlign?: 'start' | 'center' | 'end'
tooltipSide?: 'left' | 'right' | 'top' | 'bottom'
+ open?: boolean
+ onOpenChange?: (open: boolean) => void
}
export const ChartIntervalDropdown = ({
@@ -35,6 +37,8 @@ export const ChartIntervalDropdown = ({
organizationSlug,
dropdownAlign = 'start',
tooltipSide = 'right',
+ open,
+ onOpenChange,
}: ChartIntervalDropdownProps) => {
const selectedInterval = CHART_INTERVALS.find((i) => i.key === value) || CHART_INTERVALS[1]
@@ -42,7 +46,7 @@ export const ChartIntervalDropdown = ({
const retentionDays = getEntitlementMax()
return (
- <DropdownMenu>
+ <DropdownMenu open={open} onOpenChange={onOpenChange}>
<DropdownMenuTrigger asChild>
<Button type="default" iconRight={<ChevronDown size={14} />}>
<span>{selectedInterval.label}</span>
diff --git a/apps/studio/components/ui/ShortcutTooltip.tsx b/apps/studio/components/ui/ShortcutTooltip.tsx
index 202c9dec5e9..5b8c3b70889 100644
--- a/apps/studio/components/ui/ShortcutTooltip.tsx
+++ b/apps/studio/components/ui/ShortcutTooltip.tsx
@@ -1,5 +1,5 @@
import { TooltipContentProps } from '@ui/components/shadcn/ui/tooltip'
-import { Fragment, type ReactNode } from 'react'
+import { Fragment, useState, type ReactNode } from 'react'
import { KeyboardShortcut, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { hotkeyToKeys } from '@/state/shortcuts/formatShortcut'
@@ -18,9 +18,11 @@ interface ShortcutTooltipProps {
*/
label?: string
/**
- * Controlled open state for the tooltip. Pass `false` to force the tooltip
- * closed (e.g. while a popover or dialog opened by the wrapped element is
- * visible). Leave `undefined` for default uncontrolled behavior.
+ * Override the tooltip's open state. Pass `false` to force the tooltip closed
+ * (e.g. while a popover or dialog opened by the wrapped element is visible).
+ * Leave `undefined` to let hover/focus drive it. The tooltip is always
+ * controlled internally so toggling this prop won't trigger Radix's
+ * controlled/uncontrolled warning.
*/
open?: boolean
}
@@ -50,8 +52,11 @@ export const ShortcutTooltip = ({
const def = SHORTCUT_DEFINITIONS[shortcutId]
const label = labelOverride ?? def.label
+ const [hoverOpen, setHoverOpen] = useState(false)
+ const resolvedOpen = open ?? hoverOpen
+
return (
- <Tooltip delayDuration={delayDuration} open={open}>
+ <Tooltip delayDuration={delayDuration} open={resolvedOpen} onOpenChange={setHoverOpen}>
<TooltipTrigger asChild>{children}</TooltipTrigger>
<TooltipContent
side={side}
diff --git a/apps/studio/pages/project/[ref]/observability/auth.tsx b/apps/studio/pages/project/[ref]/observability/auth.tsx
index 21122182fdb..4e7333cfdac 100644
--- a/apps/studio/pages/project/[ref]/observability/auth.tsx
+++ b/apps/studio/pages/project/[ref]/observability/auth.tsx
@@ -4,6 +4,7 @@ import { ArrowRight, LogsIcon, RefreshCw } from 'lucide-react'
import { useRouter } from 'next/router'
import { parseAsJson, useQueryState } from 'nuqs'
import { useState } from 'react'
+import { Button } from 'ui'
import ReportFilterBar from '@/components/interfaces/Reports/ReportFilterBar'
import ReportHeader from '@/components/interfaces/Reports/ReportHeader'
@@ -26,16 +27,18 @@ import { LogsDatePicker } from '@/components/interfaces/Settings/Logs/Logs.DateP
import UpgradePrompt from '@/components/interfaces/Settings/Logs/UpgradePrompt'
import DefaultLayout from '@/components/layouts/DefaultLayout'
import ObservabilityLayout from '@/components/layouts/ObservabilityLayout/ObservabilityLayout'
-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import type { ChartHighlightAction } from '@/components/ui/Charts/ChartHighlightActions'
import { ReportSettings } from '@/components/ui/Charts/ReportSettings'
import { ObservabilityLink } from '@/components/ui/ObservabilityLink'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import {
createErrorsReportConfig,
createLatencyReportConfig,
createUsageReportConfig,
} from '@/data/reports/v2/auth.config'
import { useRefreshHandler, useReportDateRange } from '@/hooks/misc/useReportDateRange'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
import type { NextPageWithLayout } from '@/types'
const AuthReport: NextPageWithLayout = () => {
@@ -87,6 +90,7 @@ const AuthUsage = () => {
})
const [isRefreshing, setIsRefreshing] = useState(false)
+ const [showDatePicker, setShowDatePicker] = useState(false)
const [monitoringStatusCodeFilter, setMonitoringStatusCodeFilter] = useQueryState(
'monitoring_status_code',
@@ -166,6 +170,13 @@ const AuthUsage = () => {
}
)
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_REFRESH, onRefreshReport, {
+ enabled: !isRefreshing,
+ })
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER, () => {
+ setShowDatePicker((open) => !open)
+ })
+
const router = useRouter()
const highlightActions: ChartHighlightAction[] = [
@@ -203,19 +214,27 @@ const AuthUsage = () => {
content={
<div className="flex flex-col gap-2">
<div className="flex items-center gap-2">
- <ButtonTooltip
- type="default"
- disabled={isRefreshing}
- icon={<RefreshCw className={isRefreshing ? 'animate-spin' : ''} />}
- className="w-7"
- tooltip={{ content: { side: 'bottom', text: 'Refresh report' } }}
- onClick={onRefreshReport}
- />
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
+ label="Refresh report"
+ side="bottom"
+ >
+ <Button
+ type="default"
+ disabled={isRefreshing}
+ icon={<RefreshCw className={isRefreshing ? 'animate-spin' : ''} />}
+ className="w-7"
+ onClick={onRefreshReport}
+ />
+ </ShortcutTooltip>
<ReportSettings chartId={chartSyncId} />
<LogsDatePicker
onSubmit={handleDatePickerChange}
value={datePickerValue}
helpers={datePickerHelpers}
+ open={showDatePicker}
+ onOpenChange={setShowDatePicker}
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER}
/>
<UpgradePrompt
show={showUpgradePrompt}
diff --git a/apps/studio/pages/project/[ref]/observability/database.tsx b/apps/studio/pages/project/[ref]/observability/database.tsx
index 14e65530f23..3a03f2c6400 100644
--- a/apps/studio/pages/project/[ref]/observability/database.tsx
+++ b/apps/studio/pages/project/[ref]/observability/database.tsx
@@ -26,6 +26,7 @@ import type { MultiAttribute } from '@/components/ui/Charts/ComposedChart.utils'
import { LazyComposedChartHandler } from '@/components/ui/Charts/ComposedChartHandler'
import { ReportSettings } from '@/components/ui/Charts/ReportSettings'
import { ObservabilityLink } from '@/components/ui/ObservabilityLink'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import { analyticsKeys } from '@/data/analytics/keys'
import { useDiskAttributesQuery } from '@/data/config/disk-attributes-query'
import { useProjectDiskResizeMutation } from '@/data/config/project-disk-resize-mutation'
@@ -43,6 +44,8 @@ import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL } from '@/lib/constants'
import { formatBytes } from '@/lib/helpers'
import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
import type { NextPageWithLayout } from '@/types'
const DatabaseReport: NextPageWithLayout = () => {
@@ -82,6 +85,7 @@ const DatabaseUsage = () => {
const [isRefreshing, setIsRefreshing] = useState(false)
const [showIncreaseDiskSizeModal, setshowIncreaseDiskSizeModal] = useState(false)
+ const [showDatePicker, setShowDatePicker] = useState(false)
const isReplicaSelected = state.selectedDatabaseId !== project?.ref
@@ -191,6 +195,13 @@ const DatabaseUsage = () => {
}
)
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_REFRESH, onRefreshReport, {
+ enabled: !isRefreshing,
+ })
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER, () => {
+ setShowDatePicker((open) => !open)
+ })
+
const stateSyncedFromUrlRef = useRef(false)
useEffect(() => {
if (stateSyncedFromUrlRef.current) return
@@ -218,20 +229,28 @@ const DatabaseUsage = () => {
<ReportStickyNav
content={
<>
- <ButtonTooltip
- type="default"
- disabled={isRefreshing}
- icon={<RefreshCw className={isRefreshing ? 'animate-spin' : ''} />}
- className="w-7"
- tooltip={{ content: { side: 'bottom', text: 'Refresh report' } }}
- onClick={onRefreshReport}
- />
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
+ label="Refresh report"
+ side="bottom"
+ >
+ <Button
+ type="default"
+ disabled={isRefreshing}
+ icon={<RefreshCw className={isRefreshing ? 'animate-spin' : ''} />}
+ className="w-7"
+ onClick={onRefreshReport}
+ />
+ </ShortcutTooltip>
<ReportSettings chartId="database-charts" />
<div className="flex items-center gap-3">
<LogsDatePicker
onSubmit={handleDatePickerChange}
value={datePickerValue}
helpers={datePickerHelpers}
+ open={showDatePicker}
+ onOpenChange={setShowDatePicker}
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER}
/>
<UpgradePrompt
show={showUpgradePrompt}
diff --git a/apps/studio/pages/project/[ref]/observability/edge-functions.tsx b/apps/studio/pages/project/[ref]/observability/edge-functions.tsx
index 199253e96ff..ea8d6a69480 100644
--- a/apps/studio/pages/project/[ref]/observability/edge-functions.tsx
+++ b/apps/studio/pages/project/[ref]/observability/edge-functions.tsx
@@ -4,6 +4,7 @@ import dayjs from 'dayjs'
import { ArrowRight, RefreshCw } from 'lucide-react'
import { parseAsJson, useQueryState } from 'nuqs'
import { useMemo, useState } from 'react'
+import { Button } from 'ui'
import ReportHeader from '@/components/interfaces/Reports/ReportHeader'
import ReportPadding from '@/components/interfaces/Reports/ReportPadding'
@@ -25,14 +26,16 @@ import { LogsDatePicker } from '@/components/interfaces/Settings/Logs/Logs.DateP
import UpgradePrompt from '@/components/interfaces/Settings/Logs/UpgradePrompt'
import DefaultLayout from '@/components/layouts/DefaultLayout'
import ObservabilityLayout from '@/components/layouts/ObservabilityLayout/ObservabilityLayout'
-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { ReportSettings } from '@/components/ui/Charts/ReportSettings'
import { useChartHoverState } from '@/components/ui/Charts/useChartHoverState'
import { ObservabilityLink } from '@/components/ui/ObservabilityLink'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import { useEdgeFunctionsQuery } from '@/data/edge-functions/edge-functions-query'
import { edgeFunctionReports } from '@/data/reports/v2/edge-functions.config'
import { useRefreshHandler, useReportDateRange } from '@/hooks/misc/useReportDateRange'
import { BASE_PATH } from '@/lib/constants'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
import type { NextPageWithLayout } from '@/types'
const EdgeFunctionsReportV2: NextPageWithLayout = () => {
@@ -92,6 +95,7 @@ const EdgeFunctionsUsage = () => {
const queryClient = useQueryClient()
const [isRefreshing, setIsRefreshing] = useState(false)
+ const [showDatePicker, setShowDatePicker] = useState(false)
const reportConfig = useMemo(() => {
return edgeFunctionReports({
@@ -130,6 +134,13 @@ const EdgeFunctionsUsage = () => {
}
)
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_REFRESH, onRefreshReport, {
+ enabled: !isRefreshing,
+ })
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER, () => {
+ setShowDatePicker((open) => !open)
+ })
+
return (
<>
<ReportHeader title="Edge Functions" showDatabaseSelector={false} />
@@ -137,14 +148,19 @@ const EdgeFunctionsUsage = () => {
content={
<div className="flex flex-col gap-2">
<div className="flex items-center gap-2">
- <ButtonTooltip
- type="default"
- disabled={isRefreshing}
- icon={<RefreshCw className={isRefreshing ? 'animate-spin' : ''} />}
- className="w-7"
- tooltip={{ content: { side: 'bottom', text: 'Refresh report' } }}
- onClick={onRefreshReport}
- />
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
+ label="Refresh report"
+ side="bottom"
+ >
+ <Button
+ type="default"
+ disabled={isRefreshing}
+ icon={<RefreshCw className={isRefreshing ? 'animate-spin' : ''} />}
+ className="w-7"
+ onClick={onRefreshReport}
+ />
+ </ShortcutTooltip>
<ReportSettings chartId="edge-functions-charts" />
@@ -153,6 +169,9 @@ const EdgeFunctionsUsage = () => {
value={datePickerValue}
helpers={datePickerHelpers}
onSubmit={handleDatePickerChange}
+ open={showDatePicker}
+ onOpenChange={setShowDatePicker}
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER}
/>
<UpgradePrompt
show={showUpgradePrompt}
diff --git a/apps/studio/pages/project/[ref]/observability/postgrest.tsx b/apps/studio/pages/project/[ref]/observability/postgrest.tsx
index d79ca051434..498fd11bc3d 100644
--- a/apps/studio/pages/project/[ref]/observability/postgrest.tsx
+++ b/apps/studio/pages/project/[ref]/observability/postgrest.tsx
@@ -1,7 +1,8 @@
import { useParams } from 'common'
import dayjs from 'dayjs'
import { ArrowRight, RefreshCw } from 'lucide-react'
-import { useEffect, useRef } from 'react'
+import { useEffect, useRef, useState } from 'react'
+import { Button } from 'ui'
import ReportFilterBar from '@/components/interfaces/Reports/ReportFilterBar'
import ReportHeader from '@/components/interfaces/Reports/ReportHeader'
@@ -17,10 +18,12 @@ import {
import UpgradePrompt from '@/components/interfaces/Settings/Logs/UpgradePrompt'
import DefaultLayout from '@/components/layouts/DefaultLayout'
import ObservabilityLayout from '@/components/layouts/ObservabilityLayout/ObservabilityLayout'
-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { ObservabilityLink } from '@/components/ui/ObservabilityLink'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import { useRefreshHandler, useReportDateRange } from '@/hooks/misc/useReportDateRange'
import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
import type { NextPageWithLayout } from '@/types'
const PostgRESTReport: NextPageWithLayout = () => {
@@ -69,6 +72,7 @@ const PostgrestReport = () => {
})
const state = useDatabaseSelectorStateSnapshot()
+ const [showDatePicker, setShowDatePicker] = useState(false)
const hasStateSyncedFromUrlRef = useRef(false)
useEffect(() => {
@@ -102,6 +106,13 @@ const PostgrestReport = () => {
refetch
)
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_REFRESH, onRefreshReport, {
+ enabled: !isRefetching,
+ })
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER, () => {
+ setShowDatePicker((open) => !open)
+ })
+
return (
<>
<ReportHeader showDatabaseSelector={false} title="Data API" />
@@ -109,18 +120,26 @@ const PostgrestReport = () => {
content={
<div className="flex flex-col gap-2">
<div className="flex gap-2">
- <ButtonTooltip
- type="default"
- disabled={isRefetching}
- icon={<RefreshCw className={isRefetching ? 'animate-spin' : ''} />}
- className="w-7"
- tooltip={{ content: { side: 'bottom', text: 'Refresh report' } }}
- onClick={onRefreshReport}
- />
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
+ label="Refresh report"
+ side="bottom"
+ >
+ <Button
+ type="default"
+ disabled={isRefetching}
+ icon={<RefreshCw className={isRefetching ? 'animate-spin' : ''} />}
+ className="w-7"
+ onClick={onRefreshReport}
+ />
+ </ShortcutTooltip>
<LogsDatePicker
onSubmit={handleDatePickerChange}
value={datePickerValue}
helpers={datePickerHelpers}
+ open={showDatePicker}
+ onOpenChange={setShowDatePicker}
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER}
/>
<UpgradePrompt
show={showUpgradePrompt}
diff --git a/apps/studio/pages/project/[ref]/observability/realtime.tsx b/apps/studio/pages/project/[ref]/observability/realtime.tsx
index 303d883065c..658cb034610 100644
--- a/apps/studio/pages/project/[ref]/observability/realtime.tsx
+++ b/apps/studio/pages/project/[ref]/observability/realtime.tsx
@@ -3,6 +3,7 @@ import { useParams } from 'common'
import dayjs from 'dayjs'
import { ArrowRight, RefreshCw } from 'lucide-react'
import { useEffect, useMemo, useRef, useState } from 'react'
+import { Button } from 'ui'
import ReportFilterBar from '@/components/interfaces/Reports/ReportFilterBar'
import ReportHeader from '@/components/interfaces/Reports/ReportHeader'
@@ -16,11 +17,13 @@ import { LogsDatePicker } from '@/components/interfaces/Settings/Logs/Logs.DateP
import UpgradePrompt from '@/components/interfaces/Settings/Logs/UpgradePrompt'
import DefaultLayout from '@/components/layouts/DefaultLayout'
import ObservabilityLayout from '@/components/layouts/ObservabilityLayout/ObservabilityLayout'
-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { ObservabilityLink } from '@/components/ui/ObservabilityLink'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import { realtimeReports } from '@/data/reports/v2/realtime.config'
import { useRefreshHandler, useReportDateRange } from '@/hooks/misc/useReportDateRange'
import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
import type { NextPageWithLayout } from '@/types'
const RealtimeReport: NextPageWithLayout = () => {
@@ -42,6 +45,7 @@ export default RealtimeReport
const RealtimeUsage = () => {
const [isRefreshing, setIsRefreshing] = useState(false)
+ const [showDatePicker, setShowDatePicker] = useState(false)
const { db, chart, ref } = useParams()
const {
@@ -102,6 +106,13 @@ const RealtimeUsage = () => {
}
)
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_REFRESH, onRefreshReport, {
+ enabled: !isRefreshing,
+ })
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER, () => {
+ setShowDatePicker((open) => !open)
+ })
+
const urlStateHasSyncedRef = useRef(false)
useEffect(() => {
if (urlStateHasSyncedRef.current) return
@@ -134,18 +145,26 @@ const RealtimeUsage = () => {
content={
<div className="flex flex-col gap-3">
<div className="flex gap-2">
- <ButtonTooltip
- type="default"
- disabled={isRefreshing}
- icon={<RefreshCw className={isRefreshing ? 'animate-spin' : ''} />}
- className="w-7"
- tooltip={{ content: { side: 'bottom', text: 'Refresh report' } }}
- onClick={onRefreshReport}
- />
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
+ label="Refresh report"
+ side="bottom"
+ >
+ <Button
+ type="default"
+ disabled={isRefreshing}
+ icon={<RefreshCw className={isRefreshing ? 'animate-spin' : ''} />}
+ className="w-7"
+ onClick={onRefreshReport}
+ />
+ </ShortcutTooltip>
<LogsDatePicker
onSubmit={handleDatePickerChange}
value={datePickerValue}
helpers={datePickerHelpers}
+ open={showDatePicker}
+ onOpenChange={setShowDatePicker}
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER}
/>
<UpgradePrompt
show={showUpgradePrompt}
diff --git a/apps/studio/pages/project/[ref]/observability/storage.tsx b/apps/studio/pages/project/[ref]/observability/storage.tsx
index 4e0ea74cbcb..ba9be481393 100644
--- a/apps/studio/pages/project/[ref]/observability/storage.tsx
+++ b/apps/studio/pages/project/[ref]/observability/storage.tsx
@@ -1,6 +1,8 @@
import dayjs from 'dayjs'
import { ArrowRight, ExternalLinkIcon, RefreshCw } from 'lucide-react'
import Link from 'next/link'
+import { useState } from 'react'
+import { Button } from 'ui'
import {
NetworkTrafficRenderer,
@@ -25,11 +27,13 @@ import {
import UpgradePrompt from '@/components/interfaces/Settings/Logs/UpgradePrompt'
import DefaultLayout from '@/components/layouts/DefaultLayout'
import ObservabilityLayout from '@/components/layouts/ObservabilityLayout/ObservabilityLayout'
-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { ObservabilityLink } from '@/components/ui/ObservabilityLink'
+import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
import { useStorageReport } from '@/data/reports/storage-report-query'
import { useRefreshHandler, useReportDateRange } from '@/hooks/misc/useReportDateRange'
import { DOCS_URL } from '@/lib/constants'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
import type { NextPageWithLayout } from '@/types'
export const StorageReport: NextPageWithLayout = () => {
@@ -73,6 +77,15 @@ export const StorageReport: NextPageWithLayout = () => {
refresh
)
+ const [showDatePicker, setShowDatePicker] = useState(false)
+
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_REFRESH, onRefreshReport, {
+ enabled: !report.isLoading,
+ })
+ useShortcut(SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER, () => {
+ setShowDatePicker((open) => !open)
+ })
+
return (
<ReportPadding>
<ReportHeader title="Storage" showDatabaseSelector={false} />
@@ -80,18 +93,26 @@ export const StorageReport: NextPageWithLayout = () => {
content={
<div className="flex flex-col gap-2">
<div className="flex items-center gap-2">
- <ButtonTooltip
- type="default"
- disabled={report.isLoading}
- icon={<RefreshCw className={report.isLoading ? 'animate-spin' : ''} />}
- className="w-7"
- tooltip={{ content: { side: 'bottom', text: 'Refresh report' } }}
- onClick={onRefreshReport}
- />
+ <ShortcutTooltip
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_REFRESH}
+ label="Refresh report"
+ side="bottom"
+ >
+ <Button
+ type="default"
+ disabled={report.isLoading}
+ icon={<RefreshCw className={report.isLoading ? 'animate-spin' : ''} />}
+ className="w-7"
+ onClick={onRefreshReport}
+ />
+ </ShortcutTooltip>
<LogsDatePicker
onSubmit={handleDatepickerChange}
value={datePickerValue}
helpers={datePickerHelpers}
+ open={showDatePicker}
+ onOpenChange={setShowDatePicker}
+ shortcutId={SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER}
/>
{selectedDateRange && (
<div className="flex items-center gap-x-2 text-xs">
diff --git a/apps/studio/state/shortcuts/referenceGroups.ts b/apps/studio/state/shortcuts/referenceGroups.ts
index 7a5b32e3291..56072a19229 100644
--- a/apps/studio/state/shortcuts/referenceGroups.ts
+++ b/apps/studio/state/shortcuts/referenceGroups.ts
@@ -7,6 +7,7 @@ export const SHORTCUT_REFERENCE_GROUPS = {
NAVIGATION_FUNCTIONS: 'navigation.functions',
NAVIGATION_FUNCTION_DETAIL: 'navigation.function-detail',
NAVIGATION_REALTIME: 'navigation.realtime',
+ NAVIGATION_OBSERVABILITY: 'navigation.observability',
NAVIGATION_ADVISORS: 'navigation.advisors',
} as const
@@ -19,6 +20,7 @@ export const SHORTCUT_REFERENCE_GROUP_LABELS: Record<string, string> = {
[SHORTCUT_REFERENCE_GROUPS.NAVIGATION_FUNCTIONS]: 'Edge Functions Navigation',
[SHORTCUT_REFERENCE_GROUPS.NAVIGATION_FUNCTION_DETAIL]: 'Edge Function Tabs',
[SHORTCUT_REFERENCE_GROUPS.NAVIGATION_REALTIME]: 'Realtime Navigation',
+ [SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY]: 'Observability Navigation',
[SHORTCUT_REFERENCE_GROUPS.NAVIGATION_ADVISORS]: 'Advisors Navigation',
}
@@ -40,6 +42,8 @@ export const SHORTCUT_REFERENCE_GROUP_ORDER = [
'functions-overview',
SHORTCUT_REFERENCE_GROUPS.NAVIGATION_REALTIME,
'realtime-inspector',
+ SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ 'observability-page',
SHORTCUT_REFERENCE_GROUPS.NAVIGATION_ADVISORS,
'advisors-page',
'logs-preview',
diff --git a/apps/studio/state/shortcuts/registry.ts b/apps/studio/state/shortcuts/registry.ts
index da427efdd28..6643be580ac 100644
--- a/apps/studio/state/shortcuts/registry.ts
+++ b/apps/studio/state/shortcuts/registry.ts
@@ -17,6 +17,14 @@ import {
} from './registry/functions-overview'
import { LIST_PAGE_SHORTCUT_IDS, listPageRegistry } from './registry/list-page'
import { LOGS_PREVIEW_SHORTCUT_IDS, logsPreviewRegistry } from './registry/logs-preview'
+import {
+ OBSERVABILITY_NAV_SHORTCUT_IDS,
+ observabilityNavRegistry,
+} from './registry/observability-nav'
+import {
+ OBSERVABILITY_PAGE_SHORTCUT_IDS,
+ observabilityPageRegistry,
+} from './registry/observability-page'
import {
PLATFORM_WEBHOOKS_SHORTCUT_IDS,
platformWebhooksRegistry,
@@ -127,6 +135,10 @@ export const SHORTCUT_IDS = {
// Realtime Inspector page shortcuts
...REALTIME_INSPECTOR_SHORTCUT_IDS,
+ // Observability sub-page navigation chords
+ ...OBSERVABILITY_NAV_SHORTCUT_IDS,
+ // Observability shared page-action shortcuts
+ ...OBSERVABILITY_PAGE_SHORTCUT_IDS,
// Advisors sub-page navigation chords
...ADVISORS_NAV_SHORTCUT_IDS,
// Advisors lint page shortcuts (tabs, refresh, close detail)
@@ -458,6 +470,10 @@ export const SHORTCUT_DEFINITIONS: Record<ShortcutId, ShortcutDefinition> = {
// Realtime Inspector page shortcut registration
...realtimeInspectorRegistry,
+ // Observability sub-page navigation chord registration
+ ...observabilityNavRegistry,
+ // Observability shared page-action shortcut registration
+ ...observabilityPageRegistry,
// Advisors sub-page navigation chord registration
...advisorsNavRegistry,
// Advisors lint page shortcut registration
diff --git a/apps/studio/state/shortcuts/registry/observability-nav.ts b/apps/studio/state/shortcuts/registry/observability-nav.ts
new file mode 100644
index 00000000000..648e86b254a
--- /dev/null
+++ b/apps/studio/state/shortcuts/registry/observability-nav.ts
@@ -0,0 +1,91 @@
+import { SHORTCUT_REFERENCE_GROUPS } from '../referenceGroups'
+import { RegistryDefinations } from '../types'
+
+/**
+ * Contextual chords for jumping between Observability sub-pages — `U + <letter>`.
+ *
+ * Active only while ObservabilityLayout is mounted (i.e. the user is somewhere
+ * under `/project/<ref>/observability/*`). Mirrors the database-nav pattern:
+ * the leading `U` is layout-scoped so it doesn't burn a global key. `U` matches
+ * the global `G U` that takes the user into Observability in the first place.
+ */
+export const OBSERVABILITY_NAV_SHORTCUT_IDS = {
+ NAV_OBSERVABILITY_OVERVIEW: 'nav.observability-overview',
+ NAV_OBSERVABILITY_QUERY_PERFORMANCE: 'nav.observability-query-performance',
+ NAV_OBSERVABILITY_API_GATEWAY: 'nav.observability-api-gateway',
+ NAV_OBSERVABILITY_DATABASE: 'nav.observability-database',
+ NAV_OBSERVABILITY_DATA_API: 'nav.observability-data-api',
+ NAV_OBSERVABILITY_AUTH: 'nav.observability-auth',
+ NAV_OBSERVABILITY_FUNCTIONS: 'nav.observability-functions',
+ NAV_OBSERVABILITY_STORAGE: 'nav.observability-storage',
+ NAV_OBSERVABILITY_REALTIME: 'nav.observability-realtime',
+}
+
+export type ObservabilityNavShortcutId =
+ (typeof OBSERVABILITY_NAV_SHORTCUT_IDS)[keyof typeof OBSERVABILITY_NAV_SHORTCUT_IDS]
+
+export const observabilityNavRegistry: RegistryDefinations<ObservabilityNavShortcutId> = {
+ [OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_OVERVIEW]: {
+ id: OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_OVERVIEW,
+ label: 'Go to Overview',
+ sequence: ['U', 'O'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ },
+ [OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_QUERY_PERFORMANCE]: {
+ id: OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_QUERY_PERFORMANCE,
+ label: 'Go to Query Performance',
+ sequence: ['U', 'Q'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ },
+ [OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_API_GATEWAY]: {
+ id: OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_API_GATEWAY,
+ label: 'Go to API Gateway',
+ sequence: ['U', 'G'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ },
+ [OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_DATABASE]: {
+ id: OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_DATABASE,
+ label: 'Go to Database',
+ sequence: ['U', 'D'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ },
+ [OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_DATA_API]: {
+ id: OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_DATA_API,
+ label: 'Go to Data API',
+ sequence: ['U', 'P'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ },
+ [OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_AUTH]: {
+ id: OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_AUTH,
+ label: 'Go to Auth',
+ sequence: ['U', 'A'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ },
+ [OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_FUNCTIONS]: {
+ id: OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_FUNCTIONS,
+ label: 'Go to Edge Functions',
+ sequence: ['U', 'F'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ },
+ [OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_STORAGE]: {
+ id: OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_STORAGE,
+ label: 'Go to Storage',
+ sequence: ['U', 'S'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ },
+ [OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_REALTIME]: {
+ id: OBSERVABILITY_NAV_SHORTCUT_IDS.NAV_OBSERVABILITY_REALTIME,
+ label: 'Go to Realtime',
+ sequence: ['U', 'L'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_OBSERVABILITY,
+ },
+}
diff --git a/apps/studio/state/shortcuts/registry/observability-page.ts b/apps/studio/state/shortcuts/registry/observability-page.ts
new file mode 100644
index 00000000000..b92e1a34087
--- /dev/null
+++ b/apps/studio/state/shortcuts/registry/observability-page.ts
@@ -0,0 +1,73 @@
+import { RegistryDefinations } from '../types'
+
+/**
+ * Shortcuts scoped to Observability report pages. Reuses the existing
+ * conventions from logs-preview (Shift+R refresh, Shift+P toggle date picker)
+ * and list-page (Shift+F focus filter/search, F C reset filters,
+ * Shift+N create new). Pages bind these via `useShortcut` and pass `label`
+ * overrides where the surface action is more specific than the generic label.
+ */
+export const OBSERVABILITY_PAGE_SHORTCUT_IDS = {
+ OBSERVABILITY_REFRESH: 'observability.refresh',
+ OBSERVABILITY_TOGGLE_DATE_PICKER: 'observability.toggle-date-picker',
+ OBSERVABILITY_FOCUS_FILTER: 'observability.focus-filter',
+ OBSERVABILITY_RESET_FILTERS: 'observability.reset-filters',
+ OBSERVABILITY_NEW_REPORT: 'observability.new-report',
+ OBSERVABILITY_RESET_REPORT: 'observability.reset-report',
+ OBSERVABILITY_FILTER_REQUESTS: 'observability.filter-requests',
+}
+
+export type ObservabilityPageShortcutId =
+ (typeof OBSERVABILITY_PAGE_SHORTCUT_IDS)[keyof typeof OBSERVABILITY_PAGE_SHORTCUT_IDS]
+
+export const observabilityPageRegistry: RegistryDefinations<ObservabilityPageShortcutId> = {
+ [OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_REFRESH]: {
+ id: OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_REFRESH,
+ label: 'Refresh report',
+ sequence: ['Shift+R'],
+ showInSettings: false,
+ options: { ignoreInputs: true, registerInCommandMenu: true, conflictBehavior: 'allow' },
+ },
+ [OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER]: {
+ id: OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_TOGGLE_DATE_PICKER,
+ label: 'Open time picker',
+ sequence: ['Shift+P'],
+ showInSettings: false,
+ options: { ignoreInputs: true, registerInCommandMenu: true, conflictBehavior: 'allow' },
+ },
+ [OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_FOCUS_FILTER]: {
+ id: OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_FOCUS_FILTER,
+ label: 'Add filter',
+ sequence: ['Shift+F'],
+ showInSettings: false,
+ options: { registerInCommandMenu: true },
+ },
+ [OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_RESET_FILTERS]: {
+ id: OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_RESET_FILTERS,
+ label: 'Reset filters',
+ sequence: ['F', 'C'],
+ showInSettings: false,
+ options: { ignoreInputs: true, registerInCommandMenu: true },
+ },
+ [OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_NEW_REPORT]: {
+ id: OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_NEW_REPORT,
+ label: 'New custom report',
+ sequence: ['Shift+N'],
+ showInSettings: false,
+ options: { ignoreInputs: true, registerInCommandMenu: true },
+ },
+ [OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_RESET_REPORT]: {
+ id: OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_RESET_REPORT,
+ label: 'Reset report',
+ sequence: ['R', 'C'],
+ showInSettings: false,
+ options: { ignoreInputs: true, registerInCommandMenu: true },
+ },
+ [OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_FILTER_REQUESTS]: {
+ id: OBSERVABILITY_PAGE_SHORTCUT_IDS.OBSERVABILITY_FILTER_REQUESTS,
+ label: 'Filter requests',
+ sequence: ['Shift+S'],
+ showInSettings: false,
+ options: { ignoreInputs: true, registerInCommandMenu: true },
+ },
+}