1 +#
Launcher Popup Redesign — Design Spec 4 +**Status:** Approved (owner-delegated, autonomous)
5 +**Goal:** Turn the text-glyph, narration-heavy launcher into a fast graphical result list with **real application icons**, stronger fuzzy matching, and pure node-tested ranking logic — same architecture as the system/clipboard/caldav work.
9 +##
1. Problems with the current launcher 11 +- **No real app icons.** Each app desktop entry carries an `icon` name (`e.icon`), and `buildApps` already plumbs it into the row, but the view renders `String(row.iconRole).slice(0,2)` — two letters of text — instead of the actual themed icon. The single biggest visual miss.
12 +- **Weak matching.** `fuzzyScore` only does exact / prefix / substring. "frfx" will not find "firefox"; "sysmon" will not find "System Monitor". No real subsequence fuzzy match.
13 +- **Logic tangled in QML, untested.** `normalize`, `prefixIntent`, `fuzzyScore`, `calculatorValue`, `rowVerb`, `rowIconRole`, `shapeRow`, `buildApps`, `windowRows`, ranking — all pure, all stuck in `Launcher.qml`, none node-tested.
14 +- **Narration bloat.** `launcherPanelContract()`, `scrollableListChrome()`, `launcherPreviewPanel()` and `previewActionRows()` serialize large self-describing metadata blobs (`"source": "Nuguland SearchResults.qml ..."`, `sidePanelWidth`, `scrollEdgeFade`, `flickMonitor`, `velocitySamples`) that the view reads back to decide chrome. Dead weight — delete.
15 +- **Side preview panel (386px) is dead space.** A fixed second panel that re-states the selected row's title/subtitle/action verbs. The result row already shows that. Squeezes the actual result list to `parent.width - 396`. Remove.
19 +##
2. Decisions (locked) 23 +| Architecture | Pure `launch.js` (node-tested, dual-mode export, no I/O) + thin `Launcher.qml` (gathers apps/windows/clip rows, performs I/O actions) + pure view — mirrors `sysinfo.js`/`clip.js`/`caldav.js`. |
24 +| Matching | **Subsequence fuzzy** in `fuzzyScore`: exact (+1000), prefix (+800−len), word-boundary subsequence (high), loose subsequence (low), substring fallback, else −1. Contiguous + start-of-word runs score higher. |
25 +| App icons | App rows render the **real themed icon** via `Quickshell.Widgets.IconImage` / `Quickshell.iconPath(row.icon, true)` as an `Image`; fall back to the app Nerd Font glyph when the name resolves empty. |
26 +| Provider glyphs | Non-app providers use verified Nerd Font glyphs (Symbols Nerd Font Mono), written as `\uXXXX`: app `` (rocket, fallback), action `` (gear), calculator ``, clipboard ``, window ``. |
27 +| Providers | Keep app / action / calculator / clipboard / window with prefix intents: `=` calculator, `>` action, `clip ` clipboard, else all. Keep calculator `Function()` eval behind the existing regex guard. |
28 +| Layout | Single full-width result list of rounded cards (no side panel, no provider chips). Leading icon slot (real app icon or provider glyph) · title · muted `verb · subtitle` meta. Selected row tinted `ui.focus`; others tinted by provider color. |
29 +| Calculator row | When the query is a calculator expression, the top row shows the expression and the **big computed value**; Enter copies the value (existing `wl-copy` path). |
30 +| Search field | Keep the docked search field + keyboard nav (`↑↓ select · Enter activate`). Restyle to the dark-card aesthetic. Drop the narration-driven scroll-hint string. |
31 +| Removed | `launcherPanelContract()`, `scrollableListChrome()`, `launcherPreviewPanel()`, `previewActionRows()`, the side preview panel, provider chips, and the matching narration fields in `stateJson()` / `search()`. |
32 +| IPC contract | Keep `stateJson()`, `search(q)`, `activate(rowJson)`, `activateFirst`, `activateId`, `launchRecord(rowJson)`, `hotkey`. Add `selfTest()`. The `search()` return keeps `{query, providerIntent, selectedIndex, results}` (drop the narration keys). |
33 +| Activation | Keep all I/O behavior: app launch via `uwsm app -s a/w` (desktop id), window focus via niri, calculator/clip via `wl-copy`, action via `runAction` (niri overview/screenshot/color, lock). Keep `rememberActivation` telemetry (stores `launchRecords`/`lastInteraction` only — it does **not** feed scoring, so ranking stays a pure function of query + static per-provider boost; do not add a usage input to `rankResults`). |
39 +###
3.1 `launch.js` (new — pure, node-tested) 41 +- `prefixIntent(raw) → {intent, query}` — `=`→calculator, `>`→action, `clip `→clipboard, else `all`; strips the prefix from `query`.
42 +- `fuzzyScore(query, title, boost) → number` — subsequence-aware ranking (see Decisions). `boost` adds a per-provider weight. Returns −1 on no match.
43 +- `calculatorValue(expr) → string|null` — regex-guards `[0-9+\-*/(). %]` then `Function("return ("+expr+")")()`; null on guard fail / non-finite.
44 +- `rowVerb(provider, row)`, `rowIconRole(provider, row)`, `providerGlyph(provider)`.
45 +- `shapeRow(row, provider, score) → row` — adds provider/verb/iconRole/glyph/score/keyboard; preserves `icon` (desktop icon name) for apps.
46 +- `buildApps(entries) → rows` — maps DesktopEntry objects (keep current field mapping incl. `icon`), sorted by title.
47 +- `rankResults(query, {apps, actions, windows, clipRows}) → {results, selectedIndex, providerIntent, calc}` — the pure ranking core: applies `prefixIntent`, scores each provider's rows, filters `score < 0`, sorts by score desc then title, computes calculator row, returns capped list.
48 +- Dual-mode export tail (guarded `module.exports`), identical pattern to `clip.js`.
50 +###
3.2 `launch.test.js` (new — node) 51 +Assert: `prefixIntent` for each prefix; `fuzzyScore` exact > prefix > word-boundary subsequence > loose subsequence > −1, and "frfx"→"firefox" matches while "zzz"→"firefox" is −1; `calculatorValue` evaluates `2+2`→`4`, rejects `a()`/`x=1`; `buildApps` sorts + carries `icon`; `rankResults` ranks an exact app title to `selectedIndex 0`, honors `>` action intent, honors `clip ` intent, emits a `calc` row for `=2*21`. Prints `ALL PASS`.
53 +###
3.3 `Launcher.qml` (reworked — thin) 54 +- Imports `launch.js`; delegates all parsing/scoring/ranking.
55 +- Keeps: `apps` from `DesktopEntries`, `niriService.windows`, `clipboardService.launcherRows(q)`, the `actions` array, and all I/O in `activate`/`runAction`/`launchRecord`/`rememberActivation`/`activateFirst`/`activateId`/`hotkey`.
56 +- `search(raw)` builds the input bundle and returns `launch.rankResults(...)` serialized to `{query, providerIntent, selectedIndex, results}`.
57 +- Adds `selfTest()` (fixtures through launch.js: prefixIntent, fuzzyScore ordering, calculatorValue, rankResults) returning `{pass, fail, cases}`.
58 +- Deletes `launcherPanelContract`, `scrollableListChrome`, `launcherPreviewPanel`, `previewActionRows`, `recordWheelSelection` narration, and the narration `stateJson` fields (`backend`, `wheelTrace`, `desktopEntrySource`, `fakeApps`, etc).
60 +###
3.4 `PopoutHost.qml` `LauncherPanel` (rewrite) 61 +- Drop the `Row` split + 386px side panel + provider chips. Full-width `Column`/`Flickable` of result cards.
62 +- `ResultRow`: leading 32px slot = real app `IconImage` (app provider, `row.icon`) **or** provider Nerd Font glyph; title (`NuguText`); muted `verb · subtitle` meta. Selected row tinted `ui.focus`, border `ui.focus`; others provider-tinted.
63 +- Calculator result row: expression small, value large + monospace.
64 +- Keep `setQuery`/`select`/`wheelSelect` keyboard+wheel nav; drop `launcherPreviewPanel`/`scrollableListChrome` calls. Bottom search field + simplified `↑↓ select · Enter activate` hint.
66 +###
3.5 `SurfaceManager.qml` 67 +- Keep the `"launcher"` popup size (`heightBudget(560)`); width already full. No narration catalog changes needed beyond dropping any launcher narration strings if present.
72 +- Icon name resolves empty / image load fails → fall back to provider Nerd Font glyph.
73 +- `calculatorValue` guard fail or non-finite → no calc row (query falls through to app/all matching).
74 +- `clipboardService.launcherRows` throws / missing service → empty clip rows (keep current try/catch).
75 +- `niriService.windows` absent → empty window rows.
76 +- Empty query → apps listed (sorted), `selectedIndex 0`.
79 +- `node launch.test.js` → `ALL PASS`.
80 +- `qs ipc call nuguland launcherState` / a dedicated `selfTest` IPC → pass counts (after `rm -rf ~/.cache/quickshell/qmlcache` + restart).
81 +- Manual: restart, open launcher, screenshot — verify real app icons render, "frfx" finds Firefox, `=2*21` shows `42`, `>` lists actions, `clip ` lists clipboard rows, ↑↓ selects.
84 +- New providers (emoji, files, web search).
85 +- Usage-aware ranking (none exists today; `rememberActivation` is telemetry-only — do not add it).
86 +- Multi-column / grid layout.