feat: the key picker has its own border in the share popup
CI / Checks (pull_request) Successful in 40s
PR title / Conventional title (pull_request) Successful in 2s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kebandClaude Opus 5.5 committed 2026-10-13 12:42:33 +02:00
1 parent 176600be54
commit 8d65b60e69
2 files changed
+32 -11

No files matched your search

+25 -6
View File
@@ -57,8 +57,10 @@ type searchView struct {
// secrets only, and enter gives the selected one's link to pick // secrets only, and enter gives the selected one's link to pick
// instead of going there. // instead of going there.
pick func(m *Model, r ref.Ref) tea.Cmd pick func(m *Model, r ref.Ref) tea.Cmd
pickTitle string pickTitle string // the popup's
pickLines []string // what picking does, above the input pickLines []string // what picking is for, above the picker
pickHeading string // the picker's title, on its border
pickHelp []string // inside it, above the tabs
// loaded are the scopes a search has loaded since the popup opened: // loaded are the scopes a search has loaded since the popup opened:
// typing loads the scope once, so lists that fail aren't asked for // typing loads the scope once, so lists that fail aren't asked for
@@ -658,7 +660,15 @@ func (m Model) searchViewBox() string {
v := m.search v := m.search
focused := !m.termBlurred focused := !m.termBlurred
w := searchWidth(m.w) w := searchWidth(m.w)
popupW := w
if v.pick != nil {
w -= 4 // inside the picker's border, in the popup
}
listH := max(5, min(m.h-10, 14)) listH := max(5, min(m.h-10, 14))
if v.pick != nil {
// What it's for, the help, the tabs and a border more.
listH = max(5, min(m.h-10-len(v.pickLines)-len(v.pickHelp)-5, 14))
}
srcW := 10 srcW := 10
for _, o := range v.scopes { for _, o := range v.scopes {
@@ -753,7 +763,7 @@ func (m Model) searchViewBox() string {
ts := panes.TitleStyle(m.st, focused) ts := panes.TitleStyle(m.st, focused)
var body []string var body []string
if v.pick != nil { if v.pick != nil {
for _, l := range v.pickLines { for _, l := range v.pickHelp {
body = append(body, " "+l) body = append(body, " "+l)
} }
body = append(body, "", " "+m.goToTabs(ts)) body = append(body, "", " "+m.goToTabs(ts))
@@ -789,11 +799,20 @@ func (m Model) searchViewBox() string {
// Tabs in the title, the current one underlined, like the panes; a // Tabs in the title, the current one underlined, like the panes; a
// picker has its own title, and the tabs over the input. // picker has its own title, and the tabs over the input.
head := ts.Render(goToTitle+" ") + m.goToTabs(ts) head := ts.Render(goToTitle+" ") + m.goToTabs(ts)
if v.pick != nil { if v.pick == nil {
head = ts.Render(v.pickTitle)
}
return panes.Box(m.st, head, foot, body, w, len(body)+2, focused) return panes.Box(m.st, head, foot, body, w, len(body)+2, focused)
} }
// A picker: in its own border, under what it's for.
var outer []string
for _, l := range v.pickLines {
outer = append(outer, " "+l)
}
outer = append(outer, "")
for _, l := range strings.Split(panes.Box(m.st, ts.Render(v.pickHeading), "", body, w, len(body)+2, focused), "\n") {
outer = append(outer, " "+l)
}
return panes.Box(m.st, ts.Render(v.pickTitle), foot, outer, popupW, len(outer)+2, focused)
}
// selectLabel names what enter does with the selected entry. // selectLabel names what enter does with the selected entry.
func (v *searchView) selectLabel() string { func (v *searchView) selectLabel() string {
+7 -5
View File
@@ -15,7 +15,6 @@ import (
"git.kebcloud.no/keb/lazysecrets/internal/provider" "git.kebcloud.no/keb/lazysecrets/internal/provider"
"git.kebcloud.no/keb/lazysecrets/internal/ref" "git.kebcloud.no/keb/lazysecrets/internal/ref"
"git.kebcloud.no/keb/lazysecrets/internal/share" "git.kebcloud.no/keb/lazysecrets/internal/share"
"git.kebcloud.no/keb/lazysecrets/internal/ui/panes"
) )
// Sharing env files as an encrypted lazysecrets://share link (package // Sharing env files as an encrypted lazysecrets://share link (package
@@ -146,10 +145,13 @@ func (m *Model) pickShareKey(s sharing) tea.Cmd {
return m.seal(s) // the picker showed what's shared return m.seal(s) // the picker showed what's shared
} }
m.search.pickTitle = shareTitle(s) m.search.pickTitle = shareTitle(s)
m.search.pickLines = append(m.sharedFiles(s), "", m.search.pickLines = m.sharedFiles(s)
panes.TitleStyle(m.st, true).Render("Pick a secret to encrypt with"), m.search.pickHeading = "Pick a secret to encrypt with"
m.st.Muted.Render("The recipient needs read access to it to decrypt the files. Its value isn't"), m.search.pickHelp = []string{
m.st.Muted.Render("shown or put in the link. share.key sets one for a repo, or for all.")) m.st.Muted.Render("The recipient needs read access to it to decrypt the files. Its value"),
m.st.Muted.Render("isn't shown or put in the link. share.key sets one for a repo, or for all."),
}
m.search.input.SetWidth(searchWidth(m.w) - 10) // inside the picker's border
m.fillSearch(false) m.fillSearch(false)
return tea.Batch(cmd, m.searchLoads()) return tea.Batch(cmd, m.searchLoads())
} }