Add omni search: ranked mixed results in the TUI and CLI

Back the TUI "/" popup with the server's search command and add a matching
pipelines search CLI command.

- protocol: SearchRequest/SearchResponse and per-kind SearchResult payloads,
  one shared Label for the six-kind badge dispatch and RuneIndexFold for
  case-insensitive matching.
- pipeline: the read-only, ranked, bounded Store.Search implementation.
- cli: search QUERY [--type KIND] [--limit N] [--json], printing the shared
  label plus a text-field snippet when present.
- tui: type to search, up/down to choose, Enter to open and Esc to cancel over
  one mixed ranked list, with short type badges and a bracketed non-colour
  match marker; Enter navigates to the matched pipeline, run, step, field
  section or artifact entry.
- tests: protocol and TUI coverage, including an env-gated live test against
  the running server.
This commit is contained in:
2026-10-16 23:03:17 +01:00
parent aac1be18cc
commit 80232a4ffe
7 changed files with 1697 additions and 32 deletions
+36 -1
View File
@@ -38,9 +38,10 @@ type options struct {
option, feedback string
output string
conflict string
kind string
all bool
json, source, noOpen, yes, allow, createOnly, force, wait bool
version, expected int
version, expected, limit int
timeout, waitTimeout time.Duration
}
@@ -101,6 +102,9 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
f.DurationVar(&o.waitTimeout, "wait-timeout", 0, "Client limit for --wait after the run is admitted (0 waits until terminal); separate from per-request --timeout")
case "runs":
f.StringVar(&o.name, "pipeline", "", "Filter by exact pipeline name or ID")
case "search":
f.StringVar(&o.kind, "type", "", "Narrow to one kind: "+strings.Join(protocol.SearchKinds, ", "))
f.IntVar(&o.limit, "limit", 0, "Maximum results (default 50, max 200)")
case "retry":
f.BoolVar(&o.yes, "yes", false, "Confirm retry without an interactive prompt")
f.StringVar(&o.key, "request-key", "", "Idempotency key (default: generated unique key)")
@@ -729,6 +733,37 @@ func (a App) Run(ctx context.Context, args []string) error {
return err
case "import":
return a.importBundle(ctx, o, f.Args(), call)
case "search":
query := strings.Join(pos, " ")
if strings.TrimSpace(query) == "" {
return fmt.Errorf("search requires a query; use pipelines help search")
}
r, err := call(protocol.Message{Type: protocol.Search, Search: &protocol.SearchRequest{Query: query, Kind: o.kind, Limit: o.limit}})
if err != nil {
return err
}
if r.SearchResults == nil {
return fmt.Errorf("server did not return search results; update pipelines-server")
}
if o.json {
return a.output(r.SearchResults)
}
if len(r.SearchResults.Results) == 0 {
fmt.Fprintln(a.Out, "No matches")
}
for _, hit := range r.SearchResults.Results {
// The shared Label renders every kind; the CLI additionally shows a
// text-field hit's snippet, which the TUI marks on its own line.
label := hit.Label()
if hit.Field != nil {
label += ": " + hit.Field.Snippet
}
fmt.Fprintf(a.Out, "%s\t%s\t%d\t%s\t%s\n", hit.Kind, hit.Target, hit.Score, hit.MatchedField, label)
}
if r.SearchResults.Truncated {
fmt.Fprintf(a.Err, "Results truncated (cap %d, scan bound %d bytes)\n", r.SearchResults.Cap, r.SearchResults.ScanBoundBytes)
}
return nil
case "show", "versions":
value, err := one()
if err != nil {