repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

network: spec + sanitized iwctl fixtures for popup redesign

fbb879830781384897ff5fe7cc9cf8cad7848950

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Synthetic fixtures, byte-identical to real iwctl output format (ANSI
signal encoding, reset-at-line-start quirk, fixed-width columns, spaced
SSIDs). Plus edge cases: disconnected station, wifi-off device, empty
network list. No real MAC/BSSID/IP/neighbor SSIDs (repo pushes to GitHub).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (8)

+250 / −0 text lines

Diff layout

quickshell/nuguland/docs/superpowers/specs/2026-06-29-network-popup-redesign-design.md

Added
new file mode 100644

+190 / −0 text lines

1# Network (Connectivity) Popup Redesign
2
3**Date:** 2026-06-29
4**Status:** approved (autonomous — standing /goal "ultracode next are audio, bright, networn and power")
5**Popup:** 3 of 4 (audio ✅, brightness ✅, network ▶, power ⏳)
6
7## Problem
8
9`Network.qml` is a **hollow stub**: `hostNetworks()→[]`, `wifiOn()→true`,
10`scan/select/toggleWifi/forget/checkConnectivity` all no-op (set
11`error="…owned-by-iwd"`). The ConnectivityPanel renders Bluetooth (real,
12native `Quickshell.Bluetooth`) but the WiFi half shows nothing real.
14Host runs **iwd**, not NetworkManager. `Quickshell.Networking` is NM-only →
15**FORBIDDEN**. WiFi management must go through `iwctl` (the iwd CLI).
17## Goal
19Build real iwd WiFi management — scan / list / connect / forget / toggle —
20via `iwctl` Process calls plus a pure, node-tested parser. Keep the
21Bluetooth half working untouched. Apply the solid-dark washout fix to the
22WiFi view. Delete narration. Same architecture that shipped audio + brightness.
24## Architecture (the proven pattern)
26| Layer | File | Responsibility |
27|-------|------|----------------|
28| Pure logic | `network.js` | Parse raw `iwctl` text → plain data; shape/sort/role/label. NO I/O. Dual-mode export (node tests + QML import), like `clip.js`/`audio.js`/`brightness.js`. |
29| Service (native boundary) | `Network.qml` | Spawn `iwctl` via `Process`, feed stdout to `network.js`, hold model + cadence, expose IPC. |
30| View | `PopoutHost.qml` ConnectivityPanel | Pure graphical — WiFi list + connect flow + toggle; Bluetooth half unchanged. |
32**Native boundary rule (unchanged):** native objects (`Process`,
33`Quickshell.Bluetooth`) stay in QML. Only pure text-parsing / shaping /
34formatting moves to `network.js` as plain-data functions. Raw `iwctl`
35output (ANSI intact) is passed to `network.js`; **QML never pre-strips
36ANSI** — signal strength is encoded in it.
38## iwctl command surface
40Device name is **discovered** (`iwctl device list` → first `station`-mode
41device), never hardcoded `wlan0`.
43```
44list devices: iwctl device list
45list networks: iwctl station <dev> get-networks
46station state: iwctl station <dev> show
47known nets: iwctl known-networks
48scan (async): iwctl station <dev> scan # returns immediately
49connect known/open: iwctl station <dev> connect <ssid>
50connect new psk: iwctl --passphrase <pp> station <dev> connect <ssid>
51forget: iwctl known-networks <ssid> forget
52toggle wifi: iwctl device <dev> set-property Powered on|off
53disconnect: iwctl station <dev> disconnect
54```
56### Async scan (must not look broken)
58`scan` returns immediately; `get-networks` does **not** reflect new results
59for ~1–4 s. So:
60- `scan()` sets a real `scanning` state, spawns the scan, then re-reads
61 `get-networks` on a delayed/polled Timer (≈2 s, a couple of retries).
62- `"Operation already in progress"` on stderr = scan-in-progress, **not** a
63 hard error → keep `scanning=true`, don't surface as error.
65## `network.js` — pure parser API (node-tested against fixtures)
67Fixtures: `test-fixtures/iwctl/*.txt` (synthetic, byte-identical to real
68`iwctl` format — ANSI resets carried to line starts, fixed-width columns,
69signal bars as bright-`*` then grey-`\x1b[1;90m*\x1b[0m`).
71```
72parseDevices(raw) -> [{ name, address, powered:bool, mode }]
73 deviceForStation(devices) -> first mode==="station" name
74parseNetworks(raw) -> [{ ssid, security, signal:0..4, connected:bool }]
75parseStation(raw) -> { scanning:bool, state, connectedNetwork, ipv4, security, rssi }
76parseKnown(raw) -> [{ ssid, security }]
77```
79Shaping / view helpers (pure):
80```
81mergeNetworks(networks, known, station) -> enrich each net:
82 { ...net, known:bool, connected:bool, needsPassphrase:bool }
83needsPassphrase(security, known) -> security!=="open" && !known
84signalRole(bars) -> "ui.minor" (≤1) | "ui.accent" (2–3) | "content.accent" (4)
85signalGlyph(bars) -> nerd-font wifi glyph by strength
86securityLabel(sec) -> "open" -> "Open", "psk" -> "WPA", "8021x" -> "Enterprise"
87networkId(ssid) -> stable id (ssid itself; never empty)
88sortNetworks(list) -> connected first, then signal desc, then ssid asc
89```
91### Parser correctness facts (bake into tests)
93- **Signal bars** = count of bright `*` *before* the first
94 `\x1b[1;90m` grey marker in the signal column; if no grey marker, all 4
95 bright. Fixture rows: `home-wifi`→2, `home-wifi-5g`→4,
96 `Cafe Guest WiFi`→3, `Reading Room`→2, `Neighbor 2G`→1.
97- **Names contain spaces** (`Cafe Guest WiFi`, `Reading Room`) → fixed-column
98 slice (visible cols: name 6–39, security 40–59, signal 60+), NOT
99 whitespace split. Strip ANSI for name/security columns only.
100- **Connected marker** = visible `> ` at cols 2–3 (`home-wifi` is connected).
101- **Leading `\x1b[0m`**: the first data row begins with a stray reset
102 (iwctl carries the previous line's reset to the next line's start) — must
103 not break lead/marker detection.
104- **Edge fixtures must not throw**: `station-show-disconnected.txt`
105 (no Connected network / RSSI lines), `device-list-off.txt`
106 (`Powered off`), `get-networks-empty.txt` (header only, zero rows).
108`network.test.js` prints `network.test.js: ALL PASS`, asserts the specific
109rows above + every edge fixture.
111## `Network.qml` — service
113- Replace all stub bodies with real `Process`-driven impls.
114- Discover device once on load; cache name.
115- `refresh()`: run `device list`, `get-networks`, `known-networks`,
116 `station show`; parse each; `mergeNetworks` → model.
117- `scan()`: spawn scan, set `scanning`, delayed re-`refresh()`.
118- `connect(ssid, passphrase)`, `forget(ssid)`, `toggleWifi(on)`,
119 `disconnect()` — all real.
120- Preserve the IPC contract (consumed by `shell.qml` IpcHandlers /
121 `stateJson`): `stateJson`, `scan`, `select`/`connect`, `toggleWifi`,
122 `forget`, `checkConnectivity`. Add `selfTest()` (runs parser over fixtures
123 inline? no — fixtures aren't shipped to runtime; `selfTest()` runs the
124 pure functions over small inline literals, like audio/brightness).
125- **Delete narration**: `connectivityPanelContract()`, backend metadata
126 (`usesNativeQuickshellNetworking`, `hostStack`, `nativeApi`, …), the
127 `network-mini-graph` shader descriptor.
129### Security (HARD — written normal, not caveman)
131- All `iwctl` invocations use **discrete argv** arrays
132 (`["iwctl","--passphrase",pp,"station",dev,"connect",ssid]`). NEVER
133 `sh -c "…interpolated…"`: SSIDs may contain spaces, quotes, and shell
134 metacharacters → command injection. (Contrast brightness, which uses
135 `sh -c` on a trusted device path; here the inputs are untrusted.)
136- The passphrase MUST NEVER enter `stateJson`, `lastAction`, `error`, or any
137 log line. It exists only as a transient argument to the connect call.
138- Known tradeoff: `iwctl --passphrase <pp>` is briefly visible in
139 `ps`/`/proc/<pid>/cmdline`. Acceptable on a single-user laptop;
140 documented here. (Zero-leak alternative = iwd DBus agent; out of scope —
141 its stdin prompt is tty-bound and unreliable when piped.)
143## View — ConnectivityPanel (WiFi half only; Bluetooth untouched)
145- **Washout fix** (memory `nuguland-popup-frame-light-washout`): popup frame
146 is light. Never tint the card fill with low-alpha accent — it bleeds white.
147 Solid dark base `theme.withAlpha(theme.ui.backdrop, 0.55)`
148 (connected/selected ≈0.82); identity via a thin accent bar + border;
149 signal/role color on the bar + glyph, not the fill.
150- Header row: `WiFi [on/off toggle] [scan ⟳]` (scan spins while `scanning`).
151- Network rows (sorted): glyph (signal) • ssid • security/connected label •
152 action. Connected row gets `[forget]`; others `[connect]`.
153- **Connect flow (stateful — spell out so secured connect doesn't silently
154 fail):**
155 - **open** network → `[connect]` calls connect directly (no passphrase).
156 - **known** network (iwd has the secret) → `[connect]` calls connect
157 directly.
158 - **new secured** network (`needsPassphrase`) → tapping `[connect]` reveals
159 an inline passphrase field + confirm; confirm calls
160 `connect(ssid, passphrase)`. Field is `echoMode: TextInput.Password`,
161 cleared immediately after submit, never bound into any state object.
162- Bluetooth half: render exactly as today (native `Quickshell.Bluetooth`).
163 No regression.
165## Verification (controller does, after build — NOT subagents)
1671. `node network.test.js` → ALL PASS.
1682. `rm -rf ~/.cache/quickshell/qmlcache` → restart `quickshell.service`.
1693. `journalctl --user -u quickshell.service` → no errors.
1704. `qs -c nuguland ipc call nuguland networkSelfTest` → all pass.
1715. Open connectivity popout → screenshot → crop → Read; verify WiFi list,
172 signal glyphs, connected marker, solid-dark cards, Bluetooth intact.
1736. **Live state-change ops (controller only, deliberate):** verify
174 scan refreshes the list; toggle off→on; connect to a known/open net;
175 confirm Bluetooth unaffected. Subagents MUST NOT run any state-changing
176 `iwctl` op during the build — fixtures only.
178## Subagent safety (bake into every workflow prompt)
180- Build + node-test against **fixtures only**. DO NOT execute `connect`,
181 `disconnect`, `scan`, `set-property Powered off`, or `forget` against the
182 live device during the build — a subagent dropping WiFi or powering the
183 radio off mid-run is a real failure mode.
184- Verify the Bluetooth half still uses native `Quickshell.Bluetooth` and is
185 not refactored or broken by shared-panel edits.
187## Out of scope
189NM / `Quickshell.Networking` (forbidden — iwd host). iwd DBus agent. VPN.
190Wired/ethernet config. Per-network advanced settings.

