/**
* The IDEA-style shell (Islands): title bar, tool window stripes and island
* panels around the editor area on the frame background, status bar, and the
* overlay layer. Without an open project the welcome view replaces the frame,
* or, editing loose files (LightEdit), a frame with the editor only.
*/
import { useSyncExternalStore } from "react";
import { useEditorRegistry } from "@/editor/api";
import { Breadcrumbs } from "@/editor/core";
import { basename, useProject } from "@/platform/project";
import { isUntitledUri, untitledTitle } from "@/platform/virtualDocs";
import { useT } from "@/platform/i18n";
import { ProgressBar } from "@/ui";
import projectMark from "../../src-tauri/icons/source/openidea-mark.svg";
import { useDistractionFree } from "./distractionFree";
import { EditorArea } from "./EditorArea";
import { OverlayHost } from "./OverlayHost";
import { subscribeTabColors, tabColorOverride, tabColorVars, tabColorsVersion } from "./tabColors";
import { StatusBar } from "./StatusBar";
import { TitleBar } from "./TitleBar";
import { WindowGroupTabs } from "./WindowGroupTabs";
import { useApplyTheme } from "./theme";
import { ToolWindowLayout } from "./toolwindows/ToolWindows";
import { Welcome } from "./Welcome";
import { WindowResizeHandles } from "./WindowResizeHandles";
import { useContributions, useStandaloneEditor } from "./contributions";
import styles from "./Workbench.module.css";
/** View › Appearance switches (`appearance.showMainToolbar`, `appearance.showStatusBar`), shown by default. */
function useAppearanceFlag(key: "showMainToolbar" | "showStatusBar"): boolean {
return useProject((s) => s.settings?.appearance?.[key] !== false);
}
/** Where View › Appearance › Navigation Bar puts the file path breadcrumbs. */
type NavigationBarPosition = "top" | "statusBar" | "hidden";
function useNavigationBarPosition(): NavigationBarPosition {
const position = useProject((s) => s.settings?.appearance?.navigationBar);
// Nothing loaded yet, or a malformed value: match the backend default (`statusBar`).
return position === "top" || position === "statusBar" || position === "hidden" ? position : "statusBar";
}
/** LightEdit: editor tabs only; no tool windows, toolbar widgets or project status items. */
function LightEditFrame({ title }: { title?: string }) {
const path = useEditorRegistry((s) => s.active?.ctx.path);
const distractionFree = useDistractionFree((s) => s.active);
const statusBar = useAppearanceFlag("showStatusBar");
const name = path ? (isUntitledUri(path) ? untitledTitle(path) : basename(path)) : "LightEdit";
return (
<>