The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.
TypeScript code-editorcross-platformdapdatabase-clientdebuggerdesktop-appdeveloper-toolsgithttp-clientideintellijlsprusttauriterminal
feat(workbench): add the Navigation Bar with a top / status bar / hidden position choice (#2317)
Muu632b21ac46ef
diff --git a/crates/ide-core/src/settings.rs b/crates/ide-core/src/settings.rsindex de8b16b3c..64ee8f85f 100644--- a/crates/ide-core/src/settings.rs+++ b/crates/ide-core/src/settings.rs@@ -369,6 +369,21 @@ impl Default for NotificationGroupSettings {}}+/// Where the Navigation Bar (the file path breadcrumbs) is shown. Mirrors+/// IDEA's `View | Appearance | Navigation Bar` (Top / Status Bar / Don't show).+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]+#[serde(rename_all = "camelCase")]+pub enum NavigationBarPosition {+ /// Above the editor, below the main menu / toolbar.+ Top,+ /// In the footer, next to the status bar widgets — the default, matching+ /// where the bar lived before the three-state choice existed.+ #[default]+ StatusBar,+ /// Not shown at all.+ Hidden,+}+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]#[serde(default, rename_all = "camelCase")]pub struct AppearanceSettings {@@ -417,6 +432,9 @@ pub struct AppearanceSettings {/// View › Appearance › Toolbar; hidden leaves IDEA's compact window header.pub show_main_toolbar: bool,pub show_status_bar: bool,+ /// View › Appearance › Navigation Bar: the file path breadcrumbs, shown in+ /// the status bar by default, above the editor, or not at all.+ pub navigation_bar: NavigationBarPosition,/// Status bar widgets shown (`true`) or hidden (`false`) by the user/// (status bar context menu); widgets not listed use their default.pub status_bar_widgets: BTreeMap<String, bool>,@@ -489,6 +507,7 @@ impl Default for AppearanceSettings {widescreen_tool_windows: false,show_main_toolbar: true,show_status_bar: true,+ navigation_bar: NavigationBarPosition::StatusBar,status_bar_widgets: BTreeMap::new(),main_toolbar: None,}diff --git a/crates/ide-workspace/src/settings.rs b/crates/ide-workspace/src/settings.rsindex 6a391df95..66f88f3f2 100644--- a/crates/ide-workspace/src/settings.rs+++ b/crates/ide-workspace/src/settings.rs@@ -61,6 +61,28 @@ fn parse_layer(text: &str) -> Result<Json, String> {serde_json::to_value(table).map_err(|e| e.to_string())}+/// Older settings stored the navigation bar choice as a boolean (`showNavigationBar`,+/// `true` = enabled). Remap it into the three-state `navigationBar` before+/// deserialization, so a plain `navigationBar` field is all specta has to export.+fn normalize_navigation_bar(mut layer: Json) -> Json {+ let Some(appearance) = layer.get_mut("appearance").and_then(Json::as_object_mut) else {+ return layer;+ };+ if appearance.contains_key("navigationBar") {+ // Already migrated; leave invalid values alone so the layer is rejected as a whole.+ return layer;+ }+ let Some(legacy) = appearance.remove("showNavigationBar") else {+ return layer;+ };+ if let Some(on) = legacy.as_bool() {+ appearance.insert("navigationBar".into(), Json::String(if on { "statusBar" } else { "hidden" }.into()));+ }+ // Not a boolean: leave it out and let the default apply, rather than silently+ // turning the navigation bar back on.+ layer+}+/// Reads one layer; `None` when missing or invalid (logged).fn read_layer(file: &Path) -> Option<Json> {let text = match std::fs::read_to_string(file) {@@ -82,6 +104,9 @@ fn read_layer(file: &Path) -> Option<Json> {/// Merges `layer` onto `merged` if the result still deserializes.fn try_merge(merged: &mut Json, layer: Json) -> Result<(), String> {+ // Migrate the legacy boolean every layer carries it, before it can clobber+ // the three-state key coming from a lower-priority layer.+ let layer = normalize_navigation_bar(layer);let mut candidate = merged.clone();deep_merge(&mut candidate, layer);serde_json::from_value::<Settings>(candidate.clone()).map_err(|e| e.to_string())?;@@ -667,6 +692,82 @@ mod tests {assert!(!store.reload().appearance.show_main_toolbar);}+ #[test]+ fn legacy_navigation_bar_boolean_migrates_to_the_three_state_key() {+ let tmp = tempfile::tempdir().unwrap();+ // `true` → `statusBar`, where the bar lived before the three-state choice.+ std::fs::write(tmp.path().join("settings.toml"), "[appearance]\nshowNavigationBar = true\n").unwrap();+ assert_eq!(+ SettingsStore::load(tmp.path(), None).effective().appearance.navigation_bar,+ ide_core::settings::NavigationBarPosition::StatusBar+ );+ // `false` → `hidden`.+ std::fs::write(tmp.path().join("settings.toml"), "[appearance]\nshowNavigationBar = false\n").unwrap();+ assert_eq!(+ SettingsStore::load(tmp.path(), None).effective().appearance.navigation_bar,+ ide_core::settings::NavigationBarPosition::Hidden+ );+ // An explicit three-state value wins over the migrated legacy key.+ std::fs::write(+ tmp.path().join("settings.toml"),+ "[appearance]\nshowNavigationBar = true\nnavigationBar = \"top\"\n",+ )+ .unwrap();+ assert_eq!(+ SettingsStore::load(tmp.path(), None).effective().appearance.navigation_bar,+ ide_core::settings::NavigationBarPosition::Top+ );+ // A non-boolean legacy value is dropped and the default (status bar) is used.+ std::fs::write(tmp.path().join("settings.toml"), "[appearance]\nshowNavigationBar = \"everywhere\"\n").unwrap();+ assert_eq!(+ SettingsStore::load(tmp.path(), None).effective().appearance.navigation_bar,+ ide_core::settings::NavigationBarPosition::StatusBar+ );+ }++ #[test]+ fn navigation_bar_layers_migrate_without_rewriting_other_settings() {+ use ide_core::settings::NavigationBarPosition::{Hidden, StatusBar, Top};++ let tmp = tempfile::tempdir().unwrap();+ let project = tmp.path().join("project");+ std::fs::create_dir_all(project.join(".openidea")).unwrap();+ let global_file = tmp.path().join("settings.toml");+ let project_file = project.join(".openidea/settings.toml");+ let global =+ "# keep this comment\n[editor]\nfontSize = 17 # keep this too\n[appearance]\nnavigationBar = \"top\"\n";+ std::fs::write(&global_file, global).unwrap();+ let store = SettingsStore::load(tmp.path(), Some(&project));+ assert_eq!(store.effective().appearance.navigation_bar, Top);+ assert_eq!(std::fs::read_to_string(&global_file).unwrap(), global);++ for (layer, expected) in [+ ("[appearance]\nshowNavigationBar = false\n", Hidden),+ ("[appearance]\nshowNavigationBar = true\n", StatusBar),+ ("[appearance]\nnavigationBar = \"hidden\"\n", Hidden),+ ("[editor]\nfontSize = 19\n", Top),+ ] {+ std::fs::write(&project_file, layer).unwrap();+ assert_eq!(store.reload().appearance.navigation_bar, expected);+ assert_eq!(std::fs::read_to_string(&project_file).unwrap(), layer);+ }++ std::fs::remove_file(&project_file).unwrap();+ let legacy = global.replace("navigationBar = \"top\"", "showNavigationBar = false");+ std::fs::write(&global_file, &legacy).unwrap();+ assert_eq!(store.reload().appearance.navigation_bar, Hidden);+ let updated = store.set(SettingsScope::Global, "appearance.navigationBar", serde_json::json!("top")).unwrap();+ assert_eq!(updated.appearance.navigation_bar, Top);+ assert_eq!(updated.editor.font_size, 17.0);+ let written = std::fs::read_to_string(&global_file).unwrap();+ assert!(written.starts_with(&legacy));+ assert_eq!(+ store.set(SettingsScope::Global, "appearance.navigationBar", Json::Null).unwrap().appearance.navigation_bar,+ Hidden+ );+ assert_eq!(std::fs::read_to_string(&global_file).unwrap(), legacy);+ }+#[test]fn mcp_server_is_default_off_and_cannot_be_enabled_by_a_project() {let tmp = tempfile::tempdir().unwrap();diff --git a/src-tauri/src/menu.rs b/src-tauri/src/menu.rsindex 00b5cea3e..a3c59654c 100644--- a/src-tauri/src/menu.rs+++ b/src-tauri/src/menu.rs@@ -392,6 +392,15 @@ pub fn spec(os: Os) -> Vec<Entry> {SEP,toggle("view.toggleToolbar", "Toolbar"),toggle("view.toggleToolWindowBars", "Tool Window Bars"),+ sub(+ "navigationBar",+ "Navigation Bar",+ vec![+ toggle("view.navigationBarTop", "Top"),+ toggle("view.navigationBarStatusBar", "Status Bar"),+ toggle("view.navigationBarHidden", "Don't Show"),+ ],+ ),toggle("view.toggleStatusBar", "Status Bar"),sub("statusBarWidgets", "Status Bar Widgets", vec![Entry::Dynamic(DYNAMIC_STATUS_BAR_WIDGETS)]),],diff --git a/src/bindings.ts b/src/bindings.tsindex 456e76a7f..244352866 100644--- a/src/bindings.ts+++ b/src/bindings.ts@@ -1958,6 +1958,11 @@ export type AppearanceSettings = {/** View › Appearance › Toolbar; hidden leaves IDEA's compact window header. */showMainToolbar?: boolean,showStatusBar?: boolean,+ /**+ * View › Appearance › Navigation Bar: the file path breadcrumbs, shown in+ * the status bar by default, above the editor, or not at all.+ */+ navigationBar?: NavigationBarPosition,/*** Status bar widgets shown (`true`) or hidden (`false`) by the user* (status bar context menu); widgets not listed use their default.@@ -6079,6 +6084,21 @@ export type ModuleStructureSettings = {dependencies?: ModuleDependency[],};+/**+ * Where the Navigation Bar (the file path breadcrumbs) is shown. Mirrors+ * IDEA's `View | Appearance | Navigation Bar` (Top / Status Bar / Don't show).+ */+export type NavigationBarPosition =+/** Above the editor, below the main menu / toolbar. */+"top" |+/**+ * In the footer, next to the status bar widgets — the default, matching+ * where the bar lived before the three-state choice existed.+ */+"statusBar" |+/** Not shown at all. */+"hidden";+export type NavigationFiles = {paths: IpcPath[],indexing: boolean,diff --git a/src/editor/core/actions.ts b/src/editor/core/actions.tsindex 587c11c9b..a3d845812 100644--- a/src/editor/core/actions.ts+++ b/src/editor/core/actions.ts@@ -1009,12 +1009,7 @@ export function registerEditorActions(): () => void {when: "projectOpen",// ⌘↑ / ⌘↓ inside a popup (Search Everywhere's previous / next group) stay with it.keyWhen: "!popupOpen",- run: () => {- if (activeSlot()) return openNavBarPopup();- // No editor: the status bar breadcrumbs (StatusItems › Breadcrumbs) take focus.- const crumbs = document.querySelectorAll<HTMLButtonElement>('nav[aria-label="Breadcrumbs"] button');- crumbs[crumbs.length - 1]?.focus();- },+ run: () => openNavBarPopup(),},{id: "navigate.lastEditLocation",diff --git a/src/editor/core/controller.test.ts b/src/editor/core/controller.test.tsindex 06c685eaa..97fa23f42 100644--- a/src/editor/core/controller.test.ts+++ b/src/editor/core/controller.test.ts@@ -4,7 +4,7 @@ import { createMemoryBackend } from "./backend";import { initialTabsState } from "./model/tabs";import { useDocMeta } from "./model/document";import { resetDistractionFree, setDistractionFree } from "@/workbench/distractionFree";-import { registerTextEditorWrapper } from "@/workbench/contributions";+import { registerTextEditorWrapper, setProjectViewLead, useProjectViewLead } from "@/workbench/contributions";import { registerActions } from "@/platform/actions";import { useProject } from "@/platform/project";import { useRemote } from "@/platform/remote";@@ -23,6 +23,15 @@ afterEach(() => {});describe("EditorController", () => {+ it("returns navigation context to the editor when activating a non-text tab", async () => {+ ctrl = new EditorController(createMemoryBackend({ "/p/a.ts": "one\n" }));+ ctrl.start();+ await ctrl.openFile("/p/a.ts", { focus: false });+ setProjectViewLead({ path: "/p/src", dir: true });+ await ctrl.openInput({ kind: "agent-session", key: "task" });+ expect(useProjectViewLead.getState().lead).toBeNull();+ });+it("autosaves on blur, but not while focus is in a popup over the editor", async () => {const backend = createMemoryBackend({ "/p/a.c": "int main() {\n \n}\n" });const save = vi.spyOn(backend, "save");diff --git a/src/editor/core/controller.ts b/src/editor/core/controller.tsindex 97843b8f5..42912925c 100644--- a/src/editor/core/controller.ts+++ b/src/editor/core/controller.ts@@ -19,6 +19,7 @@ import {type NavigationLocation,} from "@/editor/api";import {+ clearProjectViewLead,getFileDecoration,menuGroupItems,notifications,@@ -448,6 +449,7 @@ export class EditorController implements SlotHost {// Active editor follows the active pane's active tab.const tab = this.activeTabOf(next);+ if (prev.activePane !== next.activePane || this.activeTabOf(prev)?.id !== tab?.id) clearProjectViewLead();const slot = tab && isTextTab(tab) ? (this.slots.get(tab.id) ?? null) : null;if (slot !== this.activeSlot) this.setActiveSlot(slot, tab);this.publishContext();@@ -671,7 +673,11 @@ export class EditorController implements SlotHost {path: slot?.model.path ?? nonTextTab?.input.path ?? null,doc: slot?.model.doc ?? null,});- if (slot) this.recordNav(slot, true);+ if (slot) {+ // The editor is the context again: the navigation bar leaves the project view's node.+ clearProjectViewLead();+ this.recordNav(slot, true);+ }}this.scheduleStatus();}@@ -680,6 +686,7 @@ export class EditorController implements SlotHost {onFocus(slot: EditorSlot) {slot.model.lastFocused = slot;+ clearProjectViewLead();const loc = this.locateTab(slot.tabId);if (loc) {const s = useTabs.getState();diff --git a/src/editor/core/index.ts b/src/editor/core/index.tsindex 6160fd243..ba9b0e331 100644--- a/src/editor/core/index.ts+++ b/src/editor/core/index.ts@@ -24,14 +24,17 @@ import { PasteHistoryDialogHost, registerPasteHistoryActions } from "./view/Pastimport { NavBarPopup } from "./view/NavBarPopup";import { installClipboardTracking } from "./clipboardHistory";import {- Breadcrumbs,CaretStatus,EncodingStatus,IndentStatus,LineEndingStatus,ReadOnlyStatus,+ StatusBarBreadcrumbs,} from "./view/StatusItems";+/** The workbench navigation bar (View › Appearance › Navigation Bar). */+export { Breadcrumbs } from "./view/StatusItems";+export function activate(): void | (() => void) {const ctrl = editorController();ctrl.start();@@ -78,7 +81,7 @@ export function activate(): void | (() => void) {id: "editor.breadcrumbs",align: "left",priority: 0,- component: Breadcrumbs,+ component: StatusBarBreadcrumbs,title: "Navigation Bar",}),registerStatusItem({diff --git a/src/editor/core/view/EditorArea.module.css b/src/editor/core/view/EditorArea.module.cssindex 722677b2a..d67c9a966 100644--- a/src/editor/core/view/EditorArea.module.css+++ b/src/editor/core/view/EditorArea.module.css@@ -194,6 +194,7 @@flex: none;max-width: 240px;gap: 5px;+ color: var(--fg);}.crumbButton:last-child {flex: 0 1 auto;@@ -211,7 +212,7 @@.statusSep {flex: none;color: var(--fg-faint);- margin: 0 1px;+ margin: 0 2px;}.lock {display: inline-flex;diff --git a/src/editor/core/view/NavBarPopup.tsx b/src/editor/core/view/NavBarPopup.tsxindex 74ef75732..496afcda7 100644--- a/src/editor/core/view/NavBarPopup.tsx+++ b/src/editor/core/view/NavBarPopup.tsx@@ -8,7 +8,8 @@ import { useEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEveimport clsx from "clsx";import { create } from "zustand";import { call, commands, isTauri, type OutlineItem } from "@/platform/ipc";-import { useProject } from "@/platform/project";+import { projectFolder, useProject } from "@/platform/project";+import { useProjectViewLead } from "@/workbench/contributions";import { Icon, Popup, T } from "@/ui";import { editorController, useEditorStatus } from "../controller";import { useOutline } from "../model/document";@@ -42,8 +43,13 @@ export function NavBarPopup() {function OpenNavBar() {const seq = useNavBarPopup((s) => s.seq);const status = useEditorStatus((s) => s.status);- if (!status) return null;- return <NavBar key={seq} path={status.path} line={status.line} col={status.col} />;+ const project = useProject((s) => s.project);+ const lead = useProjectViewLead((s) => s.lead);+ const path = lead?.path ?? status?.path ?? project?.root;+ if (!path) return null;+ return (+ <NavBar key={seq} path={path} line={status?.line ?? 0} col={status?.col ?? 0} directory={lead?.dir ?? !status} />+ );}async function childrenOf(seg: NavSegment, outline: readonly OutlineItem[] | undefined): Promise<NavChild[]> {@@ -58,22 +64,19 @@ function anchorPoint(): { x: number; y: number } {return r ? { x: r.left + 8, y: r.top + 4 } : { x: 80, y: 80 };}-function NavBar({ path, line, col }: { path: string; line: number; col: number }) {+function NavBar({ path, line, col, directory }: { path: string; line: number; col: number; directory: boolean }) {const project = useProject((s) => s.project);const outline = useOutline((s) => s[path]);const initial = useMemo(- () =>- navSegments(- project ? { root: project.root, name: project.name } : null,- path,- outline ? symbolChain(outline, line, col) : [],- ),+ () => navSegments(projectFolder(project, path), path, outline ? symbolChain(outline, line, col) : [], directory),// The bar is a snapshot of where ⌘↑ was pressed.// eslint-disable-next-line react-hooks/exhaustive-deps[],);const [segments, setSegments] = useState<NavSegment[]>(initial);- const [active, setActive] = useState(() => initial.findIndex((s) => s.kind === "file"));+ const [active, setActive] = useState(() =>+ Math.max(0, directory ? initial.length - 1 : initial.findIndex((s) => s.kind === "file")),+ );const [list, setList] = useState<{ seg: number; items: NavChild[]; active: number; left: number } | null>(null);const [anchor] = useState(anchorPoint);const buttons = useRef<Array<HTMLButtonElement | null>>([]);diff --git a/src/editor/core/view/StatusItems.tsx b/src/editor/core/view/StatusItems.tsxindex 3026e7d8b..7a752626a 100644--- a/src/editor/core/view/StatusItems.tsx+++ b/src/editor/core/view/StatusItems.tsx@@ -7,10 +7,11 @@ import { shortcutLabel } from "@/platform/keymap";import { basename, dirname, projectFolder, relativePath, useProject } from "@/platform/project";import type { LineEnding, OutlineItem } from "@/platform/ipc";import { BarButton, Icon, Menu, badgeKind, fileIconName } from "@/ui";-import { notifications } from "@/workbench/contributions";+import { notifications, useProjectViewLead } from "@/workbench/contributions";+import { useDistractionFree } from "@/workbench/distractionFree";import { ENCODING_CHOICES, useEditorPrefs } from "@/platform/editorSettings";import { isVirtualUri } from "@/platform/virtualDocs";-import { editorController, useEditorStatus, useGotoLine } from "../controller";+import { editorController, isTextInput, useEditorStatus, useGotoLine, useTabs } from "../controller";import { useDocMeta, useOutline } from "../model/document";import { symbolChain } from "./outline";import { NavChildrenPopup } from "./NavBarPopup";@@ -26,6 +27,19 @@ function useActiveMeta() {const NO_SYMBOLS: OutlineItem[] = [];+/**+ * The active tab's path, known as soon as the tab becomes active — before its+ * editor slot reports a status. Switching to a file that is still loading (or+ * replacing a preview tab) would otherwise leave the bar without a path.+ */+function useActiveTabPath(): string | null {+ return useTabs((s) => {+ const pane = s.panes[s.activePane];+ const tab = pane?.tabs.find((t) => t.id === pane.active);+ return tab && isTextInput(tab.input) ? tab.input.path : null;+ });+}+/*** Symbols at the caret while `path` is the active editor, `null` otherwise. Selected* from the status store so callers re-render when the chain changes, not on every@@ -50,30 +64,29 @@ interface Crumb {run?: () => void;}-/**- * IDEA new UI navigation bar in the status bar: project › dirs › file ›- * symbols, with icons; clicking a segment opens a popup of its children.- */-export function Breadcrumbs() {- const path = useEditorStatus((s) => s.status?.path ?? null);- const currentProject = useProject((s) => s.project);- const project = projectFolder(currentProject, path ?? "");- const outline = useOutline((s) => (path ? s[path] : undefined));- const chain = useCaretSymbols(path, outline) ?? NO_SYMBOLS;- const [popup, setPopup] = useState<{ nav: NavSegment; anchor: HTMLElement } | null>(null);- if (!path) return null;- const parent = dirname(path);+/** The project (or workspace member) node: the first crumb of every navigation path. */+function projectCrumb(project: { root: string; name: string }): Crumb {+ return {+ label: project.name,+ icon: "module",+ title: project.root,+ nav: { kind: "dir", path: project.root, label: project.name, root: true },+ };+}++/** The project › dirs › file part of the navigation path (IDEA navigation bar). */+function pathCrumbs(project: { root: string; name: string } | null, path: string, dir = false): Crumb[] {+ const target = dir ? path : dirname(path);const segments: Crumb[] = [];- if (project)- segments.push({- label: project.name,- icon: "module",- title: project.root,- nav: { kind: "dir", path: project.root, label: project.name, root: true },- });- if (project && parent !== project.root && parent.startsWith(project.root + "/")) {+ if (project && target !== project.root && !target.startsWith(project.root + "/")) project = null;+ if (project) segments.push(projectCrumb(project));+ else {+ const label = basename(target) || target;+ segments.push({ label, icon: "folder", title: target, nav: { kind: "dir", path: target, label } });+ }+ if (project && target !== project.root && target.startsWith(project.root + "/")) {// Every directory from the root to the file, eliding the middle of deep paths.- const dirs = relativePath(project.root, parent).split("/");+ const dirs = relativePath(project.root, target).split("/");const shown = dirs.length > 4 ? [...dirs.slice(0, 1), "…", ...dirs.slice(-2)] : dirs;let consumed = 0;for (const label of shown) {@@ -82,37 +95,58 @@ export function Breadcrumbs() {segments.push({label,title: dirs.join("/"),- run: () => void executeAction("navigate.selectIn", { path: parent }),+ run: () => void executeAction("navigate.selectIn", { path: target }),});continue;}consumed += 1;- const dir = `${project.root}/${dirs.slice(0, consumed).join("/")}`;+ const at = `${project.root}/${dirs.slice(0, consumed).join("/")}`;segments.push({label,icon: "folder",- title: relativePath(project.root, dir),- nav: { kind: "dir", path: dir, label },+ title: relativePath(project.root, at),+ nav: { kind: "dir", path: at, label },});}}+ if (dir) return segments;const file = basename(path);- const stem = file.includes(".") ? file.slice(0, file.lastIndexOf(".")) || file : file;segments.push({label: file,icon: fileIconName(file),title: project ? relativePath(project.root, path) : path,nav: { kind: "file", path, label: file },});- for (const item of chain.filter((it, i) => i > 0 || it.name !== stem))- segments.push({- label: item.name,- icon: `symbol-${badgeKind(item.kind)}`,- title: item.detail ?? item.name,- nav: { kind: "symbol", path, label: item.name, item },- });+ return segments;+}++/** A row of crumbs; a segment with `nav` opens a popup of its children. */+function CrumbNav({ segments, className, ariaLabel }: { segments: Crumb[]; className?: string; ariaLabel?: string }) {+ const [popup, setPopup] = useState<{ nav: NavSegment; anchor: HTMLElement } | null>(null);return (- <nav className={styles.status} aria-label={tx("Breadcrumbs")}>+ <nav+ className={className}+ aria-label={ariaLabel}+ onKeyDown={(e) => {+ const buttons = [...e.currentTarget.querySelectorAll<HTMLButtonElement>("button")];+ const index = buttons.indexOf(e.target as HTMLButtonElement);+ if (index < 0) return;+ let next: number;+ if (e.key === "ArrowLeft") next = Math.max(0, index - 1);+ else if (e.key === "ArrowRight") next = Math.min(buttons.length - 1, index + 1);+ else if (e.key === "Home") next = 0;+ else if (e.key === "End") next = buttons.length - 1;+ else if (e.key === "ArrowDown") {+ e.preventDefault();+ e.stopPropagation();+ buttons[index]?.click();+ return;+ } else return;+ e.preventDefault();+ e.stopPropagation();+ buttons[next]?.focus();+ }}+ >{segments.map((s, i) => (<Fragment key={i}>{i > 0 && <Icon name="chevron-right" size={12} className={styles.statusSep} />}@@ -127,7 +161,7 @@ export function Breadcrumbs() {else s.run?.();}}>- {s.icon && <Icon name={s.icon} size={14} className={styles.crumbIcon} />}+ {s.icon && <Icon name={s.icon} size={16} className={styles.crumbIcon} />}<span className={styles.crumbLabel}>{s.label}</span></BarButton></Fragment>@@ -137,6 +171,59 @@ export function Breadcrumbs() {);}+/**+ * IDEA new UI navigation bar (the top of the workbench, or the status bar+ * footer via `inStatusBar`): project › dirs › file › symbols, with icons;+ * clicking a segment opens a popup of its children.+ */+export function Breadcrumbs({ className, inStatusBar = false }: { className?: string; inStatusBar?: boolean }) {+ const statusPath = useEditorStatus((s) => s.status?.path ?? null);+ const activeTabPath = useActiveTabPath();+ // The project view's node wins while the tree is the user's context (IDEA's bar+ // follows it, e.g. a folder selected there), then the editor's file.+ const lead = useProjectViewLead((s) => s.lead);+ const path = lead?.path ?? activeTabPath ?? statusPath;+ const currentProject = useProject((s) => s.project);+ const project = projectFolder(currentProject, path ?? "");+ const outline = useOutline((s) => (path ? s[path] : undefined));+ const chain = useCaretSymbols(path, outline) ?? NO_SYMBOLS;+ const position = useProject((s) => s.settings?.appearance?.navigationBar);+ // The status bar is the default (where the bar lived before the three-state+ // choice), so the footer instance shows unless the user moved the bar to the+ // top or hid it; the workbench top instance only renders for an explicit+ // `top` (its caller gates the same way).+ const shown = inStatusBar ? position !== "top" && position !== "hidden" : position === "top";+ const distractionFree = useDistractionFree((s) => s.active);+ if (!shown || distractionFree) return null;+ const segments: Crumb[] = [];+ const isDir = !!lead && lead.path === path && lead.dir;+ if (path) {+ segments.push(...pathCrumbs(project, path, isDir));+ const file = basename(path);+ const stem = file.includes(".") ? file.slice(0, file.lastIndexOf(".")) || file : file;+ if (!isDir)+ for (const item of chain.filter((it, i) => i > 0 || it.name !== stem))+ segments.push({+ label: item.name,+ icon: `symbol-${badgeKind(item.kind)}`,+ title: item.detail ?? item.name,+ nav: { kind: "symbol", path, label: item.name, item },+ });+ } else if (!inStatusBar && currentProject) {+ // The top bar keeps its row: opening, closing or switching a tab clears the+ // active editor's status for a frame, and with no editor open IDEA still+ // shows the project node instead of dropping the bar's height.+ segments.push(projectCrumb(project ?? currentProject));+ }+ if (!segments.length) return null;+ return <CrumbNav segments={segments} className={className ?? styles.status} ariaLabel={tx("Breadcrumbs")} />;+}++/** The status bar instance of the navigation bar; renders only for `statusBar`. */+export function StatusBarBreadcrumbs() {+ return <Breadcrumbs inStatusBar />;+}+/*** Settings › Editor › General › Breadcrumbs: the code structure at the caret* (class › method …) above or below the editor of `tabId`.diff --git a/src/editor/core/view/navBar.test.ts b/src/editor/core/view/navBar.test.tsindex 72f6e8ec4..f7e54d69b 100644--- a/src/editor/core/view/navBar.test.ts+++ b/src/editor/core/view/navBar.test.ts@@ -32,6 +32,15 @@ describe("navigation bar popup model", () => {]);});+ it("navigates folders and the project root without adding a file segment", () => {+ const project = { root: "/p", name: "proj" };+ expect(navSegments(project, "/p", [], true).map((s) => s.label)).toEqual(["proj"]);+ expect(navSegments(project, "/p/src/lib", [], true).map((s) => s.label)).toEqual(["proj", "src", "lib"]);+ expect(navSegments(project, "/external/lib", [], true)).toEqual([+ { kind: "dir", path: "/external/lib", label: "lib" },+ ]);+ });+it("lists folder children without IDE-hidden names, and symbol children", () => {const e = (name: string, kind: FileEntry["kind"]) =>({diff --git a/src/editor/core/view/navBar.ts b/src/editor/core/view/navBar.tsindex 81631ce14..93f4d97da 100644--- a/src/editor/core/view/navBar.ts+++ b/src/editor/core/view/navBar.ts@@ -24,9 +24,10 @@ export function navSegments(project: { root: string; name: string } | null,path: string,chain: readonly OutlineItem[],+ directory = false,): NavSegment[] {const out: NavSegment[] = [];- const parent = parentOf(path);+ const parent = directory ? path : parentOf(path);if (project && (parent === project.root || parent.startsWith(project.root + "/"))) {out.push({ kind: "dir", path: project.root, label: project.name, root: true });const rel = parent.slice(project.root.length + 1);@@ -36,6 +37,7 @@ export function navSegments(out.push({ kind: "dir", path: dir, label: part });}} else out.push({ kind: "dir", path: parent, label: nameOf(parent) || parent });+ if (directory) return out;const file = nameOf(path);out.push({ kind: "file", path, label: file });const stem = file.includes(".") ? file.slice(0, file.lastIndexOf(".")) || file : file;diff --git a/src/editor/core/view/statusItems.test.tsx b/src/editor/core/view/statusItems.test.tsxindex e4df5d5fe..b317830d9 100644--- a/src/editor/core/view/statusItems.test.tsx+++ b/src/editor/core/view/statusItems.test.tsx@@ -1,7 +1,7 @@import { Profiler } from "react";import { describe, expect, it, vi } from "vitest";-import { act, render, screen } from "@testing-library/react";-import type { OutlineItem } from "@/platform/ipc";+import { act, fireEvent, render, screen } from "@testing-library/react";+import type { OutlineItem, Settings } from "@/platform/ipc";import type { EditorStatus } from "../controller";vi.mock("../controller", async () => {@@ -10,13 +10,17 @@ vi.mock("../controller", async () => {editorController: () => ({ openFile: vi.fn(), slots: new Map() }),useEditorStatus: create<{ status: EditorStatus | null }>(() => ({ status: null })),useGotoLine: create(() => ({ open: false })),+ useTabs: create(() => ({ panes: {}, activePane: "" })),+ isTextInput: (input: { kind: string }) => input.kind === "file" || input.kind === "virtual",};});-const { useEditorStatus } = await import("../controller");+const { useEditorStatus, useTabs } = await import("../controller");const { useOutline } = await import("../model/document");+const { useProject } = await import("@/platform/project");+const { clearProjectViewLead, setProjectViewLead } = await import("@/workbench/contributions");const { Breadcrumbs, CodeBreadcrumbs } = await import("./StatusItems");-const { NavBarPopup } = await import("./NavBarPopup");+const { NavBarPopup, openNavBarPopup, useNavBarPopup } = await import("./NavBarPopup");const PATH = "/p/Orders.ts";const span = (from: number, to: number) => ({ start: { line: from, col: 0 }, end: { line: to, col: 0 } });@@ -43,6 +47,17 @@ const caret = (line: number, col: number): EditorStatus => ({describe("caret-driven status widgets", () => {it("re-render when the symbol at the caret changes, not on every caret move", () => {+ useProject.setState({+ project: {+ root: "/workspace",+ name: "Workspace",+ settings: { appearance: { navigationBar: "top" } },+ trusted: true,+ isGit: false,+ workspace: { version: 1, name: "Workspace", projects: ["/a", "/b"] },+ },+ settings: { appearance: { navigationBar: "top" } } as unknown as Settings,+ });useOutline.setState({ [PATH]: [item("Orders", 0, 40, [item("place", 2, 10), item("cancel", 12, 20)])] });act(() => useEditorStatus.setState({ status: caret(3, 4) }));let commits = 0;@@ -87,7 +102,7 @@ describe("caret-driven status widgets", () => {});it("shows the member and its directories in workspace breadcrumbs", async () => {- const { useProject } = await import("@/platform/project");+ // No `navigationBar` key: the status bar is the default placement.useProject.setState({project: {root: "/workspace",@@ -97,10 +112,153 @@ it("shows the member and its directories in workspace breadcrumbs", async () =>isGit: false,workspace: { version: 1, name: "Workspace", projects: ["/a", "/b"] },},+ settings: {} as unknown as Settings,});useEditorStatus.setState({ status: { ...caret(0, 0), path: "/b/src/file.ts" } });- const view = render(<Breadcrumbs />);+ const view = render(<Breadcrumbs inStatusBar />);expect(screen.getByRole("navigation", { name: "Breadcrumbs" }).textContent).toBe("bsrcfile.ts");view.unmount();useProject.setState({ project: null });});++it("keeps the top bar on the project node when no editor is active", async () => {+ useProject.setState({+ project: {+ root: "/workspace",+ name: "Workspace",+ settings: { appearance: { navigationBar: "top" } },+ trusted: true,+ isGit: false,+ workspace: { version: 1, name: "Workspace", projects: ["/a", "/b"] },+ },+ settings: { appearance: { navigationBar: "top" } } as unknown as Settings,+ });+ // Switching tabs clears the active editor's status for a frame.+ useEditorStatus.setState({ status: null });+ const view = render(<Breadcrumbs className="nav" />);+ expect(screen.getByRole("navigation", { name: "Breadcrumbs" }).textContent).toBe("Workspace");+ view.unmount();+ // The footer instance stays empty: the status bar itself reserves the row.+ useProject.setState({ settings: {} as unknown as Settings });+ const footer = render(<Breadcrumbs inStatusBar />);+ expect(screen.queryByRole("navigation", { name: "Breadcrumbs" })).toBeNull();+ footer.unmount();+ useProject.setState({ project: null, settings: null });+});++it("shows the incoming tab's path while a tab switch is still loading", async () => {+ useProject.setState({+ project: {+ root: "/workspace",+ name: "Workspace",+ settings: { appearance: { navigationBar: "top" } },+ trusted: true,+ isGit: false,+ workspace: { version: 1, name: "Workspace", projects: ["/a", "/b"] },+ },+ settings: { appearance: { navigationBar: "top" } } as unknown as Settings,+ });+ // The tab is active, but its editor slot has not reported a status yet.+ useEditorStatus.setState({ status: { ...caret(0, 0), path: "/a/old.ts" } });+ useTabs.setState({+ activePane: "p1",+ panes: {+ p1: {+ id: "p1",+ tabs: [+ {+ id: "t1",+ input: { kind: "file", key: "file:/b/src/file.ts", path: "/b/src/file.ts" },+ preview: false,+ pinned: false,+ },+ ],+ active: "t1",+ mru: ["t1"],+ },+ },+ });+ const view = render(<Breadcrumbs className="nav" />);+ expect(screen.getByRole("navigation", { name: "Breadcrumbs" }).textContent).toBe("bsrcfile.ts");+ const buttons = screen.getByRole("navigation", { name: "Breadcrumbs" }).querySelectorAll("button");+ buttons[0]!.focus();+ fireEvent.keyDown(buttons[0]!, { key: "ArrowRight" });+ expect(document.activeElement).toBe(buttons[1]);+ fireEvent.keyDown(buttons[1]!, { key: "End" });+ expect(document.activeElement).toBe(buttons[2]);+ view.unmount();+ useTabs.setState({ panes: {}, activePane: "" });+ useProject.setState({ project: null, settings: null });+});++it("follows the project view's folder until the editor takes over", async () => {+ useProject.setState({+ project: {+ root: "/workspace",+ name: "Workspace",+ settings: { appearance: { navigationBar: "top" } },+ trusted: true,+ isGit: false,+ workspace: { version: 1, name: "Workspace", projects: ["/a", "/b"] },+ },+ settings: { appearance: { navigationBar: "top" } } as unknown as Settings,+ });+ useEditorStatus.setState({ status: { ...caret(0, 0), path: "/b/src/file.ts" } });+ // The Project view holds the context: the bar shows its folder, not the editor's file.+ setProjectViewLead({ path: "/b/src/lib", dir: true });+ const view = render(<Breadcrumbs className="nav" />);+ expect(screen.getByRole("navigation", { name: "Breadcrumbs" }).textContent).toBe("bsrclib");+ act(() => setProjectViewLead({ path: "/external/lib", dir: true }));+ expect(screen.getByRole("navigation", { name: "Breadcrumbs" }).textContent).toBe("lib");+ view.unmount();+ // Focusing the editor or switching tabs hands the context back.+ clearProjectViewLead();+ const back = render(<Breadcrumbs className="nav" />);+ expect(screen.getByRole("navigation", { name: "Breadcrumbs" }).textContent).toBe("bsrcfile.ts");+ back.unmount();+ useProject.setState({ project: null, settings: null });+});++it("opens the hidden navigation bar on the project when no editor is active", () => {+ useEditorStatus.setState({ status: null });+ clearProjectViewLead();+ useProject.setState({+ project: { root: "/p", name: "Project", settings: {}, trusted: true, isGit: false, workspace: null },+ settings: { appearance: { navigationBar: "hidden" } } as unknown as Settings,+ });+ openNavBarPopup();+ const view = render(<NavBarPopup />);+ expect(screen.getByRole("toolbar", { name: "Navigation bar" }).textContent).toBe("Project");+ expect(screen.getByRole("button", { name: "Project" }).getAttribute("aria-current")).toBe("location");+ view.unmount();+ useNavBarPopup.setState({ open: false });+ useProject.setState({ project: null, settings: null });+});++it("shows the project › dirs › file path above the editor", async () => {+ useProject.setState({+ project: {+ root: "/workspace",+ name: "Workspace",+ settings: { appearance: { navigationBar: "top" } },+ trusted: true,+ isGit: false,+ workspace: { version: 1, name: "Workspace", projects: ["/a", "/b"] },+ },+ settings: { appearance: { navigationBar: "top" } } as unknown as Settings,+ });+ useEditorStatus.setState({ status: { ...caret(0, 0), path: "/b/src/file.ts" } });+ const view = render(<Breadcrumbs className="nav" />);+ const bar = screen.getByRole("navigation", { name: "Breadcrumbs" });+ expect(bar.textContent).toBe("bsrcfile.ts");+ expect(bar.className).toBe("nav");+ view.unmount();+ // View › Appearance › Navigation Bar hides it.+ useProject.setState({+ settings: { appearance: { navigationBar: "hidden" } } as unknown as Settings,+ });+ const hidden = render(<Breadcrumbs className="nav" />);+ expect(screen.queryByRole("navigation", { name: "Breadcrumbs" })).toBeNull();+ hidden.unmount();+ useProject.setState({ project: null, settings: null });+});diff --git a/src/features/project-tree/index.ts b/src/features/project-tree/index.tsindex 269988cd4..721dff766 100644--- a/src/features/project-tree/index.ts+++ b/src/features/project-tree/index.ts@@ -13,6 +13,7 @@ import {registerProjectViewRoot,registerToolWindow,registerUndoHandler,+ setProjectViewLead,useLocalChanges,useProjectViewRoots,} from "@/workbench/contributions";@@ -29,6 +30,7 @@ import {applyFsChange,dropOutlines,initProjectTree,+ leadSelection,reloadAll,reloadLoadedDirs,setChangedFiles,@@ -173,6 +175,14 @@ export function activate(): () => void {if (s.lists !== prev.lists) syncChanged();});+ // IDEA's navigation bar shows the tree's current node while the tree is the+ // user's context; the editor hands it back on focus or on a tab switch.+ const publishLead = () => setProjectViewLead(leadSelection());+ publishLead();+ const unsubLead = useProjectTree.subscribe((s, prev) => {+ if (s.selected !== prev.selected || s.lead !== prev.lead) publishLead();+ });+const disposers = [() => {clearTimeout(unityTimer);@@ -182,6 +192,10 @@ export function activate(): () => void {() => clearTimeout(openTimer),unsubEditor,unsubDecorations,+ () => {+ unsubLead();+ setProjectViewLead(null);+ },unsubProject,unsubExtraRoots,unsubExcludes,diff --git a/src/features/project-tree/store.ts b/src/features/project-tree/store.tsindex d083c4aa1..ddec3bc44 100644--- a/src/features/project-tree/store.ts+++ b/src/features/project-tree/store.ts@@ -35,7 +35,12 @@ import {type TreeOptions,} from "./model";import { projectFs } from "./fs";-import { projectViewRoots, useProjectViewRoots, type ProjectViewRootContribution } from "@/workbench/contributions";+import {+ projectViewRoots,+ useProjectViewRoots,+ type ProjectViewLead,+ type ProjectViewRootContribution,+} from "@/workbench/contributions";import { ancestorsWithin, isSameOrInside, nameOf, type PackageKind } from "./paths";export interface ViewOptions extends TreeOptions {@@ -404,6 +409,14 @@ export function setSelection(selected: ReadonlySet<string>, lead: string | null)set({ selected, lead });}+/** The selection's lead node, in the shape the navigation bar shows (IDEA's bar follows the tree). */+export function leadSelection(): ProjectViewLead | null {+ const { lead, selected } = get();+ const node = currentModel().byKey.get(lead ?? [...selected][0] ?? "");+ if (!node || node.placeholder || node.group) return null;+ return { path: node.path, dir: node.dir };+}+export function setViewOption<K extends keyof ViewOptions>(key: K, value: ViewOptions[K]) {const options = { ...get().options, [key]: value };set({ options });diff --git a/src/features/settings/__tests__/appearanceToggles.test.ts b/src/features/settings/__tests__/appearanceToggles.test.tsindex 46f86ca3c..7cd218112 100644--- a/src/features/settings/__tests__/appearanceToggles.test.ts+++ b/src/features/settings/__tests__/appearanceToggles.test.ts@@ -14,7 +14,7 @@ vi.mock("@/platform/ipc", async (importOriginal) => {});import { useProject } from "@/platform/project";-import { appearanceToggleActions } from "../appearanceRuntime";+import { appearanceToggleActions, navigationBarActions } from "../appearanceRuntime";import { validateAppearanceExtras } from "../model/behaviorSchema";let appearance: Record<string, unknown>;@@ -53,3 +53,23 @@ describe("View › Appearance toggles", () => {expect(action.toggled?.()).toBe(!initial);});});++describe("View › Appearance › Navigation Bar", () => {+ it("marks only the chosen position and stores it", async () => {+ // Nothing stored yet: the default is the status bar.+ const [top, statusBar, hidden] = navigationBarActions();+ expect(top.toggled?.()).toBe(false);+ expect(statusBar.toggled?.()).toBe(true);+ expect(hidden.toggled?.()).toBe(false);++ await statusBar.run({ ctx: {} } as ActionContext);+ expect(settingsSet).toHaveBeenCalledWith("global", "appearance.navigationBar", JSON.stringify("statusBar"));+ expect(top.toggled?.()).toBe(false);+ expect(statusBar.toggled?.()).toBe(true);++ await hidden.run({ ctx: {} } as ActionContext);+ expect(settingsSet).toHaveBeenCalledWith("global", "appearance.navigationBar", JSON.stringify("hidden"));+ expect(statusBar.toggled?.()).toBe(false);+ expect(hidden.toggled?.()).toBe(true);+ });+});diff --git a/src/features/settings/__tests__/behavior.test.ts b/src/features/settings/__tests__/behavior.test.tsindex 1c4e6a060..b209bfd41 100644--- a/src/features/settings/__tests__/behavior.test.ts+++ b/src/features/settings/__tests__/behavior.test.ts@@ -90,6 +90,22 @@ describe("appearance & behavior settings", () => {expect(validateAppearanceExtras({ showToolWindowBadges: 1 }).showToolWindowBadges).toBe(true);});+ it("defaults the Navigation Bar to the status bar and migrates the legacy boolean", () => {+ expect(validateAppearanceExtras({}).navigationBar).toBe("statusBar");+ expect(validateAppearanceExtras({ navigationBar: "top" }).navigationBar).toBe("top");+ expect(validateAppearanceExtras({ navigationBar: "hidden" }).navigationBar).toBe("hidden");+ // Older settings stored the choice as `showNavigationBar: bool`+ // (`true` meant shown, which was the status bar).+ expect(validateAppearanceExtras({ showNavigationBar: true }).navigationBar).toBe("statusBar");+ expect(validateAppearanceExtras({ showNavigationBar: false }).navigationBar).toBe("hidden");+ expect(validateAppearanceExtras({ showNavigationBar: true, navigationBar: "top" }).navigationBar).toBe("top");+ expect(validateAppearanceExtras({ showNavigationBar: false, navigationBar: "statusBar" }).navigationBar).toBe(+ "statusBar",+ );+ // Anything that is neither a position nor a boolean falls back to the default.+ expect(validateAppearanceExtras({ navigationBar: "everywhere" }).navigationBar).toBe("statusBar");+ });+it("defaults Use smaller indents in trees to off and applies the indent variable", () => {expect(validateAppearanceExtras({}).smallTreeIndents).toBe(false);expect(validateAppearanceExtras({ smallTreeIndents: true }).smallTreeIndents).toBe(true);diff --git a/src/features/settings/appearanceRuntime.ts b/src/features/settings/appearanceRuntime.tsindex d7b2feffb..e43a7499a 100644--- a/src/features/settings/appearanceRuntime.ts+++ b/src/features/settings/appearanceRuntime.ts@@ -124,6 +124,9 @@ type AppearanceFlag = "compactMode" | "showMainToolbar" | "showToolWindowBars" |const appearanceFlag = (key: AppearanceFlag) => validateSettings(useProject.getState().settings).appearance[key];+const navigationBarPosition = (): NavigationBarPosition =>+ validateSettings(useProject.getState().settings).appearance.navigationBar;+function appearanceToggle(id: string, title: string, key: AppearanceFlag, keywords: string[]): Action {return {id,@@ -154,6 +157,35 @@ export function appearanceToggleActions(): Action[] {];}+// ---------------------------------------------------------------------------+// View › Appearance › Navigation Bar: a radio choice (Top / Status Bar / hidden)++type NavigationBarPosition = "top" | "statusBar" | "hidden";++function navigationBarAction(id: string, title: string, position: NavigationBarPosition, keywords: string[]): Action {+ return {+ id,+ title,+ category: "View",+ keywords: ["appearance", "navigation bar", ...keywords],+ toggled: () => navigationBarPosition() === position,+ run: async () => {+ if (!isTauri()) return;+ useProject.setState({+ settings: await call(commands.settingsSet("global", "appearance.navigationBar", JSON.stringify(position))),+ });+ },+ };+}++export function navigationBarActions(): [Action, Action, Action] {+ return [+ navigationBarAction("view.navigationBarTop", "Top", "top", ["above editor", "menu bar"]),+ navigationBarAction("view.navigationBarStatusBar", "Status Bar", "statusBar", ["footer", "bottom"]),+ navigationBarAction("view.navigationBarHidden", "Don't Show", "hidden", ["hide", "breadcrumbs", "file path"]),+ ];+}+// ---------------------------------------------------------------------------// Drag-and-drop with Alt pressed only (tool window buttons and editor tabs)diff --git a/src/features/settings/index.ts b/src/features/settings/index.tsindex e86d20855..58ed18a80 100644--- a/src/features/settings/index.ts+++ b/src/features/settings/index.ts@@ -37,7 +37,7 @@ import {settingsTitle,useSettingsDialog,} from "./model/staging";-import { appearanceToggleActions, zoomActions } from "./appearanceRuntime";+import { appearanceToggleActions, navigationBarActions, zoomActions } from "./appearanceRuntime";import { activateFileTypes } from "./fileTypesRuntime";import { trackRuntimeSettings } from "./runtime";import { installActionProxies, installSettingsHost } from "./window/bridge";@@ -124,6 +124,7 @@ export function activate(): () => void {registerOverlay({ id: "settings.projectStructure", component: LazyProjectStructureDialog }),registerActions(zoomActions()),registerActions(appearanceToggleActions()),+ registerActions(navigationBarActions()),registerActions(settingsActions((page, newProjects) => void showSettings(page, newProjects))),registerActions([{diff --git a/src/features/settings/model/behaviorSchema.ts b/src/features/settings/model/behaviorSchema.tsindex 43d4a59e9..25eb41898 100644--- a/src/features/settings/model/behaviorSchema.ts+++ b/src/features/settings/model/behaviorSchema.ts@@ -12,6 +12,7 @@ import { validateIconThemeOptionsMap } from "@/platform/iconThemeOptions";export type Antialiasing = "subpixel" | "greyscale" | "none";export type OpenProjectIn = "ask" | "new" | "same";export type NotificationDisplay = "balloon" | "sticky" | "none";+export type NavigationBarPosition = "top" | "statusBar" | "hidden";/** Themes selectable as "preferred" when syncing with the OS. */export type ConcreteTheme = ThemeChoiceId;@@ -48,6 +49,9 @@ export interface AppearanceExtras {/** View › Appearance › Toolbar; hidden leaves IDEA's compact window header. */showMainToolbar: boolean;showStatusBar: boolean;+ /** View › Appearance › Navigation Bar: the file path breadcrumbs, shown above+ * the editor, in the status bar, or not at all. */+ navigationBar: NavigationBarPosition;}export interface DateFormatValid {@@ -111,8 +115,11 @@ export const DEFAULT_APPEARANCE_EXTRAS: AppearanceExtras = {widescreenToolWindows: false,showMainToolbar: true,showStatusBar: true,+ navigationBar: "statusBar",};+const NAV_BAR_POSITIONS: readonly NavigationBarPosition[] = ["top", "statusBar", "hidden"];+export const DEFAULT_GENERAL_EXTRAS: GeneralExtras = {openProjectIn: "ask",updateSource: "auto",@@ -172,6 +179,13 @@ export function validateAppearanceExtras(raw: unknown): AppearanceExtras {widescreenToolWindows: b("widescreenToolWindows"),showMainToolbar: b("showMainToolbar"),showStatusBar: b("showStatusBar"),+ // Legacy settings stored this as `showNavigationBar: bool` (`true` = shown,+ // which was the status bar); `navigationBar` is the three-state key.+ navigationBar: (() => {+ const legacy = a.showNavigationBar;+ if (!("navigationBar" in a) && typeof legacy === "boolean") return legacy ? "statusBar" : "hidden";+ return oneOf(a.navigationBar, NAV_BAR_POSITIONS, d.navigationBar);+ })(),};}diff --git a/src/features/settings/pages/behavior.tsx b/src/features/settings/pages/behavior.tsxindex b1c1e7985..38563adb4 100644--- a/src/features/settings/pages/behavior.tsx+++ b/src/features/settings/pages/behavior.tsx@@ -25,6 +25,7 @@ import {type DateFormatValid,type NotificationDisplay,type NotificationGroupValid,+ type NavigationBarPosition,type OpenProjectIn,} from "../model/behaviorSchema";import { ACCENT_PRESETS, LIMITS, type ThemeId } from "../model/schema";@@ -368,6 +369,12 @@ const AA_OPTIONS: SelectOption<Antialiasing>[] = [{ value: "none", label: "No antialiasing" },];+const NAV_BAR_OPTIONS: SelectOption<NavigationBarPosition>[] = [+ { value: "top", label: "Top" },+ { value: "statusBar", label: "Status Bar" },+ { value: "hidden", label: "Don't show" },+];+function ToolWindowsGrid() {return (<Grid@@ -644,6 +651,7 @@ export const BEHAVIOR_PAGES: PageSpec[] = [options: [{ kind: "toggle", key: "appearance.showMainToolbar", label: "Show main toolbar" },{ kind: "toggle", key: "appearance.showStatusBar", label: "Show status bar" },+ { kind: "select", key: "appearance.navigationBar", label: "Navigation bar", options: NAV_BAR_OPTIONS },{kind: "custom",label: "Main menu",diff --git a/src/platform/locales/en.json b/src/platform/locales/en.jsonindex 8677ee366..3d4db1359 100644--- a/src/platform/locales/en.json+++ b/src/platform/locales/en.json@@ -404,6 +404,10 @@"menu.view.toggleToolbar": "Toolbar","menu.view.toggleToolWindowBars": "Tool Window Bars","menu.view.toggleStatusBar": "Status Bar",+ "menu.view.navigationBar": "Navigation Bar",+ "menu.view.navigationBarTop": "Top",+ "menu.view.navigationBarStatusBar": "Status Bar",+ "menu.view.navigationBarHidden": "Don't Show","menu.statusBarWidgets": "Status Bar Widgets","menu.code.quickDefinition": "Quick Definition","menu.code.quickTypeDefinition": "Quick Type Definition",diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.jsonindex 4dd7a6971..ef981f5d2 100644--- a/src/platform/locales/text/en.json+++ b/src/platform/locales/text/en.json@@ -597,6 +597,9 @@"Status Bar": "Status Bar","Status Bar Widget": "Status Bar Widget","Show main toolbar": "Show main toolbar",+ "Navigation bar": "Navigation bar",+ "Don't show": "Don't show",+ "Don't Show": "Don't Show","Show status bar": "Show status bar","No background tasks": "No background tasks","Status Bar Widgets": "Status Bar Widgets",diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.jsonindex dccdf58c9..92c471558 100644--- a/src/platform/locales/text/zh.json+++ b/src/platform/locales/text/zh.json@@ -3482,6 +3482,8 @@"Up options": "Up 选项","e.g. --force-recreate --remove-orphans": "例如 --force-recreate --remove-orphans","Show main toolbar": "显示主工具栏",+ "Don't show": "不显示",+ "Don't Show": "不显示","Show status bar": "显示状态栏","Compact Mode": "紧凑模式","Toolbar": "工具栏",diff --git a/src/platform/locales/zh.json b/src/platform/locales/zh.jsonindex 84a8fc974..f89e2edc2 100644--- a/src/platform/locales/zh.json+++ b/src/platform/locales/zh.json@@ -404,6 +404,10 @@"menu.view.toggleToolbar": "工具栏","menu.view.toggleToolWindowBars": "工具窗口栏","menu.view.toggleStatusBar": "状态栏",+ "menu.view.navigationBar": "导航栏",+ "menu.view.navigationBarTop": "顶部",+ "menu.view.navigationBarStatusBar": "状态栏",+ "menu.view.navigationBarHidden": "不显示","menu.statusBarWidgets": "状态栏微件","menu.code.quickDefinition": "快速定义","menu.code.quickTypeDefinition": "快速类型定义",diff --git a/src/styles/tokens.css b/src/styles/tokens.cssindex d2abf49bf..5b3604f64 100644--- a/src/styles/tokens.css+++ b/src/styles/tokens.css@@ -269,6 +269,7 @@ html {--h-row: 24px;--h-list-row: 24px;--h-statusbar: 30px;+ --h-navigationbar: 26px;--h-field: 28px;--h-button: 28px;--w-gutter: 52px;diff --git a/src/workbench/Workbench.module.css b/src/workbench/Workbench.module.cssindex 7993b2b9a..c9735d71e 100644--- a/src/workbench/Workbench.module.css+++ b/src/workbench/Workbench.module.css@@ -14,6 +14,19 @@.content[inert] {visibility: hidden;}+/* IDEA's navigation bar under the main toolbar: project › dirs › file › symbols.+ Same surface as the toolbar above it (the editor island below provides the split). */+.navigationBar {+ flex: none;+ display: flex;+ align-items: center;+ gap: 2px;+ height: var(--h-navigationbar);+ padding: 0 10px;+ overflow: hidden;+ color: var(--fg);+ font-size: var(--fs-ui);+}.opening {position: absolute;inset: 0;diff --git a/src/workbench/Workbench.tsx b/src/workbench/Workbench.tsxindex dad58aaa4..092a90348 100644--- a/src/workbench/Workbench.tsx+++ b/src/workbench/Workbench.tsx@@ -5,6 +5,7 @@* or, editing loose files (LightEdit), a frame with the editor only.*/import { useEditorRegistry } from "@/editor/api";+import { Breadcrumbs } from "@/editor/core";import { basename, useProject } from "@/platform/project";import { useT } from "@/platform/i18n";import { ProgressBar } from "@/ui";@@ -28,6 +29,14 @@ 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);@@ -78,6 +87,7 @@ export function Workbench() {const distractionFree = useDistractionFree((s) => s.active);const mainToolbar = useAppearanceFlag("showMainToolbar");const statusBar = useAppearanceFlag("showStatusBar");+ const navBarPosition = useNavigationBarPosition();const frame = project ? styles.framed : lightEdit || standaloneTitle ? styles.lightEditFrame : undefined;return (@@ -89,6 +99,7 @@ export function Workbench() {{project ? (<><TitleBar compact={distractionFree || !mainToolbar} />+ {!distractionFree && navBarPosition === "top" && <Breadcrumbs className={styles.navigationBar} />}{!distractionFree && <WindowGroupTabs />}{[...banners.values()].map(({ id, component: Banner }) => (<Banner key={id} />diff --git a/src/workbench/contributions.ts b/src/workbench/contributions.tsindex 5e1431f92..e3595695e 100644--- a/src/workbench/contributions.ts+++ b/src/workbench/contributions.ts@@ -1152,6 +1152,30 @@ export function provideProjectViewSelection(get: () => string[]): () => void {/** Selected project view paths (absolute); empty without a project view. */export const projectViewSelection = (): string[] => projectSelection?.() ?? [];+/** The project view node the user last selected; `dir` decides the icon and popup of the last crumb. */+export interface ProjectViewLead {+ path: string;+ dir: boolean;+}++/**+ * The project view's current node, for the navigation bar: IDEA's bar shows the+ * tree while that is the user's context and returns to the editor's file once the+ * editor takes over (focus, tab switch). `null` = the editor is the context.+ */+export const useProjectViewLead = create<{ lead: ProjectViewLead | null }>(() => ({ lead: null }));++export function setProjectViewLead(lead: ProjectViewLead | null) {+ const prev = useProjectViewLead.getState().lead;+ if (prev?.path === lead?.path && prev?.dir === lead?.dir) return;+ useProjectViewLead.setState({ lead });+}++/** Hands the context back to the editor. */+export function clearProjectViewLead() {+ if (useProjectViewLead.getState().lead) useProjectViewLead.setState({ lead: null });+}+/** Runs the groups' `prepare` hooks, giving up after `timeoutMs` so the menu never waits long. */export async function prepareMenuGroups(menu: ContextMenuId, ctx: MenuGroupContext, timeoutMs = 200): Promise<void> {const pending = groupsFor(menu)