@@ -56,6 +56,7 @@ import { CHAT_EDITING_SIDEBAR_PANEL_ID, CHAT_SIDEBAR_PANEL_ID } from './chatView
5656import { ChatViewsWelcomeExtensions , IChatViewsWelcomeContributionRegistry } from './viewsWelcome/chatViewsWelcome.js' ;
5757import { IChatQuotasService } from './chatQuotasService.js' ;
5858import { Checkbox } from '../../../../base/browser/ui/toggle/toggle.js' ;
59+ import { mainWindow } from '../../../../base/browser/window.js' ;
5960
6061const defaultChat = {
6162 extensionId : product . defaultChatAgent ?. extensionId ?? '' ,
@@ -341,6 +342,15 @@ class ChatSetupRequests extends Disposable {
341342 this . resolve ( ) ;
342343 }
343344 } ) ) ;
345+
346+ this . _register ( this . context . onDidChange ( ( ) => {
347+ if ( ! this . context . state . installed || this . context . state . entitlement === ChatEntitlement . Unknown ) {
348+ // When the extension is not installed or the user is not entitled
349+ // make sure to clear quotas so that any indicators are also gone
350+ this . state = { entitlement : this . state . entitlement , quotas : undefined } ;
351+ this . chatQuotasService . clearQuotas ( ) ;
352+ }
353+ } ) ) ;
344354 }
345355
346356 private async resolve ( ) : Promise < void > {
@@ -737,7 +747,8 @@ class ChatSetupController extends Disposable {
737747
738748 this . telemetryService . publicLog2 < InstallChatEvent , InstallChatClassification > ( 'commandCenter.chatInstall' , { installResult, signedIn } ) ;
739749
740- if ( activeElement === getActiveElement ( ) ) {
750+ const currentActiveElement = getActiveElement ( ) ;
751+ if ( activeElement === currentActiveElement || currentActiveElement === mainWindow . document . body ) {
741752 ( await showCopilotView ( this . viewsService ) ) ?. focusInput ( ) ;
742753 }
743754 }
0 commit comments