feat(desktop): the whole-display full screen is on by default, has a switch in App Settings, and the tabs go around the camera

Three things the owner asked for after seeing the first build on a MacBook
Pro with a camera housing, and one bug that run found.

On by default. `wholeScreen` in desktop.json now reads as on when it is
absent. The View menu item shows only while a display with a housing is
connected, since the option's own value no longer says anything about the Mac.

A switch in App Settings (Appearance > Mac App). The setting stays the app's:
the app tells each page what the switch shows
(`CodemanHostCutout.option({ available, enabled })`, on every page load and
whenever it changes), the group shows only inside the app on a Mac with such a
display, and saving sends a changed switch back through
`CodemanHost.setWholeScreen` (IPC `wholeScreen`, trusted frames only). The
menu item and every open page follow. It is never a key of the settings the
page stores or the server keeps.

Tabs on both sides of the camera. The toolbar's box used to start left of the
housing, so the first row of tabs ended there and the room up to the toolbar
stayed empty: three of ten tabs in the first row on that display. Now
`fitTabs()` reads the tabs' rectangles, finds the one that would overlap the
housing and gives the room to the tab before it as its right margin, so the
row carries on right of the housing (five of ten there, same header height).
Nothing is added to the strip and no tab is reordered. The tab strip calls it
once its row mode is decided and before it measures one row; a resize observer
follows a tab that grows or is added with no render behind it. The toolbar
keeps its own box, a user-chosen width included, and takes the covering box
(`html.host-cutout-toolbar`) only when it would reach the housing, and in a
solo window.

The bug: a window that comes out of a macOS Space is its own first responder
and takes no keys. Ticking the option while in macOS's full screen left the
terminal with a hollow cursor until a click. The web view now gets the keys
when nothing else had them.

Seen on the MacBook with the first build: launch into the mode, typing, the
menu bar sliding in over the header, leaving and entering, both change-overs,
relaunch, command+W, Dock and menu bar never stuck. Not yet seen there: this
commit's default, switch and focus fix (the Mac went to sleep before the
second round).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-11-24 19:59:58 +01:00
1 parent d5ddf2e250
commit 150f01e9b4
18 files changed
+899 -118

No files matched your search

