Skip to content

Commit b9888d5

Browse files
committed
Send to account tab if required
1 parent ecfe769 commit b9888d5

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,6 @@ export class ClineProvider
529529
>
530530
> = {},
531531
) {
532-
// Check MDM compliance before proceeding
533-
if (!this.checkMdmCompliance()) {
534-
return // Block task creation if not compliant
535-
}
536-
537532
const {
538533
apiConfiguration,
539534
organizationAllowList,
@@ -1252,6 +1247,11 @@ export class ClineProvider
12521247

12531248
// Update VSCode context for experiments
12541249
await this.updateVSCodeContext()
1250+
1251+
// Check MDM compliance and send user to account tab if not compliant
1252+
if (!this.checkMdmCompliance()) {
1253+
await this.postMessageToWebview({ type: "action", action: "accountButtonClicked" })
1254+
}
12551255
}
12561256

12571257
/**
@@ -1466,6 +1466,7 @@ export class ClineProvider
14661466
codebaseIndexEmbedderBaseUrl: "",
14671467
codebaseIndexEmbedderModelId: "",
14681468
},
1469+
mdmCompliant: this.checkMdmCompliance(),
14691470
}
14701471
}
14711472

@@ -1721,11 +1722,6 @@ export class ClineProvider
17211722
const compliance = this.mdmService.isCompliant()
17221723

17231724
if (!compliance.compliant) {
1724-
vscode.window.showErrorMessage(compliance.reason, "Sign In").then((selection) => {
1725-
if (selection === "Sign In") {
1726-
this.postMessageToWebview({ type: "action", action: "accountButtonClicked" })
1727-
}
1728-
})
17291725
return false
17301726
}
17311727

webview-ui/src/App.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const App = () => {
4242
experiments,
4343
cloudUserInfo,
4444
cloudIsAuthenticated,
45+
mdmCompliant,
4546
} = useExtensionState()
4647

4748
// Create a persistent state manager
@@ -63,15 +64,23 @@ const App = () => {
6364
const settingsRef = useRef<SettingsViewRef>(null)
6465
const chatViewRef = useRef<ChatViewRef>(null)
6566

66-
const switchTab = useCallback((newTab: Tab) => {
67-
setCurrentSection(undefined)
67+
const switchTab = useCallback(
68+
(newTab: Tab) => {
69+
// Check MDM compliance before allowing tab switching
70+
if (mdmCompliant === false && newTab !== "account") {
71+
return
72+
}
6873

69-
if (settingsRef.current?.checkUnsaveChanges) {
70-
settingsRef.current.checkUnsaveChanges(() => setTab(newTab))
71-
} else {
72-
setTab(newTab)
73-
}
74-
}, [])
74+
setCurrentSection(undefined)
75+
76+
if (settingsRef.current?.checkUnsaveChanges) {
77+
settingsRef.current.checkUnsaveChanges(() => setTab(newTab))
78+
} else {
79+
setTab(newTab)
80+
}
81+
},
82+
[mdmCompliant],
83+
)
7584

7685
const [currentSection, setCurrentSection] = useState<string | undefined>(undefined)
7786

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface ExtensionStateContextType extends ExtensionState {
3737
cloudIsAuthenticated: boolean
3838
sharingEnabled: boolean
3939
maxConcurrentFileReads?: number
40+
mdmCompliant?: boolean
4041
condensingApiConfigId?: string
4142
setCondensingApiConfigId: (value: string) => void
4243
customCondensingPrompt?: string

0 commit comments

Comments
 (0)