feat: one server button, and only primary agents to pick
The session screen now has a single server icon that opens the instance list; picking an instance drops the live connection and connects to it, and disconnecting moved into that list. A custom SVG rack stands in for the missing server symbol on Android. The agent sheet lists primary agents only: a session cannot run a subagent (General, Explore) as its own agent. Bump version to 0.1.5 (build 6).
This commit is contained in:
1 parent
9d9678e294
commit
e240a33e31
8 files changed
+76
-10
No files matched your search
@@ -495,7 +495,9 @@ func (ch *chat) openPicker(kind string) {
|
||||
var agents []ocapi.AgentInfo
|
||||
agents, err = client.Agents(ctx, ch.dir)
|
||||
for _, a := range agents {
|
||||
if a.Hidden {
|
||||
// A session runs a primary agent; subagents are what the
|
||||
// primary one delegates to.
|
||||
if a.Hidden || a.Mode == "subagent" {
|
||||
continue
|
||||
}
|
||||
items = append(items, pickerItem{
|
||||
|
||||
@@ -87,7 +87,11 @@ func newChatServer(t *testing.T) *chatServer {
|
||||
{"id":"claude","providerID":"anthropic","name":"Claude"}]}`)
|
||||
})
|
||||
mux.HandleFunc("/api/agent", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"data":[{"id":"build","name":"Build"},{"id":"plan","name":"Plan"}]}`)
|
||||
fmt.Fprint(w, `{"data":[
|
||||
{"id":"build","name":"Build","mode":"primary"},
|
||||
{"id":"plan","name":"Plan","mode":"primary"},
|
||||
{"id":"general","name":"General","mode":"subagent","hidden":false},
|
||||
{"id":"explore","name":"Explore","mode":"subagent"}]}`)
|
||||
})
|
||||
mux.HandleFunc("/api/session/ses_1/model", func(w http.ResponseWriter, r *http.Request) {
|
||||
var body map[string]any
|
||||
@@ -260,3 +264,18 @@ func TestCreateSession(t *testing.T) {
|
||||
t.Fatal("no create request reached the server")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAgentPickerSkipsSubagents(t *testing.T) {
|
||||
srv := newChatServer(t)
|
||||
a := uitest.Mount(t, func() ui.Node { return rootWithStore(&memStore{}) }, uitest.Platform(ui.PlatformAndroid))
|
||||
connectViaForm(t, a, srv.URL)
|
||||
a.WaitFor("First session")
|
||||
a.Tap("First session")
|
||||
a.WaitFor("Hello from the agent")
|
||||
|
||||
a.Tap("Agent")
|
||||
a.WaitFor("Build")
|
||||
a.Expect("Plan")
|
||||
a.ExpectNo("General")
|
||||
a.ExpectNo("Explore")
|
||||
}
|
||||
@@ -341,6 +341,17 @@ func (c *controller) instancesSheet() ui.Node {
|
||||
}),
|
||||
)
|
||||
}),
|
||||
ui.Show(signal.Func(func() bool { return c.connected.Get() }),
|
||||
func() ui.Node {
|
||||
return ui.Button(ui.ButtonProps{
|
||||
Title: ui.Val("断开当前连接"),
|
||||
Variant: ui.ButtonGray,
|
||||
OnPress: func() {
|
||||
c.instancesOpen.Set(false)
|
||||
c.disconnect()
|
||||
},
|
||||
})
|
||||
}),
|
||||
ui.Button(ui.ButtonProps{
|
||||
Title: ui.Val("添加服务器"),
|
||||
Icon: ui.IconPlus,
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package appui
|
||||
|
||||
import (
|
||||
"github.com/egoist/asuka/colors"
|
||||
"github.com/egoist/asuka/sdk/svg"
|
||||
"github.com/egoist/asuka/ui"
|
||||
)
|
||||
|
||||
// serverIcon is a rack, drawn as vector paths: Asuka's built-in symbols
|
||||
// have no server glyph on Android, and an SVG keeps it crisp at any size.
|
||||
var serverIcon = svg.MustParse(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="8" x="2" y="2" rx="2"/><rect width="20" height="8" x="2" y="14" rx="2"/><line x1="6" x2="6.01" y1="6" y2="6"/><line x1="6" x2="6.01" y1="18" y2="18"/></svg>`)
|
||||
|
||||
// instancesButton opens the server list: one button, because picking a
|
||||
// server is also how the live one is replaced.
|
||||
func (c *controller) instancesButton() ui.Node {
|
||||
return ui.View(ui.ViewProps{
|
||||
OnPress: func() { c.instancesOpen.Set(true) },
|
||||
Label: ui.Val("实例"),
|
||||
Hint: ui.Val("打开服务器列表"),
|
||||
Style: ui.Style{Padding: ui.All(8)},
|
||||
}, svg.View(svg.Props{
|
||||
Icon: serverIcon,
|
||||
Color: ui.Val(colors.Accent),
|
||||
Style: ui.Style{Width: ui.Pt(22), Height: ui.Pt(22)},
|
||||
}))
|
||||
}
|
||||
@@ -171,6 +171,14 @@ func connectViaForm(t *testing.T, a *uitest.App, url string) {
|
||||
a.Tap("连接")
|
||||
}
|
||||
|
||||
// disconnectViaInstances opens the instance list and drops the live
|
||||
// connection from there; the sessions header has only the list button.
|
||||
func disconnectViaInstances(t *testing.T, a *uitest.App) {
|
||||
t.Helper()
|
||||
a.Tap("实例")
|
||||
a.Tap("断开当前连接")
|
||||
}
|
||||
|
||||
func unlockWith(t *testing.T, a *uitest.App, password string) {
|
||||
t.Helper()
|
||||
a.WaitFor("这台服务器需要密码。")
|
||||
@@ -261,7 +269,7 @@ func TestMultipleConnectionsAndSwitch(t *testing.T) {
|
||||
a := mount(t, st)
|
||||
a.WaitFor("Session A")
|
||||
|
||||
a.Tap("断开")
|
||||
disconnectViaInstances(t, a)
|
||||
a.Expect("A")
|
||||
a.Expect("B")
|
||||
|
||||
@@ -277,7 +285,7 @@ func TestAddAnotherConnection(t *testing.T) {
|
||||
}}
|
||||
a := mount(t, st)
|
||||
a.WaitFor("Session A")
|
||||
a.Tap("断开")
|
||||
disconnectViaInstances(t, a)
|
||||
a.Tap("添加服务器")
|
||||
a.Type("http://192.168.1.5:3000", srvB.URL)
|
||||
a.Type("名称(可选)", "B")
|
||||
@@ -296,7 +304,7 @@ func TestDeleteConnection(t *testing.T) {
|
||||
}}
|
||||
a := mount(t, st)
|
||||
a.WaitFor("Session A")
|
||||
a.Tap("断开")
|
||||
disconnectViaInstances(t, a)
|
||||
|
||||
a.Tap("操作")
|
||||
a.Tap("删除")
|
||||
|
||||
@@ -22,9 +22,7 @@ func (c *controller) sessionsScreen() ui.Node {
|
||||
return ui.Text(c.errorMsg, ui.Style{Font: fonts.Footnote, Color: colors.Red, Lines: 2})
|
||||
}),
|
||||
),
|
||||
ui.Button(ui.ButtonProps{Title: ui.Val("实例"), Variant: ui.ButtonPlain,
|
||||
OnPress: func() { c.instancesOpen.Set(true) }}),
|
||||
ui.Button(ui.ButtonProps{Title: ui.Val("断开"), Variant: ui.ButtonPlain, OnPress: c.disconnect}),
|
||||
c.instancesButton(),
|
||||
),
|
||||
ui.Show(signal.Func(func() bool { return len(c.sessions.Get()) == 0 }),
|
||||
func() ui.Node {
|
||||
|
||||
Reference in new issue
Block a user