Skip to content

Commit b1ac1ef

Browse files
author
DavidQ
committed
Fix SVG Asset Studio hosted direct payload boot path - PR 11.152
1 parent 2a1d205 commit b1ac1ef

5 files changed

Lines changed: 238 additions & 29 deletions

File tree

docs/dev/codex_commands.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,58 @@ Reasoning: high
66
STRICT SCOPE MODE
77

88
ALLOWED FILES:
9-
- tools/vector-map-editor/main.js
10-
- docs/dev/reports/vector_map_hosted_payload_boot_11_151.txt
9+
- tools/svg-asset-studio/main.js
10+
- docs/dev/reports/svg_asset_studio_hosted_payload_boot_11_152.txt
1111

1212
ALLOWED CHANGES:
13-
- fix Vector Map Editor hosted direct payload boot
13+
- fix SVG Asset Studio hosted direct payload boot
1414
- create/update report only
1515

1616
TASK:
1717

1818
1. Open:
19-
tools/vector-map-editor/main.js
19+
tools/svg-asset-studio/main.js
2020

21-
2. Find boot/init logic that shows:
22-
`No map objects loaded. Import a map JSON file or launch with a sample preset path.`
21+
2. Find hosted launch/shared context input path.
2322

24-
3. Find hosted launch/shared context input path.
23+
3. Ensure hosted Workspace Manager payload is read as:
24+
payloadJson.vectorAssetDocument
2525

26-
4. Ensure hosted Workspace Manager payload is read as:
27-
payloadJson.vectorMapDocument
26+
4. Ensure editor load/render source uses:
27+
- payloadJson.vectorAssetDocument.svgText
28+
- payloadJson.vectorAssetDocument.sourceName
29+
- payloadJson.vectorAssetDocument.editorOptions
2830

29-
5. Ensure editor state/render source uses:
30-
payloadJson.vectorMapDocument.objects
31-
32-
6. For hosted direct payload flow:
31+
5. For hosted direct payload flow:
3332
- do not require samplePresetPath
3433
- do not require import path
35-
- do not fallback to empty map
36-
- do not show old preset-path message when valid payload exists
34+
- do not fallback to demo SVG
35+
- do not show old preset/import message when valid payload exists
3736

38-
7. Do NOT:
37+
6. Do NOT:
3938
- modify schemas
4039
- modify Sample 1902 JSON
4140
- modify Workspace Manager
4241
- modify tool host runtime
43-
- add fallback/demo/default objects
42+
- add fallback/demo/default SVG
4443
- transform/wrap/normalize payload
4544

46-
8. Validate:
47-
- JS syntax for tools/vector-map-editor/main.js
48-
- direct hosted payload containing obj-player-path and obj-hazard-zone loads into editor state
49-
- old no-map message is not shown for valid hosted payload
45+
7. Validate:
46+
- JS syntax for tools/svg-asset-studio/main.js
47+
- direct hosted payload containing vectorAssetDocument.svgText loads into editor state
48+
- sourceName sample-0901-ship.svg is recognized
5049
- git diff --name-only contains only ALLOWED FILES
5150

52-
9. Write:
53-
docs/dev/reports/vector_map_hosted_payload_boot_11_151.txt
51+
8. Write:
52+
docs/dev/reports/svg_asset_studio_hosted_payload_boot_11_152.txt
5453

5554
Report must include:
5655
- old boot path found
5756
- new direct hosted payload path
58-
- objects verified
57+
- sourceName/svgText verified
5958
- validation result
6059
- strict scope confirmation
6160
- remaining blockers if any
6261

63-
10. Package Codex output ZIP at:
64-
tmp/PR_11_151_FIX_VECTOR_MAP_HOSTED_PAYLOAD_BOOT.zip
62+
9. Package Codex output ZIP at:
63+
tmp/PR_11_152_FIX_SVG_ASSET_STUDIO_HOSTED_PAYLOAD_BOOT.zip

