Adds crates/komorebi-core/tests/common (StubWindow, StubPlatform): a
Clone-but-not-Copy window and a platform whose window operations and every
WorkspacePlatform and MonitorPlatform hook append a line to an ordered log,
with failure injection per operation (fail("hide 3"), fail("place_container")),
scripted end_update passes and a per-workspace hide spot kept in the platform
state the way macOS keeps its corner. The log and settings are thread-local
and every test starts with fresh().
tests/container_behaviour.rs pins Container<W> (24 tests): add/remove/focus
ordering, the focus index after removal at each position (it is idx-1 whatever
was focused, and dangles after an out-of-range removal), empty-container cases,
the order of hide_window calls (from the back, a failing window is skipped),
load_focused_window stopping at the first failure, the omitted window, restore,
locking and the JSON shape.
Verified: cargo test -p komorebi-core --test container_behaviour, 24 passed
(nix shell gcc, own target dir). No non-test source changed.
Candidate 4: wip-cand3c (core line with macOS on komorebi-core, HideSpot, settings S1-S3, bar e2e scenario, handover scenario fix), wip-u-core3 (shared Workspace update_shared and the Windows converge of window_manager/process_command), wip-u-stallfix (lock-holder instrumentation, sysinfo scan before the lock, bar restart and hwnd file off the lock, subscriber write timeout) and wip-u-pkg2 (one komorebi package and binary, daemons as libraries). Conflicts, if any, are resolved here.
notify_subscribers connects to every subscriber socket and write_all()s the
notification with the window manager locked (every command, the reaper and
the event thread), with no timeout: a subscriber that stops reading stalls the
lock holder, and with it every thread.
komorebi_transport::notify_sockets skips a subscriber whose write fails with
TimedOut or WouldBlock (warns, keeps it subscribed, goes on to the next);
every other write error still aborts as before. The timeout itself is the
caller's: the connect closure passed by the Windows daemon sets a 1 s write
timeout on the stream. KDE and macOS pass connect closures without a timeout,
so nothing changes for them. A new unit test covers the skip. The connect
itself cannot be bounded (uds_windows has no connect timeout), and the
listener's lock wait is untouched.
BEHAVIOUR: a Windows subscriber that does not read for a second misses that
notification instead of blocking the daemon. Gate needed: Windows e2e commands
and config_reload, the lock stress, subscriber scenarios if any. Verified:
native cargo test -p komorebi-transport 14 passed (incl. the new test);
tools/fast-check native, Windows clippy -D warnings and KDE check + lib tests
PASS; macOS type-check run by hand (fast-check's macOS step fails to select
a package on this merged tree) PASS. e2e not run.
Instrumentation for the stalls of the stall analysis; no behaviour change.
lock_holder.rs: a place that has just locked the window manager calls
lock_holder::held("site") and keeps the returned guard next to the lock
guard; the holder (what, thread, since) is recorded in a slot of its own
(a mutex held only for a copy; the window manager lock itself is unchanged),
a hold of 200 ms or more is logged at warn when it ends ("window manager
lock held by X (thread T) for N ms"), and lock_holder::describe() names the
holder for the waiters: the border manager's "stuck for N ms" warning and
the listener's "could not acquire window manager lock" warning now end with
the holder. Sites: every command (held as "command <message>"), process_event,
reaper, monitor reconciliator, border manager, transparency and stackbar
managers. komorebi-transport: ConnectionPolicy::lock_holder() (default None),
used in that warning; the Windows policy implements it, KDE and macOS keep the
text they had.
replace-configuration logs info lines "replace-configuration: <step> took N
ms" for restore, preload, init, restore of the new wm, reload, swap, the
process scan for komorebi-bar and the bar restart; every command logs at
debug how long the command, update_known_hwnds and notify_subscribers took.
Verified: tools/fast-check: native, Windows clippy -D warnings, KDE check +
lib tests PASS; the macOS step of fast-check fails to select a package on this
merged tree (tool issue: -p komorebi), the macOS check run by hand with -p
komorebi-macos -p komorebic-macos -p komorebi-client-macos -p
komorebi-bar-macos passes. Not run: e2e.
Merge of kfm's macOS core migration (wip-u-kfm2 9cb4f2fa) and the settings
stack through S3 (wip-u-settings2 696d2929), both on wip-u-integ2. Two files
conflicted, both macOS; every hunk is resolved the same way: take kfm's
version of the file (its new shapes: komorebi_core Monitor/Workspace,
workspace_config and monitor_config as free functions) and re-apply the S3
change to it, because the settings side only touched lines kfm moved.
- komorebi-for-mac/komorebi/src/monitor.rs: conflict 1 (imports): kfm's
header doc kept, the DEFAULT_CONTAINER_PADDING / DEFAULT_WORKSPACE_PADDING
imports dropped (S3). Conflict 2 (std imports): kfm's side (no VecDeque).
The four padding reads (the two default fallbacks in the monitor's
workspace globals) call crate::settings::container_padding() /
workspace_padding(); the now unused Ordering import is removed.
- komorebi-for-mac/komorebi/src/static_config.rs: both conflicts are the
padding defaults in kfm's free functions (workspace_config, monitor_config):
kfm's text kept, the two defaults read from settings. Re-applied S3 in this
file: apply_globals applies paddings, aspect ratio, layout_defaults and
display_index_preferences as one Handle::update of a SharedDelta; the
readers (layout_defaults, aspect ratio, display preferences, paddings) use
the accessors; the statics' imports and the now unused AspectRatio imports
are removed.
komorebi-core and the shared crates read none of the removed statics
(grep: only the unrelated DEFAULT_*_PADDING consts in komorebi-config), so no
hook is needed. S3 semantics are unchanged from wip-u-settings2 (statics
removed, one update per load, reload merges, a few keys reset); the pins
are the settings crate's reload.rs and shared tests plus the KDE
tests/config.rs.
Verified: see the run in the progress log (macOS fake-CC clippy -D warnings
-p komorebi-macos --all-targets clean at this revision).
The shared half of update (core-model.md section 12) as
Workspace::update_shared: begin_update (Flow::Skip, or a guard held until
the end), the empty containers dropped and containers_pruned, the work
area, offsets and paddings, the layout and behaviour rules, then the tile
branch: place_monocle, maximize_in_layout, adopt_widths_before_layout and
adopt_actual_widths for a scrolling workspace, the layout (calculate, or
scrolling_layouts with the containers that rest hidden), adjust_layout and
place_container per container, latest_layout, and end_update, which can ask
for one more pass (Pass::Again), and the resize_dimensions resize. The
text is KDE's with the Windows pass loop in it; the hooks are the parts the
two daemons do differently. It is not called update so that a daemon keeps
its own update (macOS's, which has another shape, stays as it is); every
hook has a default so that MacosPlatform compiles unchanged, and the
defaults of the ones a daemon must provide fail. Placement carries what the
hooks of a pass need (the work areas, the paddings, the border, whether the
workspace scrolls, whether it has resize adjustments, whether a window is
maximized). Flow and Pass are the answers of begin_update and end_update.
A test with a stub platform pins the call order and the second pass.
Verified: cargo test -p komorebi-core --features schemars (native): 29
passed, 0 failed; Windows clippy --locked --all-targets -D warnings: PASS
(compiles the crate). Not run: the daemons (nothing calls update_shared
yet).
The macOS corner is a property of the monitor that the workspace is on, which
the monitor gives the workspace when it updates its globals; macOS has
no field for it in the shared WorkspaceGlobals and keeps it in its
WorkspacePlatform::State, so the hooks need the workspace. hide_spot(&Workspace<P>)
and hide_spot_on_display(&Workspace<P>), called with self where they were called with
&self.globals; KDE and Windows do not override them (they return (), the
default), so nothing changes there; the test stub's two overrides follow.
Verified: native cargo test -p komorebi-core 26 passed; fast-check Windows
clippy -D warnings, KDE check + lib tests and macOS fake-CC type-check PASS. Not
verified: any run. Gates: none beyond the previous revision's (this changes no
call a daemon makes).
BEHAVIOUR for the shared signature; none intended on KDE or Windows. Needs
the Windows and KDE gates below.
ContainerWindow gets 'type HideSpot: Copy + Default' (() on KDE and Windows;
on macOS the monitor's corner and, when known, the display bounds) and its
four operations return eyre::Result: hide_window(spot), restore_window(),
hide_stacked(spot), restore_stacked(). Container::hide(omit, spot),
restore(), load_focused_window(spot) and add_window(window, spot) return
Result (hide logs a window that cannot be hidden and goes on, as macOS does;
the others propagate). WorkspacePlatform gets two hooks with a default of
Default::default(): hide_spot(&globals) (the spot of a window) and
hide_spot_on_display(&globals) (the containers of a workspace that is being
hidden; macOS passes the display there and not for its floating windows).
The eight shared workspace functions that hide (focus_container_by_window,
new_container_for_window, move_window_to_container,
new_container_for_focused_window, new_monocle_container,
reintegrate_monocle_container, new_container_for_floating_window,
new_floating_window) and hide take the spot from the hook; new_container_for_window
and hide now return Result.
KDE and Windows: their Window impls return Ok(()) and take (); about 90 call
sites pass () and drop the Ok (let _ = ...) or use ?; nothing is hidden or
restored with a different argument than before: the same backend().hide /
restore, hide_with_border(false) and restore_with_border(false) calls run in
the same order, the Result is always Ok. macOS: the Window impl hides with
hide_on(spot.position, spot.screen) and restores, skipping both under
cfg!(test) as the old container code did; its ContainerExt is unchanged until
the Workspace layer.
No silent bind: every shared function whose behaviour depends on the spot
changed its signature (an added argument, or a Result where there was
none), so any caller written for the old form is a compile error in all
three trees (the six unused-Result warnings it produced on each of KDE and
Windows were each fixed by hand-checked 'let _ ='). The four macOS-only
extension methods (add_window_at, load_focused_window_at, hide_on,
restore_focused_window) share no name with a core inherent method (checked: the
intersection of the two name lists is empty), so no inherent method can shadow one.
Core tests: a stub window records the spot it is given; new tests pin that
a floating window is hidden at hide_spot, the containers of a hidden workspace
at hide_spot_on_display, and that stacking passes hide_spot through
add_window and load_focused_window; the container tests assert the spot.
Verified: native cargo test -p komorebi-core 26 passed; fast-check: Windows
clippy --all-targets -D warnings PASS, KDE check + lib tests PASS, macOS fake-CC
type-check PASS; KDE cargo test -p komorebi-linux --no-fail-fast 672 passed, 0
failed. Not verified: Windows and macOS tests, any run. Verified on the Mini:
not yet.
Gates for the coordinator: Windows e2e: workspaces, stacking, monocle (the
commands scenario), floating (toggle-float), lifecycle, resize, scrolling,
borders; KDE VM fast tier plus the stack, workspace, monocle and float
scenarios. These exercise exactly the hide/restore/stack paths touched.
Adds crates/komorebi-settings/tests/reload.rs: a load applied through a
Handle merges what the file gives, resets layout_defaults and the aspect
ratio when absent (the first load without the key turns the initial
Widescreen into Standard, as the statics do), keeps paddings and display
index preferences, never touches groups it does not name, and a reader that
holds the earlier snapshot still sees the earlier load whole. Test only.
Verified: native cargo test -p komorebi-settings: 18 unit + 3 integration
passed.
Merge of wip-u-core (kfde: komorebi-core with Container, Workspace<P>, Monitor<P>) and wip-u-pkg-mig3.
Conflicts and how they were resolved:
- komorebi-for-kde/Cargo.toml, komorebi-for-kde/Cargo.lock: deleted, as in the migration (one root
workspace); kfde's only edit there, the komorebi-core workspace dependency, is applied as a path
dependency in the crate manifest.
- komorebi-for-kde/komorebi/Cargo.toml: the migration's manifest (inlined dependencies, package name
komorebi-linux, [lib]/[[bin]]) plus kfde's komorebi-core dependency and the komorebi-core/schemars
feature.
- Cargo.lock: the migration's lock re-resolved with cargo metadata --offline: the only change is the
new komorebi-core 0.1.42 entry; no version of any other package moved (compared by name/version with
both parents; kfde's Windows lock differs only by the komorebi -> komorebi-windows rename).
- komorebi-bar/src/widgets/komorebi.rs: deleted (the Windows bar moved to komorebi-bar/src/windows/);
kfde's one-line edit (title: value.title() instead of value.title().ok()) applied to
komorebi-bar/src/windows/widgets/komorebi.rs.
- komorebi-for-kde/nix/root-crates.json: crates/komorebi-core added (tools/kde-closure-check now ok with
11 root crates).
Gates run: tools/fast-check --since wip-u-pkg-mig3: native tests, Windows clippy -D warnings, KDE check+lib+schemas, macOS fake-CC check, nix evaluation (root and both nested flakes) PASS; KDE cargo test -p komorebi-linux -p komorebic -p komorebi-client -p komorebi-hotkeys -p komorebi-core: 902 passed, 0 failed; CLI docs oracle identical x3; bar schema harness byte-identical for both bars (its Window::title stub now returns Option); bar-core tests 3+6; kde-closure-check ok; by evaluation an edit of the Windows bar or daemon leaves the kfde derivations unchanged, a KDE edit leaves Windows unchanged, and an edit of crates/komorebi-core changes Windows and kfde but not macOS. Not run: nix builds, VM, e2e (the Windows daemon changed: kfde's e2e gate applies), any Mac run.
Step 11(iii) prerequisite. The macOS Window holds retained Accessibility
references and cannot be Copy, so the bound of ContainerWindow is Clone.
KDE and Windows windows are still Copy; they satisfy it unchanged. The seven
places in komorebi-core/src/workspace.rs that copied a window out of a
borrowed Option (if let Some(window) = self.maximized_window) borrow it
instead (&self.maximized_window), and two places clone where the old text
used the value twice (new_maximized_window, new_maximized_window's
unmaximize hook). No behaviour change on KDE or Windows: a clone of a Copy
type is the copy.
Verified: native cargo test -p komorebi-core, fast-check: Windows clippy
--all-targets -D warnings PASS, KDE check + lib tests PASS (291 passed), macOS
fake-CC type-check PASS. Not run: Windows e2e (needed only if you want a
second look: no Windows window type changed).
wip-u-kfm carries the macOS clippy fixes (&Path, drain, filter, slice fill, sort_by_key, collapsible_match allows, capture_spike, bar stroke literals). The bar stroke literal revision touches komorebi-for-mac/komorebi-bar, which the migration moved to komorebi-bar/src/macos; conflicts are resolved here by applying the same edit at the new paths.
komorebi-core gets Monitor<P: MonitorPlatform> (MonitorPlatform extends
WorkspacePlatform), moved from komorebi-for-kde/komorebi/src/monitor.rs
and made generic: the id and serial_number_id are the platform's
associated types (Id with serialize_id/deserialize_id hooks so each daemon
keeps writing its id as the plain number it always did; SerialNumber), and
the fields only a platform has are P::Extra, flattened into the monitor's
JSON (NoExtra for a platform with none). The schema is named Monitor.
The workspace accessors (impl_ring_elements! is not generic) are written
out, and eight functions move with them: focused_workspace_layout,
focused_workspace_name, new_workspace_idx, ensure_workspace_count,
remove_workspaces, remove_workspace_by_idx, add_container and
focus_workspace, the last taking the name the platform last knew for a
new workspace from the known_workspace_name hook (Windows keeps its
names in the extra fields). WorkspacePlatform now needs Clone, Debug and
PartialEq of the platform marker and ContainerWindow needs Debug, because
the derives on the generic structs ask for them.
One serde fact the tests pin: a flattened map is read through a buffer
that keeps its keys as strings, so an extra field with integer keys (the
Windows workspace_names) needs a deserialize_with that parses them; the
Windows converge must carry it.
Tests with stub platforms: the JSON of a monitor with flat extra fields
and the id as a number, a monitor without extra fields, the name hook of
focus_workspace, the schema name and flat properties.
Verified: cargo test -p komorebi-core --features schemars (native): 27
passed, 0 failed; Windows clippy --workspace --locked --all-targets
-D warnings: PASS. Not run: the daemons.
Four more functions of the workspace move into komorebi-core, written
from the KDE text with three hooks that have defaults: primary_container_idx
(the layout's primary position; 0 for the default layouts, Windows
overrides it for custom layouts), unmaximize_window (KDE asks the
compositor, a no-op on Windows, as new_floating_window does there today)
and before_hide_containers (the KDE scrolling prelude of hide, returning
the resize adjustments to put back). effective_layout_options needs no
hook: a layout that is not one of the defaults has no default options,
which is the Windows custom-layout arm and an unreachable pattern on KDE.
Tests with the stub platform cover promote, new_floating_window and hide.
The daemons still have their own copies; the next revisions make them use
these.
Verified: cargo test -p komorebi-core --features schemars (native): 23
passed, 0 failed. Not run: the daemons.
clippy::match_like_matches_macro (-D warnings, seen by native clippy on the Mac Mini) flagged the match
with a Keyboard/Media/Systray arm of cfg!(target_os = "windows") and a true arm. The same boolean is
written !matches!(self, Keyboard | Media | Systray) || cfg!(target_os = "windows"): false only for those
three variants off Windows. Behaviour identical.
Gates run: Windows clippy -D warnings PASS; native cargo clippy -p komorebi-bar-core --all-targets -D
warnings PASS; bar-core tests (3 unit + 6 oracle) PASS; macOS fake-CC check PASS.
komorebi-core gets Workspace<P: WorkspacePlatform>, moved from
komorebi-for-kde/komorebi/src/workspace.rs (KDE is the base), together
with WorkspaceLayer, WorkspaceWindowLocation, CachedLayoutDefault and the
two threshold helpers, and these 52 functions of its impl, whose text is
the same on both daemons (add_container_to_back/front, the container
focus and removal family, insert_container_at_idx, swap_containers,
preselect and monocle operations, new_container_for_window and
resolve_placement_index, location_from_exe, visible_windows, the
enforce_resize_* family, the window lookups, remove_floating_window and
the floating focus helpers, is_scrolling). They are generic over
P::Window (Container<P::Window>, PlatformWindowId<P>), and every private
function is pub so the daemons' own methods can call it. The accessors
the impl_ring_elements! macro made are written out.
WorkspacePlatform is the hook trait: Window (a WorkspaceWindow), State
(what only a platform keeps in a workspace; skipped in the JSON and the
schema), default_padding, foreground_window_id, cursor_position,
should_act_window and should_act_window_individual (the platform holds
the compiled regexes), the three scrolling lookups and
after_floating_removed (KDE refocuses a floating window). Default for
Workspace<P> is the KDE one with the padding from the hook. serde and
schemars bounds are on P::Window; the schema is named Workspace.
Not used by any daemon yet; the next revisions make each daemon use it.
Four tests with a stub platform cover new_container_for_window, the
focus, the JSON keys and the default.
Verified: cargo test -p komorebi-core --features schemars (native): 20
passed, 0 failed; Windows clippy --workspace --locked --all-targets
-D warnings: PASS (compiles the crate). Not run: the daemons.
clippy::ptr_arg: the function only opens the file, so any path will do, and
every caller that passes a &PathBuf still compiles through deref. Needed so
the macOS StaticConfigExt methods can take &Path (next revision).
Verified: fast-check native, Windows clippy -D warnings, KDE check and lib
tests, macOS fake-CC type-check PASS. Verified on the Mini: not yet.
A supertrait of ContainerWindow with the four lookups the shared workspace
code makes (title, exe, class, path, each Option<String>), for the
functions that move into komorebi-core next. The crate's stub window
implements it and a test checks the four answers. Nothing uses it yet.
Verified: cargo test -p komorebi-core --features schemars (native): 16
passed, 0 failed. Not run: the daemons.
The plain data a monitor gives the workspaces it shows (padding, border
width and offset, work area, offsets, floating layer behaviour), moved
from komorebi-for-kde/komorebi/src/workspace.rs (the Windows struct is
the same nine fields with the same derives) into komorebi-core, with the
KDE doc comments and two unit tests. komorebi-core now depends on
komorebi-config (for FloatingLayerBehaviour, default features off) and
komorebi-layouts (for Rect); its schemars feature enables theirs. The
struct derives JsonSchema under the feature, as Windows' did; a workspace
skips the field when serialised and in its schema, so no schema changes.
No daemon uses it yet: the next two revisions converge KDE and Windows.
Verified: cargo test -p komorebi-core --features schemars (native): 15
passed, 0 failed. Not run: the daemons.
New crate crates/komorebi-core, a member of the root workspace (KDE and
macOS take it by path when they adopt it). It holds Container<W>, moved
from komorebi-for-kde/komorebi/src/container.rs (KDE is the base) and
made generic: W is any type that implements ContainerWindow, a small
trait for what the container asks of a platform window (its id, the
executable name, hide and restore, and the hide and restore that
load_focused_window uses, which on Windows leave the border alone).
Container keeps no Backend calls; hiding and restoring is the window's
own business.
The serialised form is unchanged: id, locked (which may be missing when
read, as on Windows), windows with elements and focused. The schemars
schema of Container<W> is named Container whatever W is
(schemars(rename)), so schema.json keeps its definition name; a test
checks it. The tests of container.rs that need no daemon moved with it,
over a stub window, plus tests for the JSON, the hide/restore calls and
the missing locked field.
No daemon uses it yet: the next revisions converge KDE and Windows.
Verified: cargo test -p komorebi-core --features schemars (native):
13 passed, 0 failed. Not run: Windows, KDE, macOS builds (nothing
depends on the crate yet).
Merge of wip-stage (kfde, bar, settings), wip-cand1 (kfw, kfm), wip-u-nix and wip-u-pkg (the
unified-binaries doc), so the migration is built on the open stacks and does not conflict with them later.
Staging merge of three stacks that make no runtime change on Windows or KDE: the KDE Backend/Container/process_command refactors (wip-u-kfde), the shared bar core moves (wip-u-bar) and komorebi-settings with the S1/S2 pins (wip-u-settings). Conflicts, if any, are resolved here. Not yet gated: the KDE VM suites and the Windows bar check are owed.
Shared now holds every non-platform setting of docs/dev/settings.md 2.1:
border (enabled, width, offset, radius, six colours), animation (global and
per-prefix enabled, style, duration; fps; Animation::motion_for reading all
three from one snapshot), paddings and constants, transparency, floating
window aspect ratio, layout defaults, display index preferences, with the
per-platform defaults (PlatformDefaults::{WINDOWS, KDE, MACOS}: border 8/10/10
and -1/0/0, padding 10/5/5). SharedDelta::apply reproduces what
StaticConfig::apply_globals does with each key: absent keys keep the old value
(border, paddings, transparency, display preferences, a missing animation
block), absent layout_defaults and floating_window_aspect_ratio reset (the
latter to Standard although the static starts at Widescreen), an animation
block without fps resets fps, a global animation value clears its per-prefix
map and a map replaces the whole map.
No daemon uses the crate yet.
Verified: native cargo test -p komorebi-settings: 18 passed (9 handle, 9
shared: defaults per platform, default colours equal the komorebi-themes
conversion, keep-versus-reset per key, animation merge, motion_for);
clippy clean for the crate. The tests encode what apply_globals does as read
on wip-main; they were not run against the daemons.
New crate crates/komorebi-settings (workspace member, Cargo.lock +1
package, no new third-party dependency). Settings<P> is a shared part and a
platform part P; Handle<P> holds the current value as an Arc that readers
snapshot once per unit of work and writers replace through update (writers
serialised, one publish, nothing published if the edit panics). Handle::scoped
sets one field and restores the previous value on drop only if the field
still holds the value it set, replacing the save-and-restore store pairs in
the daemons (Windows WINDOW_HANDLING_BEHAVIOUR, KDE ANIMATION_ENABLED_GLOBAL).
Shared starts with the border and the per-platform defaults; the rest follows
in the next revision. See docs/dev/settings.md.
No daemon uses the crate yet.
Verified: native cargo test -p komorebi-settings: 9 passed (snapshot
isolation, concurrent updates lose nothing, no torn reads under a writer,
scoped restore and 'change made meanwhile wins'); clippy clean for the crate.
komorebi-config warns about an unused import when built without its schemars
feature (not touched here). KDE, macOS and Windows trees not touched.
The two komorebi_layout.rs were identical except for the position of one
`pub use`. The widget moves to
crates/komorebi-bar-core/src/widgets/komorebi_layout.rs together with the
KomorebiLayoutExt trait; the shells re-export the module. Its three
komorebi_client calls go through the platform seam: new hook
`BarPlatform::send_komorebi_message` (next to send_komorebi_batch), which
both os.rs implement as `komorebi_client::send_message`, so each bar sends
exactly what it sent. DefaultLayout and SocketMessage come from
komorebi-layouts and komorebi-protocol (what komorebi_client re-exports).
About 290 lines per bar are gone.
Verified: native bar-core tests 3+6; schema harness macOS and Windows
byte-identical (3,774 / 9,091 lines); Windows clippy -D warnings --locked
clean; macOS fake-CC check --locked 0 errors (files touched first). Not
run: the bars; clicking the layout widget is unverified on both.
Candidate for the Windows e2e gate: the Windows Backend switches and lock order (wip-u-kfw) with the macOS registry and Window methods (wip-u-kfm). Merge of two independent stacks that both touch crates/komorebi-backend; conflicts, if any, are resolved in this revision.
The (now identical) config.rs of both bars becomes
crates/komorebi-bar-core/src/config/komobar.rs; each shell config.rs is one
line, `pub use komorebi_bar_core::config::*;`. Import edits only: statics
from crate::statics, PathExt/SocketMessage from komorebi-protocol, Rect from
komorebi-layouts, the platform hooks and WidgetConfig as in the core. The
core gains komorebi-themes (KomobarTheme, Colour; schemars forwarded): one
line in each Cargo.lock. About 590 lines per bar are gone.
Because the configuration types are now all in the core, the oracle test
regenerates the macOS schema natively: the macOS view of
`schema_for!(KomobarConfig)` is byte-identical to
komorebi-for-mac/schema.bar.json (new test `generated`). Windows is still
compared by the out-of-tree harness: three descriptions in komorebi-protocol
and komorebi-themes read differently when compiled for Windows, which a
Linux test cannot do.
Verified: native bar-core tests 3 unit + 6 oracle (incl. the generated macOS
view); schema harness macOS and Windows byte-identical (3,774 / 9,091
lines); Windows clippy -D warnings --locked clean; macOS fake-CC check
--locked 0 errors (core files touched first). Not run: the bars.
The mouse code in config.rs called `crate::bar::exec_powershell` and
`komorebi_client::send_batch` directly, which ties config.rs to the Windows
shell. Two new hooks, `exec_shell_command(&str)` and
`send_komorebi_batch(Vec<SocketMessage>)`, carry them: Windows os.rs calls
exactly `crate::bar::exec_powershell` and `komorebi_client::send_batch`;
macOS os.rs forwards send_batch the same way and answers
exec_shell_command with an Unsupported error (the macOS bar has no shell
session, and its mouse block was commented out), which nothing calls yet.
Windows behaviour is unchanged (same calls); config.rs of Windows now only
depends on the platform seam.
Verified: Windows clippy -D warnings --locked clean; macOS fake-CC check
--locked 0 errors (files touched first). Not run: the bars.
The widget configuration enum moves to widgets/widget.rs of the core with
all thirteen variants (Keyboard, Media and Systray are no longer cfg-gated
or commented out per tree), plus `supported()`/`unsupported()`/`enabled()`
(enabled is now false for a widget the platform cannot run) and
`warn_unsupported`, which both shells call when they read the config. The
construction of the widget from its config (`as_boxed_bar_widget`, which
needs the runtime types) becomes the extension trait `WidgetConfigExt` in
each shell widget.rs; macOS builds a no-op `Unsupported` for the three
Windows-only widgets, which `enabled()` never lets through.
BEHAVIOUR (macOS), per D-coord-1: a macOS config with a `Keyboard`, `Media`
or `Systray` widget is now accepted and skipped with a logged warning ("the
Keyboard widget is not supported on this platform and is skipped"); before
it failed to deserialize (unknown variant), so the whole bar config was
rejected. Mac hand check: such a config starts the bar and logs the
warning. The macOS schema view removes the three variants from the
schema, so komorebi-for-mac/schema.bar.json and the nix options do not
change.
Verified: schema harness macOS and Windows byte-identical (3,774 / 9,091
lines); native bar-core tests 3+5; Windows clippy -D warnings --locked
clean (re-run after touching the files: Checking komorebi-bar-core and
komorebi-bar); macOS fake-CC check --locked 0 errors. Not run: the bars.
NetworkConfig, NetworkSelectConfig, InterfaceDisplayType and
DefaultInterfaceConfig move to widgets/network_config.rs (the macOS file had
the first two without default_interface_options). The union NetworkConfig
therefore also has `default_interface_options` on macOS. The macOS schema
view already removes it from the schema, and serde ignored the key before,
so reading a config is unchanged; the macOS network widget now logs a
warning when the key is set ("not supported on macOS and is ignored").
BEHAVIOUR (macOS): one new log line when `default_interface_options` is
configured; nothing else. Needs no gate beyond the Mac hand check listed in
docs/dev/macos-handcheck.md.
Verified: schema harness macOS and Windows byte-identical (3,774 / 9,091
lines; the macOS view is what removes the field); native bar-core tests
3+5; Windows clippy -D warnings --locked clean; macOS fake-CC check
--locked 0 errors.
The seven Komorebi*Config structs (komorebi.rs) and the KomorebiLayout enum
with its hand-written Deserialize and Display (komorebi_layout.rs) are data:
they move to crates/komorebi-bar-core/src/widgets/komorebi_config.rs, which
needs komorebi-layouts (DefaultLayout; schemars forwarded) and color-eyre
in the core: two lines in each Cargo.lock. The two shells re-export them.
The inherent impl of KomorebiLayout (is_default, on_click, show_icon, show,
the egui painting) cannot stay an inherent impl of a foreign type: it
becomes the extension trait `KomorebiLayoutExt` in each shell with the same
bodies; komorebi.rs imports the trait. Because the types are no longer in
the shell file, the two komorebi_layout.rs differ no more than the Windows
one; the macOS widget files keep their own komorebi.rs runtime.
Verified: schema harness macOS and Windows byte-identical (3,774 / 9,091
lines); native bar-core tests 3+5; Windows clippy -D warnings --locked
clean; macOS fake-CC check --locked 0 errors (core files touched first). I
reverted a stray `cargo fmt --all` that had reformatted unrelated files.
Not run: the bars.
KeyboardConfig, MediaConfig, SystrayConfig, OverflowTogglePosition,
ButtonPosition, FieldMatch and HiddenIconRule (pure data: serde and schemars
derives, no platform code) move from the Windows widget files to
crates/komorebi-bar-core/src/widgets/platform_config.rs, so that the next
revision can give WidgetConfig a variant for every widget. The Windows
widget files re-export them (`pub use`), so no other file changes; the
runtime halves (Win32, systray_util) stay in komorebi-bar. The core gains the
komorebi-config dependency (for MatchingStrategy; the schemars feature now
forwards to komorebi-config and komorebi-protocol); one line in each
Cargo.lock. Nothing on macOS refers to the types yet, so the macOS schema
cannot change. The schema harness (out of tree) no longer slices systray.rs
by line number.
Verified: schema harness macOS and Windows byte-identical (3,774 / 9,091
lines); native bar-core tests 3+5; Windows clippy -D warnings --locked
clean; macOS fake-CC check --locked 0 errors. Not run: the bars.
Move of the (now byte-identical) applications.rs of both bars to
crates/komorebi-bar-core/src/widgets/applications.rs. Edits: `PathExt` comes
from komorebi_protocol::pathext (what komorebi_client re-exports; it picks
%VAR% handling by target_os), `ImageIcon` from widgets::icons. The core
gains the komorebi-protocol (default features off) and tracing dependencies:
two lines in each Cargo.lock. Both bars re-export the module. 409 lines per
bar are gone. The schema harness now builds a copy of the core next to its
copy of komorebi-protocol (out of tree).
Verified: schema harness macOS and Windows byte-identical (3,774 / 9,091
lines); native bar-core tests 3+5; Windows clippy -D warnings --locked
clean; macOS fake-CC check --locked 0 errors. Not run: the bars.
The two applications.rs differed in how an application icon is found for a
command string. The shared file now asks the platform (new hook
`BarPlatform::command_icon(&str) -> Option<ImageIcon>`). Windows os.rs gets
the former `UserCommand::get_executable` logic verbatim (as the private
`executable_of`) and the windows-icons lookup; macOS returns None, exactly
what its commented-out version did. `1.0` vs `1.0_f32` unified. The two
files are now byte-identical. No schema text changes.
Known and preserved: `UserCommand::launch_if_ready` spawns `cmd /C <command>`
in both bars, so launching an application from the macOS bar is broken (it
was before).
Verified: schema harness macOS and Windows byte-identical; Windows clippy
-D warnings --locked clean; macOS fake-CC check --locked 0 errors. Not run:
the bars.
The icon cache (IconsCache, ICONS_CACHE, ImageIcon, ImageIconId,
rgba_to_color_image) was in widgets/mod.rs of both bars with two small
differences: Windows has `Hwnd(isize)`, `SystrayIcon(String)` and `remove`,
macOS has `WindowId(u32)` and a private rgba_to_color_image. The core file
is the Windows one with the macOS variant and `From<u32>` added (an enum
with every variant, as D26 does for WidgetConfig); both bars re-export the
items from widgets/mod.rs so no widget changes. The core gains the `image`
dependency (one line in each Cargo.lock) and a Default impl for IconsCache
(clippy).
Verified: schema harness macOS and Windows byte-identical (3,774 / 9,091
lines); native bar-core tests 3+5; Windows clippy -D warnings --locked
clean; macOS fake-CC check --locked 0 errors (re-run after touching the core
files). Not run: the bars.
Windows call sites read the frame about 60 times and rely on the Win32
error (or unwrap_or_default). The shared window_rect is built on window(id),
which also asks title, class, exe and path and gives None for every failure.
Add the provided method Backend::frame(id) -> Result<Rect>: WindowGone for
an unknown window, Platform for a failed read. The default goes through
window() (a table lookup on KDE through Shared<B> and on the fake, so the
cached/requested-rect semantics of seam.md section 2 row 2 are kept);
WindowsBackend overrides it with Window::window_rect (one DWM call) and
MacosBackend with MacosApi::window_rect (the two Accessibility reads, no
metadata). The contract tests check frame agrees with window().rect and is
WindowGone for an unknown id; FakeBackend gets a test. A provided method, so
no adapter had to change to compile.
Not a behaviour change (nothing calls it yet). Verified: tools/fast-check
(native crate tests pass, Windows clippy -D warnings, KDE check + lib tests,
macOS fake-CC type-check) PASS; macOS cannot be run here.
Pure move of the (now byte-identical) time.rs of both bars into
crates/komorebi-bar-core/src/widgets/time.rs; the only edit is the path of
Alignment. komorebi-bar-core gains the lazy_static dependency (TIME_RANGES);
Cargo.lock of the root and of komorebi-for-mac get that one line. Both bars
re-export the module. 541 lines per bar are gone.
Verified: schema harness: macOS byte-identical (3,774 lines), Windows
byte-identical (9,091 lines); native bar-core tests 3+5 passed; Windows
clippy -D warnings clean (--locked); macOS fake-CC check --locked 0 errors.
Not run: the bars.
Pure move of the (now byte-identical) storage.rs of both bars into
crates/komorebi-bar-core/src/widgets/storage.rs; the only edit is the path
of Alignment (crate::bar::Alignment -> crate::alignment::Alignment). Both
bars re-export it (`pub use komorebi_bar_core::widgets::storage`), so no
other file changes. 207 lines per bar are gone.
Verified: schema harness: macOS byte-identical (3,774 lines), Windows
byte-identical (9,091 lines); native bar-core tests 3+5 passed; Windows
clippy -D warnings clean; macOS fake-CC check 0 errors. Not run: the bars.
The two storage.rs differed in the click handler and in four doc strings.
The click now asks the platform (new SystemTool::StorageLocation(label)) and
each shell keeps exactly what it spawned: Windows `cmd.exe /C explorer.exe
<first word of the label>`, macOS `open <label without its last word>`. The
macOS doc strings take the Windows spelling (C:\, Local Disk); the macOS
schema view sets the macOS text back, so komorebi-for-mac/schema.bar.json
and nix/komorebi-bar-options.nix do not change.
Verified: schema harness S/bar2/regen.sh: macOS byte-identical (3,774
lines), Windows byte-identical (9,091 lines); the two storage.rs are now
byte-identical to each other; Windows clippy -D warnings clean; macOS
fake-CC check 0 errors. No click was exercised (cannot here).
Both bars now print `schema.bar.json` as the view of the generated union
schema (komorebi_bar_core::schema::generated_text): Windows through the
Windows view (the identity), macOS through the macOS view. The sources of
both bars are still separate, so the generated text is what it was and the
macOS changes set what is already there (they are idempotent); this is the
switch that lets the next revisions move code that differs only in schema
text into the core in the Windows spelling.
Verified: out-of-tree schema harness (S/bar2/regen.sh, real sources, bins
updated to call generated_text): macOS byte-identical to
komorebi-for-mac/schema.bar.json (3,774 lines), Windows byte-identical to
schema.bar.json (9,091 lines). Native bar-core tests 3+5 passed, Windows
clippy -D warnings clean, macOS fake-CC check 0 errors. The binaries were
not run (cannot on Linux).
Step 11(ii), the pure part. macOS cannot act on a window from its id: it
needs the Accessibility element, the pid and the observer. Registry<H> is
that table, generic over the handle so that its rules run on any host.
Rules, written at the top of registry.rs and tested: thread-safe; a
lookup clones the handle and releases the lock before anything is done to
it; a removed or replaced handle is handed back to the caller instead of
being dropped under the lock (dropping a macOS handle can make an AX round
trip, which must never happen with a lock held: seam.md 3.3); a stale or
unknown id is Error::WindowGone, never a panic; an entry ends on remove,
remove_pid (application quit) or a failed call; re-inserting replaces.
Nothing uses it yet; no daemon changes.
Verified: native cargo test -p komorebi-backend: 38 unit (9 new) + 7 doc
(1 new) + 1 compile_fail passed, 0 failed. Not run: the Windows, KDE and macOS
checks (the new module is std-only and no other file changed).
The Windows schema.bar.json is the union of the bar configuration (every
widget, the mouse options, Windows spelling). New module `schema` holds the
macOS view as data: 16 changes (set text/defaults that read differently,
remove the mouse property, the Keyboard/Media/Systray widget variants and
the NetworkConfig default_interface_options) followed by pruning of the
definitions nothing refers to any more. Same design as komorebi-config
(schema.rs, changes.rs); the changes are idempotent so a bar can print its
own generated schema through its view.
Nothing uses the views yet; no bar source changed.
Verified: native `cargo test -p komorebi-bar-core` 3 unit + 5 oracle passed
(new: the macOS view of the checked-in Windows file is byte-identical to
komorebi-for-mac/schema.bar.json; the Windows view is the Windows file; a
view is idempotent). Windows clippy -D warnings clean; macOS fake-CC check
0 errors. Not verified: nothing rendered.
The doc of Backend::focus said Windows and macOS do focus and then center_cursor_in; writing the adapters showed that Window::focus on both takes mouse_follows_focus and centres the pointer itself (Windows also defers the focus while the window slides in). Doc comment only.
Verified: see the gates below; native cargo test -p komorebi-backend passes (doctests unchanged).
komorebi_backend::contract: a Harness trait (how a test puts a live window on the desktop of the backend under test) and 14 checks, run by check_all::<H>(): windows listed by id; window agrees with windows/is_window/window_rect; an unknown window is not a window; every window command on an unknown or on a destroyed window fails with WindowGone naming that window; a destroyed window is neither alive nor listed; set_rect on a live window succeeds and the frame stays readable (a request: the value read is not checked); hide/restore tolerate repeats; focus names a known window; capabilities and Unsupported agree (supported means never Unsupported, unsupported means always Unsupported, with a live or unknown window); monitors are sane and found by point; Batch scopes nest around writes; the backend works from another thread; it is usable as a trait object.
Only what the Backend documentation promises is checked, because a write is a request and platforms act at different speeds. The fake passes under three configurations (plain, with a frame offset, with no capability at all, as macOS would be) and a deliberately broken backend (set_rect answers Ok for a gone window) is shown to fail exactly the two checks that cover it.
Verified: native cargo test -p komorebi-backend: 29 unit tests passed, 6 doctests passed, 1 compile_fail doctest passed, 0 failed; clippy --all-targets -D warnings clean.
The in-memory desktop of komorebi-for-kde (backend/fake.rs) moved into the shared crate, rewritten against WindowId/MonitorId/Result and the generic Backend only (look, border colours, wallpaper and drag frames stay out: they are KDE's).
Same behaviour as the KDE fake (permissive mode, minimum sizes, user_* helpers, maximize, fullscreen, workspaces, the ordered Command log with 15 of KDE's 18 variants; close() leaves the foreground window alone, as KDE's did), plus:
- failure injection: fail_next(Op, Error) and fail_next_for(Op, WindowId, Error), oldest first, one per call; the failed call is still logged as a command and changes nothing else (none existed on KDE);
- frame offsets: set_frame_offset / set_window_frame_offset make window_rect differ from the request by a constant, as the Windows shadow border does;
- capabilities: all four on by default, set_supported switches one off and its operations return Unsupported without being logged;
- batches: begin/end are counted (open_batches) and logged as BatchBegin/BatchEnd;
- FakeBackend<X>: a platform extension logs its own commands in order with record_ext (Command::Ext(X)); the shared fake is FakeBackend<NoExt> (new/permissive/with_one_monitor), an extension uses empty/permissive_ext/one_monitor because default type parameters are not inferred.
Verified: native cargo test -p komorebi-backend: 24 unit tests and 6 doctests passed, 0 failed (the KDE fake tests were ported and 6 failure/offset/capability/batch/extension tests added); clippy --all-targets -D warnings clean; cargo fmt applied.
New crate crates/komorebi-backend (edition 2024, root workspace member, depends only on komorebi-layouts for Rect).
- WindowId and MonitorId: opaque u64 newtypes. KDE and macOS ids convert with from_u32/to_u32; a Windows HWND/HMONITOR goes through from_hwnd/to_hwnd, which keep the bits of the isize unchanged (isize as usize as u64), so no handle is lost whether or not it fits in 32 bits (the e2e samples stay below 2^32, which is an observation, not a guarantee).
- WindowInfo and MonitorInfo: plain data; only id, pid, rect, minimized and alive are required, the rest (title, class, exe, path, fullscreen, maximized, normal; name and serial id of a monitor) are Option (seam.md consequence 6).
- Error: WindowGone(id) (finding 9: macOS uses a failed write as its signal that a window died), Unsupported(Capability) and Platform(cause).
- Backend: only the operations of seam.md section 2.1 that at least two platforms have (5 queries, 9 commands), a Capability query for workspaces, maximize, opacity and focus-follows-mouse (their methods default to Unsupported), begin_batch/end_batch with a no-op default plus the Batch guard (finding 8), the documented set_rect contract (a request; reads after a write return what the platform defines, consequence 2 as corrected) and the thread contract (any non-main thread, no waiting for the platform's main thread: consequences 3 and 4, written as TARGET rules). Every doc comment says which platforms implement the method.
Verified: native cargo test -p komorebi-backend (2 unit tests, 3 doctests, 0 failed) and cargo clippy -p komorebi-backend --all-targets -- -D warnings clean. The Windows/KDE/macOS gates are not affected yet (new crate, nothing depends on it).
Pure move of the three widget files that are byte-identical in the two bars since the previous revision. Each bar's widgets/mod.rs re-exports them (pub use komorebi_bar_core::widgets::memory / date / update). The core takes chrono, chrono-tz, reqwest (blocking) and serde_json (now a normal dependency, it was only a dev-dependency).
Removed: 541 lines from each bar (138 + 245 + 158), 541 added once.
Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors; native cargo test -p komorebi-bar-core 3 unit + 2 oracle passed; harness regeneration byte-identical for both (macOS 3,774 lines, Windows 9,091 lines). Not verified: rendering.
The click on the cpu widget (task manager) and on the battery widget (power settings) now calls platform().open_system_tool(...) instead of spawning cmd.exe in shared code. The Windows hook spawns the same commands as before; the macOS hook still spawns the same (broken there) cmd.exe commands, so neither platform's behaviour changes. Fixing macOS is now a change to one function of komorebi-for-mac/komorebi-bar/src/platform.rs.
Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors; native cargo test -p komorebi-bar-core 3 unit + 2 oracle passed; harness regeneration byte-identical for both. Not verified: that a click still opens the tool (no screen).
komorebi_bar_core::platform holds what the widgets need from the operating system and differs between the bars: BarPlatform { open_system_tool, latest_release_api_url, calendar_icon }, the SystemTool enum (task manager, power settings, network settings, a URL) and install()/platform(), a once-set global the shell fills first thing in main() (a widget calls platform() when it is clicked or built, never before main). Each bar gets an os.rs with its implementation (main.rs re-exports the core module as crate::platform, so shared files can say crate::platform::platform()): Windows spawns exactly the commands the widgets spawn today (cmd.exe /C taskmgr.exe, cmd.exe /C start ms-settings:batterysaver, cmd.exe /C ncpa, explorer.exe <url>); macOS maps TaskManager to open -a 'Activity Monitor' and network settings to open x-apple.systempreferences:... as memory.rs and network.rs do today, and keeps the commands the shared files spawn on macOS today for the rest (cmd.exe taskmgr.exe for cpu, cmd.exe start ms-settings:batterysaver for battery, explorer.exe for a URL), which are broken there: a one-line fix per tool in os.rs, not part of this change.
Nothing calls the hooks yet: the next revisions switch the widgets over, one concern each.
Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors (6 bar warnings, unchanged); native cargo test -p komorebi-bar-core 3 unit + 2 oracle passed; rustfmt --check clean on the new files and both main.rs. No widget calls the hooks yet, so no behaviour changes.
Pure move of the two widget files that are byte-identical in the Windows and macOS bars. Each bar's widgets/mod.rs re-exports them (pub use komorebi_bar_core::widgets::battery / cpu), so crate::widgets::battery::... resolves as before; the files themselves are unchanged.
Dependencies: the core takes sysinfo from the root workspace (0.39) and starship-battery 0.11, the versions the Windows bar already used. The macOS bar therefore now gets these two widgets built against sysinfo 0.39 (its own workspace pins 0.38, still used by its other widgets until they move) and starship-battery 0.11 (was 0.10; its own dependency on the crate is removed). Both compile unchanged; behaviour of the libraries is not verified on macOS.
Not changed on purpose: the macOS bug that these two files spawn cmd.exe (taskmgr.exe, explorer.exe) on click is still there, identically; it is fixed behind the platform hook, not inside a move.
Removed: 325 lines from each bar (191 + 134), 325 added once.
Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors (bar warnings 6, unchanged; macOS Cargo.lock: starship-battery 0.10.3 -> 0.11.1 with its dependencies (uom, plist, nix), sysinfo 0.39.6 added next to 0.38.4); native cargo test -p komorebi-bar-core 3 unit + 2 oracle passed; harness regeneration (S/bar2/regen.sh, which now fails when a harness does not build): macOS byte-identical (3,774 lines), Windows byte-identical (9,091 lines). Not verified: rendering, sysinfo and starship-battery behaviour on macOS.