Show server-queued chat prompts from the server, with Remove
The thread reads the session's queued prompts from the chat_subscribe reply and chat_queue frames: a reload draws them as Queued after the transcript, a delivered one enters the transcript as Sent, a refused one becomes Not sent, and Remove sends chat_unqueue. A prompt the server reports queued is dropped from the device unsent store; the any-frame queued heuristic is used only with a server that does not report its queue.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -55,12 +56,20 @@ func (s *queueServer) stop() {
|
||||
|
||||
func openQueueStore(t *testing.T, path string) *pipeline.Store {
|
||||
t.Helper()
|
||||
store, err := pipeline.Open(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
// A just-stopped server's background workers may still be finishing a
|
||||
// write when the database is reopened; wait out that brief lock.
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for {
|
||||
store, err := pipeline.Open(path)
|
||||
if err == nil {
|
||||
t.Cleanup(func() { store.Close() })
|
||||
return store
|
||||
}
|
||||
if !strings.Contains(err.Error(), "SQLITE_BUSY") || time.Now().After(deadline) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
}
|
||||
t.Cleanup(func() { store.Close() })
|
||||
return store
|
||||
}
|
||||
|
||||
func queuedOps(t *testing.T, store *pipeline.Store) []string {
|
||||
|
||||
Reference in New Issue
Block a user