-
Notifications
You must be signed in to change notification settings - Fork 21
🐛 hide agent button when genAI disabled #722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: David Zager <[email protected]>
WalkthroughThe VS Code extension now clears all GenAI-related config errors ("genai-disabled", "provider-not-configured", "provider-connection-failed") before setting a new one during initialization and on configuration changes. Catch blocks uniformly clear these errors and set a fresh provider-connection-failed error with the caught message. In the webview AnalysisPage, a new isGenAIDisabled flag is derived from rawConfigErrors, and the Agent Mode toggle is conditionally hidden when isGenAIDisabled is true. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Assessment against linked issues
Possibly related PRs
Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
vscode/src/extension.ts (1)
253-270
: Prevent duplicate GenAI errors at startup.During initialize(),
updateConfigErrors(...)
runs first, then you push the result ofsetupModelProvider(...)
. If GenAI is disabled, this can add a secondgenai-disabled
entry. Apply the same “clear GenAI-related errors” filter here before pushing.this.setupModelProvider(paths().settingsYaml) .then((configError) => { this.state.mutateData((draft) => { - if (configError) { - draft.configErrors.push(configError); - } + // Clear GenAI-related config errors to avoid duplicates at startup + draft.configErrors = draft.configErrors.filter( + (e) => + e.type !== "genai-disabled" && + e.type !== "provider-not-configured" && + e.type !== "provider-connection-failed", + ); + if (configError) draft.configErrors.push(configError); }); }) .catch((error) => { this.state.logger.error("Error setting up model provider:", error); this.state.mutateData((draft) => { - if (error) { - const configError = createConfigError.providerConnnectionFailed(); - configError.error = error instanceof Error ? error.message : String(error); - draft.configErrors.push(configError); - } + // Clear GenAI-related config errors to avoid duplicates at startup + draft.configErrors = draft.configErrors.filter( + (e) => + e.type !== "genai-disabled" && + e.type !== "provider-not-configured" && + e.type !== "provider-connection-failed", + ); + const configError = createConfigError.providerConnnectionFailed(); + configError.error = error instanceof Error ? error.message : String(error); + draft.configErrors.push(configError); }); });
♻️ Duplicate comments (1)
vscode/src/extension.ts (1)
347-361
: Intentional full rebuild on settings save is preserved.Clearing
configErrors
beforeupdateConfigErrors
matches the prior design decision (see retrieved learnings). No action needed.
🧹 Nitpick comments (3)
webview-ui/src/components/AnalysisPage/AnalysisPage.tsx (2)
91-91
: Derive a more general “GenAI unavailable” guard (optional).Today you only hide the toggle when
genai-disabled
is present. Consider also guarding onprovider-not-configured
andprovider-connection-failed
to prevent an ON toggle when the provider is unusable.- const isGenAIDisabled = rawConfigErrors.some((error) => error.type === "genai-disabled"); + const isGenAIUnavailable = rawConfigErrors.some( + (e) => + e.type === "genai-disabled" || + e.type === "provider-not-configured" || + e.type === "provider-connection-failed", + );
155-171
: LGTM: Toggle is hidden when GenAI is disabled.This meets #716's objective. If you adopt the broader guard above, replace
!isGenAIDisabled
with!isGenAIUnavailable
. Also consider addingdata-testid="agent-mode-switch"
to simplify Playwright assertions.- {!isGenAIDisabled && ( + {!isGenAIUnavailable && ( <ToolbarItem> <div> <div className="agent-mode-wrapper"> <Switch id="agent-mode-switch" + data-testid="agent-mode-switch" isChecked={isAgentMode} label="Agent Mode" onChange={(_event) => handleAgentModeToggle()} aria-label="Toggle Agent Mode" isReversed /> </div> </div> </ToolbarItem> )}vscode/src/extension.ts (1)
392-404
: Align error message truncation with setupModelProvider (optional).
setupModelProvider()
truncates messages to 150 chars; here you don’t. Consider consistent truncation to avoid noisy toasts.- const configError = createConfigError.providerConnnectionFailed(); - configError.error = error instanceof Error ? error.message : String(error); + const configError = createConfigError.providerConnnectionFailed(); + const msg = error instanceof Error ? error.message : String(error); + configError.error = msg.length > 150 ? msg.slice(0, 150) + "..." : msg; draft.configErrors.push(configError);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
vscode/src/extension.ts
(1 hunks)webview-ui/src/components/AnalysisPage/AnalysisPage.tsx
(2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: pranavgaikwad
PR: konveyor/editor-extensions#581
File: vscode/src/extension.ts:243-251
Timestamp: 2025-07-23T12:10:46.399Z
Learning: In vscode/src/extension.ts, clearing all configErrors in the onDidSaveTextDocument listener for settings YAML is intentional behavior. The setupModelProvider and updateConfigErrors functions are designed to work together to rebuild the entire configuration error state.
📚 Learning: 2025-08-05T16:16:56.005Z
Learnt from: abrugaro
PR: konveyor/editor-extensions#657
File: tests/global.setup.ts:22-27
Timestamp: 2025-08-05T16:16:56.005Z
Learning: In the Playwright test framework for konveyor/editor-extensions, the global setup in tests/global.setup.ts is designed to handle only essential initialization like extension installation verification. Individual tests are responsible for configuring GenAI when needed, rather than doing it globally. The openAnalysisView() method is used as a fast verification mechanism to ensure the extension was successfully installed, which is more efficient than configuring GenAI globally for all tests.
Applied to files:
webview-ui/src/components/AnalysisPage/AnalysisPage.tsx
📚 Learning: 2025-07-23T12:10:46.399Z
Learnt from: pranavgaikwad
PR: konveyor/editor-extensions#581
File: vscode/src/extension.ts:243-251
Timestamp: 2025-07-23T12:10:46.399Z
Learning: In vscode/src/extension.ts, clearing all configErrors in the onDidSaveTextDocument listener for settings YAML is intentional behavior. The setupModelProvider and updateConfigErrors functions are designed to work together to rebuild the entire configuration error state.
Applied to files:
vscode/src/extension.ts
🧬 Code graph analysis (1)
vscode/src/extension.ts (1)
shared/src/types/types.ts (1)
createConfigError
(202-242)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build (windows)
- GitHub Check: Build (macos)
- GitHub Check: Build (linux)
🔇 Additional comments (1)
vscode/src/extension.ts (1)
375-383
: Good: de-dup GenAI-related config errors on config change.Filtering
genai-disabled
,provider-not-configured
, andprovider-connection-failed
before pushing the new one prevents stacked/stale errors. Nice.
Fixes #716
Fixes #719
Summary by CodeRabbit