Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,8 @@ export class ClineProvider
this.postMessageToWebview({ type: "state", state })

// Check MDM compliance and send user to account tab if not compliant
if (!this.checkMdmCompliance()) {
// Only redirect if there's an actual MDM policy requiring authentication
Copy link
Contributor

Choose a reason for hiding this comment

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

Great improvement to only check MDM compliance when there's actually an MDM policy! Consider adding JSDoc comments to document the three states of mdmCompliant:

  • undefined: No MDM policy exists
  • true: MDM policy exists and user is compliant
  • false: MDM policy exists and user is non-compliant

This would help future developers understand the distinction.

if (this.mdmService?.requiresCloudAuth() && !this.checkMdmCompliance()) {
await this.postMessageToWebview({ type: "action", action: "accountButtonClicked" })
}
}
Expand Down Expand Up @@ -1872,7 +1873,9 @@ export class ClineProvider
codebaseIndexSearchMaxResults: codebaseIndexConfig?.codebaseIndexSearchMaxResults,
codebaseIndexSearchMinScore: codebaseIndexConfig?.codebaseIndexSearchMinScore,
},
mdmCompliant: this.checkMdmCompliance(),
// Only set mdmCompliant if there's an actual MDM policy
Copy link
Contributor

Choose a reason for hiding this comment

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

Good consistency with the MDM compliance check. The comment clearly explains the three states, which is helpful.

// undefined means no MDM policy, true means compliant, false means non-compliant
mdmCompliant: this.mdmService?.requiresCloudAuth() ? this.checkMdmCompliance() : undefined,
profileThresholds: profileThresholds ?? {},
cloudApiUrl: getRooCodeApiUrl(),
hasOpenedModeSelector: this.getGlobalState("hasOpenedModeSelector") ?? false,
Expand Down Expand Up @@ -2172,7 +2175,7 @@ export class ClineProvider

/**
* Check if the current state is compliant with MDM policy
* @returns true if compliant, false if blocked
* @returns true if compliant or no MDM policy exists, false if MDM policy exists and user is non-compliant
*/
public checkMdmCompliance(): boolean {
if (!this.mdmService) {
Expand Down
5 changes: 5 additions & 0 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2618,5 +2618,10 @@ export const webviewMessageHandler = async (
}
break
}
case "showMdmAuthRequiredNotification": {
// Show notification that organization requires authentication
vscode.window.showWarningMessage(t("common:mdm.info.organization_requires_auth"))
break
}
}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/ca/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/de/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@
"cloud_auth_required": "Your organization requires Roo Code Cloud authentication. Please sign in to continue.",
"organization_mismatch": "You must be authenticated with your organization's Roo Code Cloud account.",
"verification_failed": "Unable to verify organization authentication."
},
"info": {
"organization_requires_auth": "Your organization requires authentication."
}
},
"prompts": {
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/locales/es/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/fr/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/hi/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/id/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/it/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/ja/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/ko/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/nl/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/pl/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/pt-BR/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/ru/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/tr/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/vi/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/zh-CN/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/i18n/locales/zh-TW/common.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/shared/WebviewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export interface WebviewMessage {
| "deleteCommand"
| "createCommand"
| "insertTextIntoTextarea"
| "showMdmAuthRequiredNotification"
text?: string
editedMessageContent?: string
tab?: "settings" | "history" | "mcp" | "modes" | "chat" | "marketplace" | "account"
Expand Down
5 changes: 4 additions & 1 deletion webview-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ const App = () => {

const switchTab = useCallback(
(newTab: Tab) => {
// Check MDM compliance before allowing tab switching
// Only check MDM compliance if mdmCompliant is explicitly false (meaning there's an MDM policy and user is non-compliant)
// If mdmCompliant is undefined or true, allow tab switching
if (mdmCompliant === false && newTab !== "account") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider extracting this MDM check logic into a custom hook or utility function for better reusability and testability. For example:

This would make the logic easier to test and reuse if needed elsewhere.

// Notify the user that authentication is required by their organization
vscode.postMessage({ type: "showMdmAuthRequiredNotification" })
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding test coverage for this new notification feature. It would be valuable to verify:

  • The notification is triggered when mdmCompliant === false and user tries to switch tabs
  • The correct message is displayed to the user
  • The notification handler works correctly

Also, have you considered the UX for repeated attempts? Currently, the notification will show every time the user clicks a different tab. Would it make sense to throttle this or show it only once per session with a more persistent indicator?

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a telemetry event here to track when users encounter MDM blocks. This could help understand usage patterns and potential friction points:

return
}

Expand Down