diff --git a/frontend/src/components/shared/TopControls.tsx b/frontend/src/components/shared/TopControls.tsx
index 684d65cc1..bf42b773f 100644
--- a/frontend/src/components/shared/TopControls.tsx
+++ b/frontend/src/components/shared/TopControls.tsx
@@ -20,63 +20,64 @@ const viewOptionStyle = {
// Build view options showing text always
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",
- },
+ const viewerOption = {
+ label: (
+
+ {switchingTo === "viewer" ? (
+
+ ) : (
+
+ )}
+ Viewer
+
+ ),
+ value: "viewer",
+ };
+
+ const pageEditorOption = {
+ label: (
+
+ {currentView === "pageEditor" ? (
+ <>
+ {switchingTo === "pageEditor" ? : }
+ Page Editor
+ >
+ ) : (
+ <>
+ {switchingTo === "pageEditor" ? : }
+ Page Editor
+ >
+ )}
+
+ ),
+ value: "pageEditor",
+ };
+
+ const fileEditorOption = {
+ label: (
+
+ {currentView === "fileEditor" ? (
+ <>
+ {switchingTo === "fileEditor" ? : }
+ Active Files
+ >
+ ) : (
+ <>
+ {switchingTo === "fileEditor" ? : }
+ Active Files
+ >
+ )}
+
+ ),
+ value: "fileEditor",
+ };
+
+ // Build options array conditionally
+ return [
+ viewerOption,
+ ...(isToolSelected ? [] : [pageEditorOption]),
+ fileEditorOption,
];
-
- // 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 {