Files
supabase/apps/studio/state/shortcuts/registry/unified-logs.ts
Saxon FletcherandClaude Opus 5 9b12165400 feat(studio): multi-select logs with click, shift, and keyboard ranges (#50689)
<img width="1454" height="786" alt="image"
src="https://github.com/user-attachments/assets/995790b1-a242-4a61-a0a0-349de7234923"
/>


Stack 4/4 · previous: #50688

## Problem

Selecting several logs to copy or send to the Assistant meant using a
separate checkbox column and a banner above the table. Clicking a row
and checking a row were two different selections.

## Solution

- Unified Logs uses `useTableRowSelection`, so a row click,
Cmd/Ctrl-click, Shift-click, and the checkbox all act on one selection.
The selection resets when the project or filters change, and a linked
`?id=` still restores its log.
- The level indicator and checkbox now share one column. The checkbox
shows on hover, focus, or when the row is selected.
- The detail panel shows every selected log: one log gets the tabs, and
two or more show their combined JSON. Copy-as-JSON and "Explain with AI"
move into the panel header (`LogSelectionActions`), replacing
`RowSelectionHeader`.
- New Shift+↑ / Shift+↓ shortcuts extend the selection, with a hint in
the panel footer. Prev/next navigation follows display order and keeps
the row in view.
- `LogTypeIcon` no longer puts a nested button inside clickable rows.

## Review instructions

1. Click a log, then Shift-click another. The range should be selected
and the panel should show the combined JSON.
2. Cmd-click to add or remove single logs. Use the copy button (or its
shortcut) and "Explain with AI".
3. With the panel open, press Shift+↑ / Shift+↓ to grow and shrink the
selection.
4. Change a filter. The selection should clear.

## Checklist

- [ ] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary

* **New Features**
* Added multi-row selection in Unified Logs, including additive, range,
checkbox, and keyboard selection.
* Added bulk JSON viewing and copying, plus AI-assisted actions for
selected logs.
* Added Shift+Arrow shortcuts to extend selections and improved row
navigation.
* **Accessibility**
* Improved labels and focus behavior for log controls and log type
indicators.
* **Bug Fixes**
* Kept single-log Overview and Raw JSON views available alongside
multi-log selection.
* Applied metadata visibility settings to selected-log actions and
disabled actions for invalid log data.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-25 19:03:01 +10:00

110 lines
4.4 KiB
TypeScript

import { SHORTCUT_REFERENCE_GROUPS } from '../referenceGroups'
import { RegistryDefinations } from '../types'
/**
* Shortcuts scoped to the Unified Logs page (`components/interfaces/UnifiedLogs`).
* They are page-scoped: each is only active while the relevant Unified Logs
* component is mounted.
*
* Grid/detail-panel bindings (prev/next, close) mirror the Logs Explorer
* (`logs-preview`) and Table Editor patterns so the keyboard model stays
* consistent across our data-grid surfaces. Copying selected logs reuses the
* shared `results.copy-*` shortcuts (see `LogSelectionActions`).
*/
export const UNIFIED_LOGS_SHORTCUT_IDS = {
UNIFIED_LOGS_RESET_FOCUS: 'unified-logs.reset-focus',
UNIFIED_LOGS_REFRESH: 'unified-logs.refresh',
UNIFIED_LOGS_DOWNLOAD: 'unified-logs.download',
UNIFIED_LOGS_FOCUS_FILTER: 'unified-logs.focus-filter',
UNIFIED_LOGS_CLEAR_FILTERS: 'unified-logs.clear-filters',
UNIFIED_LOGS_PREV_ROW: 'unified-logs.prev-row',
UNIFIED_LOGS_NEXT_ROW: 'unified-logs.next-row',
UNIFIED_LOGS_EXTEND_PREV_ROW: 'unified-logs.extend-prev-row',
UNIFIED_LOGS_EXTEND_NEXT_ROW: 'unified-logs.extend-next-row',
UNIFIED_LOGS_CLOSE_PANEL: 'unified-logs.close-panel',
}
export type UnifiedLogsShortcutId =
(typeof UNIFIED_LOGS_SHORTCUT_IDS)[keyof typeof UNIFIED_LOGS_SHORTCUT_IDS]
export const unifiedLogsRegistry: RegistryDefinations<UnifiedLogsShortcutId> = {
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_RESET_FOCUS]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_RESET_FOCUS,
label: 'Reset focus in logs',
sequence: ['Mod+.'],
showInSettings: false,
},
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_REFRESH]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_REFRESH,
label: 'Refresh logs',
sequence: ['Shift+R'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.UNIFIED_LOGS,
options: { ignoreInputs: true, registerInCommandMenu: true },
},
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_DOWNLOAD]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_DOWNLOAD,
label: 'Download logs',
sequence: ['Shift+E'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.UNIFIED_LOGS,
options: { ignoreInputs: true, registerInCommandMenu: true },
},
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_FOCUS_FILTER]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_FOCUS_FILTER,
label: 'Focus filter bar',
sequence: ['Shift+F'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.UNIFIED_LOGS,
options: { ignoreInputs: true, registerInCommandMenu: true },
},
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_CLEAR_FILTERS]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_CLEAR_FILTERS,
label: 'Clear filters',
sequence: ['F', 'C'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.UNIFIED_LOGS,
options: { ignoreInputs: true, registerInCommandMenu: true },
},
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_PREV_ROW]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_PREV_ROW,
label: 'Previous log',
sequence: ['ArrowUp'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.UNIFIED_LOGS,
options: { ignoreInputs: true },
},
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_NEXT_ROW]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_NEXT_ROW,
label: 'Next log',
sequence: ['ArrowDown'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.UNIFIED_LOGS,
options: { ignoreInputs: true },
},
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_EXTEND_PREV_ROW]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_EXTEND_PREV_ROW,
label: 'Extend log selection upward',
sequence: ['Shift+ArrowUp'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.UNIFIED_LOGS,
options: { ignoreInputs: true },
},
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_EXTEND_NEXT_ROW]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_EXTEND_NEXT_ROW,
label: 'Extend log selection downward',
sequence: ['Shift+ArrowDown'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.UNIFIED_LOGS,
options: { ignoreInputs: true },
},
[UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_CLOSE_PANEL]: {
id: UNIFIED_LOGS_SHORTCUT_IDS.UNIFIED_LOGS_CLOSE_PANEL,
label: 'Close log details panel',
sequence: ['Escape'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.UNIFIED_LOGS,
options: { ignoreInputs: true, conflictBehavior: 'allow' },
},
}