Skip to content

Commit 178f923

Browse files
author
DavidQ
committed
Write hosted SVG tile state from workspace shell contract only - PR 11.179
1 parent 3e0d24f commit 178f923

8 files changed

Lines changed: 356 additions & 54 deletions

File tree

docs/dev/codex_commands.md

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,53 @@
1+
# Codex Commands — PR 11.179
12

23
Model: GPT-5.4
34
Reasoning: high
45

5-
Disable assetUsageIntegration in hosted mode.
6+
Implement the correct hosted SVG tile writer.
67

7-
Modify:
8-
tools/shared/assetUsageIntegration.js
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.
913

10-
- Add hosted guard to ALL read/write functions
11-
- No fallback logic
14+
Primary files:
15+
- `tools/shared/workspaceShell.js`
16+
- `tools/SVG Asset Studio/main.js`
17+
- `tools/Workspace Manager/main.js`
1218

13-
Validate with node --check
19+
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`.
32+
33+
Validation:
34+
- `node --check tools/shared/workspaceShell.js`
35+
- `node --check "tools/SVG Asset Studio/main.js"`
36+
- `node --check "tools/Workspace Manager/main.js"`
37+
- `node --check tools/shared/platformShell.js`
38+
- `node --check tools/shared/assetUsageIntegration.js`
39+
40+
Manual UAT:
41+
- 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.
51+
52+
Return ZIP artifact at:
53+
`<project folder>/tmp/PR_11_179_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-
Disable assetUsageIntegration in hosted mode to remove global overwrite path - PR 11.178
1+
Write hosted SVG tile state from workspace shell contract only - PR 11.179
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# PR 11.179 Design Lock
2+
3+
## Decision
4+
Now that legacy writers are removed/disabled, hosted SVG tile state must have exactly one writer: Workspace Manager receiving `workspaceShell.js` state.
5+
6+
## Source of Truth
7+
`payloadJson.vectorAssetDocument`
8+
9+
## Writer
10+
Workspace Manager tile update handler for `tools:workspace-shell-state`
11+
12+
## Forbidden Writers
13+
- platformShell hosted badge renderer
14+
- assetUsageIntegration shared handoff
15+
- palette-first dependency
16+
- fallback sample labels
17+
18+
## Expected Result
19+
`Asset: sample-0901-ship.svg` or actual `vectorAssetDocument.sourceName`.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# PR 11.179 Validation
2+
3+
## Scope
4+
Implemented the hosted SVG tile writer path from `workspaceShell.js` to Workspace Manager.
5+
6+
## Files changed
7+
- `tools/shared/workspaceShell.js`
8+
- `tools/SVG Asset Studio/main.js`
9+
- `tools/Workspace Manager/main.js`
10+
- `docs/dev/reports/pr_11_179_validation.md`
11+
12+
Supporting files validated because they enforce the removed legacy paths:
13+
- `tools/shared/platformShell.js`
14+
- `tools/shared/assetUsageIntegration.js`
15+
16+
## Data flow
17+
Hosted SVG now follows this path:
18+
19+
```text
20+
SVG Asset Studio hosted iframe
21+
-> initWorkspaceShell()
22+
-> payloadJson.vectorAssetDocument
23+
-> normalized workspace shell state
24+
-> postMessage tools:workspace-shell-state
25+
-> Workspace Manager message bridge
26+
-> SVG tile label/status write
27+
```
28+
29+
## workspaceShell result
30+
`tools/shared/workspaceShell.js` now exports `initWorkspaceShell()`.
31+
32+
For hosted `svg-asset-studio`, it normalizes:
33+
- `toolId: "svg-asset-studio"`
34+
- `hostContextId`
35+
- `contractType: "vectorAssetDocument"`
36+
- `loaded: true` only when `payloadJson.vectorAssetDocument.svgText` is non-empty
37+
- `assetLabel: vectorAssetDocument.sourceName || "Inline SVG"` when loaded
38+
- `assetLabel: ""` when not loaded
39+
- `statusLabel: "Loaded"` when loaded
40+
- actionable `statusLabel` plus `errors` when the contract is missing or empty
41+
42+
It logs `[WORKSPACE_SHELL_STATE]` and posts `tools:workspace-shell-state` with `[SVG_POSTMESSAGE_SEND]`.
43+
44+
## SVG Asset Studio entry
45+
Hosted SVG mode logs `[SVG_HOSTED_WORKSPACE_ENTRY]`, dynamically imports `workspaceShell.js`, and calls `initWorkspaceShell(window.location, document)`.
46+
47+
No shared handoff or palette-first logic was restored.
48+
49+
## Workspace Manager tile writer
50+
Workspace Manager already listened for `tools:workspace-shell-state`; this PR keeps that path as the writer and tightens SVG behavior:
51+
- matches by `toolId` and `hostContextId`
52+
- writes loaded SVG tile labels from `assetLabel`
53+
- writes status from `statusLabel`
54+
- logs `[SVG_POSTMESSAGE_RECEIVE]`
55+
- logs `[SVG_TILE_WRITE]`
56+
- no longer formats missing SVG state as `none`
57+
- skips `writeSharedBindingsFromDirectPayload(...)` for `svg-asset-studio`
58+
- removed the old SVG direct-payload handoff priming writer
59+
60+
## Console evidence expected in manual UAT
61+
- `[SVG_HOSTED_WORKSPACE_ENTRY]`
62+
- `[WORKSPACE_SHELL_STATE]`
63+
- `[SVG_POSTMESSAGE_SEND]`
64+
- `[SVG_POSTMESSAGE_RECEIVE]`
65+
- `[SVG_TILE_WRITE]`
66+
67+
Manual console capture was not run in this terminal session.
68+
69+
## Tile label result expected in manual UAT
70+
For sample 1902, the SVG tile should show the actual `vectorAssetDocument.sourceName` such as `sample-0901-ship.svg`, or `Inline SVG` when the SVG text has no source name. It should not show `Asset: none`.
71+
72+
## Validation
73+
- PASS: `node --check tools/shared/workspaceShell.js`
74+
- PASS: `node --check "tools/SVG Asset Studio/main.js"`
75+
- PASS: `node --check "tools/Workspace Manager/main.js"`
76+
- PASS: `node --check tools/shared/platformShell.js`
77+
- PASS: `node --check tools/shared/assetUsageIntegration.js`
78+
79+
## Full samples smoke
80+
Skipped. Reason: targeted hosted SVG tile write path; full samples smoke takes about 20 minutes and is not required.
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# BUILD_PR_LEVEL_11_179_WRITE_SVG_TILE_FROM_WORKSPACE_SHELL
2+
3+
## Purpose
4+
Add the single correct writer for hosted SVG tile state.
5+
6+
## Current State
7+
After PR 11.178:
8+
- legacy platformShell badge row is blocked/removed for hosted tools
9+
- assetUsageIntegration shared read/write path is disabled in hosted mode
10+
- shared handoff no longer owns SVG state
11+
12+
That means the bad writers are gone.
13+
14+
Now Workspace Manager must write the SVG tile label from `workspaceShell.js` state only.
15+
16+
## Correct Data Flow
17+
```text
18+
SVG Asset Studio hosted iframe
19+
-> workspaceShell.js
20+
-> payloadJson.vectorAssetDocument
21+
-> normalized state
22+
-> postMessage tools:workspace-shell-state
23+
-> Workspace Manager
24+
-> SVG tile label/status
25+
```
26+
27+
## Scope
28+
One PR purpose only:
29+
- Create the correct hosted SVG workspace-shell write path.
30+
31+
Do not modify schemas.
32+
Do not modify sample 1902 JSON.
33+
Do not restore shared handoff.
34+
Do not use assetUsageIntegration.
35+
Do not route hosted SVG through platformShell.
36+
Do not migrate all tools.
37+
38+
## Implementation Requirements
39+
40+
### 1. Ensure workspaceShell has a public init
41+
File:
42+
`tools/shared/workspaceShell.js`
43+
44+
Export a clear initializer, for example:
45+
`initWorkspaceShell()`
46+
47+
It must:
48+
- detect hosted mode from URL:
49+
- `hosted=1`
50+
- `hostToolId`
51+
- `hostContextId`
52+
- read hosted context using the existing host context utility
53+
- normalize state for `svg-asset-studio`
54+
55+
SVG normalized state:
56+
- `toolId: "svg-asset-studio"`
57+
- `hostContextId`
58+
- `contractType: "vectorAssetDocument"`
59+
- `loaded: true` when `payloadJson.vectorAssetDocument.svgText` is non-empty
60+
- `assetLabel: vectorAssetDocument.sourceName || "Inline SVG"`
61+
- `statusLabel: "Loaded"` when loaded
62+
- `errors: []`
63+
64+
If not loaded:
65+
- `loaded: false`
66+
- `assetLabel: ""`
67+
- `statusLabel` must be actionable
68+
- `errors` contains missing contract reason
69+
70+
Required log:
71+
`[WORKSPACE_SHELL_STATE]`
72+
73+
### 2. SVG hosted entry must call workspaceShell
74+
File:
75+
`tools/SVG Asset Studio/main.js`
76+
77+
In hosted SVG mode:
78+
- log `[SVG_HOSTED_WORKSPACE_ENTRY]`
79+
- call `initWorkspaceShell()`
80+
- do not use platformShell or assetUsageIntegration for hosted SVG tile labels
81+
82+
### 3. workspaceShell sends parent message
83+
When normalized state is created, post to parent:
84+
85+
Message:
86+
```js
87+
{
88+
type: "tools:workspace-shell-state",
89+
payload: state
90+
}
91+
```
92+
93+
Required log before send:
94+
`[SVG_POSTMESSAGE_SEND]`
95+
96+
### 4. Workspace Manager receives and writes tile
97+
File:
98+
`tools/Workspace Manager/main.js`
99+
100+
Listen for message type:
101+
`tools:workspace-shell-state`
102+
103+
When payload is for:
104+
`toolId === "svg-asset-studio"`
105+
106+
Match by `hostContextId` if the mounted tile tracks it. If no existing hostContextId mapping is available, Codex must add the smallest mapping when launching/mounting the tool.
107+
108+
On loaded state:
109+
- set SVG tile asset label to `assetLabel`
110+
- set SVG tile status to `statusLabel`
111+
- mark tile loaded/active if existing model supports it
112+
- log `[SVG_POSTMESSAGE_RECEIVE]`
113+
- log `[SVG_TILE_WRITE]`
114+
115+
On error state:
116+
- show actionable status from `statusLabel`
117+
- do not show `Asset: none`
118+
119+
### 5. No legacy fallback
120+
Do not fallback to:
121+
- shared asset handoff
122+
- shared palette handoff
123+
- platformShell badge value
124+
- guessed sample names
125+
- palette-first ordering
126+
127+
## Acceptance
128+
Manual UAT on sample 1902:
129+
130+
Expected console:
131+
- `[SVG_HOSTED_WORKSPACE_ENTRY]`
132+
- `[WORKSPACE_SHELL_STATE]`
133+
- `[SVG_POSTMESSAGE_SEND]`
134+
- `[SVG_POSTMESSAGE_RECEIVE]`
135+
- `[SVG_TILE_WRITE]`
136+
137+
Expected UI:
138+
- SVG tile shows `Asset: sample-0901-ship.svg` or actual `sourceName`
139+
- SVG does not show `Asset: none`
140+
- legacy platformShell badge row remains removed/blocked
141+
- Vector Map Editor still works
142+
143+
Expected no logs:
144+
- no hosted SVG `renderToolAssetBadge -> none`
145+
- no hosted SVG shared asset handoff read/write
146+
- no hosted SVG palette-first dependency
147+
148+
## Validation
149+
Run:
150+
- `node --check tools/shared/workspaceShell.js`
151+
- `node --check "tools/SVG Asset Studio/main.js"`
152+
- `node --check "tools/Workspace Manager/main.js"`
153+
- `node --check tools/shared/platformShell.js`
154+
- `node --check tools/shared/assetUsageIntegration.js`
155+
156+
Full samples smoke:
157+
- Skip.
158+
- Reason: targeted hosted SVG tile write path; full samples smoke takes about 20 minutes and is not required.
159+
160+
## Report
161+
Create:
162+
`docs/dev/reports/pr_11_179_validation.md`
163+
164+
Include:
165+
- files changed
166+
- console evidence
167+
- tile label result
168+
- targeted validation result
169+
- full samples smoke skipped reason

tools/SVG Asset Studio/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ async function initializeHostedWorkspaceShellEntry() {
7272
hostContextId: params.get("hostContextId") || ""
7373
});
7474
document.body?.setAttribute("data-workspace-shell-active", VECTOR_ASSET_TOOL_ID);
75-
hostedWorkspaceShellEntryPromise = import("../shared/workspaceShell.js");
75+
hostedWorkspaceShellEntryPromise = import("../shared/workspaceShell.js").then((workspaceShell) => {
76+
if (typeof workspaceShell.initWorkspaceShell === "function") {
77+
return workspaceShell.initWorkspaceShell(window.location, document);
78+
}
79+
return null;
80+
});
7681
return hostedWorkspaceShellEntryPromise;
7782
}
7883

0 commit comments

Comments
 (0)