Repository navigation
feat: Show a disconnect dialog for lost DuckDB WebSocket connections - #763
Conversation
|
Warning Review limit reached
More reviews will be available in 15 minutes and 42 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds connection status tracking ( ChangesDuckDB WebSocket reconnect and connection-lost dialog
Sequence DiagramsequenceDiagram
participant UI as CliDuckDbConnectionLostDialog
participant Connector as WebSocketDuckDbConnector
participant WS as WebSocket
participant RoomStore as roomStore
WS-->>Connector: ws.onclose (unexpected)
Connector->>Connector: setConnectionStatus('disconnected')
Connector-->>UI: subscribeConnectionStatus listener fired
Note over UI: Opens dialog, schedules auto-retry
loop Exponential backoff
UI->>Connector: reconnect()
Connector->>WS: new WebSocket(wsUrl)
WS-->>Connector: ws.onopen → setConnectionStatus('connected')
Connector-->>UI: status = 'connected'
alt Reconnect succeeded
UI->>RoomStore: refreshDbTableSchemas()
UI->>UI: close dialog
else Reconnect failed
UI->>UI: increment attempt, schedule next retry with backoff
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/sqlrooms-cli-ui/src/components/CliDuckDbConnectionLostDialog.tsx (1)
41-41: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd TSDoc for the exported
CliDuckDbConnectionLostDialogfunction.As per coding guidelines,
**/*.{ts,tsx}: Add tsdoc to exported types and functions.📝 Proposed fix
+/** + * Modal dialog shown when the CLI DuckDB WebSocket disconnects. + * Provides manual retry and background auto-reconnect behavior. + */ export function CliDuckDbConnectionLostDialog() {🤖 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 `@apps/sqlrooms-cli-ui/src/components/CliDuckDbConnectionLostDialog.tsx` at line 41, The exported function CliDuckDbConnectionLostDialog is missing TSDoc documentation comments. Add a TSDoc comment block above the function declaration to document its purpose and any relevant details about the component. Include a brief description of what the component does enclosed in /** */ with appropriate `@param` and `@returns` tags if applicable.Source: Coding guidelines
🤖 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 `@apps/sqlrooms-cli-ui/src/components/CliDuckDbConnectionLostDialog.tsx`:
- Around line 97-123: The auto-reconnect effect in the useEffect starting at
line 98 is guarded by !isOpen, which causes reconnection attempts to halt when
users dismiss the dialog via Escape or overlay click. Replace the !isOpen check
with !hasConnectedRef.current to keep reconnection attempts active based on
connection history rather than dialog visibility, and remove isOpen from the
dependency array of the useEffect hook. Additionally, add TSDoc comments to the
exported component at line 41 following the coding guidelines for *.ts and *.tsx
files.
In `@packages/duckdb/src/connectors/WebSocketDuckDbConnector.ts`:
- Around line 224-228: When the auth handshake fails with type 'error' in the
WebSocket message handler, the socket is not being closed and cleared after
rejecting the promise. This leaves the socket reference open, causing subsequent
ensureSocket() calls to treat it as a healthy connection and preventing proper
reconnection. In the error handling block where t === 'error', after setting
opening to null and rejecting the promise, you need to also close the socket
connection and clear the socket reference (similar to how socket cleanup is
typically handled in disconnect scenarios) to ensure a fresh connection attempt
on the next ensureSocket() call.
---
Nitpick comments:
In `@apps/sqlrooms-cli-ui/src/components/CliDuckDbConnectionLostDialog.tsx`:
- Line 41: The exported function CliDuckDbConnectionLostDialog is missing TSDoc
documentation comments. Add a TSDoc comment block above the function declaration
to document its purpose and any relevant details about the component. Include a
brief description of what the component does enclosed in /** */ with appropriate
`@param` and `@returns` tags if applicable.
🪄 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: 0e889ccf-9519-462b-b1cf-8d15338a6a53
📒 Files selected for processing (6)
apps/sqlrooms-cli-ui/src/components/CliDuckDbConnectionLostDialog.tsxapps/sqlrooms-cli-ui/src/room.tsxapps/sqlrooms-cli-ui/src/store.tspackages/duckdb/README.mdpackages/duckdb/src/connectors/WebSocketDuckDbConnector.tspackages/duckdb/src/index.ts
Summary
Testing
Summary by CodeRabbit
New Features
Documentation