Skip to content

fix: PSQL console error flash, Open in Explorer on Windows, silent catch blocks#211

Merged
kix007 merged 2 commits into
mainfrom
fix/psql-error-flash-open-explorer-windows
Jun 1, 2026
Merged

fix: PSQL console error flash, Open in Explorer on Windows, silent catch blocks#211
kix007 merged 2 commits into
mainfrom
fix/psql-error-flash-open-explorer-windows

Conversation

@kix007
Copy link
Copy Markdown
Collaborator

@kix007 kix007 commented Jun 1, 2026

  • PSQL console: commit PsqlConsoleEntry in all early-return paths so error messages don't disappear after the 300ms live-output grace period

  • Open in Explorer: resolve parent directory for empty tabs, add toast feedback on failure (Windows explorer /select, needs existing file)

  • DatabaseExplorer: Drop Role, DDL load failures now show error dialogs

  • MainContent: ER Diagram connection failure shows toast instead of silent return

  • ERDDialog: SVG export failure shows error dialog instead of silent catch

Summary

Related issue

Changes

Testing notes

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

Bug Fixes

  • PSQL console error messages now persist reliably instead of disappearing
  • Improved Windows "Open in Explorer" functionality with better directory fallback handling
  • Added user-facing error notifications for previously silent failures: role deletion, DDL loading, ER diagram connections, and SVG exports

…tch blocks

- PSQL console: commit PsqlConsoleEntry in all early-return paths so error messages don't disappear after the 300ms live-output grace period

- Open in Explorer: resolve parent directory for empty tabs, add toast feedback on failure (Windows explorer /select, needs existing file)

- DatabaseExplorer: Drop Role, DDL load failures now show error dialogs

- MainContent: ER Diagram connection failure shows toast instead of silent return

- ERDDialog: SVG export failure shows error dialog instead of silent catch
@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 12:31pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

Warning

Review limit reached

@kix007, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 40 minutes and 23 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2ca18028-9b42-4da2-b050-c49ba4a9e791

📥 Commits

Reviewing files that changed from the base of the PR and between f3f3d2d and 65ff577.

📒 Files selected for processing (1)
  • src/components/layout/MainContent.tsx
📝 Walkthrough

Walkthrough

This PR adds user-facing error feedback across the application by replacing silent failures and transient error display with persistent dialogs, toasts, and console entries. Database explorer operations, file manager interactions, PSQL execution stages, watch commands, and ERD operations now inform users of failures instead of logging them silently.

Changes

Error Feedback Throughout Components

Layer / File(s) Summary
DatabaseExplorer DDL and role error dialogs
src/components/explorer/DatabaseExplorer.tsx
DDL load failures via double-click or keyboard "Enter" now show "Failed to Load DDL" dialogs. Role drop failures now show "Drop Role Failed" dialogs. Both use derived error messages instead of console-only logging.
MainContent file explorer with toast feedback
src/components/layout/MainContent.tsx
openTabFileInExplorer resolves target file paths with auto-save directory fallback, creates parent directories, and surfaces failures via toast messages for reliable Windows "Open in Explorer" behavior.
MainContent PSQL execution error persistence
src/components/layout/MainContent.tsx
PostgreSQL version detection, CLI tool download (cancelled/failed), and psql availability failures now create persistent PsqlConsoleEntry items instead of flashing and disappearing, with terminal output cleared after persistence.
MainContent watch command error handling
src/components/layout/MainContent.tsx
\watch invoked with no prior query persists error entries. After \watch completes, accumulated output is committed as a persistent entry with error detection from ERROR:/FATAL: lines.
ERD operation error feedback
src/components/layout/MainContent.tsx, src/components/tools/ERDDialog.tsx
MainContent shows toast on ERD connection failure. ERDDialog uses useConfirmDialog to display "Export Failed" dialogs with error details when SVG export fails.
CHANGELOG documentation
CHANGELOG.md
Fixed items document persistent PSQL console errors, reliable file explorer with toast feedback, and user-facing error dialogs for previously silent failure paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Errors now dance where silence dwelt,
Toasts and dialogs softly melt,
From explorer to watch and ERD's call,
Users see what failed most of all! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and comprehensively covers all three main fix categories mentioned in the PR objectives: PSQL console error persistence, Open in Explorer Windows behavior, and silent catch block error handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/psql-error-flash-open-explorer-windows

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.

Copy link
Copy Markdown

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/components/explorer/DatabaseExplorer.tsx (1)

1767-1777: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use the same qualified-name resolution for Enter-triggered DDL loads.

Line 1768 only special-cases tables and otherwise falls back to node.name, so pressing Enter on schema-qualified objects like views/functions/indexes still calls getDDL with the unqualified name. The new dialog will show the failure, but keyboard DDL remains broken for those nodes.

