Skip to content

Commit b326cf4

Browse files
fix(workspaces): preserve local workspace names across autosave and align labels.
1 parent 314bf1a commit b326cf4

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

playwright/github-byot-ai.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,23 @@ test('Local workspace can be renamed from Workspaces drawer', async ({ page }) =
399399
expect(typeof renamedRecord?.prTitle === 'string' ? renamedRecord.prTitle : '').toBe(
400400
renamedTitle,
401401
)
402+
403+
await setComponentEditorSource(
404+
page,
405+
'export const App = () => <main>rename persists after edit</main>',
406+
)
407+
408+
await expect
409+
.poll(async () => {
410+
const nextRecords = await getAllWorkspaceRecords(page)
411+
const nextRenamedRecord = nextRecords.find(
412+
record => record?.id === sourceWorkspaceId,
413+
)
414+
return typeof nextRenamedRecord?.prTitle === 'string'
415+
? nextRenamedRecord.prTitle
416+
: ''
417+
})
418+
.toBe(renamedTitle)
402419
})
403420

404421
test('chat stays usable after opening a Local workspace with PAT connected', async ({

src/app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ const getWorkspaceContextSnapshot = createWorkspaceContextSnapshotGetter({
664664
getActivePrContext: () => githubAiContextState.activePrContext,
665665
getPrContextState: () => workspacePrContextState,
666666
getPrNumber: () => workspacePrNumber,
667+
getWorkspaceScopeMarker: () => workspaceScopeMarker,
668+
getActiveWorkspacePersistedPrTitle: () => activeWorkspacePersistedPrTitle,
667669
})
668670

669671
const { getActiveWorkspaceTab, getEntryWorkspaceTab, getPrimaryStyleWorkspaceTab } =

src/modules/app-core/workspace-local-helpers.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const createWorkspaceContextSnapshotGetter =
77
getActivePrContext,
88
getPrContextState,
99
getPrNumber,
10+
getWorkspaceScopeMarker,
11+
getActiveWorkspacePersistedPrTitle,
1012
}) =>
1113
() => {
1214
const toSafeText = value => (typeof value === 'string' ? value.trim() : '')
@@ -32,14 +34,23 @@ const createWorkspaceContextSnapshotGetter =
3234
const formBaseBranch = toSafeText(githubPrBaseBranch?.value)
3335
const formHeadBranch = toSafeText(githubPrHeadBranch?.value)
3436
const formPrTitle = toSafeText(githubPrTitle?.value)
37+
const normalizedWorkspaceScope = toSafeText(getWorkspaceScopeMarker?.()).toLowerCase()
38+
const isLocalScope = normalizedWorkspaceScope !== 'repository'
39+
const persistedPrTitle = toSafeText(getActiveWorkspacePersistedPrTitle?.())
40+
const nextPrTitle =
41+
isActivePrContext && contextPrTitle
42+
? contextPrTitle
43+
: isLocalScope && !formPrTitle && persistedPrTitle
44+
? persistedPrTitle
45+
: formPrTitle
3546

3647
return {
3748
repositoryFullName: getCurrentSelectedRepository(),
3849
baseBranch:
3950
isActivePrContext && contextBaseBranch ? contextBaseBranch : formBaseBranch,
4051
headBranch:
4152
isActivePrContext && contextHeadBranch ? contextHeadBranch : formHeadBranch,
42-
prTitle: isActivePrContext && contextPrTitle ? contextPrTitle : formPrTitle,
53+
prTitle: nextPrTitle,
4354
prNumber,
4455
prContextState,
4556
}

0 commit comments

Comments
 (0)