Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334package tui
import ( "testing"
"albedo/cli/internal/daemon")
// Catches a stop that drops the queued messages the daemon cancelled: they// must come back after what is typed, with their attachments renumbered// behind the ones already in the composer.func TestCancelledQueuedMessagesReturnToTheComposer(t *testing.T) { m := newTestChatModel(t, &daemon.Session{ID: "s"}) image := daemon.ImageAttachment{ImageMetadata: daemon.ImageMetadata{MimeType: "image/png"}} m.TextArea.SetValue("draft " + m.Images.add(pastedImage{ImageAttachment: image})) m.pendingUsers = []PendingUserTurn{ {OperationID: "a", Text: "first [Image #1]", Images: []daemon.ImageAttachment{image}}, {OperationID: "kept", Text: "not cancelled"}, {OperationID: "b", Text: "second"}, }
m.restoreCancelled([]string{"a", "b"})
if got, want := m.TextArea.Value(), "draft [Image #1]\n\nfirst [Image #2]\n\nsecond"; got != want { t.Fatalf("composer = %q, want %q", got, want) } if _, items := m.Images.resolve(m.TextArea.Value()); len(items) != 2 { t.Fatalf("composer holds %d images, want 2", len(items)) } if len(m.pendingUsers) != 1 || m.pendingUsers[0].OperationID != "kept" { t.Fatalf("pending = %+v, want only the message that was not cancelled", m.pendingUsers) }}