Rework omni search onto a typed search contract and add a TUI artifacts view
Protocol: replace the loose Query/Kind/Matches/Limit search fields with a Search request object and a SearchResults response, and have the server answer search from Store.Search over the shared run projections (runFrom/runStamps).
CLI: add the read-only 'pipelines search QUERY [--type KIND] [--limit N] [--json]' command with usage/help, and document the typed targets, ranking and bounds in docs/cli.md.
TUI: the '/' popup keeps type-to-search, up/down, Enter and Esc, renders one ranked list with kind badges and a bracketed (non-colour) match snippet, and Enter opens the matched pipeline, run, step, artifact or field; footer text updated to match.
TUI: add a dedicated run artifacts view ('A') with open/copy of recorded files, and move artifacts out of the run-detail File changes section (artifactCaptureNotes).
Tests: add Store.OpenReadOnly for read-only inspection of a live database plus pipeline/server/TUI search tests and artifacts tests, including env-gated live checks.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"github.com/charmbracelet/x/ansi"
|
||||
)
|
||||
|
||||
// TestLiveArtifactsFromCapture renders the artifacts view from real
|
||||
// `pipelines inspect RUN_ID --json` captures. It is env-gated and skips unless
|
||||
// PIPELINES_ARTIFACT_CAPTURES names one or more capture files, so it never
|
||||
// depends on a running server in CI; the operator points it at real captures to
|
||||
// re-confirm that mixed artifact types, a partial capture, a running visit and
|
||||
// a finished visit with none all render.
|
||||
func TestLiveArtifactsFromCapture(t *testing.T) {
|
||||
list := os.Getenv("PIPELINES_ARTIFACT_CAPTURES")
|
||||
if strings.TrimSpace(list) == "" {
|
||||
t.Skip("set PIPELINES_ARTIFACT_CAPTURES to comma-separated `pipelines inspect RUN_ID --json` files")
|
||||
}
|
||||
m := New(context.Background(), "ws://127.0.0.1:8080/connect")
|
||||
m.width, m.height = 120, 60
|
||||
var rendered strings.Builder
|
||||
for _, path := range strings.Split(list, ",") {
|
||||
path = strings.TrimSpace(path)
|
||||
if path == "" {
|
||||
continue
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var detail protocol.RunDetail
|
||||
if err := json.Unmarshal(data, &detail); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.runDetail = &detail
|
||||
view := ansi.Strip(m.artifactsView(50))
|
||||
t.Logf("capture %s (run #%d executing=%t):\n%s", path, detail.ID, detail.Executing, view)
|
||||
rendered.WriteString(view)
|
||||
}
|
||||
text := rendered.String()
|
||||
for _, want := range []string{"[img]", "partial capture", "capture pending", "not recorded for this visit", "image/png", "KiB"} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Errorf("live captures did not render %q", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user