Search across containers, volumes and images #21

Closed
opened 2026-11-30 14:39:43 +00:00 by jfro · 1 comment
Owner

What

  • A global search (Ctrl+K or the sidebar) that matches containers, compose projects, volumes, images (and networks once #12 lands), and jumps to the item.
  • Reuse the existing per-page search fields.
**What** - A global search (Ctrl+K or the sidebar) that matches containers, compose projects, volumes, images (and networks once #12 lands), and jumps to the item. - Reuse the existing per-page search fields.
jfro added this to the v1.0 milestone 2026-11-30 14:47:14 +00:00
Author
Owner

Design notes for #21 from Nye (research, tested on Qt 6.8):

Shape: a Ctrl+K palette (SearchPalette.qml, a modal Popup near the top of the window) plus a "Search Ctrl+K" entry at the top of the sidebar that opens it. Type to filter, Up/Down to move, Enter to jump, Escape to close. Results are grouped by kind (Projects, Containers, Volumes, Images, Networks), with up to 6 per kind and a "Show all N in " row.

Tested: a QML Shortcut { sequences: ["Ctrl+K"] } in an ApplicationWindow fires even while a TextField has focus. Qt 6.8 TextInput doesn't take Ctrl+K as delete-to-end, and the field's text stays as it was. So no Keys handlers are needed. Use the window-level Shortcut (default context WindowShortcut).

Data: no new Rust. Everything is already parsed in QML:

  • Projects/containers: window.groups / window.byKey (Main.qml l.24-52). Keys: stack:<project>, container:<id>.
  • Volumes: volumesPage.volumes (from ContainerModel.volumes_json). Key volume:<name>.
  • Images: imagesPage.images. Key image:<id>.
  • Networks: from #12's page, once it lands. Either stack #21 on #12's branch or add networks as the last commit.

Matching: reuse the per-page search. Move ResourceList.matches() (l.38-47) and ContainerList.matches() (l.27-31) into one ui/qml/search.js (.pragma library, matches(item, fields, q)). The pages and the palette then use the same function and fields: containers title/name/image/project; volumes name/driver/project; images repo/tags/shortId; networks name/driver. List the .js in build.rs if qml files are listed there (check that cxx-qt's qml_module takes a qml_files .js; if not, put the function in a small Search.qml singleton like Theme). Ranking: exact > prefix > word-start > substring, then running before stopped, then name.

Jump (the fiddly part):

  1. Containers/projects: the existing select(key) (Main l.290). If the container is inside a collapsed stack, expand it first (ContainerList.collapsed l.14: expose an expand(stackKey)).
  2. Volumes/images: set page, then volumesPage.selectedKey / imagesPage.selectedKey (Main already does this in its screenshot scenes, l.356/361).
  3. Clear the target page's search field if the item doesn't match it. Otherwise the selected row is filtered out and the detail shows with no highlighted row. Expose clearSearch() on ResourceList/ContainerList.
  4. Scroll into view: ResourceList has no scroll on an outside selection change (only moveSelection scrolls). Add onSelectedKeyChanged: positionViewAtIndex(..., ListView.Contain) to both lists.
  5. "Show all N in Images" sets that page's search text to the query (this is the "reuse per-page search fields" part of the issue) and switches page.

Must-dos for review:

  • Ctrl+K works from any page, with focus in a page search field, in a log view, and while a Dialog is open. In that last case, either block it or close the dialog; don't stack popups.
  • Jumping to: a child of a collapsed stack, an item hidden by the current page filter, an item far down the list (scrolls), and a stopped container.
  • Results update live if a container disappears while the palette is open, with no stale key jump. Guard with byKey[key] before selecting.
  • Empty query shows recent items or nothing (pick one; I'd show nothing plus a hint). There's no network or engine call per keystroke.
  • Mock: a search screenshot scene (palette open with "shop": project + 4 containers + volume shop_db + image), README features list updated.
  • Escape closes the palette and puts focus back where it was.
Design notes for #21 from Nye (research, tested on Qt 6.8): ## #21 Global search — recommended approach (Nye, Nov 30) **Shape:** a Ctrl+K palette (`SearchPalette.qml`, a modal `Popup` near the top of the window) plus a "Search Ctrl+K" entry at the top of the sidebar that opens it. Type to filter, Up/Down to move, Enter to jump, Escape to close. Results are grouped by kind (Projects, Containers, Volumes, Images, Networks), with up to 6 per kind and a "Show all N in <page>" row. **Tested:** a QML `Shortcut { sequences: ["Ctrl+K"] }` in an ApplicationWindow fires even while a TextField has focus. Qt 6.8 TextInput doesn't take Ctrl+K as delete-to-end, and the field's text stays as it was. So no Keys handlers are needed. Use the window-level Shortcut (default context WindowShortcut). **Data: no new Rust.** Everything is already parsed in QML: - Projects/containers: `window.groups` / `window.byKey` (Main.qml l.24-52). Keys: `stack:<project>`, `container:<id>`. - Volumes: `volumesPage.volumes` (from `ContainerModel.volumes_json`). Key `volume:<name>`. - Images: `imagesPage.images`. Key `image:<id>`. - Networks: from #12's page, once it lands. Either stack #21 on #12's branch or add networks as the last commit. **Matching: reuse the per-page search.** Move `ResourceList.matches()` (l.38-47) and `ContainerList.matches()` (l.27-31) into one `ui/qml/search.js` (`.pragma library`, `matches(item, fields, q)`). The pages and the palette then use the same function and fields: containers title/name/image/project; volumes name/driver/project; images repo/tags/shortId; networks name/driver. List the .js in build.rs if qml files are listed there (check that cxx-qt's qml_module takes a qml_files .js; if not, put the function in a small `Search.qml` singleton like Theme). Ranking: exact > prefix > word-start > substring, then running before stopped, then name. **Jump (the fiddly part):** 1. Containers/projects: the existing `select(key)` (Main l.290). If the container is inside a collapsed stack, expand it first (`ContainerList.collapsed` l.14: expose an `expand(stackKey)`). 2. Volumes/images: set `page`, then `volumesPage.selectedKey` / `imagesPage.selectedKey` (Main already does this in its screenshot scenes, l.356/361). 3. **Clear the target page's search field** if the item doesn't match it. Otherwise the selected row is filtered out and the detail shows with no highlighted row. Expose `clearSearch()` on ResourceList/ContainerList. 4. **Scroll into view:** ResourceList has no scroll on an outside selection change (only `moveSelection` scrolls). Add `onSelectedKeyChanged: positionViewAtIndex(..., ListView.Contain)` to both lists. 5. "Show all N in Images" sets that page's search text to the query (this is the "reuse per-page search fields" part of the issue) and switches page. **Must-dos for review:** - Ctrl+K works from any page, with focus in a page search field, in a log view, and while a Dialog is open. In that last case, either block it or close the dialog; don't stack popups. - Jumping to: a child of a collapsed stack, an item hidden by the current page filter, an item far down the list (scrolls), and a stopped container. - Results update live if a container disappears while the palette is open, with no stale key jump. Guard with `byKey[key]` before selecting. - Empty query shows recent items or nothing (pick one; I'd show nothing plus a hint). There's no network or engine call per keystroke. - Mock: a `search` screenshot scene (palette open with "shop": project + 4 containers + volume `shop_db` + image), README features list updated. - Escape closes the palette and puts focus back where it was.
jfro closed this issue 2026-11-30 21:27:49 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/krane#21
No description provided.