Skip to content

Commit 3c1b50d

Browse files
author
DavidQ
committed
feat(shell): show dynamic Workspace Manager title with active tool name
update shared platform naming to display Workspace Manager (<active tool display name>) when tool is running in Workspace context
1 parent e5cc63e commit 3c1b50d

1 file changed

Lines changed: 43 additions & 6 deletions

File tree

tools/shared/platformShell.js

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,42 @@ function getManifest() {
7575
return workspaceController ? workspaceController.getManifest() : null;
7676
}
7777

78+
function isWorkspaceManagerContext() {
79+
if (typeof window === "undefined") {
80+
return false;
81+
}
82+
const currentPath = window.location.pathname || "";
83+
const searchParams = new URLSearchParams(window.location.search);
84+
const isHostedWorkspaceView = searchParams.get("hosted") === "1"
85+
|| searchParams.has("hostToolId")
86+
|| searchParams.has("hostContextId");
87+
const isWorkspaceManagerReferrer = /\/tools\/Workspace(?:%20| )Manager\//i.test(document.referrer || "");
88+
const isWorkspaceManagerParent = (() => {
89+
try {
90+
return window.top !== window
91+
&& /\/tools\/Workspace(?:%20| )Manager\//i.test(window.top.location.pathname || "");
92+
} catch {
93+
return false;
94+
}
95+
})();
96+
return isHostedWorkspaceView
97+
|| isWorkspaceManagerReferrer
98+
|| isWorkspaceManagerParent
99+
|| /\/tools\/Workspace%20Manager\//i.test(currentPath)
100+
|| /\/tools\/Workspace Manager\//i.test(currentPath);
101+
}
102+
103+
function getDisplaySurfaceName(currentTool) {
104+
if (isWorkspaceManagerContext()) {
105+
const toolName = currentTool?.displayName || document.body.dataset.toolTitle || "Tool";
106+
return `Workspace Manager (${toolName})`;
107+
}
108+
if (currentTool) {
109+
return currentTool.displayName;
110+
}
111+
return document.body.dataset.toolTitle || "Tools Platform";
112+
}
113+
78114
function formatBindingValue(label, value, fallback = "none") {
79115
const safe = String(value || "").trim();
80116
return `${label}: ${safe || fallback}`;
@@ -265,7 +301,7 @@ function renderHeaderMarkup(currentTool, isHeaderExpanded) {
265301
|| /\/tools\/Workspace%20Manager\//i.test(currentPath)
266302
|| /\/tools\/Workspace Manager\//i.test(currentPath);
267303
const sharedActionLinks = !isLanding ? renderSharedActionLinks(currentTool?.id ?? "") : "";
268-
const title = currentTool ? currentTool.displayName : (document.body.dataset.toolTitle || "Tools Platform");
304+
const title = isLanding ? (document.body.dataset.toolTitle || "Tools Platform") : getDisplaySurfaceName(currentTool);
269305
const description = currentTool
270306
? currentTool.description
271307
: "Registry-driven, engine-themed entry surface for vector maps, vector assets, tilemaps, parallax scenes, and sprite workspaces.";
@@ -314,9 +350,9 @@ function renderHeaderMarkup(currentTool, isHeaderExpanded) {
314350
}
315351

316352
function renderStatusMarkup(currentTool) {
317-
const label = currentTool
318-
? currentTool.displayName
319-
: (getPageMode() === "landing" ? "Landing Surface" : (document.body.dataset.toolTitle || "Tool Surface"));
353+
const label = getPageMode() === "landing"
354+
? "Landing Surface"
355+
: getDisplaySurfaceName(currentTool);
320356
const manifest = getManifest();
321357
const workspaceName = manifest?.name || "No active workspace";
322358
const dirtyLabel = manifest?.dirty === true ? "Unsaved changes" : "Saved";
@@ -332,8 +368,9 @@ function renderStatusMarkup(currentTool) {
332368

333369
function applyDocumentMetadata(currentTool) {
334370
document.body.classList.add("tools-platform-surface");
335-
if (currentTool) {
336-
document.title = `${currentTool.displayName} | Tools Platform`;
371+
const surfaceName = getDisplaySurfaceName(currentTool);
372+
if (currentTool || isWorkspaceManagerContext()) {
373+
document.title = `${surfaceName} | Tools Platform`;
337374
} else if (getPageMode() === "landing") {
338375
document.title = "Tools Platform";
339376
} else {

0 commit comments

Comments
 (0)