Skip to content

Commit 252e42c

Browse files
authored
Merge pull request #1608 from microsoft/roblou/renewed-mosquito
Limit placeholder view visibility (#1598)
2 parents 0208fa3 + 969803b commit 252e42c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3964,7 +3964,7 @@
39643964
{
39653965
"id": "codex-placeholder",
39663966
"name": "OpenAI Codex Agent",
3967-
"when": "github.copilot.chat.codex.notInstalled && config.chat.experimental.codex.enabled",
3967+
"when": "github.copilot.chat.codex.showPlaceholder && config.chat.experimental.codex.enabled",
39683968
"icon": "$(file)"
39693969
},
39703970
{

src/extension/contextKeys/vscode-node/placeholderView.contribution.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,38 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7+
import { IAuthenticationService } from '../../../platform/authentication/common/authentication';
78
import { IRunCommandExecutionService } from '../../../platform/commands/common/runCommandExecutionService';
9+
import { IConfigurationService } from '../../../platform/configuration/common/configurationService';
810
import { IEnvService } from '../../../platform/env/common/envService';
11+
import { Event } from '../../../util/vs/base/common/event';
912
import { Disposable } from '../../../util/vs/base/common/lifecycle';
1013

11-
const CodexPlaceholderKey = 'github.copilot.chat.codex.notInstalled';
14+
const ShowCodexPlaceholderKey = 'github.copilot.chat.codex.showPlaceholder';
1215

1316
export class PlaceholderViewContribution extends Disposable {
1417
constructor(
1518
@IRunCommandExecutionService private readonly _commandService: IRunCommandExecutionService,
1619
@IEnvService private readonly envService: IEnvService,
20+
@IAuthenticationService authenticationService: IAuthenticationService,
21+
@IConfigurationService configurationService: IConfigurationService
1722
) {
1823
super();
1924

25+
let curShouldShowPlaceholder: boolean | undefined = undefined;
2026
const updateContextKey = () => {
27+
const token = authenticationService.copilotToken;
28+
const enabledForUser = token && (token.codexAgentEnabled || configurationService.getNonExtensionConfig('chat.experimental.codex.enabled'));
2129
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+
}
2335
};
2436

25-
updateContextKey();
2637
this._register(vscode.extensions.onDidChange(updateContextKey));
38+
this._register(Event.runAndSubscribe(authenticationService.onDidAuthenticationChange, updateContextKey));
2739

2840
this._register(vscode.commands.registerCommand('github.copilot.chat.installAgent', this.installAgentCommand, this));
2941
}

0 commit comments

Comments
 (0)