Skip to content

Commit b2a39ce

Browse files
author
DavidQ
committed
Remove tool selector; keep pager-only navigation
1 parent 28ebd1d commit b2a39ce

7 files changed

Lines changed: 47 additions & 101 deletions

File tree

docs/dev/codex_rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Enable and populate existing select. No duplication.
1+
Remove select completely. Pager only.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
validation placeholder
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

22
Execute:
33

4-
- populate select from tool registry
5-
- remove tabindex -1
6-
- remove aria-hidden
7-
- bind change event
8-
- sync with pager
4+
- remove select element from DOM/template
5+
- remove all JS references to select
6+
- ensure pager still works
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fix tool selector population and enable interaction
1+
Remove tool selector; keep pager-only navigation
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
# BUILD_PR_LEVEL_20_29_REMOVE_TOOL_SELECT_KEEP_PAGER_ONLY
3+
4+
## Purpose
5+
Remove the tool `<select>` control entirely and keep the pager `[PREV] <toolname> [NEXT]` as the sole navigation.
6+
7+
## Scope
8+
- Remove `<select data-tool-host-select>` from render (DOM + code)
9+
- Remove any logic that populates or listens to the select
10+
- Keep pager working (Prev/Next)
11+
- Keep first-tool-on-load behavior
12+
- Keep mount/remount behavior
13+
14+
## Required Changes
15+
- Delete select element from pager template (or do not render it)
16+
- Remove any references:
17+
- getElementById('tool-host-select')
18+
- querySelector('[data-tool-host-select]')
19+
- select.addEventListener(...)
20+
- population logic for select
21+
- Ensure no errors if select is absent
22+
23+
## Behavior
24+
- On load:
25+
- first tool selected and mounted
26+
- label shows tool name
27+
- Prev/Next:
28+
- changes tool
29+
- updates label
30+
- remounts tool
31+
32+
## Forbidden
33+
- Do not reintroduce select
34+
- Do not break pager
35+
- Do not change layout
36+
- Do not add new UI

tools/Workspace Manager/main.js

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ async function readGameAssetCatalog(assetCatalogPath) {
8383
}
8484

8585
const refs = {
86-
toolSelect: document.querySelector("[data-tool-host-select]"),
8786
stateInput: document.querySelector("[data-tool-host-state-input]"),
8887
mountButton: null,
8988
prevButton: document.querySelector("[data-tool-host-prev]"),
@@ -107,12 +106,11 @@ const TOOL_LAUNCH_PARAM_PREFIXES = Object.freeze({
107106
workspaceHref: ["/tools/Workspace%20Manager/", "/tools/Workspace Manager/"],
108107
returnTo: ["/games/", "/samples/"]
109108
});
110-
let selectedToolId = refs.toolSelect instanceof HTMLSelectElement ? refs.toolSelect.value : "";
109+
let selectedToolId = "";
111110
let pagerEventsBound = false;
112111
let pagerMessageBridgeBound = false;
113112

114113
function refreshPagerRefs() {
115-
refs.toolSelect = document.querySelector("[data-tool-host-select]");
116114
refs.prevButton = document.querySelector("[data-tool-host-prev]");
117115
refs.nextButton = document.querySelector("[data-tool-host-next]");
118116
refs.currentLabel = document.querySelector("[data-tool-host-current-label]");
@@ -194,20 +192,12 @@ function readForwardedToolLaunchParams() {
194192
}
195193

196194
function readSelectedToolId() {
197-
refreshPagerRefs();
198-
if (refs.toolSelect instanceof HTMLSelectElement) {
199-
return refs.toolSelect.value;
200-
}
201195
return selectedToolId;
202196
}
203197

204198
function writeSelectedToolId(toolId) {
205-
refreshPagerRefs();
206199
const normalizedToolId = typeof toolId === "string" ? toolId.trim() : "";
207200
selectedToolId = normalizedToolId;
208-
if (refs.toolSelect instanceof HTMLSelectElement) {
209-
refs.toolSelect.value = normalizedToolId;
210-
}
211201
}
212202

213203
function writeStatus(text) {
@@ -496,15 +486,7 @@ function syncControlState() {
496486
}
497487
}
498488

499-
function populateToolSelect(initialToolId) {
500-
refreshPagerRefs();
501-
if (refs.toolSelect instanceof HTMLSelectElement) {
502-
refs.toolSelect.innerHTML = toolIds
503-
.map((toolId) => getToolHostEntryById(manifest, toolId))
504-
.filter(Boolean)
505-
.map((tool) => `<option value="${tool.id}">${tool.displayName}</option>`)
506-
.join("");
507-
}
489+
function syncSelectedToolState(initialToolId) {
508490
const normalizedInitialToolId = toolIds.includes(initialToolId) ? initialToolId : "";
509491
writeSelectedToolId(normalizedInitialToolId);
510492
const selectedEntry = getToolHostEntryById(manifest, readSelectedToolId());
@@ -521,7 +503,7 @@ function applyToolsUsedFilterForGame(gameEntry, preferredToolId = "") {
521503
toolIds = [...allowed];
522504
}
523505
const initialToolId = toolIds.includes(preferredToolId) ? preferredToolId : "";
524-
populateToolSelect(initialToolId);
506+
syncSelectedToolState(initialToolId);
525507
updateStandaloneHref(initialToolId);
526508
syncControlState();
527509
}
@@ -555,18 +537,6 @@ function bindPagerDelegatedEvents() {
555537
mountSelectedTool("next");
556538
}
557539
});
558-
559-
document.addEventListener("change", (event) => {
560-
const target = event.target instanceof HTMLSelectElement ? event.target : null;
561-
if (!target || !target.matches("[data-tool-host-select]")) {
562-
return;
563-
}
564-
refs.toolSelect = target;
565-
writeSelectedToolId(target.value);
566-
updateSwitchMeta();
567-
updateStandaloneHref(readSelectedToolId());
568-
mountSelectedTool("select");
569-
});
570540
}
571541

