diff --git a/PLAN.md b/PLAN.md index 8e230bf..7ebf855 100644 --- a/PLAN.md +++ b/PLAN.md @@ -42,6 +42,7 @@ M0 完成,并继续做到了 M3。所有验证都连的是本机正在运行 | 多实例 | 保存多个服务器,按最近使用排序;首屏选择连接,连接后可切换;添加/编辑/删除;从旧的单连接记录自动迁移 | | 连接界面(对齐官方) | 首连引导 →「手动输入地址」;有保存时列表:最近使用的置顶卡片(连接/已连接)、其他服务器、添加按钮;每行「…」菜单(连接/编辑/删除,删除二次确认);密码按需弹层、失败保留并可从表单重试;连接失败时回到表单并保留输入 | | 顶栏服务器入口 | 会话页只保留一个「服务器」图标按钮,打开实例列表;点选实例即断开当前连接并连到所选实例;「断开当前连接」移入实例列表 | +| 首屏无导航栏 | 未连接时直接显示服务器列表(自带标题),不再套用带「新建/刷新」的应用栏;连接后才建立导航栈与动作栏 | | Agent 选择 | 只列 `mode=primary` 的 Agent,子智能体(General/Explore)不再出现 | | 模型/Agent | 聊天页顶栏打开选择 Sheet(可搜索),切换后同步会话列表 | | 新建会话 | 会话页「新建」:标题 + 工作目录(服务端默认目录与已加载会话的目录),创建后直接进入聊天 | diff --git a/asuka.json b/asuka.json index daafd34..fc4d899 100644 --- a/asuka.json +++ b/asuka.json @@ -1,7 +1,7 @@ { "name": "OpenChamber", "id": "com.openchamber.native", - "version": "0.1.5", - "build": 6, + "version": "0.1.6", + "build": 7, "orientations": ["portrait", "landscape"] } diff --git a/internal/appui/root.go b/internal/appui/root.go index b150468..a2535af 100644 --- a/internal/appui/root.go +++ b/internal/appui/root.go @@ -28,24 +28,7 @@ func rootWithStore(st storage.Store) ui.Node { func newApp(st storage.Store) (*controller, ui.Node) { c := newController(st) signal.OnCleanup(c.shutdown) - node := ui.Stack(c.screen, ui.ScreenOptions{ - Title: ui.Val("OpenChamber"), - Actions: []ui.Action{ - { - Title: ui.Val("新建"), - Icon: ui.IconPlus, - Disabled: signal.Func(func() bool { return !c.connected.Get() }), - OnPress: c.openNewSession, - }, - { - Title: ui.Val("刷新"), - Icon: ui.IconRefresh, - Disabled: signal.Func(func() bool { return !c.connected.Get() || c.busy.Get() }), - OnPress: c.refresh, - }, - }, - }) - return c, node + return c, c.screen() } type controller struct { @@ -132,9 +115,21 @@ func newController(st storage.Store) *controller { return c } +// screen is the app's tree: a navigation stack while connected (its bar +// holds the session actions), and the bare server list while not, so the +// list is not framed by a bar whose buttons would do nothing. func (c *controller) screen() ui.Node { - return ui.SafeArea(ui.Style{Grow: 1}, - ui.Show(c.connected, c.sessionsScreen, c.connectionsScreen), + return ui.Column(ui.Style{Grow: 1}, + ui.Show(c.connected, + func() ui.Node { + return ui.Stack(c.sessionsScreen, ui.ScreenOptions{ + Title: ui.Val("OpenChamber"), + Actions: c.barActions(), + }, ui.Style{Grow: 1}) + }, + func() ui.Node { + return ui.SafeArea(ui.Style{Grow: 1}, c.connectionsScreen()) + }), c.formSheet(), c.passwordSheet(), c.instancesSheet(), @@ -142,6 +137,22 @@ func (c *controller) screen() ui.Node { ) } +func (c *controller) barActions() []ui.Action { + return []ui.Action{ + { + Title: ui.Val("新建"), + Icon: ui.IconPlus, + OnPress: c.openNewSession, + }, + { + Title: ui.Val("刷新"), + Icon: ui.IconRefresh, + Disabled: signal.Func(func() bool { return c.busy.Get() }), + OnPress: c.refresh, + }, + } +} + func (c *controller) shutdown() { if c.cancelSSE != nil { c.cancelSSE() diff --git a/internal/appui/screens.go b/internal/appui/screens.go index 0b8e870..4817d0a 100644 --- a/internal/appui/screens.go +++ b/internal/appui/screens.go @@ -13,7 +13,7 @@ import ( func (c *controller) sessionsScreen() ui.Node { nav := ui.UseNavigator() c.nav = nav - return ui.Column(ui.Style{Grow: 1}, + return ui.SafeArea(ui.Style{Grow: 1}, ui.Column(ui.Style{Grow: 1}, ui.Row(ui.Style{Padding: ui.Symmetric(8, 16), Gap: 4, Align: ui.AlignCenter}, ui.Column(ui.Style{Grow: 1, Gap: 2}, ui.Text(c.server, ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel, Lines: 1}), @@ -56,7 +56,7 @@ func (c *controller) sessionsScreen() ui.Node { OnLongPress: func() { c.sessionMenu(s.Get()) }, }, c.sessionRow(s, idx)) }), - ) + )) } func (c *controller) sessionRow(s signal.Accessor[ocapi.Session], _ signal.Accessor[int]) ui.Node {