feat: open the turn actions in a bottom sheet

The footer's "more" button now opens a sheet with the completion time
above the actions, matching the first-party client; the platform action
sheet dropped the time. Copy answer and fork from here are listed, and
a back gesture dismisses it.

Bump version to 0.1.9 (build 10).
This commit is contained in:
blumia committed 2026-11-16 18:34:32 +08:00
1 parent a471c026f1
commit d3e92f036a
3 files changed
+57 -20

No files matched your search

+54 -17
View File
@@ -60,6 +60,9 @@ type chat struct {
modelNames *signal.Signal[map[string]string]
footerOpen *signal.Signal[bool]
footerID *signal.Signal[string]
pickerOpen *signal.Signal[bool]
pickerKind string
pickerItems *signal.Signal[[]pickerItem]
@@ -100,6 +103,8 @@ func (c *controller) openChat(s *ocapi.Session, nav *ui.Navigator) *chat {
permList: signal.NewFunc([]ocapi.PermissionRequest{}, nil),
hasPerms: signal.New(false),
modelNames: signal.NewFunc(map[string]string{}, nil),
footerOpen: signal.New(false),
footerID: signal.New(""),
pickerOpen: signal.New(false),
pickerItems: signal.NewFunc([]pickerItem{}, nil),
pickerFilter: signal.New(""),
@@ -226,27 +231,58 @@ func (ch *chat) copyAnswer(id string) {
}
func (ch *chat) footerMenu(id string) {
m := ch.byID.Peek()[id]
label := ch.modelName(m.Model)
if label == "" {
label = "回答"
}
stamp := ""
if m.Time.Completed > 0 {
stamp = time.UnixMilli(m.Time.Completed).Format("2006-01-02 15:04")
}
ui.Alert(ui.AlertProps{
Title: label,
Message: stamp,
ActionSheet: true,
Actions: []ui.Action{
{Title: ui.Val("复制回答"), Icon: "doc.on.doc", OnPress: func() { ch.copyAnswer(id) }},
{Title: ui.Val("从这里分叉"), OnPress: func() { ch.forkFrom(id) }},
{Title: ui.Val("取消"), Role: ui.ActionCancel},
ch.footerID.Set(id)
ch.footerOpen.Set(true)
}
// footerSheet is the "more" panel: the completion time, then the actions,
// as the first-party client shows on touch screens.
func (ch *chat) footerSheet() ui.Node {
return ui.Sheet(ui.SheetProps{
Open: ch.footerOpen,
Detents: ui.DetentMedium,
Grabber: true,
OnDismiss: func() { ch.footerOpen.Set(false) },
Content: func() ui.Node {
id := ch.footerID.Peek()
m := ch.byID.Peek()[id]
stamp := ""
if m.Time.Completed > 0 {
stamp = time.UnixMilli(m.Time.Completed).Format("2006-01-02 15:04")
}
act := func(f func()) func() {
return func() {
ch.footerOpen.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.copyAnswer(id) })),
sheetAction("从这里分叉", "", act(func() { ch.forkFrom(id) })),
)
},
})
}
func sheetAction(title string, icon ui.Icon, onPress func()) ui.Node {
parts := make([]ui.Node, 0, 2)
if icon != "" {
parts = append(parts, ui.Symbol(icon, ui.Style{Font: fonts.Body, Color: colors.SecondaryLabel}))
}
parts = append(parts, ui.StaticText(title, ui.Style{Font: fonts.Body}))
return ui.View(ui.ViewProps{
OnPress: onPress,
Style: ui.Style{Padding: ui.Symmetric(12, 4), Align: ui.AlignCenter},
}, ui.Row(ui.Style{Gap: 12, Align: ui.AlignCenter}, parts...))
}
func (ch *chat) forkFrom(id string) {
client := ch.client()
if client == nil {
@@ -622,6 +658,7 @@ func (ch *chat) screen() ui.Node {
ch.permissionSection(),
ch.composer(),
),
ch.footerSheet(),
ui.Sheet(ui.SheetProps{
Open: ch.pickerOpen,
Detents: ui.DetentLarge,
+1 -1
View File
@@ -309,7 +309,7 @@ func TestTurnFooter(t *testing.T) {
a.Tap("更多操作")
a.WaitFor("复制回答")
a.Expect("从这里分叉")
a.Tap("取消")
a.Back()
}
func TestForkFromTurnFooter(t *testing.T) {