Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

Description

Fatal errors (module loading failures, invalid config files) were only logged to the output channel, making them easy to miss. Users had no visible indication when Prettier stopped working.

Changes

New NotificationService (src/NotificationService.ts)

  • Shows error notifications with actionable buttons (View Output, Open Settings)
  • Detects if prettier is in package.json but not installed → suggests running npm install
  • Deduplicates notifications per session to prevent spam
  • Respects user preference via configuration setting

Configuration Option (prettier.enableErrorNotifications)

  • New setting that defaults to true
  • Allows users to disable error notifications if preferred
  • When disabled, errors are still logged to the output channel

ModuleResolver Integration

  • Module load failures → notification with package.json detection
  • Invalid prettierPath setting → notification with "Open Settings" button
  • Invalid/unresolvable config files → notification

Example

When prettier is listed in package.json but not installed:

[Error Notification]
Prettier: Failed to load module. Prettier is listed in package.json 
but could not be loaded. Please run npm install (or yarn/pnpm install).

[View Output] [Dismiss]

When prettierPath setting is invalid:

[Error Notification]
Prettier: The 'prettierPath' setting does not reference a valid 
Prettier installation. Please check your settings.

[Open Settings] [View Output] [Dismiss]

Not included by design: Notifications for format errors in user code (these remain as problems/diagnostics only).

Related Issue

Fixes #3882

Type of Change

  • New feature (non-breaking change that adds functionality)

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the code style of this project (npm run lint passes)
  • I have run npm run prettier to format my code
  • I have added/updated tests that prove my fix or feature works
  • All new and existing tests pass (npm test)
  • I have updated the CHANGELOG.md with a summary of my changes
Original prompt

This section details on the original issue you should resolve

<issue_title>Use notifications for errors</issue_title>
<issue_description>Currently, fatal errors like if we cannot load the prettier module, issues with the config file, problems loading modules, etc. are printed to the output and the status bar icon changes in some cases, but otherwise it is very hard to know an error happened. We should use VSCode's notifications for errors and warnings that are fatal - we dont want to be too aggressive (i think for formatting errors due to invalid code on the file being formatted for example, a notification is too aggressive - for that we should use problems, but that is a separate issue.

Update the code to show actionable and useful error or warning notifications on errors. For example if we cannot load the prettier module because it isn't installed locally, we should notify the user of the error and tell them that we found prettier in the package.json, but it is not installed and they need to install it.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add notifications for fatal errors and warnings Add user-facing notifications for fatal errors Dec 4, 2025
Copilot AI requested a review from ntotten December 4, 2025 13:25
@ntotten
Copy link
Member

ntotten commented Dec 4, 2025

@copilot lets add a configuration option enableErrorNotifications that is defaulted to true. This will allow users to disable the notifications if they want.

- Add new setting `prettier.enableErrorNotifications` (default: true)
- Allow users to disable error notifications if desired
- Check setting before showing any notifications
- Update types and documentation

Co-authored-by: ntotten <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 4, 2025

@copilot lets add a configuration option enableErrorNotifications that is defaulted to true. This will allow users to disable the notifications if they want.

Done in ea2289b. Added the prettier.enableErrorNotifications configuration option that defaults to true. Users can now disable error notifications by setting this to false in their VS Code settings. When disabled, errors will only be logged to the output channel.

Copilot AI changed the title Add user-facing notifications for fatal errors Add user-facing notifications for fatal errors with configuration option Dec 4, 2025
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.

Use notifications for errors

2 participants