@@ -15,6 +15,7 @@ import {
1515} from './helpers/app-test-helpers.js'
1616import {
1717 getAllWorkspaceRecords ,
18+ openStoredWorkspaceContextById ,
1819 seedLocalWorkspaceContexts ,
1920} from './github-pr-drawer/github-pr-drawer.helpers.js'
2021
@@ -400,6 +401,79 @@ test('Local workspace can be renamed from Workspaces drawer', async ({ page }) =
400401 )
401402} )
402403
404+ test ( 'chat stays usable after opening a Local workspace with PAT connected' , async ( {
405+ page,
406+ } ) => {
407+ const localWorkspaceId = 'local_chat_issue_128'
408+ let streamRequestBody : ChatRequestBody | undefined
409+
410+ await page . route ( 'https://models.github.ai/inference/chat/completions' , async route => {
411+ streamRequestBody = route . request ( ) . postDataJSON ( ) as ChatRequestBody
412+
413+ await route . fulfill ( {
414+ status : 200 ,
415+ contentType : 'text/event-stream' ,
416+ body : [
417+ 'data: {"choices":[{"delta":{"content":"Local workspace chat works"}}]}' ,
418+ '' ,
419+ 'data: [DONE]' ,
420+ '' ,
421+ ] . join ( '\n' ) ,
422+ } )
423+ } )
424+
425+ await waitForAppReady ( page )
426+
427+ await seedLocalWorkspaceContexts ( page , [
428+ {
429+ id : localWorkspaceId ,
430+ repo : '' ,
431+ workspaceScope : 'local' ,
432+ head : 'feat/local-chat-issue-128' ,
433+ prTitle : 'Issue 128 local workspace' ,
434+ prContextState : 'inactive' ,
435+ tabs : [
436+ {
437+ id : 'component' ,
438+ path : 'src/component.tsx' ,
439+ language : 'tsx' ,
440+ role : 'component' ,
441+ content : 'export const App = () => <main>local chat issue 128</main>' ,
442+ order : 0 ,
443+ source : 'workspace' ,
444+ dirty : false ,
445+ } ,
446+ ] ,
447+ activeTabId : 'component' ,
448+ } ,
449+ ] )
450+
451+ await connectByotWithSingleRepo ( page )
452+ await openStoredWorkspaceContextById ( page , localWorkspaceId , {
453+ repositoryFilter : '__local__' ,
454+ } )
455+ await ensureWorkspacesDrawerClosed ( page )
456+
457+ await ensureAiChatDrawerOpen ( page )
458+
459+ await page . getByLabel ( 'Ask AI assistant' ) . fill ( 'Confirm local workspace chat context.' )
460+ await page . getByRole ( 'button' , { name : 'Send' } ) . click ( )
461+
462+ await expect ( page . getByText ( 'Local workspace chat works' ) ) . toBeVisible ( )
463+ await expect (
464+ page . getByText ( 'Select a writable repository before starting chat.' , { exact : true } ) ,
465+ ) . toHaveCount ( 0 )
466+
467+ const repositorySystemMessage = streamRequestBody ?. messages ?. find (
468+ ( message : ChatRequestMessage ) =>
469+ message . role === 'system' &&
470+ message . content ?. includes ( 'Selected repository context' ) ,
471+ )
472+ expect ( repositorySystemMessage ?. content ) . toContain (
473+ 'Repository: knightedcodemonkey/develop' ,
474+ )
475+ } )
476+
403477test ( 'BYOT controls render with default app entry' , async ( { page } ) => {
404478 await waitForAppReady ( page , appEntryPath )
405479
0 commit comments