Skip to content

feat: single-click favorite to insert query in editor#430

Merged
datlechin merged 2 commits intomainfrom
feat/favorites-single-click-415
Mar 22, 2026
Merged

feat: single-click favorite to insert query in editor#430
datlechin merged 2 commits intomainfrom
feat/favorites-single-click-415

Conversation

@datlechin
Copy link
Collaborator

@datlechin datlechin commented Mar 22, 2026

Summary

Test plan

  • Single-click a favorite → query appears in editor
  • Click the same favorite again → no duplicate insert
  • Click a different favorite, then click the first again → inserts again
  • Deselect (click empty area), then click the same favorite → inserts again
  • Cmd+click multiple favorites → no insert triggered
  • Delete key with multi-select → still works as before
  • Double-click a favorite → still inserts (existing behavior)

Closes #415 (partial — favorites quick-open item)

Summary by CodeRabbit

  • Bug Fixes
    • Fixed favorites sidebar selection so selecting a favorite reliably inserts it into the editor.
    • Prevented duplicate insertions by ensuring only newly selected favorites trigger insertion; selection clearing resets the tracking state.

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa801ec6-b36c-4ded-bdaf-2d6126374b60

📥 Commits

Reviewing files that changed from the base of the PR and between 108b167 and 6e7d70a.

📒 Files selected for processing (1)
  • TablePro/Views/Sidebar/FavoritesTabView.swift

📝 Walkthrough

Walkthrough

Detects single newly selected favorite in the sidebar list, resolves its SQLFavorite from the currently filtered tree (matching the list row tag format), calls coordinator?.insertFavorite to insert it into the editor, and tracks the last-inserted favorite ID; clears tracking when selection is emptied.

Changes

Cohort / File(s) Summary
Favorite selection → editor insertion
TablePro/Views/Sidebar/FavoritesTabView.swift
Added lastInsertedFavoriteId state; on-change logic for selectedFavoriteIds that detects exactly-one newly selected favorite via set difference, finds the matching SQLFavorite from the filtered favorites tree (matching tag "fav-<id>"), calls coordinator?.insertFavorite(sqlFavorite), stores the ID, and resets it when selection becomes empty.

Sequence Diagram

sequenceDiagram
    participant User
    participant FavoritesTabView
    participant Coordinator
    participant Editor

    User->>FavoritesTabView: Select favorite row (List tag "fav-<id>")
    FavoritesTabView->>FavoritesTabView: onChange(selectedFavoriteIds)
    FavoritesTabView->>FavoritesTabView: Compute set difference vs previous selection
    alt Exactly one new selection && differs from lastInsertedFavoriteId
        FavoritesTabView->>FavoritesTabView: Resolve SQLFavorite from filtered tree by id
        FavoritesTabView->>Coordinator: insertFavorite(SQLFavorite)
        Coordinator->>Editor: Insert SQL into editor
        FavoritesTabView->>FavoritesTabView: Update lastInsertedFavoriteId
    end
    User->>FavoritesTabView: Deselect all
    FavoritesTabView->>FavoritesTabView: Reset lastInsertedFavoriteId to nil
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit finds a favorite, quick and spry,
Hops it into editor with a joyful sigh,
One selection, one little leap,
Into the query it softly creeps,
🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: enabling single-click insertion of favorite queries into the editor, which directly matches the primary objective.
Linked Issues check ✅ Passed The PR successfully addresses the coding requirement from issue #415 regarding improving Favorites SQL scripts UX by enabling simple-click execution in the editor.
Out of Scope Changes check ✅ Passed All changes are scoped to enabling single-click favorite insertion with proper guards against multi-select operations, which is directly related to the stated objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/favorites-single-click-415

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

@datlechin datlechin merged commit f750425 into main Mar 22, 2026
2 checks passed
@datlechin datlechin deleted the feat/favorites-single-click-415 branch March 22, 2026 14:03
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.

Feedback and Feature Requests for TablePro: UI Interactions and Query Enhancements

1 participant