Skip to content

Conversation

gagik
Copy link
Contributor

@gagik gagik commented Sep 1, 2025

Expands it to match NLQ.

@Copilot Copilot AI review requested due to automatic review settings September 1, 2025 14:10
@gagik gagik requested a review from a team as a code owner September 1, 2025 14:10
Copy link
Contributor

@Copilot 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 PR implements proper hiding of assistant-related UI buttons when AI features are disabled, expanding the existing behavior for NLQ to other assistant features.

  • Refactors assistant actions to return empty object when AI features are disabled
  • Updates connection error toast to conditionally show debug button based on assistant availability
  • Simplifies explain plan modal to remove redundant assistant enablement check

Reviewed Changes

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

Show a summary per file
File Description
packages/compass-assistant/src/compass-assistant-provider.tsx Refactors useAssistantActions to check AI feature enablement and return empty object when disabled
packages/compass-assistant/src/compass-assistant-provider.spec.tsx Adds comprehensive tests for useAssistantActions behavior with different AI feature states
packages/compass-assistant/src/compass-assistant-drawer.tsx Updates clearChat call to handle optional function
packages/compass-connections/src/stores/connections-store-redux.ts Simplifies connection error handling by checking assistant availability directly
packages/compass-connections/src/components/connection-status-notifications.tsx Updates toast interface to use optional callbacks instead of boolean flags
packages/compass-explain-plan/src/components/explain-plan-modal.tsx Removes redundant isAssistantEnabled check

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

showDebugButton: boolean;
onReviewClick: () => void;
onDebugClick: () => void;
onReviewClick?: () => void;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

personal preference but I think since showing and the handler are inherently tied it's good to combine the two. It's a pattern in LG too so works out pretty well usually

@@ -37,22 +40,22 @@ export const AssistantContext = createContext<AssistantContextType | null>(
);

type AssistantActionsContextType = {
interpretExplainPlan: ({
interpretExplainPlan?: ({
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking about making these optional and using the existence of the callbacks to be able to tell if the thing should be enabled or not, but was worried that it kinda disabled some type checking benefits - you can't tell between the feature being enabled/disabled vs a mock/stub just not containing it, for example.

But I was probably overthinking it.

Lower down like in the connection error entry point it indeed makes sense to have just the optional callback rather than a boolean and the optional callback. This high up.. I don't know. It is probably fine.

I don't have strong feelings about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the alternative tends to make us be attentive in also including the isEnabled returned from the hook in our conditions for showing the button which can be easy to oversee so I find this to be more type checked for this purpose. Open to revisiting it later if we run into problems.

@@ -160,7 +155,7 @@ export const CompassAssistantProvider = registerCompassPlugin(
transport: new DocsProviderTransport({
baseUrl: atlasService.assistantApiEndpoint(),
}),
onError: (err) => {
onError: (err: Error) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I swear this gets either added or removed every other PR 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am rebasing so much everything feels like a deja-vu 😆

@gagik gagik merged commit 01231f9 into main Sep 2, 2025
31 of 33 checks passed
@gagik gagik deleted the gagik/compass-check-ai branch September 2, 2025 14:25
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