Skip to content

Commit

Permalink
Update the logged out status bar item with more obvious CTA (#3230)
Browse files Browse the repository at this point in the history
  • Loading branch information
toolmantim authored Mar 17, 2024
1 parent 88f3600 commit 5a94b6e
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 38 deletions.
105 changes: 105 additions & 0 deletions agent/recordings/enterpriseClient_3965582033/recording.har.yaml

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

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

2 changes: 2 additions & 0 deletions vscode/src/completions/inline-completion-item-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ export class InlineCompletionItemProvider
title: errorTitle,
description: `${error.userMessage} ${error.retryMessage ?? ''}`.trim(),
errorType: error.name,
removeAfterSelected: true,
onSelect: () => {
if (canUpgrade) {
telemetryService.log('CodyVSCodeExtension:upsellUsageLimitCTA:clicked', {
Expand Down Expand Up @@ -677,6 +678,7 @@ export class InlineCompletionItemProvider
title: errorTitle,
description: 'Contact your Sourcegraph site admin to enable autocomplete',
errorType: 'AutoCompleteDisabledByAdmin',
removeAfterSelected: false,
onShow: () => {
if (shown) {
return
Expand Down
24 changes: 0 additions & 24 deletions vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,30 +528,6 @@ const register = async (
vscode.commands.registerCommand('cody.debug.enable.all', () => enableDebugMode())
)

/**
* Signed out status bar indicator
*/
let removeAuthStatusBarError: undefined | (() => void)
function updateAuthStatusBarIndicator(): void {
if (removeAuthStatusBarError) {
removeAuthStatusBarError()
removeAuthStatusBarError = undefined
}
if (!authProvider.getAuthStatus().isLoggedIn) {
removeAuthStatusBarError = statusBar.addError({
title: 'Sign In to Use Cody',
errorType: 'auth',
description: 'You need to sign in to use Cody.',
onSelect: () => {
// Bring up the sidebar view
void vscode.commands.executeCommand('cody.focus')
},
})
}
}
authProvider.addChangeListener(() => updateAuthStatusBarIndicator())
updateAuthStatusBarIndicator()

let setupAutocompleteQueue = Promise.resolve() // Create a promise chain to avoid parallel execution

let autocompleteDisposables: vscode.Disposable[] = []
Expand Down
31 changes: 27 additions & 4 deletions vscode/src/notifications/setup-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { ConfigurationWithAccessToken } from '@sourcegraph/cody-shared'
import { localStorage } from '../services/LocalStorageProvider'

import { showActionNotification } from '.'
import { telemetryService } from '../services/telemetry'
import { telemetryRecorder } from '../services/telemetry-v2'

export const showSetupNotification = async (config: ConfigurationWithAccessToken): Promise<void> => {
if (config.serverEndpoint && config.accessToken) {
Expand All @@ -25,16 +27,37 @@ export const showSetupNotification = async (config: ConfigurationWithAccessToken
return
}

telemetryService.log('CodyVSCodeExtension:signInNotification:shown', undefined, { hasV2Event: true })
telemetryRecorder.recordEvent('cody.signInNotification', 'shown')

return showActionNotification({
message: 'Continue setting up Cody',
message: 'Sign in to Cody to get started',
actions: [
{
label: 'Setup',
onClick: () => vscode.commands.executeCommand('cody.focus'),
label: 'Sign In',
onClick: async () => {
vscode.commands.executeCommand('cody.focus')
telemetryService.log(
'CodyVSCodeExtension:signInNotification:signIn:clicked',
undefined,
{ hasV2Event: true }
)
telemetryRecorder.recordEvent('cody.signInNotification.signInButton', 'clicked')
},
},
{
label: 'Do not show again',
onClick: () => localStorage.set('notification.setupDismissed', 'true'),
onClick: async () => {
localStorage.set('notification.setupDismissed', 'true')
telemetryService.log(
'CodyVSCodeExtension:signInNotification:doNotShow:clicked',
undefined,
{
hasV2Event: true,
}
)
telemetryRecorder.recordEvent('cody.signInNotification.doNotShow', 'clicked')
},
},
],
})
Expand Down
37 changes: 34 additions & 3 deletions vscode/src/services/StatusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import { getConfiguration } from '../configuration'

import { getGhostHintEnablement } from '../commands/GhostHintDecorator'
import { FeedbackOptionItems, PremiumSupportItems } from './FeedbackOptions'
import { telemetryService } from './telemetry'
import { telemetryRecorder } from './telemetry-v2'
import { enableDebugMode } from './utils/export-logs'

interface StatusBarError {
title: string
description: string
errorType: StatusBarErrorName
removeAfterSelected: boolean
onShow?: () => void
onSelect?: () => void
}
Expand Down Expand Up @@ -53,6 +56,21 @@ export function createStatusBar(): CodyStatusBar {

let authStatus: AuthStatus | undefined
const command = vscode.commands.registerCommand(statusBarItem.command, async () => {
telemetryService.log(
'CodyVSCodeExtension:statusBarIcon:clicked',
{ loggedIn: Boolean(authStatus?.isLoggedIn) },
{ hasV2Event: true }
)
telemetryRecorder.recordEvent('cody.statusbarIcon', 'clicked', {
privateMetadata: { loggedIn: Boolean(authStatus?.isLoggedIn) },
})

if (!authStatus?.isLoggedIn) {
// Bring up the sidebar view
void vscode.commands.executeCommand('cody.focus')
return
}

const workspaceConfig = vscode.workspace.getConfiguration()
const config = getConfiguration(workspaceConfig)

Expand Down Expand Up @@ -111,9 +129,11 @@ export function createStatusBar(): CodyStatusBar {
detail: QUICK_PICK_ITEM_EMPTY_INDENT_PREFIX + error.error.description,
onSelect(): Promise<void> {
error.error.onSelect?.()
const index = errors.indexOf(error)
errors.splice(index)
rerender()
if (error.error.removeAfterSelected) {
const index = errors.indexOf(error)
errors.splice(index)
rerender()
}
return Promise.resolve()
},
})),
Expand Down Expand Up @@ -239,6 +259,16 @@ export function createStatusBar(): CodyStatusBar {
statusBarItem.tooltip = DEFAULT_TOOLTIP
}

// Only show this if authStatus is present, otherwise you get a flash of
// yellow status bar icon when extension first loads but login hasn't
// initialized yet
if (authStatus && !authStatus.isLoggedIn) {
statusBarItem.text = 'Sign In'
statusBarItem.tooltip = 'Sign in to get started with Cody'
statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.warningBackground')
return
}

if (errors.length > 0) {
statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.warningBackground')
statusBarItem.tooltip = errors[0].error.title
Expand Down Expand Up @@ -322,6 +352,7 @@ export function createStatusBar(): CodyStatusBar {
},
syncAuthStatus(newStatus: AuthStatus) {
authStatus = newStatus
rerender()
},
dispose() {
statusBarItem.dispose()
Expand Down
Loading

0 comments on commit 5a94b6e

Please sign in to comment.