Skip to content

Commit 9196b1c

Browse files
refactor: address comments and failing webkit.
1 parent 3225fc0 commit 9196b1c

5 files changed

Lines changed: 50 additions & 36 deletions

File tree

playwright/helpers/app-test-helpers.ts

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ export const connectByotWithSingleRepo = async (
568568

569569
const workspacesRepositoryFilter = page.getByLabel('Workspace repository filter')
570570
await expect(workspacesRepositoryFilter).toBeVisible()
571+
await expect(workspacesRepositoryFilter).toBeEnabled()
571572
await workspacesRepositoryFilter.selectOption('knightedcodemonkey/develop')
572573
await expect(workspacesRepositoryFilter).toHaveValue('knightedcodemonkey/develop')
573574

@@ -576,21 +577,42 @@ export const connectByotWithSingleRepo = async (
576577
name: 'Initialize',
577578
exact: true,
578579
})
580+
const storedWorkspace = page.getByLabel('Stored workspace')
579581

580-
if (await initializeButton.isVisible()) {
582+
await expect
583+
.poll(async () => {
584+
if (await initializeButton.isVisible()) {
585+
return 'initialize'
586+
}
587+
588+
if (await storedWorkspace.isVisible()) {
589+
const workspaceValue = await storedWorkspace
590+
.locator('option:not([value=""])')
591+
.first()
592+
.getAttribute('value')
593+
594+
if (workspaceValue) {
595+
return 'stored'
596+
}
597+
}
598+
599+
return ''
600+
})
601+
.not.toBe('')
602+
603+
const autoOpenMode = (await initializeButton.isVisible()) ? 'initialize' : 'stored'
604+
605+
if (autoOpenMode === 'initialize') {
581606
await initializeButton.click()
582607
} else {
583-
const storedWorkspace = page.getByLabel('Stored workspace')
584-
if (await storedWorkspace.isVisible()) {
585-
const workspaceValue = await storedWorkspace
586-
.locator('option:not([value=""])')
587-
.first()
588-
.getAttribute('value')
589-
590-
if (workspaceValue) {
591-
await storedWorkspace.selectOption(workspaceValue)
592-
await page.getByRole('button', { name: 'Open', exact: true }).click()
593-
}
608+
const workspaceValue = await storedWorkspace
609+
.locator('option:not([value=""])')
610+
.first()
611+
.getAttribute('value')
612+
613+
if (workspaceValue) {
614+
await storedWorkspace.selectOption(workspaceValue)
615+
await page.getByRole('button', { name: 'Open', exact: true }).click()
594616
}
595617
}
596618
}

src/modules/chat/api/completions.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
chatCompletionsUrl,
3-
chatModelOptions,
4-
defaultChatModel,
5-
isFreeChatModel,
6-
} from './constants.js'
7-
import { fetchChatModelOptions } from './models.js'
1+
import { chatCompletionsUrl, defaultChatModel } from './constants.js'
82
import {
93
buildChatRequestHeaders,
104
parseErrorResponse,
@@ -451,11 +445,4 @@ const requestChatCompletion = async ({
451445
}
452446
}
453447

454-
export {
455-
chatModelOptions,
456-
defaultChatModel,
457-
fetchChatModelOptions,
458-
isFreeChatModel,
459-
requestChatCompletion,
460-
streamChatCompletion,
461-
}
448+
export { defaultChatModel, requestChatCompletion, streamChatCompletion }

src/modules/chat/api/models.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ const isFreeModel = model => {
1818
return false
1919
}
2020

21-
return pricing.prompt === '0' && pricing.completion === '0'
21+
return (
22+
(pricing.prompt === 0 || pricing.prompt === '0') &&
23+
(pricing.completion === 0 || pricing.completion === '0')
24+
)
2225
}
2326

2427
const sortModelEntries = entries => {

src/modules/chat/drawer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ export const createChatDrawer = ({
182182
modelPicker.syncModelSelectionForKey(nextKey)
183183
syncComposerAvailability()
184184

185-
if (open) {
185+
const keyPresent = typeof nextKey === 'string' && nextKey.trim().length > 0
186+
187+
if (open && keyPresent) {
186188
void modelPicker.loadModelOptionsFromCatalog({ force: true })
187189
}
188190
},
@@ -233,7 +235,7 @@ export const createChatDrawer = ({
233235
promptInput.focus()
234236
}
235237

236-
if (open) {
238+
if (open && hasChatKey()) {
237239
void modelPicker.loadModelOptionsFromCatalog()
238240
}
239241
}

src/modules/chat/model-picker.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import {
2-
chatModelOptions,
3-
defaultChatModel,
4-
fetchChatModelOptions,
5-
isFreeChatModel,
6-
} from './api/completions.js'
1+
import { chatModelOptions, defaultChatModel, isFreeChatModel } from './api/constants.js'
2+
import { fetchChatModelOptions } from './api/models.js'
73
import { toModelId } from './utils.js'
84

95
export const createChatModelPicker = ({
@@ -92,6 +88,10 @@ export const createChatModelPicker = ({
9288
const token = getChatKey()
9389
const normalizedToken = typeof token === 'string' ? token.trim() : ''
9490

91+
if (!normalizedToken) {
92+
return
93+
}
94+
9595
if (!force && pendingCatalogLoadPromise) {
9696
await pendingCatalogLoadPromise
9797
return

0 commit comments

Comments
 (0)