feat: pick the share key in Go to, or by reference
CI / Checks (pull_request) Successful in 38s
PR title / Conventional title (pull_request) Successful in 1s

Sharing without share.key opens Go to as a picker of secrets instead
of asking for a link: it lists only secrets, enter picks one, and a
pasted reference picks it too. The key, there and in share.key or
--key, can be a secret's lazysecrets:// link, Key Vault URL or
@Microsoft.KeyVault(...) reference.

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:09:08 +02:00
1 parent 4d57c19772
commit bc691d786a
13 files changed
+152 -67

No files matched your search

+24 -30
View File
@@ -102,7 +102,7 @@ func (m *Model) handleShareFiles(msg shareFilesMsg) tea.Cmd {
case msg.err != nil:
m.flash = flash{text: "share: " + msg.err.Error(), isErr: true}
case msg.key == (ref.Ref{}):
return m.askShareKey(msg.sharing)
return m.pickShareKey(msg.sharing)
default:
m.confirmShare(msg.sharing)
}
@@ -118,40 +118,34 @@ func (m *Model) confirmShare(s sharing) {
lines = append(lines, "", m.st.Muted.Render("encrypted with ")+m.refLabel(s.key))
m.showMenu("Share as an encrypted link", lines, []option{
{key: "c", label: "Copy the link", run: func(m *Model) tea.Cmd { return m.seal(s) }},
{key: "k", label: "Encrypt with another secret…", run: func(m *Model) tea.Cmd { return m.askShareKey(s) }},
{key: "k", label: "Encrypt with another secret…", run: func(m *Model) tea.Cmd { return m.pickShareKey(s) }},
})
}
// askShareKey asks for the link to the secret to encrypt with.
func (m *Model) askShareKey(s sharing) tea.Cmd {
in := textinput.New()
in.Prompt = "key: "
in.Placeholder = "lazysecrets:// link to a secret"
in.SetWidth(max(20, min(m.w-12, 64)))
in.SetValue(m.lastShareKey)
if s.key != (ref.Ref{}) {
in.SetValue(s.key.String())
// pickShareKey asks which secret to encrypt with, in Go to.
func (m *Model) pickShareKey(s sharing) tea.Cmd {
cmd := m.openGoTo(tabSearch, true)
m.search.pick = func(m *Model, key ref.Ref) tea.Cmd {
s.key = key
m.confirmShare(s)
return nil
}
in.CursorEnd()
m.prompt = &modal{
title: "Encrypt with which secret?", input: &in,
lines: []string{
m.st.Muted.Render("Whoever can read it can open the link. s on a secret copies its link."),
m.st.Muted.Render("share.key in the config or the repo's .lazysecrets.yaml sets one."),
},
submit: func(m *Model, text string) tea.Cmd {
key, err := share.ParseKey(strings.TrimSpace(text))
if err != nil {
m.flash = flash{text: "share: " + err.Error(), isErr: true}
return nil
}
m.lastShareKey = key.String()
s.key = key
m.confirmShare(s)
return nil
},
m.search.pickTitle = "Encrypt with which secret?"
m.search.pickNote = "Whoever can read it can open the link. share.key sets a default."
m.fillSearch(false)
return tea.Batch(cmd, m.searchLoads())
}
// pickPasted picks a pasted reference to a secret, while picking one.
func (m *Model) pickPasted(text string) tea.Cmd {
key, err := share.ParseKey(strings.TrimSpace(text))
if err != nil {
m.flash = flash{text: "share: " + err.Error(), isErr: true}
return nil
}
return m.prompt.input.Focus()
pick := m.search.pick
m.search = nil
return pick(m, key)
}
// seal reads the key and encrypts the files with it.