Proposed fix
+const resolveDdlTarget = (node: TreeNode) => {
+  let iconType = node.icon;
+  let targetName = node.name;
+  const fullPath = node.id.split("-").slice(1).join("-");
+
+  if (fullPath.includes(".")) {
+    targetName = fullPath;
+  }
+
+  return { iconType, targetName };
+};
+
 ...
               } else if (isLeafSchemaItem(node.icon)) {
              (async () => {
                 try {
-                  const targetName = node.id.startsWith("table-") ? node.id.replace("table-", "") : node.name;
-                  const ddl = await getDDL(node.icon, targetName);
+                  const { iconType, targetName } = resolveDdlTarget(node);
+                  const ddl = await getDDL(iconType, targetName);
                   if (ddl) {
                     window.dispatchEvent(new CustomEvent("open-query-with-text", {
                       detail: { query: ddl, name: `DDL ${node.name}` }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/explorer/DatabaseExplorer.tsx` around lines 1767 - 1777, The
Enter-key DDL path only special-cases "table-" and falls back to node.name, so
schema-qualified objects lose their qualifier; change the targetName computation
used before calling getDDL to strip any leading type-prefix up to the first
hyphen (e.g., replace /^[^-]+-/ with '') when node.id contains a hyphen,
otherwise use node.name, then pass that targetName to getDDL (references:
node.id, node.name, getDDL).
src/components/layout/MainContent.tsx (1)

1367-1389: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Mark failed \watch runs as errors.

The loop above appends ERROR in watch: ..., but Line 1388 only checks for ERROR:/FATAL:. A failed watch therefore gets persisted as a non-error console entry.

Proposed fix
-              hasErrors: watchOutput.some(l => l.startsWith("ERROR:") || l.startsWith("FATAL:")),
+              hasErrors: watchOutput.some(
+                l =>
+                  l.startsWith("ERROR:") ||
+                  l.startsWith("FATAL:") ||
+                  l.startsWith("ERROR in watch:")
+              ),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/layout/MainContent.tsx` around lines 1367 - 1389, The
persisted watch entry is not flagged as an error because hasErrors only checks
for "ERROR:"/ "FATAL:" but the loop appends "ERROR in watch: ..."; update the
hasErrors computation when creating the watchEntry (where PsqlConsoleEntry is
constructed using watchCmd, watchOutput from psqlOutputRef.current and
executionTime) to also detect the appended watch failure string (e.g., lines
starting with "ERROR in watch" or containing "ERROR in watch:") — i.e., change
the predicate used for hasErrors (currently l.startsWith("ERROR:") ||
l.startsWith("FATAL:")) to include the watch-error pattern so failed watch runs
are marked as errors.
src/components/tools/ERDDialog.tsx (1)

241-281: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add confirmDialog to the exportSVG useCallback dependency list

exportSVG calls confirmDialog.dialog(...), but its dependency array only includes selectedDatabase, which can lead to stale closure behavior / hook-lint drift.

Suggested fix
-  }, [selectedDatabase]);
+  }, [selectedDatabase, confirmDialog]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/tools/ERDDialog.tsx` around lines 241 - 281, The exportSVG
useCallback captures confirmDialog but only lists selectedDatabase in its
dependency array, risking a stale closure; update the useCallback dependencies
for exportSVG to include confirmDialog (e.g., useCallback(...,
[selectedDatabase, confirmDialog]) or the specific dialog method reference) so
the latest confirmDialog instance is used when calling confirmDialog.dialog(...)
inside exportSVG.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/layout/MainContent.tsx`:
- Around line 996-1009: The current code calls clearPsqlOutput() immediately
after updateTabState(...), which also clears stashPsqlOutputRef and can lead to
a blank PSQL frame on a split React commit; instead, only clear the live
psqlOutput state here (e.g., set psqlOutput: [] in updateTabState) and do NOT
call clearPsqlOutput() so stashPsqlOutputRef remains populated until the next
command starts; apply this change to the error-path blocks around updateTabState
in the functions/blocks using updateTabState, clearPsqlOutput, psqlOutputRef,
stashPsqlOutputRef and runningCmdRef (the same pattern at the other locations
you noted).

---

Outside diff comments:
In `@src/components/explorer/DatabaseExplorer.tsx`:
- Around line 1767-1777: The Enter-key DDL path only special-cases "table-" and
falls back to node.name, so schema-qualified objects lose their qualifier;
change the targetName computation used before calling getDDL to strip any
leading type-prefix up to the first hyphen (e.g., replace /^[^-]+-/ with '')
when node.id contains a hyphen, otherwise use node.name, then pass that
targetName to getDDL (references: node.id, node.name, getDDL).

In `@src/components/layout/MainContent.tsx`:
- Around line 1367-1389: The persisted watch entry is not flagged as an error
because hasErrors only checks for "ERROR:"/ "FATAL:" but the loop appends "ERROR
in watch: ..."; update the hasErrors computation when creating the watchEntry
(where PsqlConsoleEntry is constructed using watchCmd, watchOutput from
psqlOutputRef.current and executionTime) to also detect the appended watch
failure string (e.g., lines starting with "ERROR in watch" or containing "ERROR
in watch:") — i.e., change the predicate used for hasErrors (currently
l.startsWith("ERROR:") || l.startsWith("FATAL:")) to include the watch-error
pattern so failed watch runs are marked as errors.

In `@src/components/tools/ERDDialog.tsx`:
- Around line 241-281: The exportSVG useCallback captures confirmDialog but only
lists selectedDatabase in its dependency array, risking a stale closure; update
the useCallback dependencies for exportSVG to include confirmDialog (e.g.,
useCallback(..., [selectedDatabase, confirmDialog]) or the specific dialog
method reference) so the latest confirmDialog instance is used when calling
confirmDialog.dialog(...) inside exportSVG.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 54b2095f-6959-4959-b212-a37c0aeaf1f8

📥 Commits

Reviewing files that changed from the base of the PR and between c3de7a0 and f3f3d2d.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • src/components/explorer/DatabaseExplorer.tsx
  • src/components/layout/MainContent.tsx
  • src/components/tools/ERDDialog.tsx

Comment thread src/components/layout/MainContent.tsx
…rame

Replace clearPsqlOutput() with inline ref+state clear at 8 entry-commit
sites so stashPsqlOutputRef survives the commit. This prevents the
PsqlWindow liveOutput fallback from going blank during split React
commits on WebView2/Windows.
@kix007 kix007 merged commit d294748 into main Jun 1, 2026
10 checks passed
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