|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | import * as vscode from 'vscode'; |
| 7 | +import { IAuthenticationService } from '../../../platform/authentication/common/authentication'; |
7 | 8 | import { IRunCommandExecutionService } from '../../../platform/commands/common/runCommandExecutionService'; |
| 9 | +import { IConfigurationService } from '../../../platform/configuration/common/configurationService'; |
8 | 10 | import { IEnvService } from '../../../platform/env/common/envService'; |
| 11 | +import { Event } from '../../../util/vs/base/common/event'; |
9 | 12 | import { Disposable } from '../../../util/vs/base/common/lifecycle'; |
10 | 13 |
|
11 | | -const CodexPlaceholderKey = 'github.copilot.chat.codex.notInstalled'; |
| 14 | +const ShowCodexPlaceholderKey = 'github.copilot.chat.codex.showPlaceholder'; |
12 | 15 |
|
13 | 16 | export class PlaceholderViewContribution extends Disposable { |
14 | 17 | constructor( |
15 | 18 | @IRunCommandExecutionService private readonly _commandService: IRunCommandExecutionService, |
16 | 19 | @IEnvService private readonly envService: IEnvService, |
| 20 | + @IAuthenticationService authenticationService: IAuthenticationService, |
| 21 | + @IConfigurationService configurationService: IConfigurationService |
17 | 22 | ) { |
18 | 23 | super(); |
19 | 24 |
|
| 25 | + let curShouldShowPlaceholder: boolean | undefined = undefined; |
20 | 26 | const updateContextKey = () => { |
| 27 | + const token = authenticationService.copilotToken; |
| 28 | + const enabledForUser = token && (token.codexAgentEnabled || configurationService.getNonExtensionConfig('chat.experimental.codex.enabled')); |
21 | 29 | const codexExtension = vscode.extensions.getExtension('openai.chatgpt'); |
22 | | - void vscode.commands.executeCommand('setContext', CodexPlaceholderKey, !codexExtension); |
| 30 | + const shouldShowPlaceholder = enabledForUser && !codexExtension; |
| 31 | + if (curShouldShowPlaceholder !== shouldShowPlaceholder) { |
| 32 | + curShouldShowPlaceholder = shouldShowPlaceholder; |
| 33 | + void vscode.commands.executeCommand('setContext', ShowCodexPlaceholderKey, shouldShowPlaceholder); |
| 34 | + } |
23 | 35 | }; |
24 | 36 |
|
25 | | - updateContextKey(); |
26 | 37 | this._register(vscode.extensions.onDidChange(updateContextKey)); |
| 38 | + this._register(Event.runAndSubscribe(authenticationService.onDidAuthenticationChange, updateContextKey)); |
27 | 39 |
|
28 | 40 | this._register(vscode.commands.registerCommand('github.copilot.chat.installAgent', this.installAgentCommand, this)); |
29 | 41 | } |
|
0 commit comments