572542
function bindPagerMessageBridge() {
@@ -584,7 +554,7 @@ function bindPagerMessageBridge() {
584554
return;
585555
}
586556

587-
const action = payload.action === "prev" || payload.action === "next" || payload.action === "select"
557+
const action = payload.action === "prev" || payload.action === "next"
588558
? payload.action
589559
: "";
590560
if (!action) {
@@ -603,26 +573,6 @@ function bindPagerMessageBridge() {
603573
return;
604574
}
605575

606-
if (action === "select") {
607-
const selectedToolId = typeof payload.toolId === "string"
608-
? payload.toolId.trim()
609-
: "";
610-
if (!selectedToolId || !toolIds.includes(selectedToolId) || !getToolHostEntryById(manifest, selectedToolId)) {
611-
writeStatus(`Tool "${selectedToolId || "(missing)"}" is not available for Workspace Manager launch.`);
612-
renderMountDiagnostic(
613-
`Tool "${selectedToolId || "(missing)"}" is not available for delegated pager selection.`,
614-
"Select a valid tool id from the active registry."
615-
);
616-
syncControlState();
617-
return;
618-
}
619-
writeSelectedToolId(selectedToolId);
620-
updateSwitchMeta();
621-
updateStandaloneHref(selectedToolId);
622-
mountSelectedTool("select");
623-
return;
624-
}
625-
626576
const offset = action === "prev" ? -1 : 1;
627577
if (!selectToolByOffset(offset)) {
628578
writeStatus(`Unable to select ${action === "prev" ? "previous" : "next"} tool.`);

tools/shared/platformShell.js

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -853,15 +853,6 @@ function renderWorkspaceSummary(currentTool) {
853853
return "";
854854
}
855855

856-
const workspacePagerOptions = getToolRegistry()
857-
.filter((entry) => entry?.active === true && entry?.visibleInToolsList === true)
858-
.map((entry) => {
859-
const displayName = normalizeTextValue(entry.displayName || entry.name || entry.id);
860-
const selected = entry.id === currentTool.id ? " selected" : "";
861-
return `<option value="${escapeHtml(entry.id)}"${selected}>${escapeHtml(displayName || entry.id)}</option>`;
862-
})
863-
.join("");
864-
865856
const lockState = resolveWorkspaceToolLockState();
866857
const workspaceActionDisabled = !lockState.workspaceReady
867858
? ' disabled aria-disabled="true"'
@@ -888,7 +879,7 @@ function renderWorkspaceSummary(currentTool) {
888879
<strong class="tools-platform-frame__project-name">${escapeHtml(workspaceName)}${escapeHtml(dirtyMark)}</strong>
889880
<span class="tools-platform-frame__project-meta">${escapeHtml(readiness)}</span>
890881
</div>
891-
<section class="tool-host-pager" aria-label="Workspace tool pager" data-tool-host-pager><button type="button" class="tool-host-pager__button" data-tool-host-prev>[PREV]</button><span class="tool-host-pager__name" data-tool-host-current-label>${escapeHtml(currentTool?.displayName || "Tool")}</span><button type="button" class="tool-host-pager__button" data-tool-host-next>[NEXT]</button><select id="tool-host-select" class="tool-host-pager__select" data-tool-host-select>${workspacePagerOptions}</select></section>
882+
<section class="tool-host-pager" aria-label="Workspace tool pager" data-tool-host-pager><button type="button" class="tool-host-pager__button" data-tool-host-prev>[PREV]</button><span class="tool-host-pager__name" data-tool-host-current-label>${escapeHtml(currentTool?.displayName || "Tool")}</span><button type="button" class="tool-host-pager__button" data-tool-host-next>[NEXT]</button></section>
892883
</div>
893884
`;
894885
}
@@ -1224,36 +1215,6 @@ function bindWorkspacePagerDelegatedEvents() {
12241215
console.warn("[WorkspacePager] Failed to dispatch delegated pager action.", error);
12251216
}
12261217
});
1227-
1228-
headerHost.addEventListener("change", (event) => {
1229-
const select = event.target instanceof HTMLSelectElement
1230-
? event.target
1231-
: null;
1232-
if (!select || !select.matches("[data-tool-host-select]")) {
1233-
return;
1234-
}
1235-
const toolId = normalizeTextValue(select.value);
1236-
if (!toolId) {
1237-
console.warn("[WorkspacePager] Select change ignored because tool id is missing.");
1238-
return;
1239-
}
1240-
console.info(`[WorkspacePager] SELECT handler fired (${toolId}).`);
1241-
1242-
if (typeof window === "undefined" || window.top === window) {
1243-
console.warn("[WorkspacePager] No parent host available for delegated pager select.");
1244-
return;
1245-
}
1246-
1247-
try {
1248-
window.top.postMessage({
1249-
type: "workspace-pager-action",
1250-
action: "select",
1251-
toolId
1252-
}, window.location.origin);
1253-
} catch (error) {
1254-
console.warn("[WorkspacePager] Failed to dispatch delegated pager select.", error);
1255-
}
1256-
});
12571218
}
12581219

12591220
function renderShell(currentTool) {

0 commit comments

Comments
 (0)