-
Notifications
You must be signed in to change notification settings - Fork 4
fix: enable sidebar toggle hotkeys in insert mode and sidebar focus #17
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
base: master
Are you sure you want to change the base?
Conversation
…ry keys Add multiple keybinding alternatives for sidebar toggle (Ctrl+Shift+B, Ctrl+\, Ctrl+4) to address terminal compatibility issues. Opening the sidebar now automatically focuses the Schema section. Enable cell editing for tables without a detected primary key by using a ctid-based WHERE clause fallback that matches the first row by all column values. Validate that updates affect exactly 1 row and provide clear feedback when ambiguous. Improve query parser to handle quoted identifiers, schema prefixes, and complex SELECT statements when extracting table names. Add --debug-keys flag to help troubleshoot keybinding issues in different terminals.
Sidebar toggle hotkeys (Ctrl+B, Ctrl+Shift+B, Ctrl+\, Ctrl+4) were not working in insert mode and when sidebar had focus. Added handling for Action::ToggleSidebar in insert mode and direct key handling in handle_sidebar_key function.
WalkthroughAdds global keyboard shortcuts (Ctrl+B, Ctrl+Shift+B, Ctrl+, Ctrl+4) for sidebar visibility toggling with automatic focus management. Introduces new Action enum variants ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Areas requiring extra attention:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
crates/tsql/src/app/app.rs (2)
2554-2575: Sidebar Ctrl+B / Ctrl+\ handling inhandle_sidebar_keylooks correct but duplicates toggle logicThe new arms correctly ensure Ctrl+B / Ctrl+Shift+B / Ctrl+\ / Ctrl+4 close the sidebar and return focus to the query even when the sidebar has focus, including in insert mode (since this path is independent of
Mode). Note that in Normal mode Ctrl+Shift+B and Ctrl+\ are already handled earlier inon_key, so these arms primarily cover Ctrl+B and all four chords whenmode != Mode::Normal, which is consistent with the PR intent.You now have essentially identical sidebar-toggling logic in several places (global Normal-mode handler, grid
Action::ToggleSidebar, editor Normal/InsertAction::ToggleSidebar, and here). Consider extracting a smallfn toggle_sidebar(&mut self)helper (ortoggle_sidebar_from_sidebarvs. generic) to keep behavior consistent and reduce future drift.
5722-5829: ** targetedclippy::too_many_argumentsallow ongrid_mouse_targetis acceptable, but consider bundling args**Adding
#[allow(clippy::too_many_arguments)]ongrid_mouse_targetis a pragmatic way to keepcargo clippy -D warningshappy for a UI helper that naturally needs several parameters (position, viewport, offsets, widths). Given the function’s focused scope and existing tests aroundgrid_mouse_target, this is reasonable.Longer-term, you might consider grouping some of the related parameters (e.g., row/col offsets + counts +
show_row_numbers+col_widths) into a small struct to remove the need for theallowand make call sites a bit clearer, but that’s optional.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
crates/tsql/src/app/app.rs(4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rs: Runcargo fmt --allto format the code before committing changes
Runcargo clippy --all --all-targets -- -D warningsto check for lints and fix them before pushing changes
**/*.rs: Userustfmtwith default settings as the source of truth for code formatting in Rust files
Usesnake_casefor function and module names in Rust
UseCamelCasefor type and trait names in Rust
UseSCREAMING_SNAKE_CASEfor constant names in Rust
Keep changes focused and prefer small, composable helper functions over large UI/app methods
Place unit tests colocated with code using#[cfg(test)]modules for pure logic testing
Files:
crates/tsql/src/app/app.rs
🧠 Learnings (1)
📚 Learning: 2025-12-14T16:15:31.051Z
Learnt from: CR
Repo: fcoury/tsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-14T16:15:31.051Z
Learning: Applies to **/*.rs : Keep changes focused and prefer small, composable helper functions over large UI/app methods
Applied to files:
crates/tsql/src/app/app.rs
🧬 Code graph analysis (1)
crates/tsql/src/app/app.rs (1)
crates/tsql/src/ui/grid.rs (2)
row(827-829)row(851-853)
🔇 Additional comments (2)
crates/tsql/src/app/app.rs (2)
3243-3251:build_update_where_clausecall now correctly passesOption<&str>Switching to
Some(original_value.as_str())matches theedited_original_value: Option<&str>parameter type and avoids unnecessary reference nesting. The borrow is confined to the call site and doesn’t outliveoriginal_value, so lifetimes are sound. No further changes needed here.
4529-4543: Insert-mode handling forToggleSidebarandShowHistoryis consistent and well‑scopedWiring
Action::ToggleSidebarandAction::ShowHistoryinto the Insert-mode branch ofhandle_editor_keybrings Insert behavior in line with Normal mode: the sidebar toggle mirrors the existing implementations (usingfocus_schema()when opening, returning focus to Query when closing from a sidebar focus), and history opens viaopen_history_picker(). Earlyreturns ensure these actions don’t fall through toself.editor.input(key).This cleanly fixes the missing Insert-mode bindings without unintended side effects.
Sidebar toggle hotkeys (Ctrl+B, Ctrl+Shift+B, Ctrl+, Ctrl+4) were not working in insert mode and when sidebar had focus. Added handling for Action::ToggleSidebar in insert mode and direct key handling in handle_sidebar_key function.
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.