Skip to content

Commit ee8b759

Browse files
author
DavidQ
committed
Fix Workspace Manager click handler to use data-tool-id for correct tool launch - PR 11.182
1 parent 422e0ec commit ee8b759

4 files changed

Lines changed: 66 additions & 82 deletions

File tree

docs/dev/codex_commands.md

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,15 @@
1-
# Codex Commands — PR 11.181
21

32
Model: GPT-5 high
43
Reasoning: high
54

6-
Fix Workspace Manager SVG launch mapping.
5+
Fix click handler in:
6+
tools/Workspace Manager/main.js
77

8-
Primary files:
9-
- `tools/Workspace Manager/main.js`
10-
- `tools/shared/toolRegistry.js` only if registry data is wrong
11-
- `tools/SVG Asset Studio/main.js` only if entry log is missing after correct launch URL
8+
- Use dataset.toolId from clicked element
9+
- Remove any fallback/default tool logic
1210

13-
Hard rules:
14-
- Do not modify schemas.
15-
- Do not modify sample 1902 JSON.
16-
- Do not modify shell behavior.
17-
- Do not restore shared handoff.
18-
- Do not migrate all tools.
11+
Validate:
12+
node --check tools/Workspace Manager/main.js
1913

20-
Steps:
21-
1. Add `[WORKSPACE_REGISTRY_RESOLVE]` logging for registry resolution.
22-
2. Add `[WORKSPACE_TOOL_TILE_RENDER]` logging for rendered tool tiles/buttons.
23-
3. Add `[WORKSPACE_TOOL_CLICK]` logging before launch dispatch.
24-
4. Keep/add `[WORKSPACE_TOOL_LAUNCH]` logging.
25-
5. Add `[SVG_LAUNCH_REQUEST]` for SVG launch.
26-
6. Fix the first broken link causing SVG click not to launch `svg-asset-studio`.
27-
7. Create report:
28-
- `docs/dev/reports/pr_11_181_validation.md`
29-
30-
Validation:
31-
- `node --check "tools/Workspace Manager/main.js"`
32-
- `node --check tools/shared/toolRegistry.js`
33-
- `node --check "tools/SVG Asset Studio/main.js"`
34-
35-
Manual UAT:
36-
- Open sample 1902.
37-
- Click SVG Asset Studio.
38-
- Confirm:
39-
- `[WORKSPACE_TOOL_CLICK] datasetToolId: svg-asset-studio`
40-
- `[WORKSPACE_TOOL_LAUNCH] requestedToolId: svg-asset-studio`
41-
- `[SVG_LAUNCH_REQUEST]`
42-
- `[SVG_ENTRY_TOP]`
43-
44-
Full samples smoke:
45-
- Skip.
46-
- Reason: targeted Workspace Manager registry/tile/click launch mapping fix.
47-
48-
Return ZIP artifact at:
49-
`<project folder>/tmp/PR_11_181_20260430_01.zip`
14+
Manual:
15+
Click SVG → verify correct logs

docs/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fix Workspace Manager SVG tool mapping from registry through click handler - PR 11.181
1+
Fix Workspace Manager click handler to use data-tool-id for correct tool launch - PR 11.182
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
# BUILD_PR_LEVEL_11_182_FIX_CLICK_HANDLER_TOOL_ID
3+
4+
## Purpose
5+
Fix Workspace Manager click handler so it launches the correct tool (SVG) instead of always launching vector-map-editor.
6+
7+
## Root Cause
8+
Click handler is not using `data-tool-id` from the clicked tile.
9+
10+
## Fix
11+
Use closest `[data-tool-id]` element and pass its dataset value to launchTool.
12+
13+
## Implementation
14+
15+
File:
16+
tools/Workspace Manager/main.js
17+
18+
Replace click handler logic with:
19+
20+
document.addEventListener("click", (e) => {
21+
const el = e.target.closest("[data-tool-id]");
22+
if (!el) return;
23+
24+
const toolId = el.dataset.toolId;
25+
26+
console.log("[WORKSPACE_TOOL_CLICK]", {
27+
clickedToolId: toolId,
28+
element: el
29+
});
30+
31+
launchTool(toolId);
32+
});
33+
34+
## Rules
35+
- MUST use dataset.toolId
36+
- MUST NOT fallback to default tool
37+
- MUST NOT use activeTool/global state
38+
39+
## Acceptance
40+
Click SVG Asset Studio:
41+
42+
Logs:
43+
[WORKSPACE_TOOL_CLICK] svg-asset-studio
44+
[WORKSPACE_TOOL_LAUNCH] svg-asset-studio
45+
46+
Then:
47+
[SVG_ENTRY_TOP]
48+
[SVG_HOSTED_WORKSPACE_ENTRY]
49+
50+
UI:
51+
SVG loads correctly

