diff --git a/frontend/src/components/shared/TopControls.tsx b/frontend/src/components/shared/TopControls.tsx
index 308f3d483..684d65cc1 100644
--- a/frontend/src/components/shared/TopControls.tsx
+++ b/frontend/src/components/shared/TopControls.tsx
@@ -19,57 +19,65 @@ const viewOptionStyle = {
// Build view options showing text always
-const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchType | null) => [
- {
- label: (
-
- {switchingTo === "viewer" ? (
-
- ) : (
-
- )}
- Viewer
-
- ),
- value: "viewer",
- },
- {
- label: (
-
- {currentView === "pageEditor" ? (
- <>
- {switchingTo === "pageEditor" ? : }
- Page Editor
- >
- ) : (
- <>
- {switchingTo === "pageEditor" ? : }
- Page Editor
- >
- )}
-
- ),
- value: "pageEditor",
- },
- {
- label: (
-
- {currentView === "fileEditor" ? (
- <>
- {switchingTo === "fileEditor" ? : }
- Active Files
- >
- ) : (
- <>
- {switchingTo === "fileEditor" ? : }
- Active Files
- >
- )}
-
- ),
- value: "fileEditor",
- },
-];
+const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchType | null, isToolSelected: boolean) => {
+ const options = [
+ {
+ label: (
+
+ {switchingTo === "viewer" ? (
+
+ ) : (
+
+ )}
+ Viewer
+
+ ),
+ value: "viewer",
+ },
+ {
+ label: (
+
+ {currentView === "fileEditor" ? (
+ <>
+ {switchingTo === "fileEditor" ? : }
+ Active Files
+ >
+ ) : (
+ <>
+ {switchingTo === "fileEditor" ? : }
+ Active Files
+ >
+ )}
+
+ ),
+ value: "fileEditor",
+ },
+ ];
+
+ // Only add Page Editor option when not in a tool
+ if (!isToolSelected) {
+ options.splice(1, 0, {
+ label: (
+
+ {currentView === "pageEditor" ? (
+ <>
+ {switchingTo === "pageEditor" ? : }
+ Page Editor
+ >
+ ) : (
+ <>
+ {switchingTo === "pageEditor" ? : }
+ Page Editor
+ >
+ )}
+
+ ),
+ value: "pageEditor",
+ });
+ }
+
+ return options;
+};
interface TopControlsProps {
currentView: WorkbenchType;
@@ -91,7 +99,7 @@ const TopControls = ({
if (!isValidWorkbench(view)) {
return;
}
-
+
const workbench = view;
// Show immediate feedback
@@ -111,39 +119,37 @@ const TopControls = ({
return (
- {!isToolSelected && (
-
-
-
- )}
+
+
+
);
};
diff --git a/frontend/src/types/workbench.ts b/frontend/src/types/workbench.ts
index 8943638f2..37ff0a41f 100644
--- a/frontend/src/types/workbench.ts
+++ b/frontend/src/types/workbench.ts
@@ -9,4 +9,4 @@ export const getDefaultWorkbench = (): WorkbenchType => 'fileEditor';
// Type guard using the same source of truth
export const isValidWorkbench = (value: string): value is WorkbenchType => {
return WORKBENCH_TYPES.includes(value as WorkbenchType);
-};
\ No newline at end of file
+};