Skip to content

Add --layout filter flag to list-windows - #2217

Open
YuriNachos wants to merge 1 commit into
nikitabobko:mainfrom
YuriNachos:YuriNachos/w5-AeroSpace
Open

Add --layout filter flag to list-windows#2217
YuriNachos wants to merge 1 commit into
nikitabobko:mainfrom
YuriNachos:YuriNachos/w5-AeroSpace

Conversation

@YuriNachos

@YuriNachos YuriNachos commented Aug 8, 2026

Copy link
Copy Markdown

Closes #429.

Summary

Adds a --layout <layout> filter flag to list-windows, so the command prints only the windows whose effective layout matches — e.g. list-windows --layout floating to list only floating windows (the scratchpad use case from #429).

Problem

list-windows currently dumps every window across the target workspaces. #429 asks for a way to filter by the window's effective layout — floating windows in particular — which is useful for scripting and for inspecting how AeroSpace assigned windows to layouts.

Changes

  • ListWindowsCmdArgs.swift — new --layout <target-layout> argument. It accepts the same layout tokens the layout command uses (floating, tiling, tiles, accordion, horizontal, vertical, h_tiles, v_tiles, h_accordion, v_accordion); an invalid token fails with Can't parse '--layout' argument. Possible values: ….
  • format.swift — new windowMatchesLayout predicate. It derives the window's effective layout through the same getChildParentRelation source of truth that backs the %{window-layout} interpolation variable, so --layout floating keeps exactly what %{window-layout} prints as floating. The family tokens are inclusive: tiling matches every tiling variant, tiles/accordion match the layout family, horizontal/vertical match the orientation, and h_*/v_* match exactly. Windows with no parent or with an illegal/native/popup parent relation match nothing.
  • ListWindowsCommand.swift — applies the filter before the count/format stage, so --count counts only the matching windows too.
  • ListWindowsTest.swift — new testParseLayoutFilter (valid tokens parse; an invalid token is rejected with the documented error) and testRunFilterByLayout (one tiling and one floating window in a workspace; each filter returns only the matching window id). Behavior without the flag is unchanged.

Testing

  • ./test.sh (build + test + lint + generate) — all tests passed.
  • The new tests assert the filter returns only matching windows and that omitting the flag preserves the previous output.

Notes

Live end-to-end verification against real windows needs Accessibility permission and a running session; it is not exercised by the headless gate. The unit tests cover the filter logic; the build + lint + generate gate covers compilation.

`list-windows` had no way to filter windows by their effective layout, so
users could not list floating windows for scratchpad-style workflows
(nikitabobko#429).

Add a `--layout <target-layout>` sub-filter that accepts the same tokens as
the `layout` command (accordion|tiles|horizontal|vertical|h_accordion|
v_accordion|h_tiles|v_tiles|tiling|floating) and keeps only windows whose
effective parent-container layout matches. Matching reuses the same
`getChildParentRelation` source of truth as the `%{window-layout}`
interpolation variable: `floating` keeps exactly what that variable reports
as `floating`, while the abstract tokens generalize over the
orientation-specific variants it prints (`h_tiles` etc.) — `tiling` matches
every tiling variant, `tiles`/`accordion` the layout family,
`horizontal`/`vertical` the orientation, and `h_*`/`v_*` exactly.
Native-fullscreen/minimized/hidden/popup windows match no token.

`--layout` composes with `--workspace`/`--monitor`/`--focused`/`--all`
exactly like `--pid`/`--app-bundle-id`.

Verification is limited to the build, swift tests (two new ListWindowsTest
cases), the CLI smoke and strict lint under `./test.sh`; live end-to-end
against running windows with Accessibility permission was not exercised.

nikitabobko#429
@nikitabobko nikitabobko added the not-actionable By default, all PRs have this label. If the PR makes sense, the label will be removed. label Aug 10, 2026
@YuriNachos

Copy link
Copy Markdown
Author

This adds the --layout filter to list-windows from #429, reusing the existing effective-layout derivation so the flag filters exactly what the command prints. Given the project's habit of shaping features in Discussions first, is the interface as implemented (regex argument named --layout) acceptable, or would you prefer to weigh the design in a Discussion before it merges? I'm happy to open one or adjust the flag shape either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not-actionable By default, all PRs have this label. If the PR makes sense, the label will be removed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: implement list-windows --layout

2 participants