okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

dawntui: tree and context inspector on listView, shared confirm for agent delete78011da

main
1.5 KiB44 linesraw
1package tui
2
3import (
4	"albedo/cli/internal/daemon"
5
6	tea "charm.land/bubbletea/v2"
7)
8
9// agentsShotModel is agentsFixture's tree without a *testing.T, for the gallery.
10func agentsShotModel(width, height int) AgentsViewModel {
11	m := NewAgentsViewModel(nil, "lead")
12	m.Gen = 1
13	m.streamReady = true
14	m.SetSize(width, height)
15	lead, coder := "lead", "coder"
16	m, _ = m.Update(agentsSnapshotMsg{Gen: 1, Root: "lead", Nodes: []daemon.AgentNode{
17		{Session: daemon.Session{ID: "lead", Title: "lead", Model: "gpt-6-luna"}, Name: "lead", Running: true},
18		{Session: daemon.Session{ID: "scout", Model: "gpt-6-luna"}, Parent: &lead, Name: "scout", Depth: 1},
19		{Session: daemon.Session{ID: "coder", Model: "gpt-6-luna"}, Parent: &lead, Name: "coder", Depth: 1, Running: true},
20		{Session: daemon.Session{ID: "tests", Model: "gpt-6-luna"}, Parent: &coder, Name: "tests", Depth: 2},
21	}})
22	return m
23}
24
25// agentsDeleteShot opens the delete question on an agent, then presses keys.
26func agentsDeleteShot(id string, keys ...tea.KeyPressMsg) func(width, height int) string {
27	return func(width, height int) string {
28		m := agentsShotModel(width, height)
29		m.selected = id
30		m, _ = m.key(tea.KeyPressMsg{Code: 'x', Mod: tea.ModCtrl})
31		for _, key := range keys {
32			m, _ = m.key(key)
33		}
34		return m.View()
35	}
36}
37
38func init() {
39	registerShots("agents",
40		shotState{"delete-confirm", agentsDeleteShot("coder")},
41		shotState{"delete-leaf-confirm", agentsDeleteShot("scout")},
42		shotState{"delete-kept", agentsDeleteShot("coder", tea.KeyPressMsg{Code: tea.KeyEscape})},
43	)
44}