feat: show a model, agent and duration footer after each turn
Match the first-party chat footer on touch screens: after a turn ends, its last assistant message gets a row with the model name (resolved from /api/model with the id as fallback), the agent and how long the turn took, plus a "more" menu. The menu shows the completion timestamp and offers copy answer and fork from here; forking copies history before the next prompt (or the whole history at the end) and opens the new session. Bump version to 0.1.7 (build 8).
This commit is contained in:
1 parent
56cf889ee9
commit
8268bdecc2
6 files changed
+308
-8
No files matched your search
@@ -21,6 +21,7 @@ type chatServer struct {
|
||||
replies chan map[string]any
|
||||
models chan map[string]any
|
||||
created chan map[string]any
|
||||
forked chan map[string]any
|
||||
events chan string
|
||||
ready chan struct{}
|
||||
readyOne sync.Once
|
||||
@@ -41,6 +42,7 @@ func newChatServer(t *testing.T) *chatServer {
|
||||
replies: make(chan map[string]any, 1),
|
||||
models: make(chan map[string]any, 1),
|
||||
created: make(chan map[string]any, 1),
|
||||
forked: make(chan map[string]any, 1),
|
||||
events: make(chan string, 8),
|
||||
ready: make(chan struct{}),
|
||||
}
|
||||
@@ -60,7 +62,8 @@ func newChatServer(t *testing.T) *chatServer {
|
||||
mux.HandleFunc("/api/session/ses_1/message", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"data":[
|
||||
{"id":"msg_1","type":"user","text":"What is this?","time":{"created":10}},
|
||||
{"id":"msg_2","type":"assistant","time":{"created":11,"completed":12},
|
||||
{"id":"msg_2","type":"assistant","agent":"build","model":{"id":"gpt-4","providerID":"openai"},
|
||||
"time":{"created":11,"completed":12000},
|
||||
"content":[{"type":"text","text":"**Hello** from the agent"}]}
|
||||
],"cursor":{}}`)
|
||||
})
|
||||
@@ -117,6 +120,19 @@ func newChatServer(t *testing.T) *chatServer {
|
||||
fmt.Fprint(w, `{"data":{"id":"ses_new","title":"New chat","time":{"created":3,"updated":3},
|
||||
"location":{"directory":"/home/me/project"}}}`)
|
||||
})
|
||||
mux.HandleFunc("/api/session/ses_1/fork", func(w http.ResponseWriter, r *http.Request) {
|
||||
var body map[string]any
|
||||
_ = json.NewDecoder(r.Body).Decode(&body)
|
||||
select {
|
||||
case cs.forked <- body:
|
||||
default:
|
||||
}
|
||||
fmt.Fprint(w, `{"data":{"id":"ses_fork","title":"Forked","time":{"created":20,"updated":20},
|
||||
"location":{"directory":"/home/me/project"}}}`)
|
||||
})
|
||||
mux.HandleFunc("/api/session/ses_fork/message", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `{"data":[],"cursor":{}}`)
|
||||
})
|
||||
mux.HandleFunc("/api/session/ses_1/permission/per_1/reply", func(w http.ResponseWriter, r *http.Request) {
|
||||
var body map[string]any
|
||||
_ = json.NewDecoder(r.Body).Decode(&body)
|
||||
@@ -279,3 +295,41 @@ func TestAgentPickerSkipsSubagents(t *testing.T) {
|
||||
a.ExpectNo("General")
|
||||
a.ExpectNo("Explore")
|
||||
}
|
||||
|
||||
func TestTurnFooter(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")
|
||||
|
||||
// The footer names the model, the agent and how long the turn took.
|
||||
a.WaitFor("GPT-4 · build · 12.0s")
|
||||
a.Tap("更多操作")
|
||||
a.WaitFor("复制回答")
|
||||
a.Expect("从这里分叉")
|
||||
a.Tap("取消")
|
||||
}
|
||||
|
||||
func TestForkFromTurnFooter(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("更多操作")
|
||||
a.Tap("从这里分叉")
|
||||
a.WaitFor("Forked")
|
||||
|
||||
select {
|
||||
case body := <-srv.forked:
|
||||
if _, ok := body["before"]; ok {
|
||||
t.Errorf("fork sent a before id for the last message: %v", body)
|
||||
}
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Fatal("no fork request reached the server")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user