mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-25 07:09:33 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79f444a2fc |
No files matched your search
@@ -1,5 +0,0 @@
|
||||
---
|
||||
'aicodeman': patch
|
||||
---
|
||||
|
||||
**Mac app: full screen over the whole display.** On a MacBook with a camera housing (the notch), macOS's full screen leaves a black bar across the top of the display. The Mac app's full screen now covers the whole display instead: Codeman's header moves up beside the camera, the tabs go around it on both sides, the toolbar stays at the right, and the terminal gains the height of the bar. The green button, the menu item, ⌃⌘F and the launch into full screen all take it, and the menu bar and the Dock still slide in when the pointer is pushed against their edge. It is on by default and can be turned off with **View > Full Screen Uses the Area Beside the Camera** or the same switch in **App Settings > Appearance > Mac App** (both only show on a Mac whose display has a camera housing); switching it while the window is in full screen changes it over at once. Off gives macOS's own full screen back, which is a Space of its own: the whole-display kind covers the desktop it is on instead. The page stays below the camera, as before, with a Codeman server from before this release and while the tabs are grouped by state, by case or as a ledger in the header strip.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"aicodeman": patch
|
||||
---
|
||||
|
||||
The Ledger tab layout shows the spinning ring on a working session again. The ledger swaps the status dot for a coloured bar, and that bar is green for idle and working alike, so hiding the dot also hid the only sign that a session was busy. A working cell now keeps the dot and its ring, the same mark the classic strip draws; idle cells stay bar-only, and an exited agent's cell still shows no ring.
|
||||
@@ -31,7 +31,6 @@ export const BROWSER_TEST_GLOBS = [
|
||||
'test/session-sidebar-ux.browser.test.ts',
|
||||
'test/header-divider.browser.test.ts',
|
||||
'test/tab-strip-corner.browser.test.ts',
|
||||
'test/host-cutout.browser.test.ts',
|
||||
'test/header-host-sensors.browser.test.ts',
|
||||
'test/session-options-responsive.browser.test.ts',
|
||||
'test/inline-rename.test.ts',
|
||||
|
||||
@@ -1211,7 +1211,7 @@ Tests: `test/terminal-touch-tap.test.ts`, `test/session-swipe-gesture.test.ts` (
|
||||
|
||||
⚠️ **The boxes ARE a DOM grouping**, unlike by state, which is safe only because a tab changes case far less often than it changes state: `_tabClusterLayout().key` is the whole structure, and the incremental path rebuilds whenever it differs from the last full render's. The keyboard walk keeps boxes together (box index first, then computed order, since a sorted rail orders rows inside each box). Drag only reorders inside one box, as it only reorders inside one state group (`_isTabDropAcrossGroups()`).
|
||||
|
||||
**Ledger.** CSS only, on `.tabs-ledger` inside `@media (min-width: 768px)` and the header host: the flat list on an auto-fill column grid with equal cells, mono type and a 3px status bar (`--ledger-bar`: yellow for a waiting alert, red for an action alert or an error, muted for stopped, exited and web tabs) instead of the dot. ⚠️ It must not change the markup (pinned: the ledger's innerHTML equals classic's); the rail, the sidebar and narrower strips show the plain list.
|
||||
**Ledger.** CSS only, on `.tabs-ledger` inside `@media (min-width: 768px)` and the header host: the flat list on an auto-fill column grid with equal cells, mono type and a 3px status bar (`--ledger-bar`: yellow for a waiting alert, red for an action alert or an error, muted for stopped, exited and web tabs) instead of the dot. ⚠️ A WORKING cell keeps the dot (`.tab-status:not(.busy)` is what is hidden): the bar is green for idle and working alike, and the spinner is the dot's own `.tab-status.busy::after` ring, so hiding every dot left a busy session with no mark (pinned by `test/tab-clusters.test.ts`); an exited agent's cell hides it, as the classic strip hides the ring there. ⚠️ It must not change the markup (pinned: the ledger's innerHTML equals classic's); the rail, the sidebar and narrower strips show the plain list.
|
||||
|
||||
**Classic, wrapped: the L-shaped strip.** Once a classic desktop strip in the header host wraps (`tabs-auto-wrap`, or the manual `tabs-two-rows`), `_syncTabStripCorner()` (app.js) adds `.tabs-corner`: `#headerRight` goes `position: absolute` over the strip's top-right corner and the strip runs the header's full width, so only the row(s) beside the toolbar stop short of it and every later row uses the width under it. A flex line cannot be shortened on its own, so in that state the strip is `display: block` with `inline-flex` tabs flowing around a `::before` float sized from the toolbar's box (`--tab-corner-width` / `--tab-corner-height`); the old `row-gap` (lineage's `--lineage-row-gap` included) becomes the tabs' bottom margin and the bottom padding shrinks by the same amount, so row spacing and lineage routing room are unchanged. ⚠️ `updateTabOverflowMode()` removes `.tabs-corner` BEFORE it measures the wrap (the corner takes the toolbar out of the header's flow, which widens the strip), so the wrap is still judged against the one-row layout and an unwrapped strip looks exactly as before. ⚠️ Flex-only rules do not apply to the strip in that state. ⚠️ A strip that already scrolls (past `--tab-strip-max-height`) keeps the plain wrap, checked on the plain strip before the class goes on: the float scrolls with the tabs while the toolbar stays put, and toggling the class on a scrolled strip lets scroll anchoring move it; a strip pushed past the max-height by the float itself falls back too. A first tab too wide for the room beside the toolbar (the whole first line would drop below it) is trimmed to the room instead (`tab-corner-fit`, `max-width: var(--tab-corner-first-max)`, its name ellipsized): a selected tab is wider (gear and close show), so a fallback here made the whole layout follow the selection. Only a room under `TAB_CORNER_MIN_FIRST_TAB` keeps the plain wrap. ⚠️ The cap goes on the first tab on every pass, never only once it measures too wide: `selectSession()` widens a newly selected tab at once and this sync is debounced, so a cap set afterwards leaves the first row below the toolbar until it runs. It changes nothing on a tab narrower than the room. A `ResizeObserver` on the toolbar re-decides wrap and corner and redraws the connection lines when a reading or the header divider resizes it without a tab render. Scope: classic arrangement, desktop, header host only; state/case/ledger, the sidebar and the vertical rail never get the class (`applySessionListLayout()` drops it when the strip moves). Tests: `test/tab-strip-corner.browser.test.ts` (browser suite).
|
||||
|
||||
|
||||
@@ -63,10 +63,7 @@ These may change in a **MINOR** (or even PATCH) release without a MAJOR bump:
|
||||
3. **Experimental / opt-in features**, regardless of the app's version:
|
||||
Gesture Control (beta), Agent Teams
|
||||
(`CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`), the native-wrapper window bridge
|
||||
(`window.CodemanHost.openWindow` / `closeWindow` / `focusWindow` /
|
||||
`cutoutReady` / `setWholeScreen`, and `window.CodemanHostCutout.apply` and
|
||||
`.option`, which a wrapper calls to say where a display's camera housing is
|
||||
and what its own full-screen option is set to), and
|
||||
(`window.CodemanHost.openWindow` / `closeWindow` / `focusWindow`), and
|
||||
anything labeled experimental in the UI or docs. These may change or be
|
||||
removed at any time.
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ per device, so a sidebar on your desktop does not force one onto your phone.
|
||||
| ---------------------- | ------------------------------------------------------------------------------------ |
|
||||
| **By state** | Groups the tabs by what each session needs from you (below). |
|
||||
| **By case** | One box per case, labelled with the case and its tab count. Inside a box, `w75-api-gateway` reads just `w75`. A case with one tab gets a box with a colour swatch. |
|
||||
| **Ledger** | The same list on an aligned column grid: equal cells, monospace names, a coloured bar on the left of each cell instead of the dot (yellow waiting, red needs you). Desktop header only. |
|
||||
| **Ledger** | The same list on an aligned column grid: equal cells, monospace names, a coloured bar on the left of each cell instead of the dot (yellow waiting, red needs you); a working session keeps its spinning ring. Desktop header only. |
|
||||
| **Classic** (default) | The single list in tab order, as before. |
|
||||
|
||||
**By state** groups the tabs like this, most urgent on top:
|
||||
|
||||
@@ -36,28 +36,24 @@ security-framework = "3"
|
||||
# through wry and tao, so no new crate is added.
|
||||
libc = "0.2"
|
||||
# JavaScript dialogs, HTTP Basic challenges, clearing cookies and the window's
|
||||
# content size (src/macos.rs), and full screen over the whole display
|
||||
# (src/whole_screen.rs). The versions wry already pulls in, so no new crate is
|
||||
# added.
|
||||
# content size (src/macos.rs). The versions wry already pulls in, so no new
|
||||
# crate is added.
|
||||
objc2 = { version = "0.6.5", default-features = false, features = ["std"] }
|
||||
block2 = { version = "0.6.2", default-features = false, features = ["std"] }
|
||||
objc2-foundation = { version = "0.3.2", default-features = false, features = [
|
||||
"std",
|
||||
"objc2-core-foundation",
|
||||
"block2",
|
||||
"NSArray",
|
||||
"NSBundle",
|
||||
"NSDate",
|
||||
"NSDictionary",
|
||||
"NSGeometry",
|
||||
"NSNotification",
|
||||
"NSObject",
|
||||
"NSOperation",
|
||||
"NSProcessInfo",
|
||||
"NSRange",
|
||||
"NSSet",
|
||||
"NSString",
|
||||
"NSTimer",
|
||||
"NSURL",
|
||||
"NSURLAuthenticationChallenge",
|
||||
"NSURLCredential",
|
||||
@@ -65,7 +61,6 @@ objc2-foundation = { version = "0.3.2", default-features = false, features = [
|
||||
"NSURLRequest",
|
||||
"NSURLResponse",
|
||||
"NSURLSession",
|
||||
"NSUserDefaults",
|
||||
"NSValue",
|
||||
] }
|
||||
objc2-app-kit = { version = "0.3.2", default-features = false, features = [
|
||||
@@ -75,10 +70,7 @@ objc2-app-kit = { version = "0.3.2", default-features = false, features = [
|
||||
"NSApplication",
|
||||
"NSButton",
|
||||
"NSControl",
|
||||
"NSEvent",
|
||||
"NSMenu",
|
||||
"NSResponder",
|
||||
"NSScreen",
|
||||
"NSTextField",
|
||||
"NSView",
|
||||
"NSWindow",
|
||||
|
||||
+1
-116
@@ -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. **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. The menu bar and the Dock still slide in when the pointer is pushed against the top edge or the Dock's edge. 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. |
|
||||
| **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). |
|
||||
@@ -274,86 +274,6 @@ address. So the app looks for running Codeman servers of this user (`ps`)
|
||||
before it offers or runs a start, and offers to connect to the ones it finds
|
||||
instead (`found_addresses` in `src/setup.rs`, unit-tested).
|
||||
|
||||
**Full screen over the whole display is the app's own, not macOS's.** A native
|
||||
full-screen Space never reaches behind a MacBook's camera housing: the system
|
||||
ends the window below it and paints the strip beside it black, and no setting
|
||||
changes that. What reaches it is the older kind of full screen, the one
|
||||
terminals offer for the same reason (Ghostty's `macos-non-native-fullscreen`,
|
||||
WezTerm's `macos_fullscreen_extend_behind_notch`, iTerm2's and kitty's
|
||||
traditional full screen): the window loses its title bar, the Dock and the menu
|
||||
bar are hidden, and the window gets the display's whole frame
|
||||
(`src/whole_screen.rs`). Every request for full screen ends in
|
||||
`-[NSWindow toggleFullScreen:]`, so the app adds an override of that one method
|
||||
to tao's window class and decides there, which is what makes the green button
|
||||
and the menu item follow the option without the app owning either. One more
|
||||
override keeps a window without a title bar usable: `⌘W` asks to close as the
|
||||
close button would (AppKit's version only beeps without one). The two kinds of
|
||||
full screen never overlap: AppKit says when a window begins and ends a change
|
||||
into or out of its own full screen, and while one is under way the app neither
|
||||
takes the title bar off nor saves the window's frame, so switching the option
|
||||
while the window is in macOS's full screen waits for the Space to close first.
|
||||
The Dock and the menu bar are out of the way only while a window is in this
|
||||
mode, and what could not be set or taken off because a native Space was in
|
||||
front is done when that changes.
|
||||
`NSPrefersDisplaySafeAreaCompatibilityMode` is `false` in `Info.plist`, which
|
||||
tells macOS that the app handles the housing itself; without it the system may
|
||||
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
|
||||
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.
|
||||
|
||||
**The menu bar and the Dock are hidden, and only auto-hide once the pointer
|
||||
reaches their edge.** Auto-hiding them, which is what a full screen like this
|
||||
normally does, is not enough here. macOS keeps an invisible window in the
|
||||
place of an auto-hidden menu bar, as high as the camera housing, and that
|
||||
window takes every click made there. The strip beside the housing is exactly
|
||||
that place, so with auto-hide a click on a tab or a toolbar button in the top
|
||||
row brought the menu bar in and never reached the page (seen on macOS 27.2,
|
||||
with a plain AppKit window as much as with this app; hovering still worked,
|
||||
which is why it looked fine). With the menu bar fully hidden macOS keeps
|
||||
nothing there and the click arrives. So the app hides both bars while the
|
||||
pointer is over the page, and switches to auto-hide only when the pointer
|
||||
touches the top edge of the display or the edge the Dock is on: pushing on
|
||||
then slides the bar in, as in any full screen. It goes back to hidden once the
|
||||
pointer has moved clear of the bar again (72 points from the top, 200 from the
|
||||
Dock's edge), and never while a menu is open, since the menu hangs from the
|
||||
bar. A timer looks at the pointer 12 times a second while a window is in the
|
||||
mode and the app is in front; the app gets no mouse events over the menu bar,
|
||||
the Dock or macOS's own window, so an event monitor could not tell when to go
|
||||
back. AppKit refuses a hidden menu bar over a Dock that only auto-hides, which
|
||||
is why the two always change together.
|
||||
|
||||
**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: 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, 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.
|
||||
|
||||
**Closing the main window quits the app.** Codeman's sessions keep running on
|
||||
the server, so nothing is lost, and reopening takes about a second.
|
||||
|
||||
@@ -559,41 +479,6 @@ crosses, so the login is never on a command line.
|
||||
built-in display's brightness when the lid opens again, and an Apple display
|
||||
with its own light sensor. If the logo does not move under a closed lid, the
|
||||
menu line says "stayed dark".
|
||||
- **Full screen over the whole display was seen on one MacBook Pro so far**
|
||||
(Mac17,13, macOS 27.2.1, built-in display only, a housing 59 points wide in
|
||||
a strip 40 points high, 2026-11-25): the launch into it with the option
|
||||
never set, typing, tabs on both sides of the housing with a tab selected on
|
||||
either side, pointer clicks on the tabs and buttons in the top row, the menu
|
||||
bar and the Dock sliding in when the pointer is pushed against their edge, a
|
||||
menu staying open while the pointer moves down it, leaving and entering, the
|
||||
change-over both ways from the View menu and from the switch in App
|
||||
Settings, typing right after each, another app in front and back, a relaunch
|
||||
and `⌘W`, with the Dock and the menu bar back every time. The pointer in
|
||||
those runs was driven by synthetic events posted where the hardware's enter
|
||||
the system, not by a hand on the trackpad. Not seen: a second display,
|
||||
closing the lid, a Dock at the left or right edge, and a MacBook with the
|
||||
wider housing of earlier models (the page was checked at those sizes in
|
||||
Chromium only).
|
||||
- **In that mode the pointer has to leave the top of the display before the
|
||||
top row takes clicks again once the menu bar was called.** Touching the top
|
||||
edge hands the strip to the menu bar until the pointer is 72 points below it
|
||||
again; a click in the top row in between goes to the menu bar. Reaching for
|
||||
a tab and overshooting to the very edge therefore brings the menu bar in,
|
||||
as it does in any full-screen window.
|
||||
- **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. 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
|
||||
|
||||
@@ -31,14 +31,6 @@
|
||||
<true/>
|
||||
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||
<true/>
|
||||
<!-- The app handles the camera housing of a MacBook display itself
|
||||
(src/whole_screen.rs): its full screen can cover the whole display,
|
||||
and nothing is drawn behind the housing. Without this key macOS may
|
||||
shrink the display's active area ("compatibility mode") as soon as a
|
||||
window reaches behind the housing, and Finder's Get Info offers
|
||||
"Scale to fit below built-in camera". -->
|
||||
<key>NSPrefersDisplaySafeAreaCompatibilityMode</key>
|
||||
<false/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>MIT License, Codeman Contributors</string>
|
||||
<!-- Voice dictation and gesture control ask for these; without the
|
||||
|
||||
@@ -59,12 +59,6 @@ pub fn respond(request: Request<Vec<u8>>) -> Response<Cow<'static, [u8]>> {
|
||||
/// server restarted, and nothing in the page asks for the login again.
|
||||
/// - defines `__codemanDesktopRefused(id)` (not enumerable) for
|
||||
/// [`refused_script`].
|
||||
/// - `cutoutReady(ready)` lets Codeman's page say whether it keeps its
|
||||
/// 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;
|
||||
@@ -94,9 +88,7 @@ pub const HOST_SHIM: &str = r#"(function () {
|
||||
return u && u.href.length <= MAX_URL ? post({ cmd: 'openWindow', url: u.href }) : false;
|
||||
},
|
||||
closeWindow: function () { post({ cmd: 'closeWindow' }); },
|
||||
focusWindow: function () { post({ cmd: 'focusWindow' }); },
|
||||
cutoutReady: function (ready) { post({ cmd: 'cutoutReady', ready: ready !== false }); },
|
||||
setWholeScreen: function (on) { return post({ cmd: 'wholeScreen', on: on === true }); }
|
||||
focusWindow: function () { post({ cmd: 'focusWindow' }); }
|
||||
})
|
||||
});
|
||||
|
||||
@@ -281,8 +273,6 @@ mod tests {
|
||||
"openWindow",
|
||||
"closeWindow",
|
||||
"focusWindow",
|
||||
"cutoutReady",
|
||||
"setWholeScreen",
|
||||
"__codemanDesktopRefused",
|
||||
"sessionExpired",
|
||||
"'auxclick'",
|
||||
|
||||
@@ -45,10 +45,6 @@ pub struct Config {
|
||||
pub auto_connect: bool,
|
||||
/// 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). 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
|
||||
/// value this version does not know reads as off: a bad style must not make
|
||||
@@ -84,7 +80,6 @@ impl Default for Config {
|
||||
servers: Vec::new(),
|
||||
auto_connect: true,
|
||||
start_fullscreen: false,
|
||||
whole_screen: true,
|
||||
logo_blink: BlinkStyles::default(),
|
||||
keep_awake: keep_awake::Settings::default(),
|
||||
window: None,
|
||||
@@ -475,19 +470,6 @@ mod tests {
|
||||
assert_eq!(c.keep_awake, Settings::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
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":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]
|
||||
fn the_style_a_mac_saved_before_there_were_states_is_kept() {
|
||||
use crate::logo::BlinkStyle;
|
||||
@@ -504,7 +486,6 @@ mod tests {
|
||||
assert!(c.remember("http://127.0.0.1:3000/", None, false).is_empty());
|
||||
assert!(c.remember("https://box.ts.net/", Some("admin"), true).is_empty());
|
||||
c.start_fullscreen = true;
|
||||
c.whole_screen = true;
|
||||
c.window = Some(WindowFrame {
|
||||
x: 10.0,
|
||||
y: 20.0,
|
||||
|
||||
+23
-199
@@ -5,9 +5,7 @@
|
||||
//! browser tab cannot: a connect screen that remembers servers (`config`,
|
||||
//! `login`), runs or installs Codeman on this machine (`setup`,
|
||||
//! `local_server`, `gui_install`) and installs it on another one over SSH
|
||||
//! (`terminal_install`), real full screen (on a MacBook with a camera
|
||||
//! housing over the whole display, if asked: `whole_screen`), native menus
|
||||
//! (`menu`), pop-outs as
|
||||
//! (`terminal_install`), real full screen, native menus (`menu`), pop-outs as
|
||||
//! app windows (Codeman's `window.CodemanHost` bridge), downloads to
|
||||
//! ~/Downloads, passwords in the Keychain (`credentials`), on macOS the
|
||||
//! JavaScript dialogs and HTTP Basic challenges wry leaves out (`macos`), and
|
||||
@@ -43,9 +41,6 @@ mod policy;
|
||||
mod probe;
|
||||
mod setup;
|
||||
mod terminal_install;
|
||||
// The pure half is only used by the macOS half and the tests.
|
||||
#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
|
||||
mod whole_screen;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
@@ -203,14 +198,6 @@ enum UserEvent {
|
||||
OldHelperRemoved(keep_awake::AdminOutcome),
|
||||
/// What the closed lid did with the logo last (logo::watch_lid_status).
|
||||
LogoLidStatus(String),
|
||||
/// A window entered or left full screen over the whole display
|
||||
/// (whole_screen.rs), named by `whole_screen::window_key`. The green
|
||||
/// button and the menu item ask AppKit, not the app, so this is how the
|
||||
/// app hears of it.
|
||||
#[cfg(target_os = "macos")]
|
||||
WholeScreenChanged {
|
||||
window: usize,
|
||||
},
|
||||
}
|
||||
|
||||
struct ProbeDone {
|
||||
@@ -342,11 +329,8 @@ struct App {
|
||||
/// The connect page opens the agent chooser when it next loads: the menu
|
||||
/// asked for it from a Codeman page.
|
||||
add_agent_on_load: bool,
|
||||
/// The main window goes into full screen once the event loop runs.
|
||||
fullscreen_at_launch: bool,
|
||||
/// While the main window may still have to be put into the full screen it
|
||||
/// asked for (at launch, or when the kind of full screen was switched):
|
||||
/// when to look next, and how many retries were made.
|
||||
/// asked for at launch: when to look next, and how many retries were made.
|
||||
fullscreen_retry: Option<(Instant, u8)>,
|
||||
/// The child that watches the connected server and blinks the logo.
|
||||
logo_watch: logo::Watcher,
|
||||
@@ -394,15 +378,6 @@ fn main() {
|
||||
};
|
||||
let config_path = config_path.filter(|_| can_save);
|
||||
let notice = (!can_save).then(|| SETTINGS_UNREADABLE.to_string());
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
whole_screen::set_enabled(config.whole_screen);
|
||||
// Runs inside an AppKit callback: only post an event.
|
||||
let changed_proxy = proxy.clone();
|
||||
whole_screen::set_change_handler(Box::new(move |window| {
|
||||
let _ = changed_proxy.send_event(UserEvent::WholeScreenChanged { window });
|
||||
}));
|
||||
}
|
||||
logo::recover_at_launch();
|
||||
// A lid keeper that was killed left lid sleep off; and 1.50.1's helper, where
|
||||
// it is still installed, gets nothing to act on.
|
||||
@@ -418,8 +393,6 @@ fn main() {
|
||||
create_main_window(&event_loop, &config).unwrap_or_else(|e| fatal(&format!("Could not open a window: {e}")));
|
||||
let webview = build_webview(&window, true, true, Load::ConnectPage, &proxy, &phase)
|
||||
.unwrap_or_else(|e| fatal(&format!("Could not create the web view: {e}")));
|
||||
#[cfg(target_os = "macos")]
|
||||
whole_screen::install(&window, &webview);
|
||||
let main_id = window.id();
|
||||
|
||||
let mut windows = HashMap::new();
|
||||
@@ -451,7 +424,6 @@ fn main() {
|
||||
keychain,
|
||||
install_reader: Arc::new(AtomicU64::new(0)),
|
||||
add_agent_on_load: false,
|
||||
fullscreen_at_launch: wants_fullscreen,
|
||||
fullscreen_retry: wants_fullscreen.then(|| (Instant::now() + FULLSCREEN_FIRST_CHECK, 0)),
|
||||
logo_watch: logo::Watcher::default(),
|
||||
keep_awake: keep_awake::KeepAwake::new(move |generation, text| {
|
||||
@@ -511,12 +483,8 @@ fn placed_position(window: &Window) -> Result<PhysicalPosition<i32>, NotSupporte
|
||||
}
|
||||
}
|
||||
|
||||
/// The main window, and whether it is to open in full screen. It is built at
|
||||
/// its windowed frame and put into full screen once the event loop runs
|
||||
/// (`fullscreen_at_launch`; `fullscreen_retry` then makes sure it gets there),
|
||||
/// never built into it: a window built straight into full screen gets the
|
||||
/// whole screen as its frame, and that is the frame AppKit puts back when the
|
||||
/// user leaves full screen.
|
||||
/// The main window, and whether it was asked into full screen (App's
|
||||
/// `fullscreen_retry` then makes sure it gets there).
|
||||
fn create_main_window(
|
||||
target: &EventLoopWindowTarget<UserEvent>,
|
||||
config: &Config,
|
||||
@@ -540,31 +508,17 @@ fn create_main_window(
|
||||
}
|
||||
}
|
||||
let window = builder.build(target)?;
|
||||
// Full screen is entered after the window exists at its windowed frame,
|
||||
// not set on the builder: a window built straight into full screen gets
|
||||
// the whole screen as its frame, and that is the frame AppKit puts back
|
||||
// when the user leaves full screen.
|
||||
let fullscreen = config.start_fullscreen || config.window.is_some_and(|f| f.fullscreen);
|
||||
if fullscreen {
|
||||
window.set_fullscreen(Some(Fullscreen::Borderless(None)));
|
||||
}
|
||||
Ok((window, fullscreen))
|
||||
}
|
||||
|
||||
/// Puts `window` into full screen: over the whole display where that applies
|
||||
/// (whole_screen.rs), macOS's own everywhere else. A window that is still on
|
||||
/// its way out of macOS's full screen is left alone; the caller asks again.
|
||||
fn enter_full_screen(window: &Window) {
|
||||
#[cfg(target_os = "macos")]
|
||||
match whole_screen::enter(window) {
|
||||
whole_screen::Entry::Entered | whole_screen::Entry::Busy => return,
|
||||
whole_screen::Entry::NotWanted => {}
|
||||
}
|
||||
window.set_fullscreen(Some(Fullscreen::Borderless(None)));
|
||||
}
|
||||
|
||||
/// Whether `window` is in full screen, of either kind.
|
||||
fn in_full_screen(window: &Window) -> bool {
|
||||
#[cfg(target_os = "macos")]
|
||||
if whole_screen::is_active(window) {
|
||||
return true;
|
||||
}
|
||||
window.fullscreen().is_some()
|
||||
}
|
||||
|
||||
/// The Authorization header for a login, when there is a password.
|
||||
fn basic_auth(username: Option<&str>, password: Option<&str>) -> Option<String> {
|
||||
username.zip(password).map(|(u, p)| policy::basic_auth_header(u, p))
|
||||
@@ -816,11 +770,6 @@ impl App {
|
||||
self.menu.window_menu.set_as_windows_menu_for_nsapp();
|
||||
self.menu.help_menu.set_as_help_menu_for_nsapp();
|
||||
}
|
||||
if std::mem::take(&mut self.fullscreen_at_launch) {
|
||||
if let Some(main) = self.windows.get(&self.main_id) {
|
||||
enter_full_screen(&main.window);
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::WindowEvent { window_id, event, .. } => self.on_window_event(window_id, event, target, control_flow),
|
||||
Event::UserEvent(event) => self.on_user_event(event, target),
|
||||
@@ -875,14 +824,12 @@ impl App {
|
||||
};
|
||||
}
|
||||
|
||||
/// The main window asked for full screen (at launch, or to change the kind
|
||||
/// it is in): if it is not there yet, ask again, a few times at most. tao
|
||||
/// reports a window as full screen from the moment it is asked and puts
|
||||
/// that back only when the entry fails, so `fullscreen()` being None means
|
||||
/// it failed, or that the window is on its way to the whole display and
|
||||
/// has to leave macOS's full screen first. Stops once the window is in
|
||||
/// full screen or minimized, so a user who leaves full screen later is
|
||||
/// never pulled back.
|
||||
/// The main window asked for full screen at launch: if it is not there
|
||||
/// yet, ask again, a few times at most. tao reports a window as full
|
||||
/// screen from the moment it is asked and puts that back only when the
|
||||
/// entry fails, so `fullscreen()` being None means it failed. Stops once
|
||||
/// the window is in full screen or minimized, so a user who leaves full
|
||||
/// screen later is never pulled back.
|
||||
fn retry_fullscreen(&mut self, now: Instant) {
|
||||
let Some((_, attempts)) = self.fullscreen_retry else {
|
||||
return;
|
||||
@@ -891,10 +838,10 @@ impl App {
|
||||
let Some(main) = self.windows.get(&self.main_id) else {
|
||||
return;
|
||||
};
|
||||
if in_full_screen(&main.window) || main.window.is_minimized() || attempts >= FULLSCREEN_ATTEMPTS {
|
||||
if main.window.fullscreen().is_some() || main.window.is_minimized() || attempts >= FULLSCREEN_ATTEMPTS {
|
||||
return;
|
||||
}
|
||||
enter_full_screen(&main.window);
|
||||
main.window.set_fullscreen(Some(Fullscreen::Borderless(None)));
|
||||
self.fullscreen_retry = Some((now + FULLSCREEN_RETRY_EVERY, attempts + 1));
|
||||
}
|
||||
|
||||
@@ -928,14 +875,7 @@ impl App {
|
||||
*control_flow = ControlFlow::Exit;
|
||||
}
|
||||
}
|
||||
WindowEvent::Moved(_) | WindowEvent::Resized(_) | WindowEvent::ScaleFactorChanged { .. } => {
|
||||
// A window over the whole display follows the display it is on.
|
||||
#[cfg(target_os = "macos")]
|
||||
self.sync_whole_screen(id);
|
||||
if id == self.main_id {
|
||||
self.record_main_frame();
|
||||
}
|
||||
}
|
||||
WindowEvent::Moved(_) | WindowEvent::Resized(_) if id == self.main_id => self.record_main_frame(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -954,20 +894,6 @@ impl App {
|
||||
}
|
||||
}
|
||||
UserEvent::LogoLidStatus(line) => self.show_lid_status(line),
|
||||
#[cfg(target_os = "macos")]
|
||||
UserEvent::WholeScreenChanged { window } => {
|
||||
let id = self
|
||||
.windows
|
||||
.iter()
|
||||
.find(|(_, w)| whole_screen::window_key(&w.window) == window)
|
||||
.map(|(id, _)| *id);
|
||||
if let Some(id) = id {
|
||||
self.sync_whole_screen(id);
|
||||
if id == self.main_id {
|
||||
self.record_main_frame();
|
||||
}
|
||||
}
|
||||
}
|
||||
UserEvent::ServerStartDone {
|
||||
generation,
|
||||
url,
|
||||
@@ -1027,15 +953,6 @@ impl App {
|
||||
if let Some(w) = self.windows.get_mut(&window) {
|
||||
w.committed = Url::parse(&url).ok();
|
||||
}
|
||||
// A new document has not said that it keeps clear of a camera
|
||||
// housing: its web view stays below it until it does.
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
if let Some(w) = self.windows.get(&window) {
|
||||
whole_screen::set_page_ready(&w.window, false);
|
||||
}
|
||||
self.sync_whole_screen(window);
|
||||
}
|
||||
}
|
||||
UserEvent::DownloadStarted { window, url, file_name } => {
|
||||
// A pop-out opened only to fetch a file would sit empty: hide
|
||||
@@ -1384,12 +1301,6 @@ impl App {
|
||||
self.config_dirty = true;
|
||||
self.to_connect_page(json!({ "type": "prefs", "startFullscreen": value }));
|
||||
}
|
||||
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();
|
||||
@@ -1435,80 +1346,6 @@ impl App {
|
||||
}
|
||||
HostCmd::OpenExternal(raw) => self.open_external_raw(&raw),
|
||||
HostCmd::SessionExpired => self.on_session_expired(window),
|
||||
HostCmd::CutoutReady(ready) => {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
if let Some(w) = self.windows.get(&window) {
|
||||
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, 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 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;
|
||||
};
|
||||
let window = &main.window;
|
||||
let whole = whole_screen::is_active(window);
|
||||
if on && !whole && window.fullscreen().is_some() && whole_screen::applies_to(window) {
|
||||
window.set_fullscreen(None);
|
||||
} else if !on && whole {
|
||||
whole_screen::leave(window);
|
||||
window.set_fullscreen(Some(Fullscreen::Borderless(None)));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
self.fullscreen_retry = Some((Instant::now() + FULLSCREEN_FIRST_CHECK, 0));
|
||||
}
|
||||
}
|
||||
|
||||
/// 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).
|
||||
#[cfg(target_os = "macos")]
|
||||
fn sync_whole_screen(&self, id: WindowId) {
|
||||
if let Some(w) = self.windows.get(&id) {
|
||||
if let Some(script) = whole_screen::sync(&w.window) {
|
||||
let _ = w.webview.evaluate_script(&script);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2100,8 +1937,6 @@ impl App {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
#[cfg(target_os = "macos")]
|
||||
whole_screen::install(&window, &webview);
|
||||
let kind = Kind::Popout {
|
||||
opened_url,
|
||||
hidden_for_download: false,
|
||||
@@ -2149,10 +1984,6 @@ impl App {
|
||||
if id == self.main_id {
|
||||
return;
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
if let Some(w) = self.windows.get(&id) {
|
||||
whole_screen::forget(&w.window);
|
||||
}
|
||||
self.windows.remove(&id);
|
||||
self.downloads.retain(|(window, _), _| *window != id);
|
||||
}
|
||||
@@ -2185,7 +2016,7 @@ impl App {
|
||||
return;
|
||||
};
|
||||
let w = &main.window;
|
||||
let fullscreen = in_full_screen(w);
|
||||
let fullscreen = w.fullscreen().is_some();
|
||||
let mut frame = self.config.window.unwrap_or(WindowFrame {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
@@ -2194,15 +2025,8 @@ impl App {
|
||||
fullscreen,
|
||||
});
|
||||
// In full screen or minimized the live geometry is not the windowed
|
||||
// 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
|
||||
// (set_whole_screen).
|
||||
#[cfg(target_os = "macos")]
|
||||
let transitional = whole_screen::in_transition(w);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let transitional = false;
|
||||
if !fullscreen && !transitional && !w.is_minimized() {
|
||||
// frame; the saved one is kept for the next launch.
|
||||
if !fullscreen && !w.is_minimized() {
|
||||
let sf = w.scale_factor();
|
||||
if let Ok(pos) = placed_position(w) {
|
||||
let p = pos.to_logical::<f64>(sf);
|
||||
|
||||
@@ -17,7 +17,6 @@ pub mod menu_id {
|
||||
pub const ADD_AGENT: &str = "add-agent";
|
||||
pub const RELOAD: &str = "reload";
|
||||
pub const START_FULLSCREEN: &str = "start-fullscreen";
|
||||
pub const WHOLE_SCREEN: &str = "whole-screen";
|
||||
pub const LOGO_BLINK: &str = "logo-blink";
|
||||
pub const DEVTOOLS: &str = "devtools";
|
||||
pub const HELP_DOCS: &str = "help-docs";
|
||||
@@ -29,10 +28,6 @@ pub struct AppMenu {
|
||||
pub window_menu: Submenu,
|
||||
pub help_menu: Submenu,
|
||||
pub start_fullscreen: CheckMenuItem,
|
||||
/// Full screen over the whole display (whole_screen.rs). None on a Mac with
|
||||
/// no camera housing in sight, where macOS's full screen already uses
|
||||
/// every pixel.
|
||||
pub whole_screen: Option<CheckMenuItem>,
|
||||
/// The one switch for the logo. None on a Mac without a lit logo, which has no
|
||||
/// such menu.
|
||||
pub logo_switch: Option<CheckMenuItem>,
|
||||
@@ -125,16 +120,6 @@ fn build_keep_awake(config: &Config) -> muda::Result<(Submenu, KeepAwakeMenu)> {
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn whole_screen_available() -> bool {
|
||||
crate::whole_screen::available()
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn whole_screen_available() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn build_menu(config: &Config) -> muda::Result<AppMenu> {
|
||||
let bar = Menu::new();
|
||||
let about = PredefinedMenuItem::about(
|
||||
@@ -201,18 +186,6 @@ pub fn build_menu(config: &Config) -> muda::Result<AppMenu> {
|
||||
config.start_fullscreen,
|
||||
None,
|
||||
);
|
||||
// Only where it can do something: a display with a camera housing is
|
||||
// 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",
|
||||
true,
|
||||
config.whole_screen,
|
||||
None,
|
||||
)
|
||||
});
|
||||
let view = Submenu::with_items(
|
||||
"View",
|
||||
true,
|
||||
@@ -235,11 +208,6 @@ pub fn build_menu(config: &Config) -> muda::Result<AppMenu> {
|
||||
),
|
||||
],
|
||||
)?;
|
||||
// Right under "Always Open in Full Screen", before the logo items and the separator.
|
||||
if let Some(item) = &whole_screen {
|
||||
view.insert(item, 4)?;
|
||||
}
|
||||
let after_full_screen = 4 + usize::from(whole_screen.is_some());
|
||||
// Only a Mac with a lit Apple logo has these items at all: the switch, and the
|
||||
// style for each state behind it.
|
||||
let mut logo_styles = Vec::new();
|
||||
@@ -267,11 +235,11 @@ pub fn build_menu(config: &Config) -> muda::Result<AppMenu> {
|
||||
}
|
||||
submenu.append(&group)?;
|
||||
}
|
||||
// Under the full-screen items, before the separator.
|
||||
// Right under "Always Open in Full Screen", before the separator.
|
||||
let lid = MenuItem::new(logo::lid_status_line(), false, None);
|
||||
view.insert(&switch, after_full_screen)?;
|
||||
view.insert(&submenu, after_full_screen + 1)?;
|
||||
view.insert(&lid, after_full_screen + 2)?;
|
||||
view.insert(&switch, 4)?;
|
||||
view.insert(&submenu, 5)?;
|
||||
view.insert(&lid, 6)?;
|
||||
logo_switch = Some(switch);
|
||||
logo_lid = Some(lid);
|
||||
}
|
||||
@@ -301,7 +269,6 @@ pub fn build_menu(config: &Config) -> muda::Result<AppMenu> {
|
||||
window_menu,
|
||||
help_menu,
|
||||
start_fullscreen,
|
||||
whole_screen,
|
||||
logo_switch,
|
||||
logo_styles,
|
||||
keep_awake,
|
||||
|
||||
@@ -585,13 +585,6 @@ pub enum HostCmd {
|
||||
/// The page got a 401 from its own server: the session cookie is gone (a
|
||||
/// server restart) and the page cannot recover on its own.
|
||||
SessionExpired,
|
||||
/// Whether the page keeps its controls clear of a camera housing when it
|
||||
/// 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.
|
||||
@@ -727,26 +720,11 @@ enum RawConnect {
|
||||
#[derive(Deserialize)]
|
||||
#[serde(tag = "cmd", rename_all = "camelCase", deny_unknown_fields)]
|
||||
enum RawHost {
|
||||
OpenWindow {
|
||||
url: String,
|
||||
},
|
||||
OpenWindow { url: String },
|
||||
CloseWindow,
|
||||
FocusWindow,
|
||||
OpenExternal {
|
||||
url: String,
|
||||
},
|
||||
OpenExternal { url: String },
|
||||
SessionExpired,
|
||||
CutoutReady {
|
||||
#[serde(default = "yes")]
|
||||
ready: bool,
|
||||
},
|
||||
WholeScreen {
|
||||
on: bool,
|
||||
},
|
||||
}
|
||||
|
||||
fn yes() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// The shape of a CLI catalogue id. It becomes one argument of `install.sh`,
|
||||
@@ -843,8 +821,6 @@ pub fn parse_ipc(frame_url: &str, body: &str, phase: &Phase, is_main_window: boo
|
||||
RawHost::FocusWindow => HostCmd::FocusWindow,
|
||||
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))
|
||||
@@ -1560,48 +1536,6 @@ mod tests {
|
||||
),
|
||||
Some(Ipc::Host(HostCmd::SessionExpired))
|
||||
);
|
||||
// The dashboard and a session pop-out both say when they keep clear
|
||||
// of a camera housing.
|
||||
assert_eq!(
|
||||
parse_ipc(main, r#"{"cmd":"cutoutReady","ready":true}"#, &loaded, true),
|
||||
Some(Ipc::Host(HostCmd::CutoutReady(true)))
|
||||
);
|
||||
assert_eq!(
|
||||
parse_ipc(
|
||||
"http://127.0.0.1:3000/session/1",
|
||||
r#"{"cmd":"cutoutReady","ready":true}"#,
|
||||
&loaded,
|
||||
false
|
||||
),
|
||||
Some(Ipc::Host(HostCmd::CutoutReady(true)))
|
||||
);
|
||||
// A layout that would only lose room behind the housing says no; a
|
||||
// message without the field is a yes, and a field of another type is
|
||||
// no message at all.
|
||||
assert_eq!(
|
||||
parse_ipc(main, r#"{"cmd":"cutoutReady","ready":false}"#, &loaded, true),
|
||||
Some(Ipc::Host(HostCmd::CutoutReady(false)))
|
||||
);
|
||||
assert_eq!(
|
||||
parse_ipc(main, r#"{"cmd":"cutoutReady"}"#, &loaded, true),
|
||||
Some(Ipc::Host(HostCmd::CutoutReady(true)))
|
||||
);
|
||||
assert_eq!(
|
||||
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",
|
||||
@@ -1614,14 +1548,6 @@ mod tests {
|
||||
] {
|
||||
assert_eq!(parse_ipc(frame, r#"{"cmd":"focusWindow"}"#, &loaded, true), None);
|
||||
assert_eq!(parse_ipc(frame, r#"{"cmd":"sessionExpired"}"#, &loaded, true), None);
|
||||
// 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),
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -121,7 +121,6 @@ run('minify tab-layout-browser.js', 'npx esbuild dist/web/public/tab-layout-brow
|
||||
run('minify app.js', 'npx esbuild dist/web/public/app.js --minify --outfile=dist/web/public/app.js --allow-overwrite');
|
||||
run('minify tab-rail-resize.js', 'npx esbuild dist/web/public/tab-rail-resize.js --minify --outfile=dist/web/public/tab-rail-resize.js --allow-overwrite');
|
||||
run('minify header-divider.js', 'npx esbuild dist/web/public/header-divider.js --minify --outfile=dist/web/public/header-divider.js --allow-overwrite');
|
||||
run('minify host-cutout.js', 'npx esbuild dist/web/public/host-cutout.js --minify --outfile=dist/web/public/host-cutout.js --allow-overwrite');
|
||||
run('minify terminal-ui.js', 'npx esbuild dist/web/public/terminal-ui.js --minify --outfile=dist/web/public/terminal-ui.js --allow-overwrite');
|
||||
run('minify respawn-ui.js', 'npx esbuild dist/web/public/respawn-ui.js --minify --outfile=dist/web/public/respawn-ui.js --allow-overwrite');
|
||||
run('minify ralph-panel.js', 'npx esbuild dist/web/public/ralph-panel.js --minify --outfile=dist/web/public/ralph-panel.js --allow-overwrite');
|
||||
@@ -152,7 +151,6 @@ console.log('\n[build] content-hash cache busting');
|
||||
'app.js',
|
||||
'tab-rail-resize.js',
|
||||
'header-divider.js',
|
||||
'host-cutout.js',
|
||||
'terminal-ui.js',
|
||||
'respawn-ui.js',
|
||||
'ralph-panel.js',
|
||||
|
||||
+1
-3
@@ -38,9 +38,7 @@ Frontend JS modules have `@fileoverview` with `@dependency`/`@loadorder` tags. L
|
||||
|
||||
**Session list layout: header strip or left sidebar** (`sessionListLayout`, default `header`; per-device via `displayKeys`, also in `SettingsUpdateSchema`): the list can move into a collapsible `<aside>` (Alt+B, `toggleSessionSidebar`) or, via `tabOrientation`, a resizable vertical `#tabRail` (desktop/tablet only). ⚠️ There is ONE `#sessionTabs`, MOVED between hosts, never a second list: `applySessionListLayout()` runs first, then `applyTabOrientation()`, both BEFORE `applyTabWrapSettings()`, and both arm/disarm `_startSidebarRichClock()`. ⚠️ Axis decisions use `_isVerticalTabList()`, never `isSessionSidebarActive()` alone. ⚠️ Rich rows share one gate, `isRichTabRows()`; rich CSS pairs sidebar+rail with comma-grouped selectors, never `:is()`, and card rules stay rail-scoped. ⚠️ Rail sort (`tabRailSort`, default `activity`) is the flex `order` property only, never a DOM reorder; the arrow-key walk and the phone swipe follow computed `order`. ⚠️ Leaving sidebar mode clears `_sidebarFilter`; the handheld overlay drawer is `inert` when closed, the docked rail never. ⚠️ The rail's **Search sessions** box (`setTabRailSearch`, in memory only) and the sidebar filter share ONE row filter, `_applyTabListFilter()` over the pure `CodemanTabSearch` (constants.js): classes only, never a reorder or layout write; the rail matches the name, the sidebar name + folder. ⚠️ A session row with a tab alert (`tabAlerts`, red or yellow) is never hidden by either box: it goes in as `keep: true`, counts toward its group (which stays on screen) but not toward `matchCount`. ⚠️ Escape in the rail box is claimed by the global capture-phase Escape branch (the box's own `onkeydown` runs after it, too late to stop `closeAllPanels()`), and a filter change that shows or hides anything redraws the connector lines, since a keystroke re-renders nothing; a floating window finds its parent tab only through `_paintedSessionTab()` (a hidden row's rect is all zero but truthy, which drew connectors from the viewport's corner). While it runs `_projectTabGroups()` projects every group open (a collapsed group's rows are not in the DOM) and `toggleTabGroupCollapsed()` refuses, leaving the stored collapse untouched; drag stays on during a search (owner decision), a drop landing between the visible neighbours; `applyTabOrientation()` clears it off the rail. Tests: `test/tab-rail-search.test.ts`, `test/tab-rail-search.browser.test.ts`. → [architecture-invariants#session-list-layout-header-strip-vs-left-sidebar](../../docs/architecture-invariants.md#session-list-layout-header-strip-vs-left-sidebar)
|
||||
|
||||
**Tab layouts** (`tabArrangement`, per-device, default `classic`; `state`/`case`/`ledger` are opt-in; Discussion #426): `state` (option C) splits the list into needs you / waiting / working / idle (idle is `quiet`: its heading stays as the row's anchor but draws no label; `tabStateOrder: 'urgent-last'` flips the order, needs you at the bottom): rows in the desktop header strip with left-aligned labels in a measured column (the brand sits over the strip's corner, so the rows after the first start under "Codeman"), sections in the flat rail and the sidebar, inline dividers on the tablet strip, group order with no headings on phones. `case` (option A) wraps each case's tabs in one `.tab-cluster` box and hides the `-<case>` of a generated name (`.tab-name-case`). `ledger` (option B) is a CSS-only grid on the desktop header strip. `classic` is the old strip; once it wraps on desktop it is L-shaped via `_syncTabStripCorner()` (the toolbar sits over its top-right corner and later rows run the full width under it, a strip already past its max-height keeps the plain wrap): ⚠️ `.tabs-corner` comes off before the wrap is measured, and the strip is `display: block` in that state, so flex-only rules do not apply to it there (`test/tab-strip-corner.browser.test.ts`). Pure cores: `CodemanTabTriage` and `CodemanTabClusters` (constants.js). ⚠️ `state` is the flex `order` property plus `aria-hidden` heading/break elements reconciled in place by `_syncTabTriageChrome()` after BOTH render paths, never a DOM reorder (a state change is an incremental pass). ⚠️ `case` boxes ARE a DOM grouping, so the incremental path rebuilds whenever `_tabClusterLayout().key` changes; membership follows `_mobileOverviewCaseFor()` like the home screens. ⚠️ Drag only reorders within a group or box (`_isTabDropAcrossGroups()`). ⚠️ Named groups in the vertical rail win over both groupings. ⚠️ `classic` must leave no trace (no headings, no inline order, no boxes, no name split), and the ledger must not change the markup. ⚠️ Grouping is a render layer: `sessionOrder`, Alt+[ / Alt+], Ctrl+Tab and Alt+1..9 keep the canonical order, and only the phone swipe walks the drawn order (`nextSession({ visual: true })` through `_stripSessionOrder()`, the same `_visibleTabRows()` walk the strip's arrow keys use); an active session the list does not draw steps in at the first or last row, and an empty drawn list goes nowhere rather than falling back to a hidden session (`test/session-swipe-gesture.test.ts`). Tests: `test/tab-triage.test.ts`, `test/tab-clusters.test.ts`. → [architecture-invariants#tab-layouts-by-state-by-case-ledger](../../docs/architecture-invariants.md#tab-layouts-by-state-by-case-ledger)
|
||||
|
||||
**Header beside a camera housing** (`host-cutout.js`, the `html.host-cutout-toolbar` rules in styles.css; Codeman Desktop only, `packages/desktop/src/whole_screen.rs`): the Mac app can take a MacBook's whole display, and the page's top edge is then the display's, with the camera housing (the notch) covering a piece of the header row. The app puts a page there only after the page said it copes: the module calls `CodemanHost.cutoutReady(true)` and is answered with `CodemanHostCutout.apply({ left, width, height })` (CSS pixels from the viewport's top-left corner; `apply(null)` when there is none any more), which sets `--host-cutout-left/-width/-height` and the class `host-cutout`. ⚠️ The TABS go around the housing by a MARGIN, never by an element: `fitTabs()` reads rectangles, finds the tab that would overlap the housing (8 px of air on each side, `GAP`, the same value as `--host-cutout-gap`) and gives the room to the tab BEFORE it in the row as its right margin, so a tab that no longer fits right of the housing wraps flush left; only a row's first tab takes the margin itself. Nothing is added to `#sessionTabs` and no tab is reordered, so order, drag and key walks see the strip they always saw; never solve it with a spacer element or `order`. It is geometric (no knowledge of the strip's mode), covers every row beside the housing and none below it. ⚠️ `updateTabOverflowMode()` calls it LAST, once the row mode and the corner are decided, and `_decideTabOverflow()` calls it right before measuring one row (the gap is part of what a row has to hold); the module's own ResizeObserver (border boxes of the strip, every tab, the toolbar and its children) and a childList observer follow changes with no render behind them (a selected tab widening, a reading arriving), always one animation frame later: a size changed inside the observer callback is reported as a ResizeObserver loop. ⚠️ The TOOLBAR (`#headerRight`) stays as it is while it ends right of the housing, the user's chosen width and the divider handle included. `fitToolbar()` gives it the covering box (`html.host-cutout-toolbar`: from just left of the housing to the header's right padding, content padded past the housing, wrapping below it) only when it would reach the housing, always in a solo window (its title shares the row), and until the header is parsed; it measures the toolbar with that class OFF, so the answer never depends on the answer before. `0.75rem` in the rule is the header's own side padding; change the two together (pinned by the test). Anything new that paints in the header's first row must sit inside the tab strip or the toolbar. ⚠️ With the tabs grouped by state, by case or as a ledger IN THE HEADER STRIP the rows follow rules a margin cannot open a gap in (flex `order`, cluster boxes, a grid): `fits()` says no there, the module answers `cutoutReady(false)` and drops the layout at once, and the app keeps the page below the housing. It re-announces only when `data-tab-arrangement`, `data-session-list` or `data-tab-orientation` change. ⚠️ The option itself is the APP's (its `desktop.json`, default on), never a key of the settings blob or of `SettingsUpdateSchema`: the app calls `CodemanHostCutout.option({ available, enabled })` on every page load and whenever it changes, App Settings shows the group `#appSettingsHostGroup` (Appearance > Mac App) only while `available`, and `saveAppSettings()` sends a changed switch through `CodemanHostCutout.setWholeScreen()`, whatever becomes of the rest of the save. ⚠️ The script is in `<head>` and NOT deferred, after the pre-paint script that writes those attributes: the app hears before first paint, so the page is not painted below the housing first and behind it a moment later; `window.app` may not exist yet, so it is only used through `?.`. In a browser tab there is no `CodemanHost.cutoutReady` and the module does nothing. Tests: `test/host-cutout.test.ts` (a row model of the strip), `test/host-cutout.browser.test.ts` (real Chromium, browser suite, not in the gate).
|
||||
**Tab layouts** (`tabArrangement`, per-device, default `classic`; `state`/`case`/`ledger` are opt-in; Discussion #426): `state` (option C) splits the list into needs you / waiting / working / idle (idle is `quiet`: its heading stays as the row's anchor but draws no label; `tabStateOrder: 'urgent-last'` flips the order, needs you at the bottom): rows in the desktop header strip with left-aligned labels in a measured column (the brand sits over the strip's corner, so the rows after the first start under "Codeman"), sections in the flat rail and the sidebar, inline dividers on the tablet strip, group order with no headings on phones. `case` (option A) wraps each case's tabs in one `.tab-cluster` box and hides the `-<case>` of a generated name (`.tab-name-case`). `ledger` (option B) is a CSS-only grid on the desktop header strip; its bar replaces the dot everywhere except a working cell, which keeps the dot and its spinning ring (the bar alone is green for idle and working alike). `classic` is the old strip; once it wraps on desktop it is L-shaped via `_syncTabStripCorner()` (the toolbar sits over its top-right corner and later rows run the full width under it, a strip already past its max-height keeps the plain wrap): ⚠️ `.tabs-corner` comes off before the wrap is measured, and the strip is `display: block` in that state, so flex-only rules do not apply to it there (`test/tab-strip-corner.browser.test.ts`). Pure cores: `CodemanTabTriage` and `CodemanTabClusters` (constants.js). ⚠️ `state` is the flex `order` property plus `aria-hidden` heading/break elements reconciled in place by `_syncTabTriageChrome()` after BOTH render paths, never a DOM reorder (a state change is an incremental pass). ⚠️ `case` boxes ARE a DOM grouping, so the incremental path rebuilds whenever `_tabClusterLayout().key` changes; membership follows `_mobileOverviewCaseFor()` like the home screens. ⚠️ Drag only reorders within a group or box (`_isTabDropAcrossGroups()`). ⚠️ Named groups in the vertical rail win over both groupings. ⚠️ `classic` must leave no trace (no headings, no inline order, no boxes, no name split), and the ledger must not change the markup. ⚠️ Grouping is a render layer: `sessionOrder`, Alt+[ / Alt+], Ctrl+Tab and Alt+1..9 keep the canonical order, and only the phone swipe walks the drawn order (`nextSession({ visual: true })` through `_stripSessionOrder()`, the same `_visibleTabRows()` walk the strip's arrow keys use); an active session the list does not draw steps in at the first or last row, and an empty drawn list goes nowhere rather than falling back to a hidden session (`test/session-swipe-gesture.test.ts`). Tests: `test/tab-triage.test.ts`, `test/tab-clusters.test.ts`. → [architecture-invariants#tab-layouts-by-state-by-case-ledger](../../docs/architecture-invariants.md#tab-layouts-by-state-by-case-ledger)
|
||||
|
||||
**Header stats styles** (`headerStatsStyle`, per-device, desktop only, default `compact`; Discussion #426 option G): `tiles` / `compact` (two pills, a ring beside every value) / `classic` (as before), keyed on `data-header-stats` (pre-paint + `applyHeaderStatsStyle()`), forced to `classic` below 768px and in a solo window. ⚠️ The clustered styles MOVE `#connectionIndicator` into `#headerSystemStats` and `#planUsageChip` right after it; `classic` moves them back to comment anchors. ⚠️ WS joins the pill only while System Stats is shown. ⚠️ The extra parts (stat rings, tile words, plan rings, meters) are always rendered and hidden by default in CSS, which is what keeps `classic` unchanged; tile words are derived beside the connection descriptor, never added to it (`test/connection-indicator.test.ts` pins its shape). ⚠️ A tile is a three-row grid (label, value, bar) with pixel line-heights and the bundled JetBrains Mono; never lay the bar over a fixed-height tile (a taller system mono put the value on top of it). The WS tile's grid lives on the inner `.connection-tile`, because JS writes the indicator's `display` inline. Tests: `test/header-stats-style.test.ts`. → [architecture-invariants#header-stats-styles](../../docs/architecture-invariants.md#header-stats-styles)
|
||||
|
||||
|
||||
@@ -7014,9 +7014,6 @@ class CodemanApp {
|
||||
container.classList.remove('tabs-corner');
|
||||
this._decideTabOverflow(container);
|
||||
this._syncTabStripCorner(container);
|
||||
// Beside a camera housing (Codeman Desktop, host-cutout.js) the tabs go around it. Last, once the strip's
|
||||
// mode is decided: the gap depends on where the tabs ended up.
|
||||
window.CodemanHostCutout?.fitTabs?.(container);
|
||||
}
|
||||
|
||||
_decideTabOverflow(container) {
|
||||
@@ -7067,8 +7064,6 @@ class CodemanApp {
|
||||
|
||||
// Measure the natural one-row overflow, then enable wrapping only if needed.
|
||||
container.classList.remove('tabs-auto-wrap');
|
||||
// The gap at a camera housing is part of what one row has to hold.
|
||||
window.CodemanHostCutout?.fitTabs?.(container);
|
||||
const shouldWrap = window.CodemanTabOverflow?.shouldAutoWrapTabs
|
||||
? window.CodemanTabOverflow.shouldAutoWrapTabs({
|
||||
deviceType,
|
||||
|
||||
@@ -1,350 +0,0 @@
|
||||
/**
|
||||
* @fileoverview Keeps the header clear of a camera housing (the notch of a MacBook display).
|
||||
*
|
||||
* In a browser tab nothing is ever drawn behind the housing: macOS keeps windows, and its own full screen,
|
||||
* below it. Codeman Desktop can take the whole display (its View menu, and the switch in App Settings: "Full
|
||||
* Screen Uses the Area Beside the Camera"), and the page's top edge is then the display's, with the housing
|
||||
* covering a piece of the header row. A page has to keep its controls out from under it, so the app only puts
|
||||
* a page there after the page said it can: this module calls `CodemanHost.cutoutReady(true)`, and the app
|
||||
* answers with `CodemanHostCutout.apply({ left, width, height })`, the housing in CSS pixels from the
|
||||
* viewport's top-left corner, or `apply(null)` when there is none any more (full screen left, the window
|
||||
* moved to another display).
|
||||
*
|
||||
* Two things in the header's first row can reach the housing, and each is kept clear in its own way:
|
||||
*
|
||||
* - The tabs go AROUND it (`fitTabs`): the tab that would sit under the housing starts just right of it, by
|
||||
* way of a margin on the tab before it, so the row carries on to the toolbar. Nothing is added to the strip
|
||||
* and no tab changes place in it, so every reader of the strip (order, drag, keys) sees what it always saw.
|
||||
* - The toolbar normally ends well right of the housing and stays as it is. One that would reach it (many
|
||||
* readings, a width the user dragged, a solo window whose title shares the row) takes the box of styles.css
|
||||
* instead (`html.host-cutout-toolbar`): from just left of the housing to the header's right edge, its
|
||||
* content padded past the housing, so whatever is left of it ends before the housing (`fitToolbar`).
|
||||
*
|
||||
* Not every layout gains from that. With the tabs grouped by state, by case or as a ledger in the header
|
||||
* strip, the rows are laid out by rules of their own that a margin cannot open a gap in. For those the page
|
||||
* says `cutoutReady(false)` and stays below the housing; it says so again whenever the layout changes.
|
||||
*
|
||||
* The app also says what the option's switch shows, `CodemanHostCutout.option({ available, enabled })`, on
|
||||
* every page load and whenever it changes; App Settings reads it through `wholeScreen()` and turns it on or
|
||||
* off with `setWholeScreen(on)`. The setting is the app's own (its `desktop.json`), never the server's.
|
||||
*
|
||||
* A page without this module (an older Codeman server) never calls `cutoutReady`, and the app keeps it below
|
||||
* the housing with a black strip above it, the way macOS's full screen looks.
|
||||
*
|
||||
* @loadorder in <head>, before first paint and before every other module, so the app hears early and the page
|
||||
* is never painted in both places. Self-contained: `window.app` is used only if it already exists.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/** No housing is larger than this; a larger value is a mistake and must not empty the header. */
|
||||
const MAX_HEIGHT = 200;
|
||||
/** Room kept free on each side of the housing, in px. styles.css uses the same value (--host-cutout-gap). */
|
||||
const GAP = 8;
|
||||
/** A row of tabs is cleared in one pass; more than a few rows beside a housing is not a real header. */
|
||||
const MAX_PASSES = 8;
|
||||
|
||||
/** `cutout` as three finite numbers, or null when it is not a usable rectangle. */
|
||||
function normalize(cutout) {
|
||||
if (!cutout || typeof cutout !== 'object') return null;
|
||||
const left = Number(cutout.left);
|
||||
const width = Number(cutout.width);
|
||||
const height = Number(cutout.height);
|
||||
if (![left, width, height].every(Number.isFinite)) return null;
|
||||
if (left < 0 || width <= 0 || height <= 0 || height > MAX_HEIGHT) return null;
|
||||
return { left, width, height };
|
||||
}
|
||||
|
||||
/** The tab arrangements that lay out every row of the header strip themselves (app.js, Tab layouts). */
|
||||
const GROUPED = ['state', 'case', 'ledger'];
|
||||
|
||||
/**
|
||||
* A solo window (/session/:id, under any base path) has no tab strip. Its URL says so before the server's
|
||||
* own marker is parsed, which sits at the end of <head>.
|
||||
*/
|
||||
function isSolo() {
|
||||
return (
|
||||
/\/session\/[^/]+\/?$/.test(location.pathname) ||
|
||||
(typeof window.__CODEMAN_SOLO__ === 'string' && window.__CODEMAN_SOLO__ !== '')
|
||||
);
|
||||
}
|
||||
|
||||
/** Whether the header can be drawn beside the housing in the layout the page is in. */
|
||||
function fits() {
|
||||
const data = document.documentElement.dataset;
|
||||
const tabsInHeader = !isSolo() && data.sessionList !== 'sidebar' && data.tabOrientation !== 'vertical';
|
||||
return !(tabsInHeader && GROUPED.includes(data.tabArrangement));
|
||||
}
|
||||
|
||||
let current = null;
|
||||
/** What the app was told last, so it only hears of a change. */
|
||||
let announced = null;
|
||||
|
||||
/** Only a native wrapper has `cutoutReady`; a browser tab stays as it is. */
|
||||
function announce() {
|
||||
const ready = fits();
|
||||
if (ready === announced) return;
|
||||
announced = ready;
|
||||
// The app answers a yes with the housing; a no takes effect here at once.
|
||||
if (!ready) apply(null);
|
||||
try {
|
||||
if (typeof window.CodemanHost?.cutoutReady === 'function') window.CodemanHost.cutoutReady(ready);
|
||||
} catch {
|
||||
/* the wrapper went away: nothing to tell */
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- the tabs
|
||||
|
||||
/** The tabs whose margin `fitTabs` widened. Nothing else sets a margin on a tab's own style. */
|
||||
const moved = new Set();
|
||||
/** What the last pass did, so a caller can tell whether a tab moved. */
|
||||
let movedKey = '';
|
||||
|
||||
function clearGaps() {
|
||||
for (const tab of moved) {
|
||||
tab.style.removeProperty('margin-left');
|
||||
tab.style.removeProperty('margin-right');
|
||||
}
|
||||
moved.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves every tab out from under the housing. A tab that would overlap it (with `GAP` px of air on each
|
||||
* side) starts right of it instead. The room is given to the tab BEFORE it in the row, as its right margin:
|
||||
* a tab that no longer fits in the row after that wraps to the next one flush left, where a margin of its
|
||||
* own would indent it. Only the first tab of a row has no such neighbour and takes the room itself.
|
||||
*
|
||||
* Purely geometric (it reads rectangles, never the strip's mode), so it holds in the single row, the
|
||||
* wrapped strip and the L-shaped one, and does nothing where the tabs are nowhere near the housing (the
|
||||
* sidebar, the rail). Returns true when a tab moved since the last pass.
|
||||
*/
|
||||
function fitTabs(strip) {
|
||||
const host = strip || document.getElementById('sessionTabs');
|
||||
clearGaps();
|
||||
let key = '';
|
||||
if (current && host) {
|
||||
const left = current.left - GAP;
|
||||
const right = current.left + current.width + GAP;
|
||||
const tabs = host.querySelectorAll('.session-tab');
|
||||
for (let pass = 0; pass < MAX_PASSES; pass++) {
|
||||
// The rows that sit beside the housing, and the first tab in them that overlaps it.
|
||||
const beside = [];
|
||||
let hit = null;
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
const rect = tabs[i].getBoundingClientRect();
|
||||
if (rect.width <= 0 || rect.height <= 0) continue;
|
||||
if (rect.top >= current.height || rect.bottom <= 0) continue;
|
||||
const entry = { tab: tabs[i], rect, index: i };
|
||||
beside.push(entry);
|
||||
if (rect.right <= left || rect.left >= right) continue;
|
||||
if (!hit || rect.top < hit.rect.top - 1 || (rect.top <= hit.rect.top + 1 && rect.left < hit.rect.left)) {
|
||||
hit = entry;
|
||||
}
|
||||
}
|
||||
if (!hit) break;
|
||||
let before = null;
|
||||
for (const entry of beside) {
|
||||
if (entry === hit || entry.rect.right > hit.rect.left + 1) continue;
|
||||
if (entry.rect.bottom <= hit.rect.top + 2 || entry.rect.top >= hit.rect.bottom - 2) continue;
|
||||
if (!before || entry.rect.right > before.rect.right) before = entry;
|
||||
}
|
||||
const target = before || hit;
|
||||
const side = before ? 'margin-right' : 'margin-left';
|
||||
const base = parseFloat(getComputedStyle(target.tab).getPropertyValue(side)) || 0;
|
||||
const margin = Math.ceil(base + right - hit.rect.left);
|
||||
target.tab.style.setProperty(side, margin + 'px');
|
||||
moved.add(target.tab);
|
||||
key += target.index + side + margin + ';';
|
||||
}
|
||||
}
|
||||
const changed = key !== movedKey;
|
||||
movedKey = key;
|
||||
return changed;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- the toolbar
|
||||
|
||||
/** What the toolbar's box was decided on, so a pass with nothing new costs one string. */
|
||||
let toolbarKey = null;
|
||||
|
||||
/**
|
||||
* Decides whether the toolbar needs the box that covers the housing (`html.host-cutout-toolbar`,
|
||||
* styles.css). It is measured as it lies without that box, so the answer never depends on the answer before.
|
||||
* Returns true when it changed.
|
||||
*/
|
||||
function fitToolbar() {
|
||||
const root = document.documentElement;
|
||||
const had = root.classList.contains('host-cutout-toolbar');
|
||||
if (!current) {
|
||||
toolbarKey = null;
|
||||
root.classList.remove('host-cutout-toolbar');
|
||||
return had;
|
||||
}
|
||||
const toolbar = document.getElementById('headerRight');
|
||||
if (!toolbar) {
|
||||
// The header is not parsed yet: cover the housing until it can be measured.
|
||||
root.classList.add('host-cutout-toolbar');
|
||||
return !had;
|
||||
}
|
||||
let key = `${window.innerWidth}|${current.left}|${current.width}|${root.dataset.headerRightWidth ?? ''}|${isSolo()}`;
|
||||
for (const child of toolbar.children) key += '|' + child.offsetWidth;
|
||||
if (key === toolbarKey) return false;
|
||||
toolbarKey = key;
|
||||
root.classList.remove('host-cutout-toolbar');
|
||||
const box = toolbar.getBoundingClientRect();
|
||||
// A solo window's title shares the row and has nothing else to stop it at the housing.
|
||||
const needs = isSolo() || (box.width > 0 && box.left < current.left + current.width + GAP);
|
||||
root.classList.toggle('host-cutout-toolbar', needs);
|
||||
return needs !== had;
|
||||
}
|
||||
|
||||
/** The tab strip measures the toolbar (wrap, the L-shaped corner), and the lineage lines follow the tabs. */
|
||||
function relayout() {
|
||||
if (typeof window.app?.updateTabOverflowMode === 'function') window.app.updateTabOverflowMode();
|
||||
else fitTabs();
|
||||
window.app?.updateConnectionLines?.();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- keeping it current
|
||||
|
||||
let sizes = null;
|
||||
let children = null;
|
||||
let frame = 0;
|
||||
|
||||
/** A size changed with no render behind it (a tab selected, renamed or hovered, a reading arriving). */
|
||||
function schedule() {
|
||||
if (frame || !current) return;
|
||||
// Not in the observer's own callback: a tab that wraps makes the strip taller, and a size changed there
|
||||
// is reported as a ResizeObserver loop.
|
||||
frame = requestAnimationFrame(() => {
|
||||
frame = 0;
|
||||
if (!current) return;
|
||||
if (fitToolbar()) relayout();
|
||||
else if (fitTabs()) window.app?.updateConnectionLines?.();
|
||||
});
|
||||
}
|
||||
|
||||
function watch() {
|
||||
sizes?.disconnect();
|
||||
children?.disconnect();
|
||||
if (!current || typeof ResizeObserver !== 'function') return;
|
||||
const strip = document.getElementById('sessionTabs');
|
||||
const toolbar = document.getElementById('headerRight');
|
||||
if (!strip) return;
|
||||
sizes ??= new ResizeObserver(schedule);
|
||||
// Tabs come and go, and so do the toolbar's readings: watch the new ones too.
|
||||
children ??= new MutationObserver(() => {
|
||||
watch();
|
||||
schedule();
|
||||
});
|
||||
// The border box: a tab that only gains padding moves its neighbours just the same.
|
||||
const box = { box: 'border-box' };
|
||||
sizes.observe(strip, box);
|
||||
for (const tab of strip.querySelectorAll('.session-tab')) sizes.observe(tab, box);
|
||||
children.observe(strip, { childList: true });
|
||||
if (toolbar) {
|
||||
sizes.observe(toolbar, box);
|
||||
for (const child of toolbar.children) sizes.observe(child, box);
|
||||
children.observe(toolbar, { childList: true });
|
||||
}
|
||||
if (!strip.dataset.hostCutoutScroll) {
|
||||
// A strip past its max-height scrolls its rows up beside the housing.
|
||||
strip.dataset.hostCutoutScroll = '1';
|
||||
strip.addEventListener('scroll', schedule, { passive: true });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lay the header out around `cutout`, or (null, or anything that is not a rectangle) as if there were none.
|
||||
* Returns true, so a caller can tell that the page took it.
|
||||
*/
|
||||
function apply(cutout) {
|
||||
// An answer that crossed a layout change: the page already said no.
|
||||
const next = fits() ? normalize(cutout) : null;
|
||||
const same =
|
||||
(!next && !current) ||
|
||||
(!!next &&
|
||||
!!current &&
|
||||
next.left === current.left &&
|
||||
next.width === current.width &&
|
||||
next.height === current.height);
|
||||
if (same) return true;
|
||||
current = next;
|
||||
const root = document.documentElement;
|
||||
if (next) {
|
||||
root.style.setProperty('--host-cutout-left', next.left + 'px');
|
||||
root.style.setProperty('--host-cutout-width', next.width + 'px');
|
||||
root.style.setProperty('--host-cutout-height', next.height + 'px');
|
||||
root.classList.add('host-cutout');
|
||||
} else {
|
||||
root.classList.remove('host-cutout');
|
||||
root.style.removeProperty('--host-cutout-left');
|
||||
root.style.removeProperty('--host-cutout-width');
|
||||
root.style.removeProperty('--host-cutout-height');
|
||||
}
|
||||
toolbarKey = null;
|
||||
fitToolbar();
|
||||
watch();
|
||||
relayout();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- the option's switch
|
||||
|
||||
/** What the app said its option is: `{ available, enabled }`, or null outside the app. */
|
||||
let option = null;
|
||||
|
||||
/** Called by the app on every page load and whenever the option changes, from its menu or from a page. */
|
||||
function setOption(state) {
|
||||
option =
|
||||
state && typeof state === 'object'
|
||||
? { available: state.available === true, enabled: state.enabled === true }
|
||||
: null;
|
||||
window.app?.syncHostWholeScreenSetting?.();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Turns the option on or off in the app. False when there is no app to tell. */
|
||||
function setWholeScreen(on) {
|
||||
try {
|
||||
if (typeof window.CodemanHost?.setWholeScreen !== 'function') return false;
|
||||
return window.CodemanHost.setWholeScreen(on === true) !== false;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
window.CodemanHostCutout = {
|
||||
apply,
|
||||
normalize,
|
||||
fits,
|
||||
fitTabs,
|
||||
option: setOption,
|
||||
/** The app's option as it stands (`{ available, enabled }`), or null where there is none. */
|
||||
wholeScreen: () => option,
|
||||
setWholeScreen,
|
||||
/** The housing the header is laid out around right now, or null. */
|
||||
current: () => current,
|
||||
};
|
||||
|
||||
announce();
|
||||
// The layout is three attributes on <html>, written before first paint (index.html) and again whenever a
|
||||
// setting changes (app.js, settings-ui.js).
|
||||
if (typeof MutationObserver === 'function') {
|
||||
new MutationObserver(announce).observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ['data-tab-arrangement', 'data-session-list', 'data-tab-orientation'],
|
||||
});
|
||||
}
|
||||
// The app can answer before the header exists: measure it once it does.
|
||||
if (typeof document.addEventListener === 'function') {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
if (!current) return;
|
||||
toolbarKey = null;
|
||||
fitToolbar();
|
||||
watch();
|
||||
relayout();
|
||||
});
|
||||
}
|
||||
})();
|
||||
@@ -498,10 +498,6 @@
|
||||
'会话列表显示为顶栏横向标签条,或左侧可折叠侧边栏(Alt+B)。完整侧边栏为每个会话显示与主界面相同的详细信息。',
|
||||
'Tall Tabs (Name + Folder)': '双行标签(名称 + 文件夹)',
|
||||
'Pop-out Button on Tabs': '标签页弹出窗口按钮',
|
||||
'Mac App': 'Mac 应用',
|
||||
'Full Screen Uses the Area Beside the Camera': '全屏使用摄像头两侧的区域',
|
||||
'Full screen covers the whole display, and the tabs and toolbar sit beside the camera. Off uses the full screen of macOS, which leaves a black bar across the top.':
|
||||
'全屏覆盖整个显示屏,标签页和工具栏位于摄像头两侧。关闭后使用 macOS 自带的全屏,顶部会留下一条黑边。',
|
||||
'New Session Button on Tabs': '标签页新建会话按钮',
|
||||
'A + on the tab that starts a session in the same case and group, in any installed CLI.':
|
||||
'标签页上的 + 按钮,可在同一案例和分组中,用任一已安装的 CLI 启动新会话。',
|
||||
|
||||
@@ -67,11 +67,6 @@
|
||||
here and boot will contradict this value, animating the drawer open by
|
||||
itself on every load between 768 and 1023px. -->
|
||||
<script>try{var m=window.innerWidth<768||(('ontouchstart' in window||navigator.maxTouchPoints>0)&&window.innerWidth<1024);var k=m?'codeman-app-settings-mobile':'codeman-app-settings';var A=JSON.parse(localStorage.getItem(k)||'{}');var L=A.sessionListLayout;var F=Number(A.sessionSidebarFontSize);var solo=/^\/session\//.test(location.pathname);var C=localStorage.getItem('codeman-sidebar-collapsed');var S=(L==='sidebar'||L==='sidebar-rich')&&!solo;document.documentElement.dataset.sessionList=S?'sidebar':'header';document.documentElement.dataset.sidebarDetail=(S&&L==='sidebar-rich')?'rich':'simple';document.documentElement.dataset.sidebar=(C===null?window.innerWidth<1024:C==='1')?'collapsed':'expanded';var V=A.tabOrientation==='vertical'&&!S&&!solo&&window.innerWidth>=768;document.documentElement.dataset.tabOrientation=V?'vertical':'horizontal';document.documentElement.dataset.tabRailDetail=(A.tabRailDetail==='simple')?'simple':'rich';document.documentElement.dataset.tabRailSort=(A.tabRailSort==='manual')?'manual':'activity';var T=A.tabArrangement;document.documentElement.dataset.tabArrangement=(T==='state'||T==='case'||T==='ledger')?T:'classic';document.documentElement.dataset.tabStateOrder=(A.tabStateOrder==='urgent-last')?'urgent-last':'urgent-first';document.documentElement.dataset.tabLogos=(A.showTabCliLogos===false)?'off':'on';var H=A.headerStatsStyle;document.documentElement.dataset.headerStats=(window.innerWidth<768||solo)?'classic':(H==='classic'||H==='tiles')?H:'compact';var W=Number(A.tabRailWidth);if(V){if(Number.isInteger(W)&&W>=208&&W<=360)document.documentElement.style.setProperty('--tab-rail-width',W+'px');else if(document.documentElement.dataset.tabRailDetail!=='simple')document.documentElement.style.setProperty('--tab-rail-width','320px');}if(Number.isInteger(F)&&F>=11&&F<=18)document.documentElement.style.setProperty('--session-sidebar-name-font-size',F+'px');}catch(e){document.documentElement.dataset.sessionList='header';document.documentElement.dataset.sidebarDetail='simple';document.documentElement.dataset.sidebar='expanded';document.documentElement.dataset.tabOrientation='horizontal';document.documentElement.dataset.tabRailDetail='rich';document.documentElement.dataset.tabRailSort='activity';document.documentElement.dataset.tabArrangement='classic';document.documentElement.dataset.tabStateOrder='urgent-first';document.documentElement.dataset.headerStats='classic';document.documentElement.dataset.tabLogos='on';}</script>
|
||||
<!-- Camera housing (the notch of a MacBook display): only Codeman Desktop ever draws
|
||||
the page behind it, and only once the page said it keeps its header clear. Not
|
||||
deferred, so the app hears before first paint and the page is never painted
|
||||
below the housing first and behind it a moment later. See host-cutout.js. -->
|
||||
<script src="host-cutout.js"></script>
|
||||
<!-- Inline critical CSS for instant skeleton paint (before styles.css loads) -->
|
||||
<style>
|
||||
.loading-skeleton{display:flex;flex-direction:column;height:100vh;height:100dvh;background:var(--bg-dark,#11151c)}
|
||||
@@ -2605,21 +2600,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Codeman Desktop's own option (host-cutout.js). Shown by settings-ui.js only inside the
|
||||
Mac app on a MacBook whose display has a camera housing; the value lives in the app. -->
|
||||
<div class="set-group" id="appSettingsHostGroup" style="display: none">
|
||||
<div class="set-group-head"><h4>Mac App</h4><span class="set-scope">device</span></div>
|
||||
<div class="set-group-body">
|
||||
<div class="set-row" data-search="full screen fullscreen camera notch housing whole display black bar mac app macbook">
|
||||
<div class="set-row-text">
|
||||
<span class="set-row-label">Full Screen Uses the Area Beside the Camera</span>
|
||||
<span class="set-row-desc">Full screen covers the whole display, and the tabs and toolbar sit beside the camera. Off uses the full screen of macOS, which leaves a black bar across the top.</span>
|
||||
</div>
|
||||
<label class="switch switch-sm"><input type="checkbox" id="appSettingsHostWholeScreen"><span class="slider"></span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ══ Animations ═══════════════════════════════════════════════
|
||||
|
||||
@@ -600,7 +600,6 @@ Object.assign(CodemanApp.prototype, {
|
||||
document.getElementById('appSettingsMobileOverview').checked = settings.mobileOverviewEnabled ?? defaults.mobileOverviewEnabled ?? false;
|
||||
const mobileOverviewItem = document.getElementById('appSettingsMobileOverviewItem');
|
||||
if (mobileOverviewItem) mobileOverviewItem.style.display = MobileDetection.getDeviceType() === 'mobile' ? '' : 'none';
|
||||
this.syncHostWholeScreenSetting();
|
||||
// Session Manager, Away Digest and Cron buttons all default OFF (opt-in under
|
||||
// Display → Header Displays; the Cron button also ships with btn-cron--hidden
|
||||
// in the template, so an unchecked box and a hidden button stay consistent).
|
||||
@@ -3102,30 +3101,9 @@ Object.assign(CodemanApp.prototype, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Codeman Desktop's own option (host-cutout.js): full screen over the whole display of a MacBook whose
|
||||
* display has a camera housing. The group shows only where the app says this Mac has such a display, and
|
||||
* the value is the app's: read from it here, written to it by saveAppSettings, never part of the settings
|
||||
* blob or of what the server stores. The app calls this again whenever the option changes (its View menu).
|
||||
*/
|
||||
syncHostWholeScreenSetting() {
|
||||
const group = document.getElementById('appSettingsHostGroup');
|
||||
const box = document.getElementById('appSettingsHostWholeScreen');
|
||||
if (!group || !box) return;
|
||||
const option = window.CodemanHostCutout?.wholeScreen?.() ?? null;
|
||||
group.style.display = option?.available ? '' : 'none';
|
||||
box.checked = option?.enabled === true;
|
||||
},
|
||||
|
||||
async saveAppSettings() {
|
||||
const keepOpen = this._keepSettingsOpenOnce === true;
|
||||
this._keepSettingsOpenOnce = false;
|
||||
// The Mac app's own option goes to the app, whatever becomes of the rest of this save.
|
||||
const hostOption = window.CodemanHostCutout?.wholeScreen?.() ?? null;
|
||||
const hostBox = document.getElementById('appSettingsHostWholeScreen');
|
||||
if (hostOption?.available && hostBox && hostBox.checked !== hostOption.enabled) {
|
||||
window.CodemanHostCutout.setWholeScreen(hostBox.checked);
|
||||
}
|
||||
// Gesture overlay is injected at page render (server-side), so a change to it
|
||||
// only takes effect on reload — remember the prior value to decide below.
|
||||
const _prev = this.loadAppSettingsFromStorage();
|
||||
|
||||
@@ -2321,13 +2321,9 @@ html[data-tab-orientation='vertical'].tab-rail-compact
|
||||
/* Everything below applies only where the tabs share the header with the toolbar, i.e. where the handle is
|
||||
visible to undo it: not in the sidebar layout, the vertical rail or a solo window, and not on a phone. */
|
||||
|
||||
/* A width the user chose: the toolbar keeps it and wraps onto a second line when its content is wider.
|
||||
Not while the toolbar is laid out around a camera housing (html.host-cutout, further down), which decides
|
||||
where it starts. */
|
||||
/* A width the user chose: the toolbar keeps it and wraps onto a second line when its content is wider. */
|
||||
@media (min-width: 769px) {
|
||||
html[data-header-right-width]:not(.host-cutout-toolbar):not([data-tab-orientation='vertical']):not(
|
||||
[data-session-list='sidebar']
|
||||
)
|
||||
html[data-header-right-width]:not([data-tab-orientation='vertical']):not([data-session-list='sidebar'])
|
||||
body:not(.solo-mode)
|
||||
.header-right {
|
||||
flex: 0 0 var(--header-right-width);
|
||||
@@ -2417,43 +2413,6 @@ body.solo-mode .header-divider {
|
||||
}
|
||||
}
|
||||
|
||||
/* A camera housing over the header row (host-cutout.js). Codeman Desktop can take a MacBook's whole display,
|
||||
and the page's top edge is then the display's, with the housing (the notch) covering a piece of this row.
|
||||
The app says where it is: --host-cutout-left, -width and -height, in pixels from the viewport's top-left
|
||||
corner. The tabs go around it by a margin the module sets (`fitTabs`), which needs no rule here.
|
||||
|
||||
This rule is for a toolbar that would reach the housing (`html.host-cutout-toolbar`, decided by the module's
|
||||
`fitToolbar`: many readings, a width the user dragged, a solo window's title in the same row). Its box then
|
||||
starts just left of the housing and runs to the header's right edge (0.75rem is the header's own padding),
|
||||
and its padding puts the first control just right of the housing. That one box keeps the row clear: the
|
||||
tabs, or a solo window's title, end where it begins, and the L-shaped strip sizes its corner from it
|
||||
(`_syncTabStripCorner()`). A toolbar wider than the room beside the housing wraps onto a second line, below
|
||||
it. --host-cutout-gap is the module's GAP: change the two together. */
|
||||
@media (min-width: 769px) {
|
||||
html.host-cutout {
|
||||
--host-cutout-gap: 8px;
|
||||
}
|
||||
|
||||
html.host-cutout-toolbar .header > .header-right {
|
||||
box-sizing: border-box;
|
||||
flex: 0 0 auto;
|
||||
width: calc(100vw - 0.75rem - var(--host-cutout-left) + var(--host-cutout-gap));
|
||||
padding-left: calc(var(--host-cutout-width) + 2 * var(--host-cutout-gap));
|
||||
/* The divider line would sit against the housing. */
|
||||
border-left-color: transparent;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
align-content: center;
|
||||
row-gap: 0.25rem;
|
||||
min-height: var(--header-height);
|
||||
}
|
||||
|
||||
/* The box's left edge is the housing's, not a width to drag. */
|
||||
html.host-cutout-toolbar .header-divider {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* The opt-in host readings (GPU, VRAM, MHz) start hidden and are shown by panels-ui.js once the host
|
||||
reports them; a plain `display` on .stat-item would override the attribute, and the Tiles style sets its own
|
||||
(a grid) at a higher specificity, so the selector carries the style attribute to outrank it. */
|
||||
@@ -23656,7 +23615,13 @@ html[data-session-list='sidebar'][data-sidebar='collapsed'] .session-sidebar .ta
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.session-tabs-host > .session-tabs.tabs-ledger > .session-tab .tab-status {
|
||||
/* The bar replaces the dot, except on a WORKING cell: the bar is green for
|
||||
idle and working alike, so the dot and its orbiting ring
|
||||
(.tab-status.busy::after) stay, the same "working" mark the classic strip
|
||||
and the home screens draw. An exited agent's cell hides it anyway, as the
|
||||
classic strip hides the ring there. */
|
||||
.session-tabs-host > .session-tabs.tabs-ledger > .session-tab .tab-status:not(.busy),
|
||||
.session-tabs-host > .session-tabs.tabs-ledger > .session-tab.tab-agent-exited .tab-status {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,348 +0,0 @@
|
||||
/**
|
||||
* @fileoverview Real-Chromium coverage for the header beside a camera housing (host-cutout.js and the
|
||||
* `html.host-cutout-toolbar` rules in styles.css).
|
||||
*
|
||||
* Codeman Desktop can draw the page behind the notch of a MacBook display, and whatever the header puts there
|
||||
* cannot be seen or clicked. What only a real layout engine answers: that no tab, button or reading ends up
|
||||
* behind the housing, in a single row, in a wrapped (L-shaped) strip and with a toolbar too wide for the room
|
||||
* beside it; that the tabs carry on right of the housing where there is room; that a tab changing size with
|
||||
* no render behind it is followed; and that taking the housing away puts the header back exactly. The real
|
||||
* `<header>` from index.html, the shipping styles.css, constants.js, app.js and host-cutout.js are loaded
|
||||
* into a page.
|
||||
*
|
||||
* Port: none (page.route on a fake origin, no server).
|
||||
*/
|
||||
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
import { chromium, type Browser, type Page } from 'playwright';
|
||||
|
||||
const dir = resolve(import.meta.dirname, '../src/web/public');
|
||||
const read = (name: string) => readFileSync(resolve(dir, name), 'utf8');
|
||||
const styles = read('styles.css');
|
||||
const header = /<header class="header">[\s\S]*?<\/header>/.exec(read('index.html'))![0];
|
||||
const ORIGIN = 'http://app.test/';
|
||||
|
||||
type Rect = { left: number; right: number; top: number; bottom: number };
|
||||
type Cutout = { left: number; width: number; height: number };
|
||||
|
||||
/** MacBook displays in whole-screen mode: viewport and housing, in points. */
|
||||
const DISPLAYS: Array<{ name: string; width: number; height: number; cutout: Cutout }> = [
|
||||
// Measured on a MacBook Pro (Mac17,13, macOS 27.2): a narrow housing in a taller strip.
|
||||
{ name: 'narrow housing, default', width: 1512, height: 993, cutout: { left: 726.5, width: 59, height: 40 } },
|
||||
{ name: '14-inch, default', width: 1512, height: 982, cutout: { left: 663.5, width: 185, height: 32 } },
|
||||
{ name: '16-inch, default', width: 1728, height: 1117, cutout: { left: 771.5, width: 185, height: 32 } },
|
||||
{ name: '14-inch, more space', width: 1800, height: 1169, cutout: { left: 790, width: 220, height: 38 } },
|
||||
{ name: '14-inch, larger text', width: 1147, height: 745, cutout: { left: 503.5, width: 140, height: 24 } },
|
||||
];
|
||||
const NARROW = DISPLAYS[0];
|
||||
const MBP14 = DISPLAYS[1];
|
||||
|
||||
describe('header beside a camera housing (real Chromium)', () => {
|
||||
let browser: Browser;
|
||||
let p: Page;
|
||||
beforeAll(async () => {
|
||||
browser = await chromium.launch();
|
||||
});
|
||||
afterAll(async () => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
/** Open the real header at a display's size with `tabs` classic tabs. */
|
||||
async function open(options: { tabs: number; width: number; height: number; attrs?: string }) {
|
||||
p = await browser.newPage({
|
||||
viewport: { width: options.width, height: options.height },
|
||||
deviceScaleFactor: 1,
|
||||
});
|
||||
await p.route(ORIGIN, (route) =>
|
||||
route.fulfill({
|
||||
contentType: 'text/html',
|
||||
body:
|
||||
'<!doctype html><html data-header-stats="compact" data-tab-orientation="horizontal" ' +
|
||||
`data-session-list="header" data-tab-arrangement="classic" ${options.attrs ?? ''}>` +
|
||||
`<head><style>${styles}</style></head><body>${header}</body></html>`,
|
||||
})
|
||||
);
|
||||
await p.goto(ORIGIN);
|
||||
await p.addScriptTag({
|
||||
content:
|
||||
'var MobileDetection = { isTouchDevice: () => false, getDeviceType: () => "desktop" }, KeyboardHandler = {}, ' +
|
||||
'SwipeHandler = {}, VoiceInput = {}, DeepgramProvider = {}, NotificationManager = function(){};\n' +
|
||||
read('constants.js') +
|
||||
'\n' +
|
||||
read('app.js') +
|
||||
'\nwindow.CodemanApp = CodemanApp;',
|
||||
});
|
||||
await p.evaluate(
|
||||
({ tabs }) => {
|
||||
const w = window as any;
|
||||
const app = Object.create(w.CodemanApp.prototype);
|
||||
app.$ = (id: string) => document.getElementById(id);
|
||||
app.sessions = new Map();
|
||||
app.loadAppSettingsFromStorage = () => ({});
|
||||
app.getDefaultSettings = () => ({});
|
||||
app.isSessionSidebarActive = () => false;
|
||||
app.updateConnectionLines = () => undefined;
|
||||
const strip = document.getElementById('sessionTabs')!;
|
||||
for (let i = 1; i <= tabs; i++) {
|
||||
const id = `s${i}`;
|
||||
app.sessions.set(id, { id, name: `session-${i}` });
|
||||
strip.insertAdjacentHTML(
|
||||
'beforeend',
|
||||
`<div class="session-tab" data-id="${id}" role="tab"><span class="tab-name">session-${i}</span></div>`
|
||||
);
|
||||
}
|
||||
// The module asks `window.app` to measure the toolbar again, as the page does.
|
||||
w.app = app;
|
||||
},
|
||||
{ tabs: options.tabs }
|
||||
);
|
||||
await p.addScriptTag({ content: read('host-cutout.js') });
|
||||
await relayout();
|
||||
}
|
||||
|
||||
const settled = () => p.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
|
||||
const relayout = async () => {
|
||||
await p.evaluate(() => (window as any).app.updateTabOverflowMode());
|
||||
await settled();
|
||||
};
|
||||
const apply = async (cutout: Cutout | null) => {
|
||||
expect(await p.evaluate((c) => (window as any).CodemanHostCutout.apply(c), cutout)).toBe(true);
|
||||
await settled();
|
||||
};
|
||||
const toolbar = () =>
|
||||
p.evaluate(() => document.getElementById('headerRight')!.getBoundingClientRect().toJSON()) as Promise<Rect>;
|
||||
const cornered = () => p.evaluate(() => document.getElementById('sessionTabs')!.classList.contains('tabs-corner'));
|
||||
/** Whether the toolbar has the box that covers the housing. */
|
||||
const boxed = () => p.evaluate(() => document.documentElement.classList.contains('host-cutout-toolbar'));
|
||||
/** Tabs that carry a margin of the module's. */
|
||||
const moved = () =>
|
||||
p.evaluate(() => document.querySelectorAll('#sessionTabs > .session-tab[style*="margin"]').length);
|
||||
const tabRects = async () => (await painted()).filter((r) => r.what.startsWith('tab '));
|
||||
|
||||
/** Everything the header row paints: tabs, the brand, the toolbar's controls. */
|
||||
const painted = () =>
|
||||
p.evaluate(() => {
|
||||
const strip = document.getElementById('sessionTabs')!.getBoundingClientRect();
|
||||
const shown = (el: Element) => {
|
||||
const s = getComputedStyle(el);
|
||||
const r = el.getBoundingClientRect();
|
||||
return s.display !== 'none' && s.visibility !== 'hidden' && r.width > 0 && r.height > 0;
|
||||
};
|
||||
const out: Array<{ what: string; left: number; right: number; top: number; bottom: number }> = [];
|
||||
for (const el of document.querySelectorAll('#sessionTabs > .session-tab')) {
|
||||
const r = el.getBoundingClientRect();
|
||||
// The strip clips what it scrolls or overflows.
|
||||
const box = {
|
||||
left: Math.max(r.left, strip.left),
|
||||
right: Math.min(r.right, strip.right),
|
||||
top: Math.max(r.top, strip.top),
|
||||
bottom: Math.min(r.bottom, strip.bottom),
|
||||
};
|
||||
if (box.right > box.left && box.bottom > box.top)
|
||||
out.push({ what: 'tab ' + el.getAttribute('data-id'), ...box });
|
||||
}
|
||||
for (const el of document.querySelectorAll('#headerRight > *, .header-brand .logo')) {
|
||||
if (!shown(el) || el.classList.contains('header-divider')) continue;
|
||||
const r = el.getBoundingClientRect();
|
||||
out.push({
|
||||
what: el.id || el.className.toString().slice(0, 40),
|
||||
left: r.left,
|
||||
right: r.right,
|
||||
top: r.top,
|
||||
bottom: r.bottom,
|
||||
});
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
/** What is painted behind the housing, or closer to it than `margin` px. */
|
||||
const behind = async (cutout: Cutout, margin = 4) =>
|
||||
(await painted()).filter(
|
||||
(r) => r.top < cutout.height && r.right > cutout.left - margin && r.left < cutout.left + cutout.width + margin
|
||||
);
|
||||
|
||||
for (const display of DISPLAYS) {
|
||||
const right = display.cutout.left + display.cutout.width;
|
||||
|
||||
it(`leaves a short row of tabs and the toolbar as they are (${display.name})`, async () => {
|
||||
await open({ tabs: 3, width: display.width, height: display.height });
|
||||
const before = { toolbar: await toolbar(), painted: await painted() };
|
||||
await apply(display.cutout);
|
||||
// Three tabs end long before the housing and the toolbar begins long after it: nothing has to move.
|
||||
expect(await behind(display.cutout)).toEqual([]);
|
||||
expect(await boxed()).toBe(false);
|
||||
expect(await moved()).toBe(0);
|
||||
expect(await toolbar()).toEqual(before.toolbar);
|
||||
expect(await painted()).toEqual(before.painted);
|
||||
await p.close();
|
||||
});
|
||||
|
||||
it(`carries the first row of a wrapped strip on past the housing (${display.name})`, async () => {
|
||||
await open({ tabs: 34, width: display.width, height: display.height });
|
||||
const natural = await toolbar();
|
||||
await apply(display.cutout);
|
||||
expect(await cornered()).toBe(true);
|
||||
expect(await behind(display.cutout)).toEqual([]);
|
||||
// The toolbar keeps its own box, and the tabs fill the row up to it on both sides of the housing.
|
||||
expect(await boxed()).toBe(false);
|
||||
expect(await toolbar()).toEqual(natural);
|
||||
const tabs = await tabRects();
|
||||
const first = tabs.filter((t) => t.top < display.cutout.height);
|
||||
expect(first.some((t) => t.right <= display.cutout.left)).toBe(true);
|
||||
expect(first.some((t) => t.left >= right)).toBe(true);
|
||||
// The first tab right of the housing starts where its 8 px of air end, not somewhere further on.
|
||||
const next = Math.min(...first.filter((t) => t.left >= right).map((t) => t.left));
|
||||
expect(next).toBeGreaterThanOrEqual(right + 8);
|
||||
expect(next).toBeLessThan(right + 10);
|
||||
// Rows below the housing are not touched: some tab there lies in the housing's column.
|
||||
const below = tabs.filter((t) => t.top >= display.cutout.height);
|
||||
expect(below.some((t) => t.left < right && t.right > display.cutout.left)).toBe(true);
|
||||
// One tab per row beside the housing gave up its margin for the gap, and no tab was added to the strip.
|
||||
const rows = new Set(first.map((t) => Math.round(t.top))).size;
|
||||
expect(await moved()).toBe(rows);
|
||||
expect(await p.evaluate(() => document.getElementById('sessionTabs')!.children.length)).toBe(34);
|
||||
await p.close();
|
||||
});
|
||||
}
|
||||
|
||||
it('keeps a strip that is too tall for the corner clear of the housing too', async () => {
|
||||
// Past its max-height the strip scrolls and keeps the plain wrap (_syncTabStripCorner).
|
||||
const display = DISPLAYS[4];
|
||||
await open({ tabs: 140, width: display.width, height: display.height });
|
||||
await apply(display.cutout);
|
||||
expect(await cornered()).toBe(false);
|
||||
expect(await behind(display.cutout)).toEqual([]);
|
||||
// Scrolled, the rows that come up beside the housing are cleared as well.
|
||||
await p.evaluate(() => (document.getElementById('sessionTabs')!.scrollTop = 40));
|
||||
await settled();
|
||||
expect(await behind(display.cutout)).toEqual([]);
|
||||
await p.close();
|
||||
});
|
||||
|
||||
it('follows a tab that grows with no render behind it (a selection shows its gear and close)', async () => {
|
||||
await open({ tabs: 34, width: NARROW.width, height: NARROW.height });
|
||||
await apply(NARROW.cutout);
|
||||
// The last tab left of the housing gets wider, as a selected one does, and nothing calls the strip.
|
||||
await p.evaluate((left) => {
|
||||
const tabs = [...document.querySelectorAll<HTMLElement>('#sessionTabs > .session-tab')];
|
||||
const row = tabs.filter((t) => t.getBoundingClientRect().top < 40 && t.getBoundingClientRect().right <= left);
|
||||
row[row.length - 1].style.paddingRight = '90px';
|
||||
}, NARROW.cutout.left);
|
||||
await settled();
|
||||
await settled();
|
||||
expect(await behind(NARROW.cutout)).toEqual([]);
|
||||
await p.close();
|
||||
});
|
||||
|
||||
it('follows a tab that is added with no render behind it', async () => {
|
||||
await open({ tabs: 34, width: NARROW.width, height: NARROW.height });
|
||||
await apply(NARROW.cutout);
|
||||
await p.evaluate(() => {
|
||||
document
|
||||
.getElementById('sessionTabs')!
|
||||
.insertAdjacentHTML(
|
||||
'afterbegin',
|
||||
'<div class="session-tab" data-id="new" role="tab"><span class="tab-name">a-new-session</span></div>'
|
||||
);
|
||||
});
|
||||
await settled();
|
||||
await settled();
|
||||
expect(await behind(NARROW.cutout)).toEqual([]);
|
||||
await p.close();
|
||||
});
|
||||
|
||||
it('gives a toolbar that would reach the housing the box that covers it, wrapped below the housing', async () => {
|
||||
await open({ tabs: 3, width: MBP14.width, height: MBP14.height });
|
||||
// A toolbar full of readings: wider than the 660 px right of the housing.
|
||||
await p.evaluate(() => {
|
||||
const right = document.getElementById('headerRight')!;
|
||||
for (let i = 0; i < 9; i++) {
|
||||
const reading = document.createElement('div');
|
||||
reading.className = 'test-reading';
|
||||
reading.style.cssText = 'flex:0 0 auto;width:110px;height:24px;background:#345';
|
||||
right.appendChild(reading);
|
||||
}
|
||||
});
|
||||
await relayout();
|
||||
const before = await toolbar();
|
||||
await apply(MBP14.cutout);
|
||||
expect(await boxed()).toBe(true);
|
||||
const after = await toolbar();
|
||||
// Its box starts just left of the housing and still ends where the header's padding begins.
|
||||
expect(after.left).toBeLessThanOrEqual(MBP14.cutout.left);
|
||||
expect(after.left).toBeGreaterThan(MBP14.cutout.left - 16);
|
||||
expect(Math.round(MBP14.width - after.right)).toBe(12);
|
||||
expect(after.bottom - after.top).toBeGreaterThan(before.bottom - before.top + 16);
|
||||
expect(await behind(MBP14.cutout)).toEqual([]);
|
||||
// Nothing is cut off either: every control is inside the viewport.
|
||||
for (const r of await painted()) expect(r.left, r.what).toBeGreaterThanOrEqual(0);
|
||||
// Readings that go away give the toolbar its own box back.
|
||||
await p.evaluate(() => document.querySelectorAll('.test-reading').forEach((el) => el.remove()));
|
||||
await settled();
|
||||
await settled();
|
||||
expect(await boxed()).toBe(false);
|
||||
expect(await behind(MBP14.cutout)).toEqual([]);
|
||||
await p.close();
|
||||
});
|
||||
|
||||
it('puts the header back exactly when the housing is gone', async () => {
|
||||
await open({ tabs: 40, width: MBP14.width, height: MBP14.height });
|
||||
const before = { toolbar: await toolbar(), painted: await painted() };
|
||||
await apply(MBP14.cutout);
|
||||
expect(await painted()).not.toEqual(before.painted);
|
||||
await apply(null);
|
||||
expect(await toolbar()).toEqual(before.toolbar);
|
||||
expect(await painted()).toEqual(before.painted);
|
||||
expect(await moved()).toBe(0);
|
||||
expect(await p.evaluate(() => document.documentElement.getAttribute('style') || '')).not.toContain('host-cutout');
|
||||
expect(await p.evaluate(() => document.documentElement.className)).not.toContain('host-cutout');
|
||||
await p.close();
|
||||
});
|
||||
|
||||
it('keeps a toolbar width the user chose while it ends right of the housing', async () => {
|
||||
await open({
|
||||
tabs: 3,
|
||||
width: MBP14.width,
|
||||
height: MBP14.height,
|
||||
attrs: 'data-header-right-width="set" style="--header-right-width: 300px"',
|
||||
});
|
||||
const chosen = await toolbar();
|
||||
expect(Math.round(chosen.right - chosen.left)).toBe(300);
|
||||
await apply(MBP14.cutout);
|
||||
expect(await boxed()).toBe(false);
|
||||
expect(await toolbar()).toEqual(chosen);
|
||||
expect(await behind(MBP14.cutout)).toEqual([]);
|
||||
await p.close();
|
||||
});
|
||||
|
||||
it('sets a chosen toolbar width aside while it would reach the housing', async () => {
|
||||
await open({
|
||||
tabs: 3,
|
||||
width: MBP14.width,
|
||||
height: MBP14.height,
|
||||
attrs: 'data-header-right-width="set" style="--header-right-width: 800px"',
|
||||
});
|
||||
const chosen = await toolbar();
|
||||
expect(Math.round(chosen.right - chosen.left)).toBe(800);
|
||||
await apply(MBP14.cutout);
|
||||
// 800 px begins the toolbar's box at 700, under the housing: it takes the box that covers the housing.
|
||||
expect(await boxed()).toBe(true);
|
||||
expect((await toolbar()).left).toBeLessThanOrEqual(MBP14.cutout.left);
|
||||
expect(await behind(MBP14.cutout)).toEqual([]);
|
||||
await apply(null);
|
||||
expect(await toolbar()).toEqual(chosen);
|
||||
await p.close();
|
||||
});
|
||||
|
||||
it('leaves the toolbar alone where the header has no tabs (sidebar, rail)', async () => {
|
||||
await open({ tabs: 0, width: MBP14.width, height: MBP14.height });
|
||||
const natural = await toolbar();
|
||||
await apply(MBP14.cutout);
|
||||
expect(await behind(MBP14.cutout)).toEqual([]);
|
||||
expect(await boxed()).toBe(false);
|
||||
expect(await toolbar()).toEqual(natural);
|
||||
await p.close();
|
||||
});
|
||||
});
|
||||
@@ -1,604 +0,0 @@
|
||||
/**
|
||||
* @fileoverview The camera housing module (host-cutout.js): what counts as a housing, when the page tells a
|
||||
* native wrapper that it may be drawn behind one, what `apply` writes, how the tabs are moved around the
|
||||
* housing and when the toolbar takes the box that covers it, the option's switch, and that the page, the
|
||||
* build and the stylesheet carry it. The tabs here are a row model (widths, margins, a wrap width); the
|
||||
* layout itself is measured in real Chromium (host-cutout.browser.test.ts).
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import vm from 'node:vm';
|
||||
|
||||
const publicDir = resolve(import.meta.dirname, '../src/web/public');
|
||||
const read = (name: string) => readFileSync(resolve(publicDir, name), 'utf8');
|
||||
const buildJs = readFileSync(resolve(import.meta.dirname, '../scripts/build.mjs'), 'utf8');
|
||||
const shim = readFileSync(resolve(import.meta.dirname, '../packages/desktop/src/assets.rs'), 'utf8');
|
||||
|
||||
type Cutout = { left: number; width: number; height: number };
|
||||
type Api = {
|
||||
apply: (cutout: unknown) => boolean;
|
||||
normalize: (cutout: unknown) => Cutout | null;
|
||||
fits: () => boolean;
|
||||
fitTabs: () => boolean;
|
||||
option: (state: unknown) => boolean;
|
||||
wholeScreen: () => { available: boolean; enabled: boolean } | null;
|
||||
setWholeScreen: (on: unknown) => boolean;
|
||||
current: () => Cutout | null;
|
||||
};
|
||||
|
||||
/** The MacBook Pro the layout was first seen on (Mac17,13): a housing 59 px wide in a strip 40 px high. */
|
||||
const NARROW: Cutout = { left: 726.5, width: 59, height: 40 };
|
||||
|
||||
type Rect = { left: number; right: number; top: number; bottom: number; width: number; height: number };
|
||||
|
||||
/** A 14-inch MacBook Pro at its default scaling. */
|
||||
const MBP14: Cutout = { left: 663.5, width: 185, height: 32 };
|
||||
|
||||
/**
|
||||
* Run the module in a page that has `dataset` on <html> and, with `host`, the bridge Codeman Desktop injects.
|
||||
* `tabs` are widths: they are laid out the way the strip lays them out, left to right from `stripLeft`, 2 px
|
||||
* apart, wrapping to a new row (36 px lower) before `rowRight`, and a margin the module sets moves them like a
|
||||
* real one. `toolbarLeft` is where the toolbar's own box begins (null: the header is not parsed yet).
|
||||
* Returns the module, what it told the bridge, the root's style and classes, and how to change the layout.
|
||||
*/
|
||||
function load(
|
||||
options: {
|
||||
dataset?: Record<string, string>;
|
||||
host?: boolean;
|
||||
pathname?: string;
|
||||
solo?: string;
|
||||
tabs?: number[];
|
||||
stripLeft?: number;
|
||||
rowRight?: number;
|
||||
toolbarLeft?: number | null;
|
||||
} = {}
|
||||
) {
|
||||
const calls: unknown[] = [];
|
||||
const switched: unknown[] = [];
|
||||
const relayouts: string[] = [];
|
||||
const props = new Map<string, string>();
|
||||
const classes = new Set<string>();
|
||||
const dataset: Record<string, string> = {
|
||||
sessionList: 'header',
|
||||
tabOrientation: 'horizontal',
|
||||
tabArrangement: 'classic',
|
||||
...options.dataset,
|
||||
};
|
||||
let observer: (() => void) | null = null;
|
||||
let ready: (() => void) | null = null;
|
||||
const documentElement = {
|
||||
dataset,
|
||||
style: {
|
||||
setProperty: (name: string, value: string) => props.set(name, value),
|
||||
removeProperty: (name: string) => props.delete(name),
|
||||
},
|
||||
classList: {
|
||||
add: (name: string) => classes.add(name),
|
||||
remove: (name: string) => classes.delete(name),
|
||||
contains: (name: string) => classes.has(name),
|
||||
toggle: (name: string, on: boolean) => (on ? classes.add(name) : classes.delete(name)),
|
||||
},
|
||||
};
|
||||
|
||||
const stripLeft = options.stripLeft ?? 100;
|
||||
const rowRight = options.rowRight ?? 1123;
|
||||
const px = (value: string | undefined, fallback: number) => (value === undefined ? fallback : parseFloat(value));
|
||||
const tabs = (options.tabs ?? []).map((width, index) => ({
|
||||
index,
|
||||
width,
|
||||
margins: new Map<string, string>(),
|
||||
rect: null as Rect | null,
|
||||
}));
|
||||
const layout = () => {
|
||||
let x = stripLeft;
|
||||
let top = 8;
|
||||
for (const tab of tabs) {
|
||||
const before = px(tab.margins.get('margin-left'), 0);
|
||||
const after = px(tab.margins.get('margin-right'), 2);
|
||||
if (x > stripLeft && x + before + tab.width + after > rowRight) {
|
||||
x = stripLeft;
|
||||
top += 36;
|
||||
}
|
||||
tab.rect = {
|
||||
left: x + before,
|
||||
right: x + before + tab.width,
|
||||
top,
|
||||
bottom: top + 30,
|
||||
width: tab.width,
|
||||
height: 30,
|
||||
};
|
||||
x += before + tab.width + after;
|
||||
}
|
||||
};
|
||||
const tabElements = tabs.map((tab) => ({
|
||||
model: tab,
|
||||
style: {
|
||||
setProperty: (name: string, value: string) => tab.margins.set(name, value),
|
||||
removeProperty: (name: string) => tab.margins.delete(name),
|
||||
},
|
||||
getBoundingClientRect: () => {
|
||||
layout();
|
||||
return tab.rect;
|
||||
},
|
||||
}));
|
||||
const strip = {
|
||||
dataset: {} as Record<string, string>,
|
||||
querySelectorAll: () => tabElements,
|
||||
addEventListener: () => {},
|
||||
};
|
||||
let toolbarLeft = options.toolbarLeft === undefined ? 1131 : options.toolbarLeft;
|
||||
const toolbar = {
|
||||
children: [{ offsetWidth: 200 }, { offsetWidth: 120 }],
|
||||
getBoundingClientRect: () => ({ left: toolbarLeft ?? 0, width: 1500 - (toolbarLeft ?? 0) }),
|
||||
};
|
||||
let headerParsed = toolbarLeft !== null;
|
||||
|
||||
const window: Record<string, unknown> = {
|
||||
innerWidth: 1512,
|
||||
app: {
|
||||
// The real one ends by having the module place the tabs (app.js, updateTabOverflowMode).
|
||||
updateTabOverflowMode: () => {
|
||||
relayouts.push('tabs');
|
||||
(window.CodemanHostCutout as Api).fitTabs();
|
||||
},
|
||||
updateConnectionLines: () => relayouts.push('lines'),
|
||||
},
|
||||
};
|
||||
if (options.solo !== undefined) window.__CODEMAN_SOLO__ = options.solo;
|
||||
if (options.host !== false) {
|
||||
window.CodemanHost = {
|
||||
cutoutReady: (yes: unknown) => calls.push(yes),
|
||||
setWholeScreen: (on: unknown) => {
|
||||
switched.push(on);
|
||||
return true;
|
||||
},
|
||||
};
|
||||
}
|
||||
const context = vm.createContext({
|
||||
window,
|
||||
document: {
|
||||
documentElement,
|
||||
getElementById: (id: string) => {
|
||||
if (id === 'sessionTabs') return headerParsed ? strip : null;
|
||||
if (id === 'headerRight') return headerParsed ? toolbar : null;
|
||||
return null;
|
||||
},
|
||||
addEventListener: (type: string, callback: () => void) => {
|
||||
if (type === 'DOMContentLoaded') ready = callback;
|
||||
},
|
||||
},
|
||||
location: { pathname: options.pathname ?? '/' },
|
||||
getComputedStyle: (element: (typeof tabElements)[number]) => ({
|
||||
getPropertyValue: (name: string) => element.model.margins.get(name) ?? (name === 'margin-right' ? '2px' : '0px'),
|
||||
}),
|
||||
MutationObserver: class {
|
||||
constructor(callback: () => void) {
|
||||
observer = callback;
|
||||
}
|
||||
observe(target: unknown, init: { attributeFilter: string[] }) {
|
||||
expect(target).toBe(documentElement);
|
||||
expect(init.attributeFilter).toEqual(['data-tab-arrangement', 'data-session-list', 'data-tab-orientation']);
|
||||
}
|
||||
},
|
||||
});
|
||||
vm.runInContext(read('host-cutout.js'), context, { filename: 'host-cutout.js' });
|
||||
return {
|
||||
api: window.CodemanHostCutout as Api,
|
||||
window,
|
||||
calls,
|
||||
switched,
|
||||
relayouts,
|
||||
props,
|
||||
classes,
|
||||
/** Where each tab is now: `[left, right, top]`. */
|
||||
places() {
|
||||
layout();
|
||||
return tabs.map((tab) => [tab.rect!.left, tab.rect!.right, tab.rect!.top]);
|
||||
},
|
||||
/** The margins the module set, by tab index. */
|
||||
margins() {
|
||||
return Object.fromEntries(
|
||||
tabs.filter((tab) => tab.margins.size).map((tab) => [tab.index, Object.fromEntries(tab.margins)])
|
||||
);
|
||||
},
|
||||
/** Change the layout the way the settings do, and let the observer see it. */
|
||||
setLayout(change: Record<string, string>) {
|
||||
Object.assign(dataset, change);
|
||||
observer?.();
|
||||
},
|
||||
/** The header arrives, as when the parser reaches <body>, with its toolbar beginning at `left`. */
|
||||
parseHeader(left: number) {
|
||||
toolbarLeft = left;
|
||||
headerParsed = true;
|
||||
ready?.();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe('camera housing: what counts as one', () => {
|
||||
it('takes three finite, positive numbers', () => {
|
||||
const { api } = load();
|
||||
expect(api.normalize(MBP14)).toEqual(MBP14);
|
||||
expect(api.normalize({ left: '663.5', width: '185', height: '32' })).toEqual(MBP14);
|
||||
expect(api.normalize({ left: 0, width: 200, height: 38 })).toEqual({ left: 0, width: 200, height: 38 });
|
||||
});
|
||||
|
||||
it('refuses anything else, so a bad message can never empty the header', () => {
|
||||
const { api } = load();
|
||||
for (const bad of [
|
||||
null,
|
||||
undefined,
|
||||
'notch',
|
||||
42,
|
||||
{},
|
||||
{ left: 663 },
|
||||
{ left: NaN, width: 185, height: 32 },
|
||||
{ left: 663, width: Infinity, height: 32 },
|
||||
{ left: -1, width: 185, height: 32 },
|
||||
{ left: 663, width: 0, height: 32 },
|
||||
{ left: 663, width: 185, height: 0 },
|
||||
{ left: 663, width: 185, height: 900 },
|
||||
]) {
|
||||
expect(api.normalize(bad), JSON.stringify(bad)).toBeNull();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('camera housing: laying the header out around it', () => {
|
||||
it('writes the housing to <html> and has the tab strip measure the toolbar again', () => {
|
||||
const page = load();
|
||||
expect(page.api.apply(MBP14)).toBe(true);
|
||||
expect(Object.fromEntries(page.props)).toEqual({
|
||||
'--host-cutout-left': '663.5px',
|
||||
'--host-cutout-width': '185px',
|
||||
'--host-cutout-height': '32px',
|
||||
});
|
||||
expect([...page.classes]).toEqual(['host-cutout']);
|
||||
expect(page.api.current()).toEqual(MBP14);
|
||||
expect(page.relayouts).toEqual(['tabs', 'lines']);
|
||||
});
|
||||
|
||||
it('does nothing for the housing it already has', () => {
|
||||
const page = load();
|
||||
page.api.apply(MBP14);
|
||||
page.relayouts.length = 0;
|
||||
expect(page.api.apply({ ...MBP14 })).toBe(true);
|
||||
expect(page.relayouts).toEqual([]);
|
||||
});
|
||||
|
||||
it('puts everything back when the housing is gone', () => {
|
||||
const page = load();
|
||||
page.api.apply(MBP14);
|
||||
page.relayouts.length = 0;
|
||||
expect(page.api.apply(null)).toBe(true);
|
||||
expect(page.props.size).toBe(0);
|
||||
expect(page.classes.size).toBe(0);
|
||||
expect(page.api.current()).toBeNull();
|
||||
expect(page.relayouts).toEqual(['tabs', 'lines']);
|
||||
});
|
||||
|
||||
it('treats a housing that is not a rectangle as none', () => {
|
||||
const page = load();
|
||||
page.api.apply(MBP14);
|
||||
page.api.apply({ left: 663, width: -4, height: 32 });
|
||||
expect(page.classes.size).toBe(0);
|
||||
expect(page.props.size).toBe(0);
|
||||
});
|
||||
|
||||
it('follows the housing to another display', () => {
|
||||
const page = load();
|
||||
page.api.apply(MBP14);
|
||||
page.api.apply({ left: 771.5, width: 185, height: 32 });
|
||||
expect(page.props.get('--host-cutout-left')).toBe('771.5px');
|
||||
expect([...page.classes]).toEqual(['host-cutout']);
|
||||
});
|
||||
|
||||
it('works before the app exists (the module runs in <head>)', () => {
|
||||
const calls: unknown[] = [];
|
||||
const props = new Map<string, string>();
|
||||
const window: Record<string, unknown> = { CodemanHost: { cutoutReady: (r: unknown) => calls.push(r) } };
|
||||
const context = vm.createContext({
|
||||
window,
|
||||
document: {
|
||||
documentElement: {
|
||||
dataset: {},
|
||||
style: { setProperty: (n: string, v: string) => props.set(n, v), removeProperty: () => {} },
|
||||
classList: { add: () => {}, remove: () => {}, contains: () => false, toggle: () => {} },
|
||||
},
|
||||
getElementById: () => null,
|
||||
addEventListener: () => {},
|
||||
},
|
||||
location: { pathname: '/' },
|
||||
});
|
||||
vm.runInContext(read('host-cutout.js'), context, { filename: 'host-cutout.js' });
|
||||
expect(calls).toEqual([true]);
|
||||
expect((window.CodemanHostCutout as Api).apply(MBP14)).toBe(true);
|
||||
expect(props.get('--host-cutout-width')).toBe('185px');
|
||||
});
|
||||
});
|
||||
|
||||
describe('camera housing: telling the app whether the page may be drawn behind it', () => {
|
||||
it('says yes once for the classic strip, the sidebar and the rail', () => {
|
||||
expect(load().calls).toEqual([true]);
|
||||
expect(load({ dataset: { sessionList: 'sidebar' } }).calls).toEqual([true]);
|
||||
expect(load({ dataset: { tabOrientation: 'vertical' } }).calls).toEqual([true]);
|
||||
});
|
||||
|
||||
it('says no while the tabs are grouped in the header strip', () => {
|
||||
for (const tabArrangement of ['state', 'case', 'ledger']) {
|
||||
const page = load({ dataset: { tabArrangement } });
|
||||
expect(page.calls, tabArrangement).toEqual([false]);
|
||||
expect(page.api.fits()).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it('says yes for grouped tabs that are not in the header', () => {
|
||||
expect(load({ dataset: { tabArrangement: 'state', sessionList: 'sidebar' } }).calls).toEqual([true]);
|
||||
expect(load({ dataset: { tabArrangement: 'ledger', tabOrientation: 'vertical' } }).calls).toEqual([true]);
|
||||
});
|
||||
|
||||
it('says yes in a solo window, which has no tab strip, under any base path', () => {
|
||||
expect(load({ dataset: { tabArrangement: 'state' }, pathname: '/session/abc' }).calls).toEqual([true]);
|
||||
expect(load({ dataset: { tabArrangement: 'state' }, pathname: '/codeman/session/abc/' }).calls).toEqual([true]);
|
||||
expect(load({ dataset: { tabArrangement: 'state' }, solo: 'abc' }).calls).toEqual([true]);
|
||||
// A dashboard URL that only mentions the word is not one.
|
||||
expect(load({ dataset: { tabArrangement: 'state' }, pathname: '/session/' }).calls).toEqual([false]);
|
||||
});
|
||||
|
||||
it('says so again when the layout changes, and only then', () => {
|
||||
const page = load();
|
||||
page.setLayout({ tabArrangement: 'classic' });
|
||||
expect(page.calls).toEqual([true]);
|
||||
page.setLayout({ tabArrangement: 'state' });
|
||||
page.setLayout({ tabArrangement: 'case' });
|
||||
expect(page.calls).toEqual([true, false]);
|
||||
page.setLayout({ tabOrientation: 'vertical' });
|
||||
expect(page.calls).toEqual([true, false, true]);
|
||||
});
|
||||
|
||||
it('drops the layout at once when it stops fitting, without waiting for the app', () => {
|
||||
const page = load();
|
||||
page.api.apply(MBP14);
|
||||
page.setLayout({ tabArrangement: 'state' });
|
||||
expect(page.classes.size).toBe(0);
|
||||
expect(page.props.size).toBe(0);
|
||||
expect(page.api.current()).toBeNull();
|
||||
});
|
||||
|
||||
it('ignores a housing the app sent before it heard the no', () => {
|
||||
const page = load({ dataset: { tabArrangement: 'ledger' } });
|
||||
expect(page.api.apply(MBP14)).toBe(true);
|
||||
expect(page.classes.size).toBe(0);
|
||||
expect(page.api.current()).toBeNull();
|
||||
});
|
||||
|
||||
it('is silent in a browser tab, where nothing is ever drawn behind a housing', () => {
|
||||
const page = load({ host: false });
|
||||
expect(page.calls).toEqual([]);
|
||||
expect(page.classes.size).toBe(0);
|
||||
expect(typeof page.api.apply).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('camera housing: the tabs go around it', () => {
|
||||
// Five tabs of 150 px from x = 100, 2 px apart: 100-250, 252-402, 404-554, 556-706, 708-858.
|
||||
// The housing with its 8 px of air on each side is 718.5 to 793.5.
|
||||
const FIVE = [150, 150, 150, 150, 150];
|
||||
|
||||
it('starts the tab that would sit under the housing just right of it', () => {
|
||||
const page = load({ tabs: FIVE });
|
||||
page.api.apply(NARROW);
|
||||
// The room is the right margin of the tab before it: 2 px of its own plus 793.5 - 708, rounded up.
|
||||
expect(page.margins()).toEqual({ 3: { 'margin-right': '88px' } });
|
||||
expect(page.places()).toEqual([
|
||||
[100, 250, 8],
|
||||
[252, 402, 8],
|
||||
[404, 554, 8],
|
||||
[556, 706, 8],
|
||||
[794, 944, 8],
|
||||
]);
|
||||
});
|
||||
|
||||
it('leaves a row alone that the housing does not reach', () => {
|
||||
const page = load({ tabs: [150, 150, 150, 150] });
|
||||
page.api.apply(NARROW);
|
||||
expect(page.margins()).toEqual({});
|
||||
});
|
||||
|
||||
it('wraps a tab that no longer fits right of the housing, flush left', () => {
|
||||
// The row ends at 900: 794 + 150 does not fit before it.
|
||||
const page = load({ tabs: FIVE, rowRight: 900 });
|
||||
page.api.apply(NARROW);
|
||||
expect(page.places()[4]).toEqual([100, 250, 44]);
|
||||
// The margin is the fourth tab's, so the wrapped one carries no indent.
|
||||
expect(page.margins()).toEqual({ 3: { 'margin-right': '88px' } });
|
||||
});
|
||||
|
||||
it('moves the first tab of a row by its own margin, having no tab before it', () => {
|
||||
const page = load({ tabs: [150, 150], stripLeft: 700 });
|
||||
page.api.apply(NARROW);
|
||||
expect(page.margins()).toEqual({ 0: { 'margin-left': '94px' } });
|
||||
expect(page.places()[0]).toEqual([794, 944, 8]);
|
||||
});
|
||||
|
||||
it('clears every row beside a tall housing, and none below it', () => {
|
||||
// Rows at 8 and 44 are beside a housing 60 px high, the one at 80 is not.
|
||||
const tabs = Array.from({ length: 18 }, () => 150);
|
||||
const page = load({ tabs });
|
||||
page.api.apply({ ...NARROW, height: 60 });
|
||||
const under = page.places().filter(([left, right, top]) => top < 60 && right > 718.5 && left < 793.5);
|
||||
expect(under).toEqual([]);
|
||||
const third = page.places().filter(([, , top]) => top === 80);
|
||||
expect(third.some(([left, right]) => right > 718.5 && left < 793.5)).toBe(true);
|
||||
});
|
||||
|
||||
it('says whether a pass moved anything, so the lineage lines are only redrawn when one did', () => {
|
||||
const page = load({ tabs: FIVE });
|
||||
page.api.apply(NARROW);
|
||||
expect(page.api.fitTabs()).toBe(false);
|
||||
expect(page.margins()).toEqual({ 3: { 'margin-right': '88px' } });
|
||||
});
|
||||
|
||||
it('follows the tabs: a wider fourth tab reaches the housing itself and is the one that moves', () => {
|
||||
// A selected tab is wider (its gear and close show): 556 + 170 passes 718.5.
|
||||
const page = load({ tabs: [150, 150, 150, 170, 150] });
|
||||
page.api.apply(NARROW);
|
||||
expect(page.margins()).toEqual({ 2: { 'margin-right': '240px' } });
|
||||
expect(page.places()[3]).toEqual([794, 964, 8]);
|
||||
// The fifth follows it in the row, with nothing under the housing.
|
||||
expect(page.places()[4]).toEqual([966, 1116, 8]);
|
||||
});
|
||||
|
||||
it('takes its margins back when the housing is gone', () => {
|
||||
const page = load({ tabs: FIVE });
|
||||
page.api.apply(NARROW);
|
||||
page.api.apply(null);
|
||||
expect(page.margins()).toEqual({});
|
||||
expect(page.places()[4]).toEqual([708, 858, 8]);
|
||||
});
|
||||
|
||||
it('adds nothing to the strip and never reorders it', () => {
|
||||
const source = read('host-cutout.js');
|
||||
expect(source).not.toMatch(/createElement|insertBefore|appendChild|\.order\b/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('camera housing: the toolbar', () => {
|
||||
it('stays as it is when it ends right of the housing', () => {
|
||||
const page = load({ toolbarLeft: 1131 });
|
||||
page.api.apply(NARROW);
|
||||
expect([...page.classes]).toEqual(['host-cutout']);
|
||||
});
|
||||
|
||||
it('takes the box that covers the housing when it would reach it', () => {
|
||||
// 793 is inside the 8 px of air right of the housing (793.5).
|
||||
const page = load({ toolbarLeft: 793 });
|
||||
page.api.apply(NARROW);
|
||||
expect([...page.classes].sort()).toEqual(['host-cutout', 'host-cutout-toolbar']);
|
||||
page.api.apply(null);
|
||||
expect(page.classes.size).toBe(0);
|
||||
});
|
||||
|
||||
it('always takes it in a solo window, whose title shares the row', () => {
|
||||
const page = load({ pathname: '/session/abc', toolbarLeft: 1131 });
|
||||
page.api.apply(NARROW);
|
||||
expect(page.classes.has('host-cutout-toolbar')).toBe(true);
|
||||
});
|
||||
|
||||
it('covers the housing until the header can be measured, then decides', () => {
|
||||
const page = load({ toolbarLeft: null });
|
||||
page.api.apply(NARROW);
|
||||
expect(page.classes.has('host-cutout-toolbar')).toBe(true);
|
||||
page.parseHeader(1131);
|
||||
expect([...page.classes]).toEqual(['host-cutout']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('camera housing: the option in App Settings', () => {
|
||||
it('knows nothing until the app says, and then what the app said', () => {
|
||||
const page = load();
|
||||
expect(page.api.wholeScreen()).toBeNull();
|
||||
expect(page.api.option({ available: true, enabled: true })).toBe(true);
|
||||
expect(page.api.wholeScreen()).toEqual({ available: true, enabled: true });
|
||||
page.api.option({ available: 'yes', enabled: 1 });
|
||||
expect(page.api.wholeScreen()).toEqual({ available: false, enabled: false });
|
||||
page.api.option(null);
|
||||
expect(page.api.wholeScreen()).toBeNull();
|
||||
});
|
||||
|
||||
it('has the settings page show it as soon as the app says', () => {
|
||||
const page = load();
|
||||
let synced = 0;
|
||||
(page.window.app as Record<string, unknown>).syncHostWholeScreenSetting = () => synced++;
|
||||
page.api.option({ available: true, enabled: false });
|
||||
expect(synced).toBe(1);
|
||||
});
|
||||
|
||||
it('turns it on and off in the app, and only with a plain true', () => {
|
||||
const page = load();
|
||||
expect(page.api.setWholeScreen(true)).toBe(true);
|
||||
expect(page.api.setWholeScreen('true')).toBe(true);
|
||||
expect(page.api.setWholeScreen(false)).toBe(true);
|
||||
expect(page.switched).toEqual([true, false, false]);
|
||||
});
|
||||
|
||||
it('says there is no app to tell in a browser tab', () => {
|
||||
const page = load({ host: false });
|
||||
expect(page.api.setWholeScreen(true)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('camera housing: wiring', () => {
|
||||
const html = read('index.html');
|
||||
const css = read('styles.css');
|
||||
|
||||
it('loads in <head>, not deferred, after the layout attributes are written', () => {
|
||||
const tag = '<script src="host-cutout.js"></script>';
|
||||
const at = html.indexOf(tag);
|
||||
expect(at).toBeGreaterThan(-1);
|
||||
expect(at).toBeLessThan(html.indexOf('</head>'));
|
||||
// The pre-paint script that writes data-tab-arrangement and its two siblings comes first: `fits()` reads them.
|
||||
expect(at).toBeGreaterThan(html.indexOf('document.documentElement.dataset.tabArrangement='));
|
||||
expect(html).not.toContain('<script defer src="host-cutout.js">');
|
||||
});
|
||||
|
||||
it('is minified and content-hashed by the build', () => {
|
||||
expect(buildJs).toContain("run('minify host-cutout.js'");
|
||||
expect(buildJs).toMatch(/HASHABLE[\s\S]{0,1500}'host-cutout\.js'/);
|
||||
});
|
||||
|
||||
it('speaks the bridge Codeman Desktop injects', () => {
|
||||
// packages/desktop/src/assets.rs (HOST_SHIM) and policy.rs (RawHost::CutoutReady).
|
||||
expect(shim).toContain("cutoutReady: function (ready) { post({ cmd: 'cutoutReady', ready: ready !== false }); }");
|
||||
expect(read('host-cutout.js')).toContain('window.CodemanHost.cutoutReady(ready)');
|
||||
});
|
||||
|
||||
it('gives a toolbar that would reach the housing a box that covers it', () => {
|
||||
const rule = /html\.host-cutout-toolbar \.header > \.header-right \{([^}]*)\}/.exec(css)?.[1] ?? '';
|
||||
expect(rule).toContain('width: calc(100vw - 0.75rem - var(--host-cutout-left) + var(--host-cutout-gap));');
|
||||
expect(rule).toContain('padding-left: calc(var(--host-cutout-width) + 2 * var(--host-cutout-gap));');
|
||||
expect(rule).toContain('flex-wrap: wrap;');
|
||||
expect(rule).toContain('box-sizing: border-box;');
|
||||
// 0.75rem is the header's own side padding: the two must change together.
|
||||
expect(/\n\.header \{[^}]*padding: 0\.35rem 0\.75rem;/.test(css)).toBe(true);
|
||||
// And the gap is the module's GAP.
|
||||
expect(css).toMatch(/html\.host-cutout \{\s*--host-cutout-gap: 8px;/);
|
||||
expect(read('host-cutout.js')).toContain('const GAP = 8;');
|
||||
});
|
||||
|
||||
it('lets that box win over a toolbar width the user chose, and hides the handle that sets it', () => {
|
||||
expect(css).toMatch(
|
||||
/html\[data-header-right-width\]:not\(\.host-cutout-toolbar\):not\(\[data-tab-orientation='vertical'\]\)/
|
||||
);
|
||||
expect(css).toMatch(/html\.host-cutout-toolbar \.header-divider \{\s*display: none;/);
|
||||
// A toolbar that ends right of the housing keeps the user's width and the handle.
|
||||
expect(css).not.toMatch(/html\.host-cutout \.header-divider/);
|
||||
expect(css).not.toMatch(/html\.host-cutout \.header > \.header-right/);
|
||||
});
|
||||
|
||||
it('has the tab strip place the tabs once its row mode is decided, and before one row is measured', () => {
|
||||
const app = read('app.js');
|
||||
const mode = /\n updateTabOverflowMode\(\) \{([\s\S]*?)\n \}/.exec(app)?.[1] ?? '';
|
||||
expect(mode.indexOf('this._syncTabStripCorner(container);')).toBeGreaterThan(-1);
|
||||
expect(mode.indexOf('window.CodemanHostCutout?.fitTabs?.(container);')).toBeGreaterThan(
|
||||
mode.indexOf('this._syncTabStripCorner(container);')
|
||||
);
|
||||
const decide = /\n _decideTabOverflow\(container\) \{([\s\S]*?)\n \}/.exec(app)?.[1] ?? '';
|
||||
const fit = decide.lastIndexOf('window.CodemanHostCutout?.fitTabs?.(container);');
|
||||
expect(fit).toBeGreaterThan(decide.lastIndexOf("container.classList.remove('tabs-auto-wrap');"));
|
||||
expect(fit).toBeLessThan(decide.indexOf('scrollWidth: container.scrollWidth'));
|
||||
});
|
||||
|
||||
it('has a switch in App Settings that only the Mac app shows, wired to the app and not to the settings blob', () => {
|
||||
const html = read('index.html');
|
||||
expect(html).toMatch(/<div class="set-group" id="appSettingsHostGroup" style="display: none">/);
|
||||
expect(html).toContain('<input type="checkbox" id="appSettingsHostWholeScreen">');
|
||||
const ui = read('settings-ui.js');
|
||||
expect(ui).toContain("group.style.display = option?.available ? '' : 'none';");
|
||||
expect(ui).toContain('window.CodemanHostCutout.setWholeScreen(hostBox.checked);');
|
||||
// Never a key of the settings object the page stores and sends to the server.
|
||||
expect(ui).not.toMatch(/wholeScreen\s*:/);
|
||||
expect(shim).toContain("setWholeScreen: function (on) { return post({ cmd: 'wholeScreen', on: on === true }); }");
|
||||
});
|
||||
});
|
||||
@@ -345,6 +345,29 @@ describe('tab layouts by case and ledger (static)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps the working spinner on a ledger cell', () => {
|
||||
// The bar replaces the status dot, but it is green for idle and working
|
||||
// alike, and the spinner is the dot's own ::after ring: hiding every dot
|
||||
// left a working session with no mark at all.
|
||||
const hides: string[] = [];
|
||||
postcss.parse(css).walkAtRules('media', (media: AtRule) => {
|
||||
if (media.params !== '(min-width: 768px)') return;
|
||||
media.walkRules((rule: Rule) => {
|
||||
if (!rule.selector.includes('.tabs-ledger')) return;
|
||||
if (!rule.nodes.some((n) => n.type === 'decl' && n.prop === 'display' && n.value === 'none')) return;
|
||||
hides.push(...rule.selectors.filter((s) => s.includes('.tab-status')));
|
||||
});
|
||||
});
|
||||
expect(hides.length).toBeGreaterThan(0);
|
||||
for (const selector of hides) {
|
||||
// Each one either spares a busy dot or is the exited-agent cell, whose
|
||||
// ring the classic strip hides too.
|
||||
expect(selector.endsWith('.tab-status:not(.busy)') || selector.includes('.tab-agent-exited')).toBe(true);
|
||||
}
|
||||
// The ring the cell keeps is the shared one every strip draws.
|
||||
expect(css).toMatch(/\.session-tab \.tab-status\.busy::after \{[^}]*animation: tab-load-spin/);
|
||||
});
|
||||
|
||||
it('dissolves the boxes into the one chip row on phones', () => {
|
||||
expect(mobileCss).toMatch(
|
||||
/:where\(\.header\) \.session-tabs-host > \.session-tabs\.tabs-clusters > \.tab-cluster \{\s*display: contents;/
|
||||
|
||||
Reference in new issue
Block a user