From 831031bb4863805abc7e272f40d5a1d576364a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Tue, 27 Oct 2026 15:42:38 +0100 Subject: [PATCH] fix: an opened link ends on the secret's details, also when its lists were loaded (#93) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Karl-Einar Bergstrøm --- internal/ui/app/links.go | 6 +++++- internal/ui/app/links_test.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/ui/app/links.go b/internal/ui/app/links.go index 5bc4c57..d9e28e6 100644 --- a/internal/ui/app/links.go +++ b/internal/ui/app/links.go @@ -643,7 +643,11 @@ func (m *Model) advanceNav() bool { } } if n.link { - m.focus = paneDetail // after: copying acts on the focused pane + // After: copying acts on the focused pane. The details describe + // the secret: when its lists were loaded already, the open got + // here in one update, and the Secrets pane was never the last + // left pane in focus. + m.lastLeft, m.focus = paneSecrets, paneDetail } return true } diff --git a/internal/ui/app/links_test.go b/internal/ui/app/links_test.go index b5f218c..094828d 100644 --- a/internal/ui/app/links_test.go +++ b/internal/ui/app/links_test.go @@ -626,3 +626,17 @@ func TestShareWebPages(t *testing.T) { t.Errorf("secret web page %q", got) } } + +// A link whose lists are there already (a repo's files, or cached) gets +// to the secret in one update: the details describe it all the same, not +// the repo, with no need to press 3. +func TestOpenLinkToRepoSecret(t *testing.T) { + t.Parallel() + r, _ := ref.Parse("lazysecrets://repo/github.com%2Facme%2Forders-service/docker-compose.yml/api.DB_PASSWORD") + d := newDriverOpts(t, Options{Open: &r}, fake.Repos()) + d.keys("o") + o, ok := d.m.detail.Secret() + if _, _, s := d.selected(); s != "api.DB_PASSWORD" || d.m.focus != paneDetail || d.m.detailOf() != paneSecrets || !ok || o.Name != "api.DB_PASSWORD" { + t.Errorf("selected %q, focus %v describing %v, detail %q", s, d.m.focus, d.m.detailOf(), o.Name) + } +}