quickshell/nuguland/test-fixtures/iwctl/device-list-off.txt

Added
new file mode 100644

+6 / −0 text lines

1 Devices 
2--------------------------------------------------------------------------------
3 Name Address Powered Adapter Mode
4--------------------------------------------------------------------------------
5 wlan0 00:11:22:33:44:55 off phy0 station
6

quickshell/nuguland/test-fixtures/iwctl/device-list.txt

Added
new file mode 100644

+6 / −0 text lines

1 Devices 
2--------------------------------------------------------------------------------
3 Name Address Powered Adapter Mode
4--------------------------------------------------------------------------------
5 wlan0 00:11:22:33:44:55 on phy0 station
6

quickshell/nuguland/test-fixtures/iwctl/get-networks-empty.txt

Added
new file mode 100644

+5 / −0 text lines

1 Available networks 
2--------------------------------------------------------------------------------
3 Network name Security Signal
4--------------------------------------------------------------------------------
5

quickshell/nuguland/test-fixtures/iwctl/get-networks.txt

Added
new file mode 100644

+12 / −0 text lines

1 Available networks 
2--------------------------------------------------------------------------------
3 Network name Security Signal
4--------------------------------------------------------------------------------
5 >  home-wifi psk ****
6 home-wifi-5g psk ****
7 Cafe Guest WiFi open ****
8 City Hotspot open ****
9 Reading Room open ****
10 Neighbor 2G psk ****
11 skynet-guest psk ****