tools/Workspace Manager/main.js

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -172,44 +172,16 @@ function readToolIdFromWorkspaceClickTarget(target = null) {
172172
if (!(target instanceof Element)) {
173173
return "";
174174
}
175-
const closestWithToolId = target.closest("[data-tool-id], [data-tool-host-tool-id], [data-tool]");
176-
const datasetToolId = normalizeTextParam(
177-
closestWithToolId?.getAttribute("data-tool-id")
178-
|| closestWithToolId?.getAttribute("data-tool-host-tool-id")
179-
|| closestWithToolId?.getAttribute("data-tool")
180-
|| ""
181-
);
182-
if (datasetToolId) {
183-
return normalizeToken(datasetToolId);
184-
}
185-
const link = target.closest("a[href]") || target.querySelector?.("a[href]");
186-
const href = link instanceof HTMLAnchorElement ? link.getAttribute("href") || link.href : "";
187-
if (!href) {
188-
return "";
189-
}
190-
try {
191-
const url = new URL(href, window.location.href);
192-
const pathname = decodeURIComponent(url.pathname).replace(/\\/g, "/");
193-
const match = manifest.tools.find((entry) => {
194-
const launchPath = normalizeTextParam(entry.launchPath).replace(/\\/g, "/");
195-
const entryPoint = normalizeTextParam(entry.entryPoint).replace(/\\/g, "/");
196-
return (launchPath && pathname.endsWith(launchPath.replace(/^\.\.\//, "/tools/")))
197-
|| (entryPoint && pathname.endsWith(`/tools/${entryPoint}`));
198-
});
199-
return match?.id || "";
200-
} catch {
201-
return "";
202-
}
175+
const closestWithToolId = target.closest("[data-tool-id]");
176+
const datasetToolId = normalizeTextParam(closestWithToolId?.dataset?.toolId);
177+
return datasetToolId ? normalizeToken(datasetToolId) : "";
203178
}
204179

205180
function traceWorkspaceToolClick({ target = null, datasetToolId = "", resolvedToolId = "", source = "" } = {}) {
206181
const clickedText = target instanceof Element ? normalizeTextParam(target.textContent || "") : "";
207182
const eventTarget = target instanceof Element ? target.tagName.toLowerCase() : "";
208183
const closestToolId = target instanceof Element
209-
? normalizeTextParam(target.closest("[data-tool-id], [data-tool-host-tool-id], [data-tool]")?.getAttribute("data-tool-id")
210-
|| target.closest("[data-tool-id], [data-tool-host-tool-id], [data-tool]")?.getAttribute("data-tool-host-tool-id")
211-
|| target.closest("[data-tool-id], [data-tool-host-tool-id], [data-tool]")?.getAttribute("data-tool")
212-
|| "")
184+
? normalizeTextParam(target.closest("[data-tool-id]")?.dataset?.toolId)
213185
: "";
214186
console.log("[WORKSPACE_TOOL_CLICK]", {
215187
source,
@@ -1566,15 +1538,10 @@ function bindPagerDelegatedEvents() {
15661538
const toolNavTarget = target.closest(".tools-platform-frame__nav-link, .tools-platform-frame__nav-tool-row");
15671539
if (toolNavTarget instanceof Element) {
15681540
const resolvedToolId = readToolIdFromWorkspaceClickTarget(toolNavTarget);
1569-
const datasetToolId = normalizeTextParam(
1570-
toolNavTarget.getAttribute("data-tool-id")
1571-
|| toolNavTarget.getAttribute("data-tool-host-tool-id")
1572-
|| toolNavTarget.getAttribute("data-tool")
1573-
|| ""
1574-
);
1541+
const datasetToolId = normalizeTextParam(toolNavTarget.closest("[data-tool-id]")?.dataset?.toolId);
15751542
traceWorkspaceToolClick({
15761543
target: toolNavTarget,
1577-
datasetToolId: datasetToolId || resolvedToolId,
1544+
datasetToolId,
15781545
resolvedToolId,
15791546
source: "tool-nav"
15801547
});

0 commit comments

Comments
 (0)