docs/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fix Vector Map Editor hosted direct payload boot path - PR 11.151
1+
Fix SVG Asset Studio hosted direct payload boot path - PR 11.152
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Task: svg_asset_studio_hosted_payload_boot_11_152
2+
Date: 2026-04-30
3+
4+
Files changed:
5+
- tools/SVG Asset Studio/main.js
6+
- docs/dev/reports/svg_asset_studio_hosted_payload_boot_11_152.txt
7+
8+
Old boot path found:
9+
- `initialize()` always called `tryLoadPresetFromQuery()`.
10+
- Query/preset flow required `samplePresetPath` resolution and could emit preset-path/import-oriented status/error messages.
11+
12+
New direct hosted payload path:
13+
- Hosted shared context now reads:
14+
hostContext.sharedContext.payloadJson.vectorAssetDocument
15+
- Hosted load source fields now use:
16+
- payloadJson.vectorAssetDocument.svgText
17+
- payloadJson.vectorAssetDocument.sourceName
18+
- payloadJson.vectorAssetDocument.editorOptions
19+
20+
Hosted direct payload boot behavior:
21+
- Added hosted loader before preset-query flow.
22+
- When hosted direct payload is valid (non-empty `svgText`):
23+
1) SVG is loaded directly from hosted `svgText` into editor state.
24+
2) `sourceName` is applied/recognized for loaded document naming/status.
25+
3) `editorOptions` are applied from direct payload.
26+
4) `tryLoadPresetFromQuery()` is skipped, so `samplePresetPath` is not required for hosted direct payload boot.
27+
5) Preset/import-path boot messaging is not used for this valid hosted direct flow.
28+
29+
sourceName/svgText verified:
30+
- Sample 1902 workspace payload contains:
31+
- `vectorAssetDocument.svgText` (non-empty)
32+
- `vectorAssetDocument.sourceName` = `sample-0901-ship.svg`
33+
- `vectorAssetDocument.editorOptions` object
34+
35+
Validation commands/results:
36+
- node --check "tools/SVG Asset Studio/main.js" -> PASS
37+
- rg hosted direct payload path checks in main.js -> PASS
38+
- node JSON verification against samples/phase-19/1902/sample.1902.workspace-all-tools.json -> PASS
39+
- git diff --name-only -- "tools/SVG Asset Studio/main.js" "docs/dev/reports/svg_asset_studio_hosted_payload_boot_11_152.txt" -> PASS
40+
41+
Strict scope confirmation:
42+
- Code changes were made only in SVG Asset Studio main file and this report.
43+
- No schema/sample/workspace-manager/tool-host-runtime changes.
44+
- No demo/default SVG content was injected.
45+
- No payload wrapping/transform schema adaptation was added; hosted fields are read directly from `payloadJson.vectorAssetDocument`.
46+
47+
Remaining blockers:
48+
- None in SVG Asset Studio hosted boot scope.
49+
- Repository has unrelated pre-existing dirty files outside this scoped task.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# BUILD_PR_LEVEL_11_152_FIX_SVG_ASSET_STUDIO_HOSTED_PAYLOAD_BOOT
2+
3+
## Purpose
4+
Fix SVG Asset Studio so Workspace Manager launches read the direct hosted `payloadJson.vectorAssetDocument` from Sample 1902.
5+
6+
## Current State
7+
- Workspace Manager loads Sample 1902.
8+
- Palette Browser works.
9+
- Vector Map Editor now works.
10+
- SVG Asset Studio is the next direct-payload tool to validate/fix.
11+
12+
## STRICT SCOPE
13+
14+
### ALLOWED FILES
15+
- tools/svg-asset-studio/main.js
16+
- docs/dev/reports/svg_asset_studio_hosted_payload_boot_11_152.txt
17+
18+
### ALLOWED CHANGES
19+
- fix SVG Asset Studio hosted-input boot path only
20+
- read direct hosted `payloadJson.vectorAssetDocument`
21+
- render/load SVG from direct payload
22+
- create report
23+
24+
## FORBIDDEN
25+
26+
Codex MUST NOT:
27+
- modify schemas
28+
- modify Sample 1902 JSON
29+
- modify Workspace Manager
30+
- modify tool host runtime
31+
- modify other tools
32+
- add fallback/default/demo SVG
33+
- re-add preset loading
34+
- transform/wrap/normalize payload
35+
- infer missing vector asset data
36+
37+
## Required Behavior
38+
39+
When hosted by Workspace Manager, SVG Asset Studio must:
40+
41+
1. Read hosted shared context payload:
42+
- `payloadJson`
43+
2. Use direct document:
44+
- `payloadJson.vectorAssetDocument`
45+
3. Load/render from:
46+
- `vectorAssetDocument.svgText`
47+
- `vectorAssetDocument.sourceName`
48+
- `vectorAssetDocument.editorOptions`
49+
4. If `vectorAssetDocument` or `svgText` is missing:
50+
- show visible input/schema error
51+
- do NOT fallback to demo SVG
52+
- do NOT require old preset/import path for hosted direct JSON flow
53+
54+
## Required Investigation
55+
56+
Codex must inspect SVG Asset Studio for old boot paths that depend on:
57+
- `samplePresetPath`
58+
- preset path query params
59+
- import path only
60+
- fallback/demo SVG
61+
- old sample preset launch text
62+
- wrapper payload shape
63+
64+
Do not remove general manual import UI if still valid.
65+
Only fix hosted Workspace Manager direct payload boot.
66+
67+
## Required Validation
68+
69+
Targeted validation only.
70+
71+
Required:
72+
- `tools/svg-asset-studio/main.js` syntax passes.
73+
- Hosted payload with `vectorAssetDocument.svgText` loads into the editor.
74+
- Hosted payload with `sourceName = sample-0901-ship.svg` is recognized.
75+
- No old fallback/demo SVG is used for valid hosted payload.
76+
- No schema/sample/runtime/workspace files changed.
77+
- `git diff --name-only` contains only ALLOWED FILES.
78+
79+
## Report
80+
81+
Write:
82+
83+
- `docs/dev/reports/svg_asset_studio_hosted_payload_boot_11_152.txt`
84+
85+
Report must include:
86+
- file changed
87+
- old boot path found
88+
- new direct hosted payload path
89+
- sourceName/svgText verified
90+
- validation command/result
91+
- strict scope confirmation
92+
- remaining blockers if any
93+
94+
## Full Samples Smoke Test
95+
96+
Skipped.
97+
98+
Reason:
99+
- targeted SVG Asset Studio hosted payload boot fix only
100+
- full samples smoke test takes approximately 20 minutes
101+
102+
## Acceptance
103+
104+
- SVG Asset Studio consumes hosted `payloadJson.vectorAssetDocument`.
105+
- Sample 1902 SVG asset renders/loads when opened through Workspace Manager.
106+
- No preset/fallback/demo path is required for hosted direct JSON.