quickshell/nuguland/test-fixtures/iwctl/known-networks.txt

Added
new file mode 100644

+7 / −0 text lines

1 Known Networks 
2--------------------------------------------------------------------------------
3 Name Security Hidden Last connected
4--------------------------------------------------------------------------------
5 home-wifi-old psk Jun 8, 10:42 AM
6 home-wifi psk Jun 28, 6:12 PM
7

quickshell/nuguland/test-fixtures/iwctl/station-show-disconnected.txt

Added
new file mode 100644

+7 / −0 text lines

1 Station: wlan0 
2--------------------------------------------------------------------------------
3 Settable Property Value
4--------------------------------------------------------------------------------
5 Scanning no
6 State disconnected
7

quickshell/nuguland/test-fixtures/iwctl/station-show.txt

Added
new file mode 100644

+17 / −0 text lines

1 Station: wlan0 
2--------------------------------------------------------------------------------
3 Settable Property Value
4--------------------------------------------------------------------------------
5 Scanning no
6 State connected
7 Connected network home-wifi
8 IPv4 address 192.168.50.20
9 IPv6 address fd00:dead:beef:0:0011:22ff:fe33:4455
10 ConnectedBss 00:11:22:33:44:55
11 Frequency 2412
12 Channel 1
13 Security WPA2-Personal
14 RSSI -69 dBm
15 AverageRSSI -68 dBm
16 ConnectedTime 43160 s