Skip to content

Commit f9f9f04

Browse files
author
DavidQ
committed
Initialize a single active workspace palette for Workspace V2 export baseline - PR_11_309
1 parent fb3ba7b commit f9f9f04

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# PR_11_309 Report - Workspace V2 Default Active Palette Initialization
2+
3+
## Scope
4+
- `tools/workspace-v2/index.js`
5+
- Workspace V2 initialization / full reset / export baseline behavior
6+
7+
## Files Changed
8+
- `tools/workspace-v2/index.js`
9+
- `docs/dev/reports/PR_11_309_report.md`
10+
11+
## What Changed
12+
- Added `ensureWorkspaceActivePaletteBaseline()` to guarantee one schema-valid active palette state exists in Workspace V2 memory.
13+
- Called baseline palette initialization:
14+
- during startup before producer session initialization
15+
- at producer session initialization start
16+
- during full reset after clearing prior state
17+
- Baseline active palette uses one active palette entry source with empty swatches:
18+
- `hostContextId: "workspace-active-palette"`
19+
- `palette.swatches: []`
20+
- This ensures workspace manifest export can always build `tools.palette-browser` with:
21+
- `schema`
22+
- `version`
23+
- `name`
24+
- `swatches: []`
25+
26+
## Validation
27+
- Command run:
28+
- `node --check tools/workspace-v2/index.js`
29+
- Result:
30+
- PASS
31+
32+
## Expected Runtime Outcome
33+
- Fresh page load and full reset now keep exactly one active palette baseline available.
34+
- Export no longer fails solely because active palette state was missing after refresh/reset.
35+
- Asset Browser session creation/launch does not remove the workspace-owned palette entry.
36+
37+
## Full Samples Smoke
38+
- Skipped.
39+
- Reason: change is isolated to Workspace V2 state initialization/reset in one JS file and does not modify shared sample infrastructure.

tools/workspace-v2/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class WorkspaceV2SessionProducer {
224224
this.initializeWorkspaceToolsSummaryNode();
225225
this.initializeHiddenImportFileInput();
226226
this.decodeSessionParamFromUrl();
227+
this.ensureWorkspaceActivePaletteBaseline();
227228
this.initializeWorkspaceProducerSession();
228229
this.refreshPaletteOwnershipStateAndUi();
229230
this.registerSnapshotHook();
@@ -506,6 +507,18 @@ class WorkspaceV2SessionProducer {
506507
);
507508
}
508509

510+
ensureWorkspaceActivePaletteBaseline() {
511+
if (this.hasWorkspaceActivePalette()) {
512+
return;
513+
}
514+
this.workspaceActivePalette = {
515+
hostContextId: "workspace-active-palette",
516+
palette: {
517+
swatches: []
518+
}
519+
};
520+
}
521+
509522
hasWorkspaceActivePalette() {
510523
return Boolean(
511524
this.workspaceActivePalette &&
@@ -670,6 +683,7 @@ class WorkspaceV2SessionProducer {
670683
}
671684

672685
initializeWorkspaceProducerSession() {
686+
this.ensureWorkspaceActivePaletteBaseline();
673687
if (this.isValidSessionPayload(this.currentSessionPayload) && this.currentHostContextId) {
674688
return;
675689
}
@@ -3174,6 +3188,7 @@ class WorkspaceV2SessionProducer {
31743188
this.resetUrlState(false);
31753189
this.currentHostContextId = "";
31763190
this.workspaceActivePalette = null;
3191+
this.ensureWorkspaceActivePaletteBaseline();
31773192
this.workspaceImportedToolEntries = {};
31783193
this.setCurrentSessionPayload(null, "");
31793194
this.initializeWorkspaceProducerSession();

0 commit comments

Comments
 (0)