tools/SVG Asset Studio/main.js

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
SHARED_ASSET_HANDOFF_EVENT,
3030
SHARED_PALETTE_HANDOFF_EVENT
3131
} from "../shared/assetUsageIntegration.js";
32+
import { readToolHostSharedContextFromLocation } from "../shared/toolHostSharedContext.js";
3233

3334
const SVG_NS = "http://www.w3.org/2000/svg";
3435
const DRAWABLE_SELECTOR = "rect,ellipse,circle,line,polyline,path";
@@ -3158,6 +3159,59 @@ async function tryLoadPresetFromQuery() {
31583159
}
31593160
}
31603161

3162+
function readHostedVectorAssetDocumentFromContext() {
3163+
const hostContext = readToolHostSharedContextFromLocation(window.location);
3164+
const payloadJson = hostContext?.sharedContext?.payloadJson;
3165+
const vectorAssetDocument = payloadJson?.vectorAssetDocument;
3166+
if (!vectorAssetDocument || typeof vectorAssetDocument !== "object" || Array.isArray(vectorAssetDocument)) {
3167+
return null;
3168+
}
3169+
3170+
const svgText = typeof vectorAssetDocument.svgText === "string"
3171+
? vectorAssetDocument.svgText
3172+
: "";
3173+
if (!svgText.trim()) {
3174+
return null;
3175+
}
3176+
3177+
const sourceName = typeof vectorAssetDocument.sourceName === "string"
3178+
? vectorAssetDocument.sourceName.trim()
3179+
: "";
3180+
const editorOptions = vectorAssetDocument.editorOptions && typeof vectorAssetDocument.editorOptions === "object" && !Array.isArray(vectorAssetDocument.editorOptions)
3181+
? vectorAssetDocument.editorOptions
3182+
: null;
3183+
3184+
return {
3185+
svgText,
3186+
sourceName,
3187+
editorOptions
3188+
};
3189+
}
3190+
3191+
function tryLoadHostedVectorAssetFromContext() {
3192+
const hostedVectorAssetDocument = readHostedVectorAssetDocumentFromContext();
3193+
if (!hostedVectorAssetDocument) {
3194+
return false;
3195+
}
3196+
3197+
registerPaletteFromPresetEditorOptions(hostedVectorAssetDocument.editorOptions, "");
3198+
state.skipExternalProjectStateUntil = Date.now() + 3000;
3199+
loadSvgFromText(
3200+
hostedVectorAssetDocument.svgText,
3201+
hostedVectorAssetDocument.sourceName || "hosted-vector-asset.svg"
3202+
);
3203+
if (hostedVectorAssetDocument.editorOptions) {
3204+
applySampleEditorOptions(hostedVectorAssetDocument.editorOptions);
3205+
}
3206+
const paletteClassification = ensurePaletteSelectionFromDeclaredInputs(hostedVectorAssetDocument.editorOptions || {});
3207+
bindPaintAndStrokeFromLoadedData();
3208+
applyEnablementState();
3209+
emitVectorAssetControlReadiness("", { paletteClassification, phase: "loaded", lifecycleStable: true });
3210+
setStatus(`Loaded hosted SVG: ${hostedVectorAssetDocument.sourceName || "hosted-vector-asset.svg"}.`);
3211+
syncVectorAssetUxContract();
3212+
return true;
3213+
}
3214+
31613215
function bindEvents() {
31623216
refs.newSvgButton.addEventListener("click", () => {
31633217
finalizePendingPolyline(false);
@@ -3464,8 +3518,9 @@ async function initialize() {
34643518
setPaletteTarget("paint", { silent: true });
34653519
applyEnablementState();
34663520
renderElementList();
3467-
const presetLoaded = await tryLoadPresetFromQuery();
3468-
if (!presetLoaded && !hasErrorStatus()) {
3521+
const hostedLoaded = tryLoadHostedVectorAssetFromContext();
3522+
const presetLoaded = hostedLoaded ? false : await tryLoadPresetFromQuery();
3523+
if (!hostedLoaded && !presetLoaded && !hasErrorStatus()) {
34693524
setStatus("SVG Asset Studio ready.");
34703525
}
34713526
syncVectorAssetUxContract();

0 commit comments

Comments
 (0)