Skip to content

Commit 42b32f7

Browse files
author
DavidQ
committed
Fix SVG launch entry path so hosted workspace shell executes - PR 11.180
1 parent 178f923 commit 42b32f7

7 files changed

Lines changed: 300 additions & 37 deletions

File tree

docs/dev/codex_commands.md

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,45 @@
1-
# Codex Commands — PR 11.179
1+
# Codex Commands — PR 11.180
22

33
Model: GPT-5.4
44
Reasoning: high
55

6-
Implement the correct hosted SVG tile writer.
7-
8-
Goal:
9-
- hosted SVG state flows from workspaceShell to Workspace Manager tile.
10-
- no platformShell badge writes.
11-
- no assetUsageIntegration handoff reads/writes.
12-
- no palette dependency.
6+
Fix SVG launch/entry path so `[SVG_HOSTED_WORKSPACE_ENTRY]` appears.
137

148
Primary files:
15-
- `tools/shared/workspaceShell.js`
16-
- `tools/SVG Asset Studio/main.js`
179
- `tools/Workspace Manager/main.js`
10+
- `tools/SVG Asset Studio/main.js`
1811

1912
Steps:
20-
1. Ensure `workspaceShell.js` exports `initWorkspaceShell()`.
21-
2. In hosted SVG mode, SVG Asset Studio calls `initWorkspaceShell()`.
22-
3. `workspaceShell.js` reads hosted context and normalizes `payloadJson.vectorAssetDocument`.
23-
4. `workspaceShell.js` logs `[WORKSPACE_SHELL_STATE]`.
24-
5. `workspaceShell.js` posts `tools:workspace-shell-state` to parent and logs `[SVG_POSTMESSAGE_SEND]`.
25-
6. Workspace Manager listens for the message.
26-
7. Workspace Manager matches `svg-asset-studio` tile by `hostContextId` where available.
27-
8. Workspace Manager writes SVG tile label/status from normalized state and logs:
28-
- `[SVG_POSTMESSAGE_RECEIVE]`
29-
- `[SVG_TILE_WRITE]`
30-
9. Do not restore shared handoff or palette-first logic.
31-
10. Create report `docs/dev/reports/pr_11_179_validation.md`.
13+
1. Add `[WORKSPACE_TOOL_LAUNCH]` logging for every mounted tool.
14+
2. Add `[SVG_LAUNCH_REQUEST]` logging for SVG with iframe URL and payload proof.
15+
3. Add `[SVG_ENTRY_TOP]` at the top of SVG Asset Studio entry.
16+
4. Ensure SVG iframe URL has:
17+
- hosted=1
18+
- hostToolId=svg-asset-studio
19+
- hostContextId non-empty
20+
5. Ensure SVG hosted guard condition matches actual URL params.
21+
6. Ensure hosted SVG calls `initWorkspaceShell()`.
22+
7. Do not restore shared handoff or platformShell badge writes.
23+
8. Add report:
24+
- `docs/dev/reports/pr_11_180_validation.md`
3225

3326
Validation:
34-
- `node --check tools/shared/workspaceShell.js`
35-
- `node --check "tools/SVG Asset Studio/main.js"`
3627
- `node --check "tools/Workspace Manager/main.js"`
28+
- `node --check "tools/SVG Asset Studio/main.js"`
29+
- `node --check tools/shared/workspaceShell.js`
3730
- `node --check tools/shared/platformShell.js`
38-
- `node --check tools/shared/assetUsageIntegration.js`
3931

40-
Manual UAT:
32+
Manual:
4133
- Open sample 1902.
42-
- Launch Workspace Manager.
43-
- Mount SVG Asset Studio.
44-
- Confirm expected logs.
45-
- Confirm SVG tile shows sourceName, not `Asset: none`.
46-
- Confirm Vector Map Editor still works.
47-
48-
Full samples smoke:
49-
- Skip.
50-
- Reason: targeted hosted SVG tile write path; full samples smoke takes about 20 minutes and is not required.
34+
- Click/mount SVG Asset Studio.
35+
- Confirm logs:
36+
- `[WORKSPACE_TOOL_LAUNCH]`
37+
- `[SVG_LAUNCH_REQUEST]`
38+
- `[SVG_ENTRY_TOP]`
39+
- `[SVG_HOSTED_WORKSPACE_ENTRY]`
40+
- `[WORKSPACE_SHELL_STATE]`
41+
- `[SVG_POSTMESSAGE_SEND]`
42+
- `[SVG_POSTMESSAGE_RECEIVE]`
5143

