diff --git a/PLAN.md b/PLAN.md index 207de8e..8e230bf 100644 --- a/PLAN.md +++ b/PLAN.md @@ -41,6 +41,8 @@ M0 完成,并继续做到了 M3。所有验证都连的是本机正在运行 | 权限审批 | 聊天页内联卡片(允许一次/总是允许/拒绝),启动时补齐待批列表,SSE 实时增删 | | 多实例 | 保存多个服务器,按最近使用排序;首屏选择连接,连接后可切换;添加/编辑/删除;从旧的单连接记录自动迁移 | | 连接界面(对齐官方) | 首连引导 →「手动输入地址」;有保存时列表:最近使用的置顶卡片(连接/已连接)、其他服务器、添加按钮;每行「…」菜单(连接/编辑/删除,删除二次确认);密码按需弹层、失败保留并可从表单重试;连接失败时回到表单并保留输入 | +| 顶栏服务器入口 | 会话页只保留一个「服务器」图标按钮,打开实例列表;点选实例即断开当前连接并连到所选实例;「断开当前连接」移入实例列表 | +| Agent 选择 | 只列 `mode=primary` 的 Agent,子智能体(General/Explore)不再出现 | | 模型/Agent | 聊天页顶栏打开选择 Sheet(可搜索),切换后同步会话列表 | | 新建会话 | 会话页「新建」:标题 + 工作目录(服务端默认目录与已加载会话的目录),创建后直接进入聊天 | | 下一步 | 打磨:图标/splash、中英 i18n、空态与错误页;可选 fork asuka 支持更低 minSdk | diff --git a/asuka.json b/asuka.json index 92b125d..daafd34 100644 --- a/asuka.json +++ b/asuka.json @@ -1,7 +1,7 @@ { "name": "OpenChamber", "id": "com.openchamber.native", - "version": "0.1.4", - "build": 5, + "version": "0.1.5", + "build": 6, "orientations": ["portrait", "landscape"] } diff --git a/internal/appui/chat.go b/internal/appui/chat.go index d698c92..5adaffa 100644 --- a/internal/appui/chat.go +++ b/internal/appui/chat.go @@ -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{ diff --git a/internal/appui/chat_test.go b/internal/appui/chat_test.go index 09bb29f..5e90274 100644 --- a/internal/appui/chat_test.go +++ b/internal/appui/chat_test.go @@ -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") +} diff --git a/internal/appui/connections.go b/internal/appui/connections.go index 8a972b9..707a868 100644 --- a/internal/appui/connections.go +++ b/internal/appui/connections.go @@ -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, diff --git a/internal/appui/icons.go b/internal/appui/icons.go new file mode 100644 index 0000000..64a0239 --- /dev/null +++ b/internal/appui/icons.go @@ -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(``) + +// 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)}, + })) +} diff --git a/internal/appui/root_test.go b/internal/appui/root_test.go index bf38a59..431b194 100644 --- a/internal/appui/root_test.go +++ b/internal/appui/root_test.go @@ -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("删除") diff --git a/internal/appui/screens.go b/internal/appui/screens.go index 9630ceb..0b8e870 100644 --- a/internal/appui/screens.go +++ b/internal/appui/screens.go @@ -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 {