feat: actions under user messages, and a dependable footer icon
Every prompt now carries a row with its time, a copy button and a menu (copy message, fork before this prompt), matching the first-party client. The turn footer's sparkles became an inline SVG: the platform symbol table left an empty square on some devices. Bump version to 0.1.10 (build 11).
This commit is contained in:
1 parent
d3e92f036a
commit
0e34d82a06
5 files changed
+135
-4
No files matched your search
@@ -43,7 +43,8 @@ M0 完成,并继续做到了 M3。所有验证都连的是本机正在运行
|
||||
| 连接界面(对齐官方) | 首连引导 →「手动输入地址」;有保存时列表:最近使用的置顶卡片(连接/已连接)、其他服务器、添加按钮;每行「…」菜单(连接/编辑/删除,删除二次确认);密码按需弹层、失败保留并可从表单重试;连接失败时回到表单并保留输入 |
|
||||
| 顶栏服务器入口 | 会话页只保留一个「服务器」图标按钮,打开实例列表;点选实例即断开当前连接并连到所选实例;「断开当前连接」移入实例列表 |
|
||||
| 首屏无导航栏 | 未连接时直接显示服务器列表(自带标题),不再套用带「新建/刷新」的应用栏;连接后才建立导航栈与动作栏 |
|
||||
| 轮次页脚 | 每个回合结束后显示「模型 · Agent · 耗时」,右侧「…」打开操作面板(时间戳、复制回答、从这里分叉);模型名由 `/api/model` 解析,耗时按 prompt→完成计算 |
|
||||
| 轮次页脚 | 每个回合结束后显示「模型 · Agent · 耗时」,右侧「…」打开操作面板(时间戳、复制回答、从这里分叉);模型名由 `/api/model` 解析,耗时按 prompt→完成计算;模型图标改用内置 SVG(不依赖平台符号表) |
|
||||
| 用户消息操作 | 每条用户消息下有「时间 · 复制 · …」一排;「…」面板含时间戳、复制消息、从此消息前分叉 |
|
||||
| Agent 选择 | 只列 `mode=primary` 的 Agent,子智能体(General/Explore)不再出现 |
|
||||
| 模型/Agent | 聊天页顶栏打开选择 Sheet(可搜索),切换后同步会话列表 |
|
||||
| 新建会话 | 会话页「新建」:标题 + 工作目录(服务端默认目录与已加载会话的目录),创建后直接进入聊天 |
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "OpenChamber",
|
||||
"id": "com.openchamber.native",
|
||||
"version": "0.1.9",
|
||||
"build": 10,
|
||||
"version": "0.1.10",
|
||||
"build": 11,
|
||||
"orientations": ["portrait", "landscape"]
|
||||
}
|
||||
+112
-1
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/egoist/asuka/colors"
|
||||
"github.com/egoist/asuka/fonts"
|
||||
"github.com/egoist/asuka/sdk/markdown"
|
||||
"github.com/egoist/asuka/sdk/svg"
|
||||
"github.com/egoist/asuka/signal"
|
||||
"github.com/egoist/asuka/ui"
|
||||
"github.com/openchamber/openchamber-native/internal/ocapi"
|
||||
@@ -62,6 +63,8 @@ type chat struct {
|
||||
|
||||
footerOpen *signal.Signal[bool]
|
||||
footerID *signal.Signal[string]
|
||||
userOpen *signal.Signal[bool]
|
||||
userID *signal.Signal[string]
|
||||
|
||||
pickerOpen *signal.Signal[bool]
|
||||
pickerKind string
|
||||
@@ -105,6 +108,8 @@ func (c *controller) openChat(s *ocapi.Session, nav *ui.Navigator) *chat {
|
||||
modelNames: signal.NewFunc(map[string]string{}, nil),
|
||||
footerOpen: signal.New(false),
|
||||
footerID: signal.New(""),
|
||||
userOpen: signal.New(false),
|
||||
userID: signal.New(""),
|
||||
pickerOpen: signal.New(false),
|
||||
pickerItems: signal.NewFunc([]pickerItem{}, nil),
|
||||
pickerFilter: signal.New(""),
|
||||
@@ -659,6 +664,7 @@ func (ch *chat) screen() ui.Node {
|
||||
ch.composer(),
|
||||
),
|
||||
ch.footerSheet(),
|
||||
ch.userSheet(),
|
||||
ui.Sheet(ui.SheetProps{
|
||||
Open: ch.pickerOpen,
|
||||
Detents: ui.DetentLarge,
|
||||
@@ -928,6 +934,7 @@ func (ch *chat) items() signal.Accessor[[]chatItem] {
|
||||
switch m.Type {
|
||||
case "user":
|
||||
out = append(out, chatItem{Key: "u/" + m.ID, Kind: "user", MsgID: m.ID})
|
||||
out = append(out, chatItem{Key: "ua/" + m.ID, Kind: "useractions", MsgID: m.ID})
|
||||
case "assistant":
|
||||
if len(m.Content) == 0 && m.Time.Completed == 0 {
|
||||
out = append(out, chatItem{Key: "a/" + m.ID, Kind: "thinking", MsgID: m.ID})
|
||||
@@ -993,6 +1000,8 @@ func (ch *chat) itemRow(it signal.Accessor[chatItem], _ signal.Accessor[int]) ui
|
||||
return ch.toolRow(cur)
|
||||
case "footer":
|
||||
return ch.footerRow(cur)
|
||||
case "useractions":
|
||||
return ch.userActionsRow(cur)
|
||||
case "shell":
|
||||
return ui.View(ui.ViewProps{Style: ui.Style{Padding: ui.Symmetric(4, 14)}},
|
||||
ui.Text(ch.shellText(cur.MsgID), ui.Style{Font: codeFont(), Color: colors.SecondaryLabel}),
|
||||
@@ -1039,13 +1048,115 @@ func (ch *chat) footerRow(cur chatItem) ui.Node {
|
||||
return strings.Join(parts, " · ")
|
||||
})
|
||||
return ui.Row(ui.Style{Padding: ui.Symmetric(6, 14), Gap: 6, Align: ui.AlignCenter},
|
||||
ui.Symbol(ui.Icon("sparkles"), ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel}),
|
||||
svg.View(svg.Props{Icon: sparklesIcon, Color: ui.Val(colors.SecondaryLabel),
|
||||
Style: ui.Style{Width: ui.Pt(14), Height: ui.Pt(14)}}),
|
||||
ui.Text(facts, ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel, Lines: 1, Grow: 1}),
|
||||
ui.Button(ui.ButtonProps{Icon: ui.IconMore, Label: ui.Val("更多操作"),
|
||||
OnPress: func() { ch.footerMenu(cur.MsgID) }}),
|
||||
)
|
||||
}
|
||||
|
||||
// userActionsRow is the line under a prompt: its time, copy, and a menu,
|
||||
// as the first-party client shows.
|
||||
func (ch *chat) userActionsRow(cur chatItem) ui.Node {
|
||||
stamp := signal.Func(func() string {
|
||||
m := ch.byID.Get()[cur.MsgID]
|
||||
if m.Time.Created <= 0 {
|
||||
return ""
|
||||
}
|
||||
return time.UnixMilli(m.Time.Created).Format("15:04")
|
||||
})
|
||||
return ui.Row(ui.Style{Padding: ui.Symmetric(2, 12), Gap: 10, Justify: ui.JustifyEnd, Align: ui.AlignCenter},
|
||||
ui.Row(ui.Style{Gap: 4, Align: ui.AlignCenter},
|
||||
ui.Symbol(ui.Icon("clock"), ui.Style{Font: fonts.Caption, Color: colors.SecondaryLabel}),
|
||||
ui.Text(stamp, ui.Style{Font: fonts.Caption, Color: colors.SecondaryLabel}),
|
||||
),
|
||||
ui.Button(ui.ButtonProps{Icon: "doc.on.doc", Label: ui.Val("复制消息"),
|
||||
OnPress: func() { ch.copyUserMessage(cur.MsgID) }}),
|
||||
ui.Button(ui.ButtonProps{Icon: ui.IconMore, Label: ui.Val("消息操作"),
|
||||
OnPress: func() { ch.userActionsMenu(cur.MsgID) }}),
|
||||
)
|
||||
}
|
||||
|
||||
func (ch *chat) copyUserMessage(id string) {
|
||||
m := ch.byID.Peek()[id]
|
||||
text := strings.TrimSpace(m.Text)
|
||||
if text == "" {
|
||||
ui.Snackbar(ui.SnackbarProps{Message: "没有可复制的文字"})
|
||||
return
|
||||
}
|
||||
ui.Copy(text)
|
||||
ui.Snackbar(ui.SnackbarProps{Message: "已复制消息"})
|
||||
}
|
||||
|
||||
func (ch *chat) userActionsMenu(id string) {
|
||||
ch.userID.Set(id)
|
||||
ch.userOpen.Set(true)
|
||||
}
|
||||
|
||||
func (ch *chat) userSheet() ui.Node {
|
||||
return ui.Sheet(ui.SheetProps{
|
||||
Open: ch.userOpen,
|
||||
Detents: ui.DetentMedium,
|
||||
Grabber: true,
|
||||
OnDismiss: func() { ch.userOpen.Set(false) },
|
||||
Content: func() ui.Node {
|
||||
id := ch.userID.Peek()
|
||||
m := ch.byID.Peek()[id]
|
||||
stamp := ""
|
||||
if m.Time.Created > 0 {
|
||||
stamp = time.UnixMilli(m.Time.Created).Format("2006-01-02 15:04")
|
||||
}
|
||||
act := func(f func()) func() {
|
||||
return func() {
|
||||
ch.userOpen.Set(false)
|
||||
f()
|
||||
}
|
||||
}
|
||||
return ui.SafeArea(ui.Style{Padding: ui.All(20), Gap: 4},
|
||||
ui.StaticText("更多操作", ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel}),
|
||||
ui.Show(signal.Func(func() bool { return stamp != "" }), func() ui.Node {
|
||||
return ui.Row(ui.Style{Padding: ui.Symmetric(8, 0), Gap: 8, Align: ui.AlignCenter},
|
||||
ui.Symbol(ui.Icon("clock"), ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel}),
|
||||
ui.StaticText(stamp, ui.Style{Font: fonts.Footnote, Color: colors.SecondaryLabel}),
|
||||
)
|
||||
}),
|
||||
sheetAction("复制消息", "doc.on.doc", act(func() { ch.copyUserMessage(id) })),
|
||||
sheetAction("从这里分叉", "", act(func() { ch.forkBefore(id) })),
|
||||
)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// forkBefore copies the transcript before a message (a prompt) into a new
|
||||
// session.
|
||||
func (ch *chat) forkBefore(id string) {
|
||||
client := ch.client()
|
||||
if client == nil {
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second)
|
||||
defer cancel()
|
||||
s, err := client.ForkSession(ctx, ch.id, ch.dir, id)
|
||||
ui.Post(func() {
|
||||
if err != nil {
|
||||
ch.errText.Set(friendlyError(err))
|
||||
return
|
||||
}
|
||||
ch.c.sessions.Update(func(list []ocapi.Session) []ocapi.Session {
|
||||
next := make([]ocapi.Session, 0, len(list)+1)
|
||||
next = append(next, s)
|
||||
return append(next, list...)
|
||||
})
|
||||
if ch.nav != nil {
|
||||
nc := ch.c.openChat(&s, ch.nav)
|
||||
ch.nav.Push(nc.screen, ui.ScreenOptions{Title: nc.title, Actions: chatActions(nc)})
|
||||
}
|
||||
})
|
||||
}()
|
||||
}
|
||||
|
||||
func (ch *chat) reasoningRow(cur chatItem) ui.Node {
|
||||
key := fmt.Sprintf("reason/%s/%d", cur.MsgID, cur.Part)
|
||||
open := signal.Func(func() bool { return ch.expanded.Get()[key] })
|
||||
|
||||
@@ -333,3 +333,18 @@ func TestForkFromTurnFooter(t *testing.T) {
|
||||
t.Fatal("no fork request reached the server")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserMessageActions(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("What is this?")
|
||||
|
||||
a.Expect("复制消息")
|
||||
a.Tap("消息操作")
|
||||
a.WaitFor("从这里分叉")
|
||||
a.Expect("复制消息")
|
||||
a.Back()
|
||||
}
|
||||
@@ -10,6 +10,10 @@ import (
|
||||
// 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>`)
|
||||
|
||||
// sparklesIcon marks the turn footer. Drawn here for the same reason as
|
||||
// the server icon: not every platform's symbol set has the name.
|
||||
var sparklesIcon = 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"><path d="M12 3l1.7 4.3L18 9l-4.3 1.7L12 15l-1.7-4.3L6 9l4.3-1.7L12 3z"/><path d="M19 15l.8 1.9L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-1.1L19 15z"/></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 {
|
||||
|
||||
Reference in new issue
Block a user