Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fcoury
Copy link
Owner

@fcoury fcoury commented Dec 14, 2025

Summary

  • Fixed a bug where clicking on items in the Schema tree sidebar would select the wrong item (several rows above where clicked)
  • The issue was that handle_schema_click was converting absolute screen coordinates to relative coordinates before passing to TreeState::click_at(), but the tree widget expects absolute coordinates

Test plan

  • Click on various items in the Schema sidebar tree and verify the correct item gets selected
  • Test clicking on items at different scroll positions
  • Verify connections list click behavior is still correct

Summary by CodeRabbit

  • Bug Fixes

    • Fixed coordinate handling for schema clicks in the sidebar to ensure accurate interaction processing.
  • Style

    • Reformatted import statements for improved code readability.

✏️ Tip: You can customize this high-level summary in your review settings.

TreeState's click_at method expects absolute screen coordinates, not
relative ones. The tree widget stores absolute y positions during
render, so we now pass mouse coordinates directly instead of converting
to relative coordinates.
@coderabbitai
Copy link

coderabbitai bot commented Dec 14, 2025

Walkthrough

The PR refactors sidebar click handling to use absolute screen coordinates instead of relative coordinates, and updates the corresponding parameter naming and documentation. An import list is also reformatted for consistency in app.rs without functional changes.

Changes

Cohort / File(s) Summary
Import reformatting
crates/tsql/src/app/app.rs
Reflowed public UI import list across lines; no functional changes to imported symbols or visibility.
Coordinate system update
crates/tsql/src/ui/sidebar.rs
Changed schema click handling from relative to absolute coordinates; renamed schema_area parameter to _schema_area; updated comments clarifying TreeState::click_at expects absolute screen coordinates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Extra attention: The coordinate system change in handle_schema_click requires verification that passing absolute instead of relative coordinates aligns with how TreeState::click_at processes them and doesn't introduce off-by-one or positioning errors elsewhere in the sidebar interaction flow.

Possibly related PRs

Poem

🐰 Coordinates shift from relative's dance,
To absolute truth at a glance,
Sidebar clicks now know their place,
In screen-space's proper embrace! 🎯

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: correct schema sidebar click offset bug' directly and clearly describes the main change: fixing a coordinate offset bug in the schema sidebar click handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fcoury/sidebar-click-offset

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 (1)
crates/tsql/src/ui/sidebar.rs (1)

419-432: Coordinate space is correct; border click filtering is optional.

The use of absolute coordinates Position::new(x, y) is appropriate—TreeState::click_at() expects absolute terminal/frame coordinates, which aligns with your implementation. If you want to improve UX by preventing accidental selection changes when clicking on the schema block border or title row, you can optionally add a check to ignore clicks on or above the schema area's top boundary:

 fn handle_schema_click(
     &mut self,
     x: u16,
     y: u16,
     _schema_area: Rect,
 ) -> (Option<SidebarAction>, Option<SidebarSection>) {
+    // Optional: ignore clicks on the border/title row(s).
+    if let Some(area) = self.schema_area {
+        if y <= area.y {
+            return (None, Some(SidebarSection::Schema));
+        }
+    }
+
     // TreeState's click_at expects absolute screen coordinates, not relative ones.
     // The tree widget stores absolute y positions in last_rendered_identifiers
     // during render, so we pass the mouse coordinates directly.
     use ratatui::layout::Position;
     self.schema_state.click_at(Position::new(x, y));

     (None, Some(SidebarSection::Schema))
 }
📜 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 55072f5 and 643d479.

📒 Files selected for processing (2)
  • crates/tsql/src/app/app.rs (1 hunks)
  • crates/tsql/src/ui/sidebar.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Run cargo fmt --all to format the code before committing changes
Run cargo clippy --all --all-targets -- -D warnings to check for lints and fix them before pushing changes

Files:

  • crates/tsql/src/ui/sidebar.rs
  • crates/tsql/src/app/app.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test (windows-latest)
🔇 Additional comments (1)
crates/tsql/src/app/app.rs (1)

29-38: Import-list reflow only — OK.
No functional delta here; just ensure the branch is formatted/linted per repo guidelines (cargo fmt --all, cargo clippy --all --all-targets -- -D warnings).

@fcoury fcoury merged commit fd2f081 into master Dec 14, 2025
6 checks passed
@fcoury fcoury deleted the fcoury/sidebar-click-offset branch December 14, 2025 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants