Skip to content

Commit

Permalink
WIP - problem is models service requires auth for feature flags, but …
Browse files Browse the repository at this point in the history
…auth is set first in authprovider...
  • Loading branch information
sqs committed Sep 14, 2024
1 parent d1f849a commit ee9894a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lib/shared/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ export class ModelsService {
} catch {
this.localModels = []
}
this._modelsChanges.next()
}

public async setAuthStatus(authStatus: AuthStatus) {
Expand All @@ -410,6 +411,7 @@ export class ModelsService {
public setModels(models: Model[]): void {
logDebug('ModelsService', `Setting primary models: ${JSON.stringify(models.map(m => m.id))}`)
this.primaryModels = models
this._modelsChanges.next()
}

/**
Expand Down Expand Up @@ -440,6 +442,11 @@ export class ModelsService {
await this.flush()
}

private readonly _modelsChanges = new Subject<void>()
public get modelsChanges(): Observable<void> {
return this._modelsChanges
}

private readonly _selectedOrDefaultModelChanges = new Subject<void>()
public get selectedOrDefaultModelChanges(): Observable<void> {
return this._selectedOrDefaultModelChanges
Expand All @@ -463,6 +470,7 @@ export class ModelsService {
...this.primaryModels,
...models.filter(model => !existingIds.has(model.id)),
]
this._modelsChanges.next()
}

private getModelsByType(usage: ModelUsage): Model[] {
Expand Down
4 changes: 2 additions & 2 deletions vscode/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export default defineConfig({
retries: isWin ? 4 : isCI ? 1 : 0, // give flaky tests more chances, but we should fix flakiness when we see it
forbidOnly: isCI,
testDir: 'test/e2e',
timeout: isWin || isCI ? 30000 : 20000,
timeout: isWin || isCI ? 30000 : 9920000,
expect: {
timeout: isWin || isCI ? 5000 : 2000,
timeout: isWin || isCI ? 5000 : 992000,
},
reporter: isCI ? [['github'], ['buildkite-test-collector/playwright/reporter']] : [['list']],
globalSetup: require.resolve('./test/e2e/utils/setup'),
Expand Down
2 changes: 2 additions & 0 deletions vscode/src/chat/chat-view/ChatController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1668,9 +1668,11 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv
models: () =>
combineLatest([
resolvedConfig,
authStatus,
modelsService.instance!.selectedOrDefaultModelChanges.pipe(
startWith(undefined)
),
modelsService.instance!.modelsChanges.pipe(startWith(undefined)),
]).pipe(map(() => modelsService.instance!.getModels(ModelUsage.Chat))),
highlights: parameters =>
promiseFactoryToObservable(() =>
Expand Down
1 change: 1 addition & 0 deletions vscode/src/services/AuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export class AuthProvider implements vscode.Disposable {
} catch (error) {
logDebug('AuthProvider', 'updateAuthStatus error', error)
} finally {
this.status.next(authStatus) // call again for ChatsController
let eventValue: 'disconnected' | 'connected' | 'failed'
if (authStatus.authenticated) {
eventValue = 'connected'
Expand Down
3 changes: 3 additions & 0 deletions vscode/test/e2e/chat-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ test.extend<DotcomUrlOverride>({ dotcomUrl: mockServer.SERVER_URL }).extend<Expe
await expect(modelSelect).toBeEnabled()
await expect(modelSelect).toHaveText(/^Claude 3.5 Sonnet/)

await page.waitForTimeout(3000000)

Check failure on line 204 in vscode/test/e2e/chat-input.test.ts

View workflow job for this annotation

GitHub Actions / test-e2e (ubuntu, 2/5)

chat-input.test.ts:191:3 › chat model selector

1) chat-input.test.ts:191:3 › chat model selector ──────────────────────────────────────────────── Error: page.waitForTimeout: Application exited 202 | await expect(modelSelect).toHaveText(/^Claude 3.5 Sonnet/) 203 | > 204 | await page.waitForTimeout(3000000) | ^ 205 | 206 | await firstChatInput.fill('to model1') 207 | await firstChatInput.press('Enter') at /home/runner/work/cody/cody/vscode/test/e2e/chat-input.test.ts:204:16

Check failure on line 204 in vscode/test/e2e/chat-input.test.ts

View workflow job for this annotation

GitHub Actions / test-e2e (ubuntu, 2/5)

chat-input.test.ts:191:3 › chat model selector

1) chat-input.test.ts:191:3 › chat model selector ──────────────────────────────────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: page.waitForTimeout: Application exited 202 | await expect(modelSelect).toHaveText(/^Claude 3.5 Sonnet/) 203 | > 204 | await page.waitForTimeout(3000000) | ^ 205 | 206 | await firstChatInput.fill('to model1') 207 | await firstChatInput.press('Enter') at /home/runner/work/cody/cody/vscode/test/e2e/chat-input.test.ts:204:16

await firstChatInput.fill('to model1')
await firstChatInput.press('Enter')

Expand All @@ -209,6 +211,7 @@ test.extend<DotcomUrlOverride>({ dotcomUrl: mockServer.SERVER_URL }).extend<Expe
}

// Verify tooltip shows the correct model
await page.waitForTimeout(30000)
await expectModelName('Claude 3.5 Sonnet')

// Change model and send another message.
Expand Down

0 comments on commit ee9894a

Please sign in to comment.