Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions playwright/github-byot-ai.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { expect, test } from '@playwright/test'
import { defaultGitHubChatModel } from '../src/modules/github/api/chat.js'
import type { ChatRequestBody, ChatRequestMessage } from './helpers/app-test-helpers.js'
Expand Down Expand Up @@ -399,6 +399,23 @@
expect(typeof renamedRecord?.prTitle === 'string' ? renamedRecord.prTitle : '').toBe(
renamedTitle,
)

await setComponentEditorSource(
page,
'export const App = () => <main>rename persists after edit</main>',
)

await expect
.poll(async () => {
const nextRecords = await getAllWorkspaceRecords(page)
const nextRenamedRecord = nextRecords.find(
record => record?.id === sourceWorkspaceId,
)
return typeof nextRenamedRecord?.prTitle === 'string'
? nextRenamedRecord.prTitle
: ''
})
.toBe(renamedTitle)
})

test('chat stays usable after opening a Local workspace with PAT connected', async ({
Expand Down
6 changes: 6 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ const getWorkspaceContextSnapshot = createWorkspaceContextSnapshotGetter({
getActivePrContext: () => githubAiContextState.activePrContext,
getPrContextState: () => workspacePrContextState,
getPrNumber: () => workspacePrNumber,
getWorkspaceScopeMarker: () => workspaceScopeMarker,
getActiveWorkspacePersistedPrTitle: () => activeWorkspacePersistedPrTitle,
})

const { getActiveWorkspaceTab, getEntryWorkspaceTab, getPrimaryStyleWorkspaceTab } =
Expand Down Expand Up @@ -1023,6 +1025,10 @@ const workspacePrSessionHandoffController = createWorkspacePrSessionHandoffContr
setWorkspacePrContextState,
setWorkspacePrNumber,
setWorkspaceScopeMarker,
clearActiveWorkspacePersistedMetadata: () => {
activeWorkspacePersistedPrTitle = ''
activeWorkspacePersistedHeadBranch = ''
},
getActiveWorkspaceCreatedAt: () => activeWorkspaceCreatedAt,
setActiveWorkspaceRecordId,
setActiveWorkspaceCreatedAt: value => (activeWorkspaceCreatedAt = value),
Expand Down
13 changes: 12 additions & 1 deletion src/modules/app-core/workspace-local-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const createWorkspaceContextSnapshotGetter =
getActivePrContext,
getPrContextState,
getPrNumber,
getWorkspaceScopeMarker,
getActiveWorkspacePersistedPrTitle,
}) =>
() => {
const toSafeText = value => (typeof value === 'string' ? value.trim() : '')
Expand All @@ -32,14 +34,23 @@ const createWorkspaceContextSnapshotGetter =
const formBaseBranch = toSafeText(githubPrBaseBranch?.value)
const formHeadBranch = toSafeText(githubPrHeadBranch?.value)
const formPrTitle = toSafeText(githubPrTitle?.value)
const normalizedWorkspaceScope = toSafeText(getWorkspaceScopeMarker?.()).toLowerCase()
const isLocalScope = normalizedWorkspaceScope !== 'repository'
const persistedPrTitle = toSafeText(getActiveWorkspacePersistedPrTitle?.())
const nextPrTitle =
isActivePrContext && contextPrTitle
? contextPrTitle
: isLocalScope && !formPrTitle && persistedPrTitle
Comment thread
knightedcodemonkey marked this conversation as resolved.
? persistedPrTitle
: formPrTitle

return {
repositoryFullName: getCurrentSelectedRepository(),
baseBranch:
isActivePrContext && contextBaseBranch ? contextBaseBranch : formBaseBranch,
headBranch:
isActivePrContext && contextHeadBranch ? contextHeadBranch : formHeadBranch,
prTitle: isActivePrContext && contextPrTitle ? contextPrTitle : formPrTitle,
prTitle: nextPrTitle,
prNumber,
prContextState,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const createWorkspacePrSessionHandoffController = ({
setWorkspacePrContextState,
setWorkspacePrNumber,
setWorkspaceScopeMarker,
clearActiveWorkspacePersistedMetadata,
getActiveWorkspaceCreatedAt,
setActiveWorkspaceRecordId,
setActiveWorkspaceCreatedAt,
Expand Down Expand Up @@ -87,6 +88,11 @@ export const createWorkspacePrSessionHandoffController = ({
if (typeof setWorkspaceScopeMarker === 'function') {
setWorkspaceScopeMarker('local')
}

if (typeof clearActiveWorkspacePersistedMetadata === 'function') {
clearActiveWorkspacePersistedMetadata()
}

lastKnownPrContextMeta = null

if (githubPrHeadBranch) {
Expand Down
Loading