-
-
Notifications
You must be signed in to change notification settings - Fork 60
feat(admin): Add terminal-style SQL Shell for ClickHouse tracing #7667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
phacops
wants to merge
23
commits into
master
Choose a base branch
from
feat/sql-shell-terminal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,350
−9
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a new SQL Shell page to snuba-admin that provides a terminal-style interface for executing ClickHouse queries with tracing. Features include: - Dark terminal aesthetic with monospace font - Shell commands: USE, SHOW STORAGES, PROFILE ON/OFF, TRACE RAW/FORMATTED - SQL query execution with full tracing support - Command history with up/down arrow navigation (persisted to localStorage) - Keyboard shortcuts: Enter to execute, Ctrl+L to clear - Query results displayed in table format with trace summaries - Prominent link in nav bar for easy access Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
345f804 to
b3b15da
Compare
Extend the SQL Shell component to support both tracing and system query modes: - Add mode prop to SQLShell component (tracing/system) - System mode adds: HOST command, SHOW HOSTS, SUDO ON/OFF - System mode requires both storage and host selection - Sudo mode shows red border warning - Add SystemShellPage as new nav entry after System Queries - Separate command history per mode Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove title display from Body component - Add visual highlight for active nav item (blue left border + background) - Adjust shell height to use full available space Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- tracing-shell uses same permission as tracing - system-shell uses same permission as system-queries Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- GitHub-inspired dark theme with gradient background - Better color palette (blues, greens, oranges) - Improved typography with better spacing and line height - Custom scrollbar styling - Better result boxes with rounded corners - Styled error messages with left border accent - Hover effects on storage list and table rows - Animated executing indicator with pulsing dot - Better sudo mode warning appearance - Overall more polished and modern look Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Decrease body margin from 20px to 10px - Reduce shell internal padding (output, input, status areas) - Increase shell height to use reclaimed space Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Tab completes storage names after "USE " command - Tab completes host names after "HOST " command (system mode) - Shows matching options when multiple completions exist - Completes to common prefix when possible - Updated status bar hint to show Tab shortcut Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Display matching suggestions in a bar above the input - Clickable suggestions to select directly - Clear suggestions when typing continues - Styled with subtle blue highlight Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Handle error objects returned from API (not just Error instances) - Extract error.error, error.message, or stringify the object - Ensures error messages are displayed in the shell Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds keyboard shortcuts commonly found in clickhouse-client and other SQL shells: - Ctrl+C: Clear current input - Ctrl+L: Clear screen - Ctrl+U: Delete from cursor to start of line - Ctrl+K: Delete from cursor to end of line - Ctrl+W: Delete word before cursor - Ctrl+A: Move cursor to start of line - Ctrl+E: Move cursor to end of line - Tab: Autocomplete - Up/Down: Navigate command history Also updated HELP output to document all shortcuts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Check for null/undefined result objects - Handle null/undefined cells (display as "NULL") - Handle undefined rows gracefully - Handle undefined column definitions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Check for null/undefined summary and query_summaries in FormattedTraceOutput - Check for null node in NodeSummary - Check for null/undefined traceOutput in RawTraceOutput - Show "No trace data available" message instead of crashing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The API returns errors as objects with {code, message, type} structure.
ErrorOutput was expecting a string and trying to render the object directly,
causing React to crash with "Objects are not valid as a React child".
- Update ErrorOutput to handle string, object, and any error types
- Extract message from error.message or error.error fields
- Fall back to JSON.stringify for unknown error shapes
- Update ShellHistoryEntry type to accept object errors
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Only show the error message, not the full stack trace. ClickHouse errors contain "Stack trace:" followed by the trace - now we strip everything after that marker for cleaner error display. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement windowed virtualization using @tanstack/react-virtual to optimize rendering of shell history entries. Previously all history was rendered directly to the DOM, which could slow down the page as history grew large. Changes: - Add @tanstack/react-virtual as direct dependency - Refactor ShellOutput to use virtualization with dynamic height measurement and 5-item overscan for smooth scrolling - Add smart auto-scroll that only follows new entries when user is at bottom of the output - Add MAX_HISTORY_ENTRIES limit (500) to prevent unbounded growth - Move scroll container management into ShellOutput component Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
Add overflow-y: auto to the navigation sidebar so it can scroll when there are more nav items than fit in the viewport. Also update the parent flex container with minHeight: 0 and overflow: hidden to properly enable flex child scrolling. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
- Replace single-line input with textarea for multi-line SQL queries - Enter executes the query, Shift+Enter adds a new line - Textarea auto-resizes based on content (up to 10 lines) - Normalize queries before API calls (collapse newlines to spaces) - Update styles for proper textarea alignment and scrolling Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create ShellInput component using CodeMirror with SQL language support - GitHub Dark theme colors for syntax highlighting: - Keywords (SELECT, FROM, WHERE): red/coral - Strings: light blue - Numbers: cyan - Comments: gray italic - Functions: purple - Special values (NULL, TRUE, FALSE): cyan bold - Refactor shell.tsx to use new ShellInput component - Use Compartments for dynamic placeholder/disabled state updates Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add CollapsibleSection component for expandable result areas - Results section expanded by default, trace sections collapsed - Compact table styling with smaller fonts and padding - NULL values displayed in gray italic - Truncated cell content with ellipsis for long values - Scrollable raw trace output with max height - Badge showing row/node/line counts in section headers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create command_parser.ts with registry-based command definitions - Each command defined with pattern, parser function, and mode restrictions - Easy to add new commands by adding entries to COMMANDS array - Export getAvailableCommands() for potential autocomplete/help generation - Remove inline parseCommand from shell.tsx Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Screenshots
Features
Commands
Tracing Shell
USE <storage>- Select storageSHOW STORAGES- List available storagesPROFILE ON/OFF- Toggle profile event collectionTRACE RAW/FORMATTED- Toggle trace output formatHELP- Show available commandsCLEAR- Clear terminal outputSystem Shell
USE <storage>- Select storageHOST <host:port>- Select target hostSHOW STORAGES/SHOW HOSTS- List available optionsSUDO ON/OFF- Toggle sudo mode (red border warning when enabled)HELP- Show available commandsCLEAR- Clear terminal outputExtensible Command Parser
command_parser.tsCOMMANDSarraySQL Syntax Highlighting
#ff7b72)#a5d6ff)#79c0ff)#8b949e)#d2a8ff)#79c0ff)Compact Collapsible Results
Multi-line Input
Keyboard Shortcuts (clickhouse-client style)
EnterShift+EnterTab↑/↓Ctrl+CCtrl+LCtrl+UCtrl+KCtrl+WCtrl+ACtrl+EAutocomplete
TabafterUSEto autocomplete storage namesTabafterHOSTto autocomplete host names (system shell)Virtualized Scrollback
@tanstack/react-virtualfor windowed virtualization of history entriesScrollable Navigation Sidebar
Visual Design
#0d1117→#161b22)Error Handling
{code, message, type}structureOther Features
Test plan
snuba admin --debugHELP,USE,SHOW STORAGES🤖 Generated with Claude Code