5244
Return ZIP artifact at:
53-
`<project folder>/tmp/PR_11_179_20260430_01.zip`
45+
`<project folder>/tmp/PR_11_180_20260430_01.zip`

docs/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Write hosted SVG tile state from workspace shell contract only - PR 11.179
1+
Fix SVG launch entry path so hosted workspace shell executes - PR 11.180
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# PR 11.180 Diagnosis
2+
3+
## Finding
4+
`[SVG_HOSTED_WORKSPACE_ENTRY]` does not appear.
5+
6+
That means the SVG hosted entry branch is not executing.
7+
8+
## Highest probability causes
9+
1. SVG is not being mounted.
10+
2. SVG launch URL lacks `hosted=1`, `hostToolId=svg-asset-studio`, or `hostContextId`.
11+
3. Workspace Manager launches a different entry file than `tools/SVG Asset Studio/main.js`.
12+
4. The guard condition in SVG entry does not match actual launch params.
13+
14+
## Fix Strategy
15+
Trace from Workspace Manager launch to SVG entry top, then correct the first broken link.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# PR 11.180 Validation
2+
3+
## Scope
4+
Added launch and entry trace logging to prove/fix the hosted SVG launch path into `tools/SVG Asset Studio/main.js` and the hosted workspace shell branch.
5+
6+
## Files changed
7+
- `tools/Workspace Manager/main.js`
8+
- `tools/SVG Asset Studio/main.js`
9+
- `docs/dev/reports/pr_11_180_validation.md`
10+
11+
## Workspace Manager launch logs
12+
`tools/Workspace Manager/main.js` now logs `[WORKSPACE_TOOL_LAUNCH]` after `runtime.launch(...)` for every mounted tool using the actual returned iframe URL/source URL.
13+
14+
The launch log includes:
15+
- requested tool id
16+
- normalized mounted tool id
17+
- iframe URL
18+
- `hosted` URL param
19+
- `hostToolId` URL param
20+
- `hostContextId` URL param
21+
- payload presence
22+
- payload keys
23+
24+
For `svg-asset-studio`, Workspace Manager also logs `[SVG_LAUNCH_REQUEST]` with:
25+
- iframe URL
26+
- hosted URL params
27+
- `payloadJson.vectorAssetDocument` existence
28+
- `sourceName`
29+
- SVG text length
30+
31+
## SVG entry log
32+
`tools/SVG Asset Studio/main.js` now logs `[SVG_ENTRY_TOP]` at module top before hosted branch detection.
33+
34+
The entry log includes:
35+
- `location.href`
36+
- `hosted`
37+
- `hostToolId`
38+
- `hostContextId`
39+
40+
The hosted guard still requires:
41+
- `hosted=1`
42+
- `hostToolId=svg-asset-studio`
43+
- non-empty `hostContextId`
44+
45+
When the guard matches, SVG still logs `[SVG_HOSTED_WORKSPACE_ENTRY]` and calls `initWorkspaceShell(window.location, document)`.
46+
47+
## Legacy path boundaries
48+
- Shared handoff logic was not restored.
49+
- platformShell badge writes were not restored.
50+
- No schemas were changed.
51+
- No sample JSON was changed.
52+
53+
## Validation
54+
- PASS: `node --check "tools/Workspace Manager/main.js"`
55+
- PASS: `node --check "tools/SVG Asset Studio/main.js"`
56+
- PASS: `node --check tools/shared/workspaceShell.js`
57+
- PASS: `node --check tools/shared/platformShell.js`
58+
59+
## Manual UAT
60+
Not run in this terminal session. Required browser UAT remains:
61+
- Open sample 1902.
62+
- Click/mount SVG Asset Studio.
63+
- Confirm logs: `[WORKSPACE_TOOL_LAUNCH]`, `[SVG_LAUNCH_REQUEST]`, `[SVG_ENTRY_TOP]`, `[SVG_HOSTED_WORKSPACE_ENTRY]`, `[WORKSPACE_SHELL_STATE]`, `[SVG_POSTMESSAGE_SEND]`, `[SVG_POSTMESSAGE_RECEIVE]`.
64+
- Confirm SVG tile shows sourceName, not `Asset: none`.
65+
66+
## Full samples smoke
67+
Skipped. Reason: targeted SVG launch path and hosted entry verification; full samples smoke takes about 20 minutes and is not required.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# BUILD_PR_LEVEL_11_180_FIX_SVG_LAUNCH_ENTRY_PATH
2+
3+
## Purpose
4+
Fix the reason `[SVG_HOSTED_WORKSPACE_ENTRY]` never appears: SVG Asset Studio is not reaching the hosted SVG entry branch.
5+
6+
## Proven State
7+
After PR 11.179:
8+
- Vector Map Editor hosted path logs correctly.
9+
- `platformShell` hosted badge row is blocked for Vector Map Editor.
10+
- No SVG hosted entry log appears.
11+
- No workspaceShell SVG state appears.
12+
13+
Therefore the SVG tool is either:
14+
1. not being launched/mounted when clicked, or
15+
2. launched with the wrong URL params, or
16+
3. launched through the wrong entry file/path, or
17+
4. `hostToolId` does not equal `svg-asset-studio`.
18+
19+
## Scope
20+
One PR purpose only:
21+
- Trace and fix SVG Asset Studio launch URL/entry path from Workspace Manager.
22+
23+
Do not modify schemas.
24+
Do not modify sample 1902 JSON.
25+
Do not change vector map behavior.
26+
Do not restore shared handoff.
27+
Do not add fallback labels.
28+
29+
## Implementation Requirements
30+
31+
### 1. Log every Workspace Manager tool launch
32+
In `tools/Workspace Manager/main.js`, before launching/mounting any tool, log:
33+
34+
`[WORKSPACE_TOOL_LAUNCH]`
35+
36+
Payload:
37+
- requestedToolId
38+
- normalizedToolId
39+
- entryUrl / iframe src
40+
- hostToolId param
41+
- hostContextId
42+
- hosted param
43+
- hasPayloadJson
44+
- payload keys
45+
46+
### 2. Log specifically for SVG
47+
When requested/normalized tool is `svg-asset-studio`, log:
48+
49+
`[SVG_LAUNCH_REQUEST]`
50+
51+
Payload:
52+
- toolId
53+
- registry entry path/url
54+
- iframe src
55+
- hostToolId
56+
- hostContextId
57+
- payloadJson.vectorAssetDocument exists
58+
- sourceName
59+
- svgText length
60+
61+
### 3. Fix launch params
62+
Ensure SVG iframe URL includes:
63+
- `hosted=1`
64+
- `hostToolId=svg-asset-studio`
65+
- `hostContextId=<non-empty>`
66+
67+
### 4. Fix launch path if wrong
68+
Ensure SVG launches the actual entry that loads:
69+
70+
`tools/SVG Asset Studio/main.js`
71+
72+
If Workspace Manager launches a different HTML/JS entry for SVG, wire the hosted guard there too or route to the correct entry.
73+
74+
### 5. Ensure SVG hosted guard condition matches actual params
75+
In `tools/SVG Asset Studio/main.js`, log at top before any branching:
76+
77+
`[SVG_ENTRY_TOP]`
78+
79+
Payload:
80+
- location.href
81+
- hosted
82+
- hostToolId
83+
- hostContextId
84+
85+
Then ensure hosted detection matches the actual URL params.
86+
87+
### 6. Keep legacy blocked
88+
Do not remove the hosted platformShell badge-row block.
89+
Do not re-enable assetUsageIntegration hosted reads/writes.
90+
91+
## Acceptance
92+
Manual UAT:
93+
94+
Click/mount SVG Asset Studio in sample 1902.
95+
96+
Expected logs:
97+
- `[WORKSPACE_TOOL_LAUNCH]` with requested/normalized `svg-asset-studio`
98+
- `[SVG_LAUNCH_REQUEST]`
99+
- `[SVG_ENTRY_TOP]`
100+
- `[SVG_HOSTED_WORKSPACE_ENTRY]`
101+
- `[WORKSPACE_SHELL_STATE]`
102+
- `[SVG_POSTMESSAGE_SEND]`
103+
- `[SVG_POSTMESSAGE_RECEIVE]`
104+
- `[SVG_TILE_WRITE]`
105+
106+
Expected UI:
107+
- SVG tile shows actual `sourceName`
108+
- no `Asset: none`
109+
110+
## Validation
111+
Run:
112+
- `node --check "tools/Workspace Manager/main.js"`
113+
- `node --check "tools/SVG Asset Studio/main.js"`
114+
- `node --check tools/shared/workspaceShell.js`
115+
- `node --check tools/shared/platformShell.js`
116+
117+
Full samples smoke:
118+
- Skip.
119+
- Reason: targeted SVG launch path and hosted entry verification; full samples smoke takes about 20 minutes and is not required.

