Skip to content

feat: tab context menu, inline quoting, session restore, handleSave target DB, PSQL console windows fix#210

Merged
kix007 merged 1 commit into
mainfrom
feat/editor-tab-context-menu-save-fixes
Jun 1, 2026
Merged

feat: tab context menu, inline quoting, session restore, handleSave target DB, PSQL console windows fix#210
kix007 merged 1 commit into
mainfrom
feat/editor-tab-context-menu-save-fixes

Conversation

@kix007
Copy link
Copy Markdown
Collaborator

@kix007 kix007 commented Jun 1, 2026

Summary

Adds a right-click context menu to query editor tabs (Close, Close Others, Close All, Rename, Duplicate, Copy File Path, Open in Explorer), fixes inline-editing SQL to properly quote identifiers with quoteIdentifier(), fixes session restore to show tabs without requiring a connection click first, fixes handleSave to respect tab-scoped target databases (preventing "relation does not exist" errors), and fixes PSQL Console output disappearing on Windows WebView2 due to React 18 batch splitting.

Related issue

N/A

Changes

  • Tab context menu: Right-click on any query tab shows Close, Close Others, Close All, Rename, Duplicate, Copy File Path, Open in Explorer. Copy File Path falls back to textarea + execCommand('copy') for Linux WebKitGTK where navigator.clipboard.writeText may be unavailable. Open in Explorer creates parent directories (mkdir recursive) before calling revealItemInDir, with openPath(parentDir) as fallback.
  • Inline editing quoting: INSERT/UPDATE/DELETE SQL generated by results-grid row edits now quotes all table/column names with quoteIdentifier() — handles mixed-case, reserved words, and schema-qualified ("schema"."table") identifiers correctly across PostgreSQL, MySQL, SQLite, and CockroachDB.
  • Session restore: Tab strip renders on queryTabs.length > 0 and editor renders on activeTab existing, removing the isDatabaseReady gate. Toolbar (Run/Save/Format) stays gated behind isDatabaseReady since those need a live DB.
  • handleSave target DB: Looks up activeTab.target for the tab-scoped database name, resolves the target connection's credentials via connections.find(), and always creates a dedicated Database.load(...) instead of reusing currentDb. Prevents "relation does not exist" when saving rows from a tab scoped to a different database/schema.
  • PSQL Console Windows fix: Stashes last non-empty psqlOutput in a ref in MainContent, always passes it as liveOutput. PsqlWindow uses a showLiveGrace state that keeps the live section visible up to 300ms post-execution (cancelled early when entries reflect the output). Bridges the WebView2 React 18 batch-split gap.
  • Permission: Added opener:allow-open-path to src-tauri/capabilities/default.json (needed for the openPath fallback in Open in Explorer).

Testing notes

  • npx tsc --noEmit passes with zero errors.
  • Manual testing on Linux: tab context menu all actions work; Copy File Path copies path; Open in Explorer opens Nautilus to the file; inline editing with mixed-case table names generates properly quoted SQL; session restore shows tabs immediately on launch; save row adds correctly without "relation does not exist"; PSQL console output persists after execution.
  • No new npm or cargo dependencies added.
  • No storage-layer changes (no touch to storage.rs or updater.rs).
  • No AI assistant code path touched.

Checklist

  • I built the app locally (npm run tauri dev or npm run tauri build) and verified the change works.
  • Frontend typecheck passes (npx tsc --noEmit).
  • Rust build passes (cargo check --manifest-path src-tauri/Cargo.toml).
  • If I added a new #[tauri::command], I registered it in src-tauri/src/lib.rs's generate_handler!.
  • If user-visible: I added a line to CHANGELOG.md under ## [Unreleased].
  • If this touches storage.rs, updater.rs, capabilities/, or the AI assistant code path, I flagged it in the summary above.

Summary by CodeRabbit

Release Notes

  • New Features

    • Right-click context menu on tabs with rename, duplicate, and close options
    • Copy file paths and open files directly in File Explorer
    • Improved SQL query handling with proper identifier support
  • Bug Fixes

    • Tab visibility now restored correctly after reconnecting
    • Windows PSQL console output no longer disappears after commands
    • SQL editing and row operations now handle identifiers correctly
    • Queries now execute against the correct database

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
queryden Ready Ready Preview, Comment Jun 1, 2026 10:43am

@kix007 kix007 merged commit c3de7a0 into main Jun 1, 2026
9 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 29e95c4a-3f9f-4ee3-ab83-44d3acbbdeb5

📥 Commits

Reviewing files that changed from the base of the PR and between 91201bc and 187c6b3.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • src-tauri/capabilities/default.json
  • src/components/layout/MainContent.tsx
  • src/components/ui/PsqlWindow.tsx

📝 Walkthrough

Walkthrough

PR #210 improves tab-based query editing by adding a per-tab right-click context menu for file and tab management, applying SQL identifier quoting to all row and save operations, routing INSERT/UPDATE execution through the active tab's explicit connection instead of global state, and preserving PSQL terminal output across live execution transitions.

Changes

Tab Editing & Execution Improvements

Layer / File(s) Summary
Tab Context Menu UI & File Utilities
src/components/layout/MainContent.tsx
Adds right-click context menu with close/rename/duplicate/file-action callbacks; imports menu components and tab-specific icons; defines getTabAutoSavePath, copyToClipboard, and openTabFileInExplorer helpers; renders context menu with toast feedback for copy-path action.
SQL Identifier Quoting in Row Operations
src/components/layout/MainContent.tsx
Enhances table-name regex to support quoted identifiers and schema-qualified names; updates UPDATE and DELETE builders to quote identifiers via qid helper and generate NULL-safe WHERE clauses.
Tab-Scoped Save Routing & Identifier Quoting
src/components/layout/MainContent.tsx
Reworks handleSave to resolve connection from active tab's explicit target (not global currentDb); applies identifier quoting and NULL-safe predicates to INSERT/UPDATE/ADD builders; updates hook dependencies to reflect tab-scoped connection selection.
PSQL Output Preservation & Live Grace Window
src/components/layout/MainContent.tsx, src/components/ui/PsqlWindow.tsx
Introduces toast state; stashes last non-empty PSQL output to avoid blanking during state transitions; renders query tabs when tabs exist; adds showLiveGrace state in PsqlWindow to keep live section visible for 300ms after execution, or until entries catch up.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • openidle-dev/queryden#203: Adds debounced filesystem writer for per-tab autosave files whose paths are resolved by utilities introduced in this PR.

Poem

🐰 Tabs now speak with context—
Right-click, rename, duplicate cheer,
SQL names safely quoted,
Save routes find their target near.
Terminal remembers its last breath,
While grace waits gentle, never death.

✨ 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/editor-tab-context-menu-save-fixes

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.

❤️ Share

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

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