Skip to content

Conversation

@brianbaldock
Copy link
Owner

This pull request improves compatibility of the Copilot streaming client with Salesforce Lightning environments (Locker/LWS), and updates project dependencies. The main change is to ensure the app gracefully falls back to REST polling when the required streaming API (TextDecoderStream) is unavailable, preventing runtime errors in restricted environments.

Compatibility improvements for Salesforce Lightning (Locker/LWS):

  • Added a runtime check for TextDecoderStream before enabling the streaming Direct Line client, logging a debug message and falling back to REST polling if unavailable. (lightningCopilotAuth.js)
  • Updated the postActivity method to only use the streaming client when TextDecoderStream is present, ensuring robust handling in environments where this API is missing. (lightningCopilotAuth.js)

Dependency updates:

  • Added @salesforce/cli as a project dependency in package.json to support Salesforce CLI operations.

Copilot AI review requested due to automatic review settings January 15, 2026 07:13
Copy link

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 enhances compatibility with Salesforce Lightning restricted environments (Locker/LWS) by adding runtime checks for the TextDecoderStream API, which may not be available in these environments. The changes ensure that the streaming DirectLine client gracefully falls back to REST polling when the required API is unavailable, preventing runtime errors.

Changes:

  • Added runtime checks for TextDecoderStream availability in both connection validation and message posting methods
  • Ensured consistent fallback behavior to REST polling when streaming is unavailable
  • Added @salesforce/cli as a project dependency
  • Removed commented lines from .gitignore

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.

File Description
lightningCopilotAuth.js Added TextDecoderStream availability checks in tryAdoptStreamingConnection and postActivity methods to gracefully fallback to REST polling in restricted Salesforce environments
package.json Added @salesforce/cli as a dependency (may be unnecessary)
.gitignore Removed commented-out lines for optional adaptive card vendor files

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

"type": "module",
"dependencies": {
"@microsoft/agents-copilotstudio-client": "^1.0.15",
"@salesforce/cli": "^2.109.6",
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The addition of @salesforce/cli as a production dependency appears unnecessary for this project. After reviewing the build scripts and codebase, this package is not imported or referenced anywhere in the code. The Salesforce CLI is typically a development or deployment tool that should be installed globally or used as a devDependency if needed for CI/CD scripts. Adding it as a production dependency significantly increases the bundle size (it's a large package with many transitive dependencies) without providing any runtime value to the LWC component. Consider removing this dependency or moving it to devDependencies if it's needed for development/deployment scripts.

Copilot uses AI. Check for mistakes.
@brianbaldock brianbaldock merged commit 85a40b0 into main Jan 15, 2026
9 checks passed
@brianbaldock brianbaldock deleted the fix/salesforce-textdecoderstream branch January 15, 2026 07:18
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