Skip to content

Commit eabcc1c

Browse files
fix: only show edited when in pr context.
1 parent 8563cb3 commit eabcc1c

9 files changed

Lines changed: 91 additions & 5 deletions

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Repository structure:
4040

4141
- Preserve current project formatting: single quotes, no semicolons, print width 90, arrowParens avoid.
4242
- Do not use index files or barrel-file architecture; prefer explicit file names and explicit import paths.
43+
- Prefer modular, colocated architecture; split focused features into nearby files and avoid monolithic modules.
4344
- Keep UI changes intentional and lightweight; avoid broad visual rewrites unless requested.
4445
- Keep runtime logic defensive for flaky/slow CDN conditions.
4546
- Preserve progressive loading behavior (lazy-load optional compilers/runtime pieces where possible).

playwright/workspace-tabs.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ test('startup restores last active workspace tab after reload', async ({ page })
266266
await expect(page.locator('#editor-panel-styles')).toHaveAttribute('hidden', '')
267267
})
268268

269-
test('editing a synced tab marks it dirty', async ({ page }) => {
269+
test('editing a synced tab keeps dirty state local without Edited indicators', async ({
270+
page,
271+
}) => {
270272
await waitForInitialRender(page)
271273

272274
await seedSyncedComponentTab(page)
@@ -282,8 +284,8 @@ test('editing a synced tab marks it dirty', async ({ page }) => {
282284
const componentTab = page
283285
.getByRole('listitem', { name: 'Workspace tab App.tsx' })
284286
.first()
285-
await expect(componentTab.locator('.workspace-tab__dirty-indicator')).toBeVisible()
286-
await expect(page.locator('#component-dirty-status')).toHaveText('Edited')
287+
await expect(componentTab.locator('.workspace-tab__dirty-indicator')).toHaveCount(0)
288+
await expect(page.locator('#component-dirty-status')).toBeHidden()
287289
})
288290

289291
test('removed default styles tab stays removed after reload', async ({ page }) => {

src/app.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
toStyleModeForTabLanguage,
3030
} from './modules/app-core/workspace-local-helpers.js'
3131
import { createWorkspaceEditorHelpers } from './modules/app-core/workspace-editor-helpers.js'
32+
import { createEditedIndicatorVisibilityController } from './modules/app-core/edited-indicator-visibility-controller.js'
3233
import { createLayoutDiagnosticsSetup } from './modules/app-core/layout-diagnostics-setup.js'
3334
import { createWorkspaceControllersSetup } from './modules/app-core/workspace-controllers-setup.js'
3435
import { createGitHubWorkflowsSetup } from './modules/app-core/github-workflows-setup.js'
@@ -436,6 +437,11 @@ const prContextUi = createGitHubPrContextUiController({
436437
closeWorkspacesDrawer: () => workspacesDrawerController?.setOpen(false),
437438
})
438439

440+
const editedIndicatorVisibilityController = createEditedIndicatorVisibilityController({
441+
getToken: () => githubAiContextState.token,
442+
getActivePrContext: () => githubAiContextState.activePrContext,
443+
})
444+
439445
const byotControls = createGitHubByotControls({
440446
controlsRoot: githubAiControls,
441447
tokenInput: githubTokenInput,
@@ -472,6 +478,7 @@ const byotControls = createGitHubByotControls({
472478
prContextUi.syncAiChatTokenVisibility(token)
473479
chatDrawerController.setToken(token)
474480
prDrawerController.setToken(token)
481+
editedIndicatorVisibilityController.refreshIndicators()
475482
},
476483
setStatus,
477484
})
@@ -510,6 +517,8 @@ const {
510517
editorPanelsByKind,
511518
editorHeaderLabelByKind,
512519
editorHeaderDirtyStatusByKind,
520+
getShouldShowEditedDesign:
521+
editedIndicatorVisibilityController.getShouldShowEditedDesign,
513522
defaultTabNameByKind,
514523
toNonEmptyWorkspaceText,
515524
getLoadedStylesTabId: () => loadedStylesTabId,
@@ -660,6 +669,8 @@ const {
660669
setHasPendingWorkspaceTabsRender: value => (hasPendingWorkspaceTabsRender = value),
661670
persistActiveTabEditorContent,
662671
getWorkspaceTabDisplay,
672+
getShouldShowEditedDesign:
673+
editedIndicatorVisibilityController.getShouldShowEditedDesign,
663674
workspaceTabsShell,
664675
workspaceTabAddWrap,
665676
setWorkspaceTabRenameState: value => (workspaceTabRenameState = value),
@@ -684,6 +695,11 @@ const {
684695
createWorkspaceTabId,
685696
})
686697

698+
editedIndicatorVisibilityController.setRefreshHandlers({
699+
syncHeaderLabels,
700+
renderWorkspaceTabs,
701+
})
702+
687703
const githubWorkflows = createGitHubWorkflowsSetup({
688704
factories: {
689705
createGitHubPrEditorSyncController,
@@ -758,6 +774,9 @@ const githubWorkflows = createGitHubWorkflowsSetup({
758774
getStyleMode: () => styleMode.value,
759775
getActivePrContextSyncKey,
760776
prContextUi,
777+
onPrContextStateChange: () => {
778+
editedIndicatorVisibilityController.refreshIndicators()
779+
},
761780
getTokenForVisibility: () => githubAiContextState.token,
762781
closeWorkspacesDrawer: () => {
763782
void workspacesDrawerController?.setOpen(false)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const createEditedIndicatorVisibilityController = ({
2+
getToken,
3+
getActivePrContext,
4+
} = {}) => {
5+
let runRefresh = () => {}
6+
7+
const hasToken = () => {
8+
const token = typeof getToken === 'function' ? getToken() : ''
9+
return typeof token === 'string' && token.trim().length > 0
10+
}
11+
12+
const hasActivePrContext = () => {
13+
const activePrContext =
14+
typeof getActivePrContext === 'function' ? getActivePrContext() : null
15+
return Boolean(activePrContext?.prTitle)
16+
}
17+
18+
const getShouldShowEditedDesign = () => hasToken() && hasActivePrContext()
19+
20+
const setRefreshHandlers = ({ syncHeaderLabels, renderWorkspaceTabs } = {}) => {
21+
runRefresh = () => {
22+
if (typeof syncHeaderLabels === 'function') {
23+
syncHeaderLabels()
24+
}
25+
26+
if (typeof renderWorkspaceTabs === 'function') {
27+
renderWorkspaceTabs()
28+
}
29+
}
30+
}
31+
32+
const refreshIndicators = () => {
33+
runRefresh()
34+
}
35+
36+
return {
37+
getShouldShowEditedDesign,
38+
setRefreshHandlers,
39+
refreshIndicators,
40+
}
41+
}
42+
43+
export { createEditedIndicatorVisibilityController }

src/modules/app-core/github-workflows-setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const createGitHubWorkflowsSetup = ({
3434
workspace.reconcileWorkspaceTabsWithPushUpdates,
3535
getActivePrContextSyncKey: runtime.getActivePrContextSyncKey,
3636
prContextUi: runtime.prContextUi,
37+
onPrContextStateChange: runtime.onPrContextStateChange,
3738
getTokenForVisibility: runtime.getTokenForVisibility,
3839
closeWorkspacesDrawer: runtime.closeWorkspacesDrawer,
3940
getActivePrEditorSyncKey: runtime.getActivePrEditorSyncKey,

src/modules/app-core/github-workflows.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const initializeGitHubWorkflows = ({
5858
reconcileWorkspaceTabsWithPushUpdates,
5959
getActivePrContextSyncKey,
6060
prContextUi,
61+
onPrContextStateChange,
6162
getTokenForVisibility,
6263
closeWorkspacesDrawer,
6364
getActivePrEditorSyncKey,
@@ -191,6 +192,10 @@ const initializeGitHubWorkflows = ({
191192
if (activeContext) {
192193
closeWorkspacesDrawer()
193194
}
195+
196+
if (typeof onPrContextStateChange === 'function') {
197+
onPrContextStateChange(activeContext)
198+
}
194199
},
195200
onSyncActivePrEditorContent: async args => {
196201
const result = await prEditorSyncController.syncFromActiveContext(args)
@@ -289,6 +294,9 @@ const initializeGitHubWorkflows = ({
289294
prDrawerController.setSelectedRepository(githubAiContextState.selectedRepository)
290295
prDrawerController.syncRepositories()
291296
prContextUi.setActivePrContext(prDrawerController.getActivePrContext())
297+
if (typeof onPrContextStateChange === 'function') {
298+
onPrContextStateChange(prDrawerController.getActivePrContext())
299+
}
292300

293301
githubPrContextClose?.addEventListener('click', () => {
294302
if (!githubAiContextState.activePrContext) {

src/modules/app-core/workspace-controllers-setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const createWorkspaceControllersSetup = ({
4848
setHasPendingWorkspaceTabsRender,
4949
persistActiveTabEditorContent,
5050
getWorkspaceTabDisplay,
51+
getShouldShowEditedDesign,
5152
workspaceTabsShell,
5253
workspaceTabAddWrap,
5354
setWorkspaceTabRenameState,
@@ -178,6 +179,7 @@ const createWorkspaceControllersSetup = ({
178179
finishWorkspaceTabRename: finishWorkspaceTabRenameDelegate,
179180
removeWorkspaceTab: removeWorkspaceTabDelegate,
180181
getWorkspaceTabDisplay,
182+
getShouldShowEditedDesign,
181183
workspaceTabsShell,
182184
workspaceTabAddWrap,
183185
syncEditorFromActiveWorkspaceTab: syncEditorFromActiveWorkspaceTabDelegate,

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const createWorkspaceEditorHelpers = ({
55
editorPanelsByKind,
66
editorHeaderLabelByKind,
77
editorHeaderDirtyStatusByKind,
8+
getShouldShowEditedDesign,
89
defaultTabNameByKind,
910
toNonEmptyWorkspaceText,
1011
getLoadedStylesTabId,
@@ -54,7 +55,11 @@ const createWorkspaceEditorHelpers = ({
5455
}
5556

5657
if (dirtyStatusLabel instanceof HTMLElement) {
57-
const isDirty = Boolean(tab?.isDirty)
58+
const shouldShowEditedDesign =
59+
typeof getShouldShowEditedDesign === 'function'
60+
? Boolean(getShouldShowEditedDesign())
61+
: true
62+
const isDirty = shouldShowEditedDesign && Boolean(tab?.isDirty)
5863
dirtyStatusLabel.hidden = !isDirty
5964
if (isDirty) {
6065
dirtyStatusLabel.removeAttribute('aria-hidden')

src/modules/app-core/workspace-tabs-renderer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const createWorkspaceTabsRenderer = ({
1919
finishWorkspaceTabRename,
2020
removeWorkspaceTab,
2121
getWorkspaceTabDisplay,
22+
getShouldShowEditedDesign,
2223
workspaceTabsShell,
2324
workspaceTabAddWrap,
2425
syncEditorFromActiveWorkspaceTab,
@@ -43,6 +44,10 @@ const createWorkspaceTabsRenderer = ({
4344
try {
4445
const tabs = workspaceTabsState.getTabs()
4546
const activeTabId = workspaceTabsState.getActiveTabId()
47+
const shouldShowEditedDesign =
48+
typeof getShouldShowEditedDesign === 'function'
49+
? Boolean(getShouldShowEditedDesign())
50+
: true
4651

4752
workspaceTabsStrip.replaceChildren()
4853

@@ -226,7 +231,7 @@ const createWorkspaceTabsRenderer = ({
226231
tabContainer.append(metaBadge)
227232
}
228233

229-
if (tab.isDirty) {
234+
if (shouldShowEditedDesign && tab.isDirty) {
230235
const dirtyBadge = document.createElement('span')
231236
dirtyBadge.className = 'workspace-tab__dirty-indicator'
232237
dirtyBadge.setAttribute('aria-hidden', 'true')

0 commit comments

Comments
 (0)