Skip to content

Conversation

@ric-v
Copy link
Member

@ric-v ric-v commented Dec 4, 2025

This pull request refactors the notebook creation commands for PostgreSQL extensions and foreign tables to improve maintainability and user experience. The main changes introduce a new MarkdownUtils helper for generating markdown content, replace hardcoded HTML with reusable markdown utilities, enhance error handling, and expand the foreign table creation notebook with more comprehensive templates and guidelines.

Markdown and Notebook Content Refactoring

  • Replaced hardcoded HTML strings in notebook markdown cells with reusable functions from the new MarkdownUtils helper, making the code more maintainable and markdown output more consistent. This affects commands for enabling extensions, extension operations, dropping extensions, and all foreign table operations. (src/commands/extensions.ts, src/commands/foreignTables.ts) [1] [2] [3] [4] [5] [6] [7] [8] [9]

  • Expanded the foreign table creation notebook to include multiple templates (basic, PostgreSQL-to-PostgreSQL, file-based), design guidelines, common patterns, and management operations, providing users with richer documentation and ready-to-use code snippets. (src/commands/foreignTables.ts)

Error Handling Improvements

  • Replaced direct calls to vscode.window.showErrorMessage with a centralized error handler (ErrorHandlers.handleCommandError) for all notebook creation commands, ensuring consistent error reporting and easier maintenance. (src/commands/extensions.ts, src/commands/foreignTables.ts) [1] [2] [3] [4] [5] [6]

Foreign Table Operations Enhancements

  • Added a new markdown cell for "Drop Foreign Table" in the foreign table operations notebook for clearer separation and documentation of destructive actions. (src/commands/foreignTables.ts)

  • Updated the operations table in the foreign table operations notebook to use the new markdown utility, improving readability and maintainability. (src/commands/foreignTables.ts)

These changes collectively improve code clarity, maintainability, and the quality of the notebook experience for users.

@ric-v ric-v requested a review from Copilot December 4, 2025 19:47
Copilot finished reviewing on behalf of ric-v December 4, 2025 19:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a comprehensive AI chat assistant feature to the PostgreSQL Explorer extension, along with significant refactoring of notebook creation commands to use reusable markdown utilities. The changes introduce modular services for chat functionality, improve error handling consistency, and enhance the user experience with rich notebook templates.

Key changes:

  • New AI Chat View with support for multiple AI providers (VS Code LM, OpenAI, Anthropic, Gemini, custom)
  • Database object mention system (@mentions) with schema introspection
  • Chat session management with history and persistence
  • Refactored notebook commands using new MarkdownUtils helper for consistent formatting
  • Centralized error handling across all commands

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/providers/chat/webviewHtml.ts 2359-line webview HTML template with embedded CSS and JavaScript for chat UI
src/providers/chat/types.ts Type definitions for chat messages, file attachments, DB mentions, and sessions
src/providers/chat/index.ts Module exports for chat functionality
src/providers/chat/SessionService.ts Service for managing chat session storage and persistence
src/providers/chat/DbObjectService.ts Service for fetching and caching database object metadata
src/providers/chat/AiService.ts Service for AI provider integration with multiple backends
src/providers/ChatViewProvider.ts Main controller for the chat view with message handling
src/extension.ts Integration of chat view and error handling updates
src/commands/helper.ts New utilities for markdown generation and error handling (imported, not shown in diff)
Multiple command files Refactored to use MarkdownUtils and centralized error handling
package.json Version bump to 0.4.0 and main entry point change

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +7 to +10
FormatHelpers,
ErrorHandlers,
SQL_TEMPLATES,
ObjectUtils
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports FormatHelpers, ObjectUtils, SQL_TEMPLATES.

Suggested change
FormatHelpers,
ErrorHandlers,
SQL_TEMPLATES,
ObjectUtils
ErrorHandlers

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +10
FormatHelpers,
ErrorHandlers,
SQL_TEMPLATES,
ObjectUtils
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports FormatHelpers, ObjectUtils, SQL_TEMPLATES.

Suggested change
FormatHelpers,
ErrorHandlers,
SQL_TEMPLATES,
ObjectUtils
ErrorHandlers

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +12
FormatHelpers,
ErrorHandlers,
SQL_TEMPLATES,
ObjectUtils
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports FormatHelpers, ObjectUtils, SQL_TEMPLATES.

Suggested change
FormatHelpers,
ErrorHandlers,
SQL_TEMPLATES,
ObjectUtils
ErrorHandlers

Copilot uses AI. Check for mistakes.
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.

1 participant