tools/SVG Asset Studio/main.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ import {
2525
import { normalizeToolSamplePath } from "../shared/toolSampleCatalog.js";
2626
import { readToolHostSharedContextFromLocation } from "../shared/toolHostSharedContext.js";
2727

28+
if (typeof window !== "undefined") {
29+
const svgEntryParams = new URLSearchParams(window.location.search);
30+
console.log("[SVG_ENTRY_TOP]", {
31+
href: window.location.href,
32+
hosted: svgEntryParams.get("hosted") || "",
33+
hostToolId: svgEntryParams.get("hostToolId") || "",
34+
hostContextId: svgEntryParams.get("hostContextId") || ""
35+
});
36+
}
37+
2838
const SVG_NS = "http://www.w3.org/2000/svg";
2939
const DRAWABLE_SELECTOR = "rect,ellipse,circle,line,polyline,path";
3040
const ALLOWED_IMPORT_TAGS = new Set([

tools/Workspace Manager/main.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,60 @@ function writeSharedBindingsFromDirectPayload(toolId = "", payloadJson = null, p
407407
}
408408
}
409409

410+
function readLaunchUrlProof(sourceUrl = "") {
411+
try {
412+
const url = new URL(sourceUrl, window.location.href);
413+
return {
414+
iframeSrc: url.toString(),
415+
hosted: url.searchParams.get("hosted") || "",
416+
hostToolId: url.searchParams.get("hostToolId") || "",
417+
hostContextId: url.searchParams.get("hostContextId") || ""
418+
};
419+
} catch {
420+
return {
421+
iframeSrc: normalizeTextParam(sourceUrl),
422+
hosted: "",
423+
hostToolId: "",
424+
hostContextId: ""
425+
};
426+
}
427+
}
428+
429+
function logWorkspaceToolLaunch({ requestedToolId = "", normalizedToolId = "", payloadJson = null, mountResult = null }) {
430+
const launchProof = readLaunchUrlProof(mountResult?.sourceUrl || mountResult?.frame?.src || "");
431+
const payloadKeys = payloadJson && typeof payloadJson === "object" && !Array.isArray(payloadJson)
432+
? Object.keys(payloadJson)
433+
: [];
434+
console.log("[WORKSPACE_TOOL_LAUNCH]", {
435+
requestedToolId,
436+
normalizedToolId,
437+
entryUrl: launchProof.iframeSrc,
438+
iframeSrc: launchProof.iframeSrc,
439+
hosted: launchProof.hosted,
440+
hostToolId: launchProof.hostToolId,
441+
hostContextId: launchProof.hostContextId,
442+
hasPayloadJson: Boolean(payloadJson && typeof payloadJson === "object" && !Array.isArray(payloadJson)),
443+
payloadKeys
444+
});
445+
if (normalizedToolId === "svg-asset-studio") {
446+
const vectorAssetDocument = payloadJson?.vectorAssetDocument;
447+
const svgText = typeof vectorAssetDocument?.svgText === "string"
448+
? vectorAssetDocument.svgText
449+
: "";
450+
console.log("[SVG_LAUNCH_REQUEST]", {
451+
toolId: normalizedToolId,
452+
registryEntryUrl: launchProof.iframeSrc,
453+
iframeSrc: launchProof.iframeSrc,
454+
hosted: launchProof.hosted,
455+
hostToolId: launchProof.hostToolId,
456+
hostContextId: launchProof.hostContextId,
457+
hasVectorAssetDocument: Boolean(vectorAssetDocument && typeof vectorAssetDocument === "object" && !Array.isArray(vectorAssetDocument)),
458+
sourceName: normalizeTextParam(vectorAssetDocument?.sourceName),
459+
svgTextLength: svgText.length
460+
});
461+
}
462+
}
463+
410464
function resolveJsonPointer(root, pointer) {
411465
if (!pointer.startsWith("#/")) {
412466
return null;
@@ -1669,6 +1723,12 @@ function mountSelectedTool(source = "manual") {
16691723
const paletteJson = workspaceManifestToolDiagnostics?.explicitPalettePayload || null;
16701724
writeSharedBindingsFromDirectPayload(toolId, payloadJson, paletteJson);
16711725
const mountResult = runtime.launch(toolId, payloadJson, paletteJson);
1726+
logWorkspaceToolLaunch({
1727+
requestedToolId: toolId,
1728+
normalizedToolId: mountResult?.tool?.id || toolId,
1729+
payloadJson,
1730+
mountResult
1731+
});
16721732
if (!mountResult || !(mountResult.frame instanceof HTMLIFrameElement)) {
16731733
const selectedEntry = getToolHostEntryById(manifest, toolId);
16741734
const displayName = selectedEntry ? selectedEntry.displayName : toolId;

0 commit comments

Comments
 (0)