+30 -15
View File
@@ -34,7 +34,7 @@ cannot do.
| **Start Codeman** | On the This Mac tab, and when `http://127.0.0.1:<port>` or `http://localhost:<port>` answers nothing, one click runs `codeman web -d` (or `~/.codeman/app`) with your login shell's environment, so the server gets your real PATH (Homebrew, nvm) for the agents it spawns. zsh, bash and other POSIX shells run the start themselves; fish, nu, xonsh, tcsh and other shells only report their environment, and the start runs under `/bin/sh` with it. Offered for those two addresses only: `codeman web -d` listens on 127.0.0.1. |
| **Login** | The app answers the server's HTTP Basic login requests itself, with the login you connected with, so the page keeps working after the server restarts (a restart forgets every session cookie). It answers only for Codeman's own pages under the server's base path: a web tab or a rendered HTML file that asks for a Basic login of its own is left to WebKit and never gets your Codeman password. WebKit keeps no copy of the login, so every request for it gets the current one. Each connect first clears the app's cookies, so connecting to the same server as another user really switches users (local storage, where Codeman keeps its per-device settings, stays; a dashboard in a web tab that keeps its own login in a cookie may ask for it again). A page that still gets a 401 reloads once. If the server refuses the login (the password was changed, say), the app does not keep sending it: it checks it with a single probe, and only if the server refuses that too does the connect screen come back with a notice. That does not take focus from the app you are in: if Codeman is in the background, its Dock icon bounces. |
| **Dialogs** | Codeman's `confirm()`, `prompt()` and `alert()` (Delete case, Kill all sessions, Update Codeman, discarding unsaved edits, ...) show as native macOS dialogs. wry implements none of them, and without them WKWebView answers Cancel without showing anything. Each dialog's first line names the page it comes from, and says so when that is an embedded frame (a web tab, a rendered HTML preview), so a frame cannot pass its text off as Codeman's. |
| **Full screen** | `⌃⌘F` or the green button. The last state is restored at launch; *Always Open in Full Screen* forces it. Leaving full screen returns to the saved window size and position. On a MacBook with a camera housing (the notch), macOS's full screen leaves a black bar across the top of the display. **View > Full Screen Uses the Area Beside the Camera** (off until you turn it on, and only in the menu on a Mac with such a display) makes full screen cover the whole display instead: Codeman's header moves up beside the camera, its tabs to the left and its toolbar to the right, and the terminal gains the height of the bar. Every way into full screen then takes it on that display (the green button, the menu item, `⌃⌘F`, the launch into full screen), and turning the option on or off while the window is in full screen changes it over at once. On a display without a housing nothing changes. See Decisions for what it trades, and Known limits. |
| **Full screen** | `⌃⌘F` or the green button. The last state is restored at launch; *Always Open in Full Screen* forces it. Leaving full screen returns to the saved window size and position. On a MacBook with a camera housing (the notch), macOS's full screen leaves a black bar across the top of the display. **Full Screen Uses the Area Beside the Camera** (on unless you turn it off; in the View menu and as a switch in Codeman's App Settings under Appearance > Mac App, both only on a Mac with such a display) makes full screen cover the whole display instead: Codeman's header moves up beside the camera, its tabs on both sides of it and its toolbar at the right, and the terminal gains the height of the bar. Every way into full screen then takes it on that display (the green button, the menu item, `⌃⌘F`, the launch into full screen), and turning the option on or off while the window is in full screen changes it over at once. On a display without a housing nothing changes. See Decisions for what it trades, and Known limits. |
| **Menus** | A real Edit menu (without one, `⌘C`/`⌘V` do nothing in a WKWebView), Reload `⌘R`, Switch Server `⇧⌘O`, Developer Tools `⌥⌘I`. The page sees every key first, so Codeman's own shortcuts keep working. If the main window ends up showing a raw file instead of Codeman, `⌘R` takes it back to Codeman. |
| **Pop-outs** | Implements Codeman's existing native-wrapper bridge, `window.CodemanHost` (`openInHostWindow` in `src/web/public/app.js`), so popping out a session or a file preview opens a real app window, and the pop-out icon is on by default. Session and rendered-HTML pop-outs come only from Codeman's own pop-out button. A `window.open` from page script opens only Codeman's file and download windows, without taking keyboard focus, at most 3 at once and then 1 per second. Only Codeman's own pop-out pages become app windows (see Decisions); when the app refuses one, Codeman shows a toast. Each pop-out opens a step down and to the right of the window in use, never exactly on top of another one. A web tab's *Open in new tab* opens the dashboard in your default browser, as it would from a browser tab. |
| **Links** | On Codeman's own pages (the dashboard and session windows), a link to another site opens in your default browser, also on `⌘`-click or a middle click. Pages can send at most 3 links to the browser at once, then 1 per second. Inside a rendered HTML preview or a web tab, a plain link to another site does nothing, while one that asks for a new window (`target="_blank"`, `window.open`) opens in your default browser within the same budget (see Known limits). |
@@ -301,21 +301,35 @@ shrink the display's active area as soon as a window reaches behind the housing.
It is not a Space, and that is the trade: the window covers the desktop it is
on, there is no slide animation, a three-finger swipe does not lead to it, and
another app's window on that desktop comes up in front of it. That is why it is
an option. On a display without a housing macOS's full screen already uses
every pixel, so the option changes nothing there and the window keeps its Space.
another app's window on that desktop comes up in front of it. That is why it
can be turned off, in the View menu or with the switch in Codeman's App
Settings (Appearance > Mac App), which is the same setting: the page asks the
app through `CodemanHost.setWholeScreen()` and the app tells every page what
the switch shows. It is on by default: on a display with a housing the black
bar costs more than the Space gives. On a display without a housing macOS's
full screen already uses every pixel, so the option changes nothing there and
the window keeps its Space.
**Leaving macOS's full screen leaves the window without a first responder.**
A window that comes out of a native Space is its own first responder and takes
no keys, so a window that goes on to cover the whole display (the option
turned on while in macOS's full screen) gives the keys to the web view itself.
Seen on a MacBook Pro before the fix: the cursor stayed hollow and typing went
nowhere until a click.
**A page is drawn behind the housing only after it said it copes.** The housing
hides whatever is behind it, so the header has to keep its controls out of the
way, and only the page can do that. Codeman's page says so through
`CodemanHost.cutoutReady()` (`src/web/public/host-cutout.js`) and is then told
where the housing is, in points from the top-left corner, and lays its header
out around it. Until a page has said so the web view stays below the housing
out around it: the tab that would sit under the housing starts just right of
it, and a toolbar that would reach it is moved past it. Until a page has said
so the web view stays below the housing
and the strip above it is black, as in macOS's full screen. That covers an
older Codeman server (its page never says it), the connect page, a raw file,
and a layout the page itself declines: with the tabs grouped by state, by case
or as a ledger in the header strip, every row of tabs would have to end at the
housing, which costs more height than the strip gives. Only Codeman's own app
or as a ledger in the header strip, the rows are laid out by rules the page
cannot open a gap in. Only Codeman's own app
shell may say it (`policy::parse_ipc`), so a rendered HTML file or a web tab
cannot get the page drawn behind the camera.
@@ -531,19 +545,20 @@ crosses, so the login is never on a command line.
Mac mini, which has no housing and no screen session). Not seen: the window
behind a real housing, the menu bar sliding in over it, the change-over from
macOS's full screen, a second display, and closing the lid.
- **In that mode the tabs get the room left of the camera only.** A wrapped tab
strip runs its later rows across the whole width, but its first row ends at
the housing, and the room between the housing and the toolbar stays empty. On
a 14 inch display that is about three tabs fewer in the first row, so with
many tabs the strip can need one row more, which takes back what the bar
gave. With the tabs in the sidebar or the rail, or with a few tabs, the whole
height of the bar is gained.
- **In that mode the tabs go around the camera in the classic tab strip only.**
A row of tabs loses the width of the housing and 8 points on each side of it,
nothing else. With the tabs grouped by state, by case or as a ledger in the
header strip the page stays below the camera, with the black strip above it.
- **Turning the option on while in macOS's full screen shows the normal window
for under a second**, between the Space closing and the window covering the
display.
- **Minimize does nothing in that mode** (`⌘M` beeps): the window has no title
bar, as in macOS's full screen. The menu item says *Toggle Full Screen* in
both kinds of full screen.
- **A MacBook started with its lid closed has no menu item for it** until the
app is started with the built-in display open: the item only exists while a
display with a housing is connected at launch, or the option is already on.
display with a housing is connected at launch. The switch in App Settings
shows as soon as a page loads while such a display is connected.
- **Self-signed HTTPS is refused.** A server started with `codeman web --https`
uses a self-signed certificate, and WKWebView rejects it (wry has no trust
override). Use `http://127.0.0.1:3000` for a server on this Mac. For another
+5 -1
View File
@@ -63,6 +63,8 @@ pub fn respond(request: Request<Vec<u8>>) -> Response<Cow<'static, [u8]>> {
/// controls clear of a camera housing, so a full screen over the whole
/// display may put the page behind it (`whole_screen.rs`; the page's side is
/// `src/web/public/host-cutout.js`). Anything but `false` is a yes.
/// - `setWholeScreen(on)` is the settings page's switch for that full screen
/// (View > Full Screen Uses the Area Beside the Camera). Only `true` is on.
pub const HOST_SHIM: &str = r#"(function () {
'use strict';
if (!/^https?:$/.test(location.protocol) || window.CodemanHost) return;
@@ -93,7 +95,8 @@ pub const HOST_SHIM: &str = r#"(function () {
},
closeWindow: function () { post({ cmd: 'closeWindow' }); },
focusWindow: function () { post({ cmd: 'focusWindow' }); },
cutoutReady: function (ready) { post({ cmd: 'cutoutReady', ready: ready !== false }); }
cutoutReady: function (ready) { post({ cmd: 'cutoutReady', ready: ready !== false }); },
setWholeScreen: function (on) { return post({ cmd: 'wholeScreen', on: on === true }); }
})
});
@@ -279,6 +282,7 @@ mod tests {
"closeWindow",
"focusWindow",
"cutoutReady",
"setWholeScreen",
"__codemanDesktopRefused",
"sessionExpired",
"'auxclick'",
+10 -6
View File
@@ -46,7 +46,8 @@ pub struct Config {
/// Always open in full screen (otherwise the last state is restored).
pub start_fullscreen: bool,
/// On a display with a camera housing, full screen covers the whole
/// display, the strip beside the camera included (whole_screen.rs).
/// display, the strip beside the camera included (whole_screen.rs). On
/// unless it was turned off; a display without a housing never sees it.
pub whole_screen: bool,
/// Whether the lit Apple logo shows what the agents are doing, and its style
/// for each state (logo.rs). The menu only shows on a Mac that has one. A
@@ -83,7 +84,7 @@ impl Default for Config {
servers: Vec::new(),
auto_connect: true,
start_fullscreen: false,
whole_screen: false,
whole_screen: true,
logo_blink: BlinkStyles::default(),
keep_awake: keep_awake::Settings::default(),
window: None,
@@ -475,13 +476,16 @@ mod tests {
}
#[test]
fn full_screen_over_the_whole_display_is_off_until_chosen() {
assert!(!Config::default().whole_screen);
fn full_screen_over_the_whole_display_is_on_until_turned_off() {
assert!(Config::default().whole_screen);
// A file from before the option.
let c: Config = serde_json::from_str(r#"{"startFullscreen":true}"#).unwrap();
assert!(!c.whole_screen);
let c: Config = serde_json::from_str(r#"{"wholeScreen":true}"#).unwrap();
assert!(c.whole_screen);
let c: Config = serde_json::from_str(r#"{"wholeScreen":false}"#).unwrap();
assert!(!c.whole_screen);
// Turned off, it stays off across a save.
let back: Config = serde_json::from_str(&serde_json::to_string(&c).unwrap()).unwrap();
assert!(!back.whole_screen);
}
#[test]
+34 -9
View File
@@ -1384,7 +1384,12 @@ impl App {
self.config_dirty = true;
self.to_connect_page(json!({ "type": "prefs", "startFullscreen": value }));
}
menu_id::WHOLE_SCREEN => self.toggle_whole_screen(),
menu_id::WHOLE_SCREEN => {
// muda has already flipped the item's check mark.
if let Some(on) = self.menu.whole_screen.as_ref().map(|item| item.is_checked()) {
self.set_whole_screen(on);
}
}
menu_id::DEVTOOLS => {
if let Some(w) = self.focused_window_id().and_then(|id| self.windows.get(&id)) {
w.webview.open_devtools();
@@ -1437,27 +1442,35 @@ impl App {
whole_screen::set_page_ready(&w.window, ready);
}
self.sync_whole_screen(window);
// A page that announces itself has just loaded: its
// settings switch needs the option's state.
self.tell_whole_screen_option(Some(window));
}
#[cfg(not(target_os = "macos"))]
let _ = ready;
}
HostCmd::SetWholeScreen(on) => self.set_whole_screen(on),
}
}
/// View > Full Screen Uses the Area Beside the Camera. A main window that
/// is in full screen changes over at once, so the user sees what the
/// option does: out of macOS's full screen and, once its Space has closed
/// View > Full Screen Uses the Area Beside the Camera, and the same switch
/// in Codeman's settings page. A main window that is in full screen
/// changes over at once, so the user sees what the option does: out of
/// macOS's full screen and, once its Space has closed
/// (`retry_fullscreen`), over the whole display, or straight back from the
/// whole display into macOS's.
fn toggle_whole_screen(&mut self) {
let Some(on) = self.menu.whole_screen.as_ref().map(|item| item.is_checked()) else {
return;
};
fn set_whole_screen(&mut self, on: bool) {
// The menu item and every page's switch show the same thing, whichever
// of them was used.
if let Some(item) = &self.menu.whole_screen {
item.set_checked(on);
}
self.config.whole_screen = on;
self.config_dirty = true;
#[cfg(target_os = "macos")]
{
whole_screen::set_enabled(on);
self.tell_whole_screen_option(None);
let Some(main) = self.windows.get(&self.main_id) else {
return;
};
@@ -1475,6 +1488,18 @@ impl App {
}
}
/// Tells one window's page, or every window's, what the option's switch in
/// its settings shows (whole_screen::option_script).
#[cfg(target_os = "macos")]
fn tell_whole_screen_option(&self, only: Option<WindowId>) {
let script = whole_screen::option_script(whole_screen::available(), self.config.whole_screen);
for (id, w) in &self.windows {
if only.is_none_or(|one| one == *id) {
let _ = w.webview.evaluate_script(&script);
}
}
}
/// Brings a window in line with full screen over the whole display: its
/// frame, how far its web view stays below a camera housing, and what its
/// page knows about the housing (whole_screen::sync).
@@ -2172,7 +2197,7 @@ impl App {
// frame; the saved one is kept for the next launch. Nor is it while
// the window animates into or out of macOS's full screen, which tao
// stops reporting as full screen the moment the app asks it to leave
// (toggle_whole_screen).
// (set_whole_screen).
#[cfg(target_os = "macos")]
let transitional = whole_screen::in_transition(w);
#[cfg(not(target_os = "macos"))]
+3 -3
View File
@@ -202,9 +202,9 @@ pub fn build_menu(config: &Config) -> muda::Result<AppMenu> {
None,
);
// Only where it can do something: a display with a camera housing is
// connected, or the option is already on (a MacBook started with its lid
// closed still gets the item that turns it off).
let whole_screen = (whole_screen_available() || config.whole_screen).then(|| {
// connected. The option is on unless it was turned off, so its own value
// says nothing about the Mac.
let whole_screen = whole_screen_available().then(|| {
CheckMenuItem::with_id(
menu_id::WHOLE_SCREEN,
"Full Screen Uses the Area Beside the Camera",
+24
View File
@@ -589,6 +589,9 @@ pub enum HostCmd {
/// is told where one is (whole_screen.rs), and so may be drawn behind it.
/// A page says no for a layout that would only lose room that way.
CutoutReady(bool),
/// Codeman's settings page turned "full screen uses the area beside the
/// camera" on or off (the View menu's item, from the page).
SetWholeScreen(bool),
}
/// Calls the bundled connect page makes.
@@ -737,6 +740,9 @@ enum RawHost {
#[serde(default = "yes")]
ready: bool,
},
WholeScreen {
on: bool,
},
}
fn yes() -> bool {
@@ -838,6 +844,7 @@ pub fn parse_ipc(frame_url: &str, body: &str, phase: &Phase, is_main_window: boo
RawHost::OpenExternal { url } if url.len() <= MAX_URL_LEN => HostCmd::OpenExternal(url),
RawHost::SessionExpired => HostCmd::SessionExpired,
RawHost::CutoutReady { ready } => HostCmd::CutoutReady(ready),
RawHost::WholeScreen { on } => HostCmd::SetWholeScreen(on),
_ => return None,
};
Some(Ipc::Host(cmd))
@@ -1583,6 +1590,18 @@ mod tests {
parse_ipc(main, r#"{"cmd":"cutoutReady","ready":"yes"}"#, &loaded, true),
None
);
// The settings page's switch for the whole-display full screen: on or
// off, said outright. No field, or one of another type, is no message.
assert_eq!(
parse_ipc(main, r#"{"cmd":"wholeScreen","on":true}"#, &loaded, true),
Some(Ipc::Host(HostCmd::SetWholeScreen(true)))
);
assert_eq!(
parse_ipc(main, r#"{"cmd":"wholeScreen","on":false}"#, &loaded, true),
Some(Ipc::Host(HostCmd::SetWholeScreen(false)))
);
assert_eq!(parse_ipc(main, r#"{"cmd":"wholeScreen"}"#, &loaded, true), None);
assert_eq!(parse_ipc(main, r#"{"cmd":"wholeScreen","on":1}"#, &loaded, true), None);
// Untrusted surfaces, other origins, connect commands: refused.
for frame in [
"http://127.0.0.1:3000/html-view/c/x.html",
@@ -1598,6 +1617,11 @@ mod tests {
// A rendered HTML file or a web tab must not get the page drawn
// behind the camera by claiming it copes.
assert_eq!(parse_ipc(frame, r#"{"cmd":"cutoutReady"}"#, &loaded, true), None);
// Nor may one change the app's own settings.
assert_eq!(
parse_ipc(frame, r#"{"cmd":"wholeScreen","on":false}"#, &loaded, true),
None
);
}
assert_eq!(
parse_ipc(main, r#"{"cmd":"startServer","url":"x"}"#, &loaded, true),
+48 -5
View File
@@ -168,6 +168,15 @@ pub fn page_script(cutout: Option<Cutout>) -> String {
)
}
/// Tells the page what its settings switch shows: whether this Mac has a
/// display the option does anything on, and whether the option is on. Like
/// [`page_script`], it does nothing in a page without the cutout module.
pub fn option_script(available: bool, enabled: bool) -> String {
format!(
"window.CodemanHostCutout&&typeof window.CodemanHostCutout.option==='function'&&window.CodemanHostCutout.option({{available:{available},enabled:{enabled}}});"
)
}
// NSApplicationPresentationOptions, as plain bits so the rule below is tested
// on any host (`imp` asserts they match AppKit's).
const AUTO_HIDE_DOCK: usize = 1 << 0;
@@ -960,12 +969,19 @@ mod imp {
changed(id);
}
/// Puts the keys back where they were before the title bar went or came.
/// A window is its own first responder when nothing else is, and takes no
/// keys: one that has just come out of macOS's full screen is left like
/// that (seen on a MacBook Pro: the option ticked while in macOS's full
/// screen, and typing went nowhere until a click). The page then gets the
/// keys, being the only thing in the window.
fn restore_responder(window: &NSWindow, responder: Option<Retained<NSResponder>>) {
if let Some(responder) = responder {
// A window is its own first responder when nothing else is.
if !ptr::eq(Retained::as_ptr(&responder).cast::<NSWindow>(), ptr::from_ref(window)) {
window.makeFirstResponder(Some(&responder));
}
let other = responder.filter(|r| !ptr::eq(Retained::as_ptr(r).cast::<NSWindow>(), ptr::from_ref(window)));
if let Some(responder) = other {
window.makeFirstResponder(Some(&responder));
} else if let Some(web_view) = with_tracked(key(window), |t| t.web_view.clone()) {
let page: &NSResponder = &web_view;
window.makeFirstResponder(Some(page));
}
}
@@ -1235,6 +1251,33 @@ mod tests {
);
}
#[test]
fn the_page_is_told_what_its_settings_switch_shows() {
assert_eq!(
option_script(true, false),
"window.CodemanHostCutout&&typeof window.CodemanHostCutout.option==='function'\
&&window.CodemanHostCutout.option({available:true,enabled:false});"
);
assert!(option_script(false, true).ends_with(".option({available:false,enabled:true});"));
}
/// Measured on a MacBook Pro (Mac17,13, macOS 27.2) at its default
/// resolution: a housing 59 pt wide in a strip 40 pt high.
#[test]
fn a_narrow_housing_is_read_like_a_wide_one() {
assert_eq!(
housing(1512.0, 40.0, 726.5, 726.5),
Some(Housing {
height: 40.0,
cutout: Some(Cutout {
left: 726.5,
width: 59.0,
height: 40.0,
}),
})
);
}
#[test]
fn entering_hides_the_dock_and_the_menu_bar_and_remembers_what_it_added() {
assert_eq!(