Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(windows): draw the menu bar and window controls in the title bar

rokartura929bf47d797
diff --git a/native/crates/app/src/contextkey.rs b/native/crates/app/src/contextkey.rs
index f879a83c606..9f65e7b590f 100644
--- a/native/crates/app/src/contextkey.rs
+++ b/native/crates/app/src/contextkey.rs
@@ -8,6 +8,8 @@ use std::sync::Arc;
use onig::{Regex, RegexOptions, Syntax};
use serde_json::Value;
+use crate::keybindings::Os;
+
/// A lookup of context key values (`IContext`); `None` is JavaScript's `undefined`.
pub trait Context {
fn value(&self, key: &str) -> Option<&Value>;
@@ -19,11 +21,18 @@ impl Context for HashMap<String, Value> {
}
}
-/// `CONSTANT_VALUES` on the native macOS build.
fn constant(key: &str) -> Option<bool> {
+ constant_in(crate::keybindings::OS, key)
+}
+
+/// `CONSTANT_VALUES` on the native build for `os`.
+fn constant_in(os: Os, key: &str) -> Option<bool> {
match key {
- "true" | "isMac" | "isMacNative" => Some(true),
- "false" | "isLinux" | "isWindows" | "isChromeOS" | "isWeb" | "isEdge" | "isFirefox" | "isChrome" | "isSafari" => Some(false),
+ "true" => Some(true),
+ "isMac" | "isMacNative" => Some(os == Os::Macintosh),
+ "isWindows" => Some(os == Os::Windows),
+ "isLinux" => Some(os == Os::Linux),
+ "false" | "isChromeOS" | "isWeb" | "isEdge" | "isFirefox" | "isChrome" | "isSafari" => Some(false),
_ => None,
}
}
diff --git a/native/crates/app/src/contextkey/tests.rs b/native/crates/app/src/contextkey/tests.rs
index 67e8dc9ab99..051d9a19b01 100644
--- a/native/crates/app/src/contextkey/tests.rs
+++ b/native/crates/app/src/contextkey/tests.rs
@@ -404,6 +404,15 @@ fn resolves_false_constant_and_expressions() {
assert_eq!(Expr::and(vec![has("A"), not("A")]).unwrap().serialize(), "false");
}
+#[test]
+fn platform_keys_follow_the_os() {
+ let keys = ["isMac", "isMacNative", "isWindows", "isLinux", "isWeb"];
+ let values = |os| keys.map(|key| constant_in(os, key));
+ assert_eq!(values(Os::Macintosh), [Some(true), Some(true), Some(false), Some(false), Some(false)]);
+ assert_eq!(values(Os::Windows), [Some(false), Some(false), Some(true), Some(false), Some(false)]);
+ assert_eq!(values(Os::Linux), [Some(false), Some(false), Some(false), Some(true), Some(false)]);
+}
+
#[test]
fn issue_129625_removes_duplicated_terms_in_and_expressions() {
assert_eq!(Expr::and(vec![has("A"), has("B"), has("A")]).unwrap().serialize(), "A && B");
diff --git a/native/crates/app/src/menus.rs b/native/crates/app/src/menus.rs
index be454a21c19..ac6dcc955d0 100644
--- a/native/crates/app/src/menus.rs
+++ b/native/crates/app/src/menus.rs
@@ -275,6 +275,7 @@ const WORKBENCH_MENUS: &[Row] = &[
(MenuId::MenubarMainMenu, Some(MenuId::MenubarPreferencesMenu), "", "&&Preferences", "", 9., Some("isMacNative"), None),
// workspaceActions.ts, windowActions.ts and editor.contribution.ts
(MenuId::MenubarFileMenu, None, "workbench.action.files.openFileFolder", "&&Open...", "2_open", 1., Some("isMacNative && openFolderWorkspaceSupport"), Some("isMacNative && openFolderWorkspaceSupport")),
+ (MenuId::MenubarFileMenu, None, "workbench.action.files.openFile", "&&Open File...", "2_open", 1., Some("!isMacNative"), None),
(MenuId::MenubarFileMenu, None, "workbench.action.files.openFolder", "Open &&Folder...", "2_open", 2., Some("openFolderWorkspaceSupport"), Some("openFolderWorkspaceSupport")),
(MenuId::MenubarFileMenu, None, "workbench.action.openWorkspace", "Open Wor&&kspace from File...", "2_open", 3., Some("enterMultiRootWorkspaceSupport"), Some("enterMultiRootWorkspaceSupport")),
(MenuId::MenubarFileMenu, Some(MenuId::MenubarRecentMenu), "", "Open &&Recent", "2_open", 4., None, None),
@@ -286,6 +287,10 @@ const WORKBENCH_MENUS: &[Row] = &[
// windowActions.ts (electron-browser) `CloseWindowAction`
(MenuId::MenubarFileMenu, None, "workbench.action.closeWindow", "Clos&&e Window", "6_close", 4., None, None),
(MenuId::MenubarFileMenu, None, "workbench.action.newWindow", "New &&Window", "1_new", 3., None, None),
+ // preferences.contribution.ts: macOS shows it under the application menu.
+ (MenuId::MenubarFileMenu, Some(MenuId::MenubarPreferencesMenu), "", "&&Preferences", "5_autosave", 2., Some("!isMacNative"), None),
+ // desktop.contribution.ts
+ (MenuId::MenubarFileMenu, None, "workbench.action.quit", "E&&xit", "z_Exit", 1., Some("!isMac"), None),
(MenuId::MenubarRecentMenu, None, "workbench.action.openRecent", "&&More...", "y_more", 1., None, None),
(MenuId::MenubarRecentMenu, None, "workbench.action.clearRecentFiles", "&&Clear Recently Opened...", "z_clear", 1., None, None),
// suggestController.ts: the suggest widget's status bar
@@ -433,6 +438,8 @@ const WORKBENCH_MENUS: &[Row] = &[
// walkThrough.contribution.ts
(MenuId::MenubarHelpMenu, None, "workbench.action.showInteractivePlayground", "Editor Playgrou&&nd", "1_welcome", 3., None, None),
(MenuId::MenubarHelpMenu, None, "workbench.action.openProcessExplorer", "Open &&Process Explorer", "5_tools", 2., None, None),
+ // windowActions.ts `ShowAboutDialogAction`: macOS shows it in the application menu.
+ (MenuId::MenubarHelpMenu, None, "workbench.action.showAboutDialog", "&&About", "z_about", 1., Some("!isMacNative"), None),
// preferences.contribution.ts
(MenuId::MenubarPreferencesMenu, None, "workbench.action.openGlobalKeybindings", "Keyboard Shortcuts", "2_configuration", 4., None, None),
// configureSnippets.ts `ConfigureSnippetsAction`; the native menu shows the title, as the reference does.
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index 665f1b4be05..d372338d96a 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -304,6 +304,7 @@ use serde_json::Value;
use crate::commands::Commands;
use crate::contextkey;
+use crate::keybindings::{OS, Os};
use crate::menus::MenuId;
use crate::editor::EditorGroup;
use crate::explorer::FileTree;
@@ -1349,6 +1350,8 @@ impl Workbench {
let command_center_visible = !compact && self.setting("window.commandCenter") != Value::Bool(false);
match (command_center_visible, is_tahoe_or_newer()) {
(true, _) => 35.,
+ // titlebarPart.ts `minimumHeight`.
+ (false, _) if OS == Os::Windows => 30.,
(false, true) => 32.,
(false, false) => 28.,
}
@@ -1430,6 +1433,8 @@ impl Workbench {
});
// On macOS a right-click or a Cmd+click on the title shows the title's own menu (titlebarPart.ts).
let title = title
+ // Windows hit-tests the drag area before any listener runs: the command center blocks it.
+ .when(OS == Os::Windows && command_center_visible, |title| title.occlude())
.on_mouse_down(MouseButton::Right, cx.listener(|workbench, event: &MouseDownEvent, window, cx| {
cx.stop_propagation();
workbench.show_title_bar_context_menu(MenuId::TitleBarTitleContext, event.position, window, cx);
@@ -1537,10 +1542,12 @@ impl Workbench {
let right = div()
.absolute()
.top(px(7.5 - lift))
- .right(px(12.))
+ // On Windows the toolbar ends at the window controls.
+ .right(px(if OS == Os::Windows { 138. + 12. } else { 12. }))
.opacity(opacity)
.flex()
.gap(px(4.))
+ .when(OS == Os::Windows, |right| right.occlude())
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
.when(!compact, |right| right.children(self.update_title_bar_entry(update_bar, !auxiliary, cx)))
.child(title_bar_toolbar(actions_bar, div().flex().gap(px(4.)).children(actions), cx));
@@ -1554,6 +1561,13 @@ impl Workbench {
.when_some(border, |bar, border| bar.border_b_1().border_color(border))
.child(center)
.child(right)
+ // titlebarPart.ts on Windows: the menu bar at the left, the window controls at the right, and the rest
+ // of the bar Windows' caption, which moves, snaps and maximizes the window.
+ .when(OS == Os::Windows, |bar| {
+ bar.window_control_area(gpui::WindowControlArea::Drag)
+ .children((!auxiliary).then(|| self.custom_menubar(foreground, window, cx)).flatten().map(|menubar| div().absolute().left_0().top_0().h_full().opacity(opacity).child(menubar)))
+ .child(div().absolute().right_0().top_0().h_full().child(self.window_controls(foreground, window)))
+ })
// titlebarpart.css `.titlebar-drag-region`: the bar drags the window and a double click runs the system's
// title bar action; the no-drag parts stop the press before it gets here.
.on_mouse_down(MouseButton::Left, |event, window, _| match event.click_count {
diff --git a/native/crates/app/src/workbench/menubar.rs b/native/crates/app/src/workbench/menubar.rs
index d07eae75e56..ad411136e24 100644
--- a/native/crates/app/src/workbench/menubar.rs
+++ b/native/crates/app/src/workbench/menubar.rs
@@ -6,7 +6,12 @@ mod tests;
use std::collections::BTreeMap;
-use gpui::{Action, AnyWindowHandle, App, Context, KeyBinding, Menu, MenuItem, OsAction, SystemMenuType, Window, actions};
+use std::cell::Cell;
+use std::rc::Rc;
+
+use gpui::{
+ Action, AnyWindowHandle, App, Bounds, Context, Div, InteractiveElement, KeyBinding, Menu, MenuItem, MouseButton, OsAction, ParentElement, Pixels, Rgba, SharedString, Styled, SystemMenuType, Window, WindowControlArea, actions, div, px,
+};
#[cfg(target_os = "macos")]
use objc2::{MainThreadMarker, sel};
#[cfg(target_os = "macos")]
@@ -15,7 +20,7 @@ use objc2_app_kit::{NSApplication, NSMenuItem};
use objc2_foundation::NSString;
use serde_json::{Value, json};
-use super::Workbench;
+use super::{Workbench, output_view};
use super::auxiliary_windows::{AuxiliaryWindow, window_workbench};
use crate::keybindings::Chord;
use super::workspace_actions::recent_openable;
@@ -210,6 +215,95 @@ impl Workbench {
let outcome = self.execute_command(id, vec![json!({ "from": "menu" })], window, cx);
super::keyboard::report_failure(outcome, cx);
}
+
+ /// menubarControl.ts `CustomMenubarControl`, the menu bar titlebarPart.ts puts after the app icon on Windows:
+ /// a title per top-level menu, or one `menu` button under `compact`.
+ pub(super) fn custom_menubar(&self, foreground: Rgba, window: &Window, cx: &mut Context<Self>) -> Option<Div> {
+ // shortcut: `toggle` stays hidden, the bar does not show on Alt; upgrade with the menu bar's keyboard focus.
+ let setting = self.setting("window.menuBarVisibility");
+ let visibility = menubar_visibility(&setting);
+ if matches!(visibility, "hidden" | "toggle") {
+ return None;
+ }
+ let selection = self.color("menubar.selectionBackground");
+ let button = |id: SharedString, index: Option<usize>, cx: &mut Context<Self>| {
+ let bounds = Rc::new(Cell::new(Bounds::default()));
+ div()
+ .id(id)
+ .h_full()
+ .flex()
+ .items_center()
+ .occlude()
+ .child(output_view::bounds_tracker(bounds.clone()))
+ .on_mouse_down(MouseButton::Left, cx.listener(move |workbench, _, window, cx| workbench.show_custom_menu(index, bounds.get(), window, cx)))
+ };
+ let context = self.key_context(window);
+ let menubar = div().h_full().flex().text_size(px(13.)).text_color(foreground);
+ if visibility == "compact" {
+ let menu = button("menubar-compact".into(), None, cx).w(px(35.)).justify_center().hover(|menu| menu.bg(selection)).child(self.icon("menu", 16., 16., foreground));
+ return Some(menubar.child(menu));
+ }
+ let mut titles = Vec::new();
+ for (index, action) in menu_actions(&self.menus, MenuId::MenubarMainMenu, &context).into_iter().enumerate() {
+ let MenuAction::Submenu { title, .. } = action else { continue };
+ let group: SharedString = format!("menubar-{index}").into();
+ let label = div().px(px(8.)).rounded(px(5.)).line_height(px(22.)).group_hover(group.clone(), move |label| label.bg(selection)).child(mnemonic_menu_label(&title));
+ titles.push(button(group.clone(), Some(index), cx).group(group).child(label));
+ }
+ Some(menubar.children(titles))
+ }
+
+ /// Opens the menu bar's menu `index` below `anchor`, or under `compact` (`None`) a menu of the menus.
+ fn show_custom_menu(&mut self, index: Option<usize>, anchor: Bounds<Pixels>, window: &mut Window, cx: &mut Context<Self>) {
+ let menubar = self.menubar(window);
+ let actions = match index {
+ Some(index) => custom_menu_actions(&menubar, &menubar.menus[index].1),
+ None => menubar.menus.iter().map(|(title, actions)| MenuAction::Submenu { title: title.clone(), actions: custom_menu_actions(&menubar, actions), checked: false }).collect(),
+ };
+ let context = self.key_context(window);
+ self.show_context_menu_actions(actions, &context, anchor, Vec::new(), window, cx);
+ }
+
+ /// The window controls titlebarPart.ts leaves room for on Windows, as Electron's title bar overlay draws them
+ /// (titlebarpart.css `.window-icon`): minimize, maximize or restore and close, 46px each. Windows runs them
+ /// from their hit test areas.
+ pub(super) fn window_controls(&self, foreground: Rgba, window: &Window) -> Div {
+ let hover = if self.theme.kind.is_light() { gpui::rgba(0x0000001a) } else { gpui::rgba(0xffffff1a) };
+ let control = |id: &'static str, icon: &str, area: WindowControlArea, hover: Rgba| {
+ div().id(id).h_full().w(px(46.)).flex().items_center().justify_center().occlude().window_control_area(area).hover(move |control| control.bg(hover)).child(self.icon(icon, 16., 16., foreground))
+ };
+ let maximize = if window.is_maximized() { "chrome-restore" } else { "chrome-maximize" };
+ div()
+ .h_full()
+ .flex()
+ .child(control("window-minimize", "chrome-minimize", WindowControlArea::Min, hover))
+ .child(control("window-maximize", maximize, WindowControlArea::Max, hover))
+ .child(control("window-close", "chrome-close", WindowControlArea::Close, gpui::rgba(0xe81123e6)))
+ }
+}
+
+/// window.ts `getMenuBarVisibility` under the custom title bar: `default` and unknown values are `classic`.
+pub fn menubar_visibility(setting: &Value) -> &str {
+ match setting.as_str() {
+ Some(visibility @ ("classic" | "visible" | "toggle" | "hidden" | "compact")) => visibility,
+ _ => "classic",
+ }
+}
+
+/// menubarControl.ts `insertActionsBefore` off macOS: the update item and a separator come before About.
+pub fn custom_menu_actions(menubar: &Menubar, actions: &[MenuAction]) -> Vec<MenuAction> {
+ let mut items = Vec::new();
+ for action in actions {
+ if let MenuAction::Command { id, .. } = action
+ && id == "workbench.action.showAboutDialog"
+ && let Some((title, id, enabled)) = &menubar.update_item
+ {
+ items.push(MenuAction::Command { id: id.to_string(), title: mnemonic_menu_label(title), enabled: *enabled, checked: false, alt: None });
+ items.push(MenuAction::Separator);
+ }
+ items.push(action.clone());
+ }
+ items
}
fn collect_command_ids(actions: &[MenuAction], ids: &mut Vec<String>) {
diff --git a/native/crates/app/src/workbench/menubar/tests.rs b/native/crates/app/src/workbench/menubar/tests.rs
index 2f6ef65f980..f194e3dcfbc 100644
--- a/native/crates/app/src/workbench/menubar/tests.rs
+++ b/native/crates/app/src/workbench/menubar/tests.rs
@@ -146,6 +146,47 @@ fn the_app_menu_shows_the_update_state_after_about(cx: &mut TestAppContext) {
assert_eq!(item(crate::update::State::Uninitialized, cx), "-", "no update item: a separator before Preferences");
}
+#[test]
+fn the_custom_menu_bar_visibility_defaults_to_classic() {
+ for (setting, visibility) in [(json!("compact"), "compact"), (json!("hidden"), "hidden"), (json!("toggle"), "toggle"), (json!("visible"), "visible"), (json!("default"), "classic"), (Value::Null, "classic")] {
+ assert_eq!(menubar_visibility(&setting), visibility, "{setting}");
+ }
+}
+
+/// menubarControl.ts `insertActionsBefore`: Windows' Help menu has the update item and a separator before About.
+#[gpui::test]
+fn the_custom_help_menu_shows_the_update_state_before_about(cx: &mut TestAppContext) {
+ let (workbench, cx) = workbench(None, cx);
+ workbench.update(cx, |workbench, _| workbench.update_state = crate::update::State::Idle { error: None, not_available: false });
+ let menubar = cx.update(|window, cx| workbench.read(cx).menubar(window));
+ let about = MenuAction::Command { id: "workbench.action.showAboutDialog".into(), title: "&&About".into(), enabled: true, checked: false, alt: None };
+ let help = custom_menu_actions(&menubar, &[MenuAction::Separator, about.clone()]);
+ let check = MenuAction::Command { id: "update.checkForUpdate".into(), title: "Check for Updates...".into(), enabled: true, checked: false, alt: None };
+ assert_eq!(help, [MenuAction::Separator, check, MenuAction::Separator, about]);
+}
+
+/// A title of the custom menu bar opens its menu as a context menu below it; `compact` lists the menus.
+#[gpui::test]
+fn a_custom_menu_bar_title_opens_its_menu(cx: &mut TestAppContext) {
+ let (workbench, cx) = workbench(None, cx);
+ let anchor = gpui::bounds(gpui::point(px(0.), px(0.)), gpui::size(px(30.), px(30.)));
+ let shown = |index, cx: &mut gpui::VisualTestContext| {
+ workbench.update_in(cx, |workbench, window, cx| {
+ workbench.show_custom_menu(index, anchor, window, cx);
+ let actions = workbench.context_menu.as_ref().unwrap().levels[0].actions.clone();
+ workbench.hide_context_menu(window, cx);
+ actions
+ })
+ };
+ let menubar = cx.update(|window, cx| workbench.read(cx).menubar(window));
+ assert_eq!(shown(Some(1), cx), menubar.menus[1].1);
+ let titles: Vec<String> = shown(None, cx).into_iter().map(|action| match action {
+ MenuAction::Submenu { title, .. } => title,
+ _ => "-".into(),
+ }).collect();
+ assert_eq!(titles, ["File", "Edit", "Selection", "View", "Go", "Help", "Preferences"]);
+}
+
/// menubar.ts `setMacWindowMenu`: Always on Top, checked from the window level, then Switch Window.
#[gpui::test]
fn the_window_menu_has_always_on_top_and_switch_window(cx: &mut TestAppContext) {
diff --git a/port/ledger.md b/port/ledger.md
index 02f99675172..1891b920f22 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -78,7 +78,7 @@ Status: `open`, `in progress`, `waiting on Artur`, `later` (postponed), `done`,
| M24 Windows | app/src/cli.rs:7 | in progress | [windows M] the command line on Windows: `bin\<applicationName>.cmd` from resources/win32/bin/code.cmd (written by port/tools/package-windows, its row). Done and cross-built, never run: stdin read and terminal width through the console API; a GUI-subsystem binary as Electron's that attaches to the starting console (electron_main_win.cc `RouteStdioToConsole` unless `ELECTRON_NO_ATTACH_CONSOLE`). | `cargo gc test -p app cli` on the windows runner |
| M24 Windows | exthost/src/main_thread_secret_state.rs:19 | in progress | [windows S] secrets in Credential Manager (keyring), with keytar's target name `<service>/<account>` so VS Code's stored secrets keep their keys. Done and cross-built, never run: main_thread_secret_state/windows.rs (generic credentials, user name the account, blob the UTF-8 secret, `CRED_PERSIST_ENTERPRISE`, keys from `CredEnumerateW` on `<service>/*`); the runner test `secrets_in_credential_manager` uses a service of its own. Difference: a secret over 2560 bytes (`CRED_MAX_CREDENTIAL_BLOB_SIZE`) fails to store, as with keytar, where upstream's safeStorage has no limit. | `cargo gc test -p exthost secret` on the windows runner |
| M24 Windows | exthost/src/request.rs:9 | in progress | [windows M] extension and gallery HTTP with the system proxy (request/windows.rs): the session proxy (`http.proxy`, `http.noProxy`, the proxy variables) else the IE settings of `WinHttpGetIEProxyConfigForCurrentUser`, WPAD and the PAC URL through `WinHttpGetProxyForUrl` first, then the manual proxy, as Chromium's ProxyConfigServiceWin `SetFromIEConfig`; rules and bypass lists (`<local>`, `<-loopback>`, wildcards, ports, schemes, CIDR blocks, the implicit localhost and link-local bypass) as proxy_config.cc and proxy_bypass_rules.cc (request/proxy_rules.rs); curl gets the first proxy of the list, without Chromium's fallback to the next; no Kerberos (SSPI). Built, not yet run on Windows. | `cargo gc test -p exthost proxy_rules` on the host; [windows] `cargo gc test -p exthost request` and a request through a PAC and a manual proxy on the windows runner |
-| M24 Windows | app/src/workbench/menubar.rs:173 | open | [windows L] menu bar in the custom title bar (menubarControl.ts `CustomMenubarControl`, `window.titleBarStyle: custom`, `window.menuBarVisibility`) and the window controls (minimize, maximize, close) titlebarPart.ts draws on Windows. The shared mechanism is M24's (decision "Menu bar and keybinding tables"); it unblocks the M23 Linux row app/src/workbench/menubar.rs:173. Windows shows now: no menu bar. | `cargo gc test -p app menubar` on the host; a ui-pair against the reference not possible (macOS reference) |
+| M24 Windows | app/src/workbench/menubar.rs:173 | in progress | [windows M] the menu bar's keyboard (Alt focus, mnemonics, arrow keys between menus, `window.menuBarVisibility: toggle` showing on Alt; `toggle` stays hidden), hover switching between open menus and the `.open` title highlight, Open Recent's recent entries (the menu keeps More... and Clear), the app icon (titlebarPart.ts `.window-appicon`), the system menu on a right click in the caption area; Windows shows now: those missing. Done: the menu bar in the custom title bar (menubarControl.ts `CustomMenubarControl`, `classic`, `visible`, `compact`, `hidden`), the update item before About, the Windows menu rows (Open File..., File > Preferences, Exit, Help > About through `isMacNative`, `isMac` and `isWindows` per `keybindings::OS`), the window controls on Windows' hit test areas (snap layouts on Maximize), the caption as the drag area, the 30px bar without the command center. Linux and macOS unchanged. | `cargo gc test -p app menubar` on the host: `a_custom_menu_bar_title_opens_its_menu`, `the_custom_help_menu_shows_the_update_state_before_about`, `the_custom_menu_bar_visibility_defaults_to_classic`; `cargo gc test -p app contextkey` (`platform_keys_follow_the_os`); x64 and arm64 cross builds; a Windows run not done |
| M24 Windows | app/src/keybindings.rs:86 | in progress | [windows M] windowsKeyboardMapper.ts for non-US layouts; Windows shows now: US-layout labels for every layout. Done: the per-platform mechanism (`Os`, `default_table` with the Linux hook for M23), `default-win.json` generated by `port/tools/default-keybindings` from the reference's Windows export, the `win` key of contributed rules, the Windows labels (keybindingLabels.ts `OperatingSystem.Windows`). | `cargo gc test -p app keybindings` on the host: `windows_default_table_binds_ctrl_keys`, `contributed_keybindings_use_the_platform_key`, `windows_and_linux_us_labels`, `windows_and_linux_aria_electron_and_user_settings_labels`; x64 and arm64 cross builds |
| M24 Windows | app/src/keyboard_layout.rs:7 | open | [windows M] keyboard layout info and raw mapping (native-keymap's Windows `GetKeyboardLayout`, `MapVirtualKeyEx`, `ToUnicodeEx`). | `cargo gc test -p app keyboard` on the windows runner |
| M24 Windows | app/src/clipboard.rs:91 | open | [windows M] clipboard file lists, HTML and custom formats (Chromium's registered clipboard formats); GPUI's Windows clipboard has text and images. Windows shows now: text only. | `cargo gc test -p app clipboard` on the windows runner |
diff --git a/port/notes.md b/port/notes.md
index 32dd08222bc..93b2f2ee00b 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -1021,9 +1021,10 @@ What to do (milestone 21, in order):
- Webview: `webview/windows.rs` is a WebView2 (webview2-com 0.38, the last on `windows` 0.61) in a child window of GPUI's HWND, loading the same host page as macOS and Linux. A WebResourceRequested filter on `https://*.vscode-webview.vscode-cdn.net/*` and `https://*.vscode-resource.vscode-cdn.net/*` (with `COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_ALL` where `ICoreWebView2_22` exists, so the content iframe's loads reach it) answers what the service worker answers upstream; `file` resources are read in place, the rest through the workbench with a deferral. A `file` resource's path is the URI path (`/c:/proj/a.png`), which matches no root and reads nothing until the drive-letter row (app/src/editor_history.rs:59) gives one conversion to a disk path. The bridge script runs in the top frame only, with `window.webkit.messageHandlers.vscodeWebviewHost` mapped onto `chrome.webview.postMessage`; messages from any other origin are dropped. `window.open` is handled with no window, as WebKit without a UI delegate does. No HTTP_LOOPBACK_ONLY_RULES: WebView2 is Chromium, which blocks non-loopback http in the https page as Electron does. Profile in `%LOCALAPPDATA%\<nameShort>\WebView2`. GPUI's DirectComposition target was topmost (`CreateTargetForHwnd(hwnd, true)`), drawing over every child window; `native/vendor/wu/crates/gpui_windows` vendors the crate with that one argument `false`. The notebook back layer clip is one window region (hit rects minus the hole), where Linux has an input shape beside the drawn one. URL splitting (`https_url_parts`) is a host test in webview.rs; the rest needs the windows runner.
- Named pipes: `exthost/src/pipe.rs` carries both the extension host connection (`\\.\pipe\vscode-ipc-<uuid>-sock`) and the single instance (`\\.\pipe\<sha256(user data)[..8]>-<version>-main-sock`, launch.rs), as ipc.net.ts names them. Instances are made as libuv's `uv_pipe_bind` makes them (duplex, byte mode, 64 KiB buffers, default security descriptor) plus `PIPE_REJECT_REMOTE_CLIENTS` and `FILE_FLAG_FIRST_PIPE_INSTANCE`, so a second listener fails as Node's `listen` does with EADDRINUSE. The handles are overlapped: synchronous I/O on one pipe handle is serialized by Windows, and the extension host reader thread blocks in a read while the main thread writes. Clients connect with `SECURITY_IDENTIFICATION`, so a pipe server cannot act as the client. The single instance name is fixed per user data folder in the machine-wide pipe namespace, as upstream's: another local user who creates it first receives a later start's arguments and working directory. A second instance calls `AllowSetForegroundWindow` with the pipe server's pid (`GetNamedPipeServerProcessId`) where main.ts asks the first instance for its pid over IPC. `generateUuid` and the profile ids read the OS random source (getrandom), not `/dev/urandom`.
- Console: the app is a GUI-subsystem binary, as Electron's, so a start from Explorer or the Start menu opens no console window; at start it attaches to the console of the process that started it unless the output is redirected or the CLI set `ELECTRON_NO_ATTACH_CONSOLE` (electron_main_win.cc, Chromium's `RouteStdioToConsole`), so `bin\<applicationName>.cmd --help` prints in the terminal.
-- Proxy: `request/windows.rs` sends through curl.exe as Linux does, with the proxy picked first: the session proxy, else the IE settings, auto-detect and the PAC URL through WinHTTP's resolver where Chromium runs the script in its own V8 (same answer, other engine), then the manual proxy. The rule and bypass parsing is Chromium's (`request/proxy_rules.rs`, built on every platform for its host tests). Difference: curl takes one proxy, so a PAC list's later entries are no fallback.
+- Proxy: `request/windows.rs` sends through curl.exe as Linux does, with the proxy picked first: the session proxy, else the IE settings, auto-detect and the PAC URL through WinHTTP's resolver where Chromium runs the script in its own V8 (same answer, other engine), then the manual proxy. The rule and bypass parsing is Chromium's (`request/proxy_rules.rs`, built on every platform for its host tests). Difference: curl takes one proxy, so a PAC list's later entries are no fallback. `WinHttpGetProxyForUrl` runs without `fAutoLogonIfChallenged` first and with it only after `ERROR_WINHTTP_LOGIN_FAILURE`, as Chromium's proxy_resolver_winhttp.cc, so the logon credentials go to a WPAD or PAC server only when it asks.
- File URIs: `uri.rs` `Uri::file` and `fs_path` are uri.ts `URI.file` and `uriToFsPath`, with the platform a parameter so the host tests check the Windows branches. The editor's model URIs take them on Windows only: elsewhere the port keeps a `//host/a` model path in the URI path (editor.rs `a_non_file_uri_keeps_its_authority`) where upstream makes `host` the authority.
- Keybindings: `keybindings.rs` `Os` is platform.ts `OperatingSystem`, `OS` the build's; labels, the Electron accelerator and contributed rules (`win`, `mac`, `linux` before `key`, keybindingService.ts `bindToCurrentPlatform`) take it as a parameter so the host tests check Windows. `default-win.json` is the reference's own Windows export ("Developer: Export Default Keybindings" with the platform forced, keybindingsExport.contribution.ts) turned into the port's table by `port/tools/default-keybindings`, which reproduces `default-macos.json` byte for byte from the macOS export; the weights come from the macOS rows. Linux keeps the macOS table until M23 adds `default-linux.json` in `default_table`. Windows has no keyboard mapper yet: labels are the US layout's.
+- Menu bar and title bar: on Windows `workbench.rs` `title_bar` adds `menubar.rs` `custom_menubar` at the left and `window_controls` at the right, gated on `keybindings::OS`, so Linux (M23) turns it on by its `OS`. A title opens its `MenubarMainMenu` submenu as the workbench's context menu below it; `compact` opens one menu of the menus. The context keys `isMac`, `isMacNative`, `isWindows` and `isLinux` follow `OS` (`contextkey.rs` `constant_in`), which brings in upstream's Windows-only rows. Difference: Electron's title bar overlay draws the window controls with the system's glyphs; the port draws them with the codicon `chrome-*` glyphs and titlebarpart.css's `.window-icon` hover colors, and marks them with GPUI's `WindowControlArea`, so Windows hit-tests them as caption buttons (`HTMINBUTTON`, `HTMAXBUTTON` with snap layouts, `HTCLOSE`). The rest of the bar is `HTCAPTION`, hit-tested before any listener runs: the menu bar, the command center and the toolbar `occlude` it.
## Accepted platform differences