| @@ -89,13 +89,17 @@ func begin(t *testing.T, options creator.Options, name string) *creator.Session |
| 89 | if view.Form == nil || len(view.Form.Fields) != 2 || view.Form.Fields[0].Name != "provider" || view.Form.Fields[1].Name != "name" { | 89 | if view.Form == nil || len(view.Form.Fields) != 2 || view.Form.Fields[0].Name != "provider" || view.Form.Fields[1].Name != "name" { |
| 90 | t.Fatalf("first view: %+v", view) | 90 | t.Fatalf("first view: %+v", view) |
| 91 | } | 91 | } |
| 92 | - if len(view.Messages) == 0 || !strings.Contains(strings.Join(view.Messages, "\n"), "args=--acp-create --project yes --output .mm/agent.yaml") { | 92 | + // A message mm sends just before a form may come with the next view: |
| 93 | - t.Fatalf("messages: %q", view.Messages) | 93 | + // the SDK hands notifications and requests over on their own goroutines. |
| 94 | - } | 94 | + said := view.Messages |
| 95 | view, err = session.Answer(context.Background(), acp.FormAnswer{Action: acp.FormAccept, Content: map[string]any{"provider": "llmman", "name": name}}) | 95 | view, err = session.Answer(context.Background(), acp.FormAnswer{Action: acp.FormAccept, Content: map[string]any{"provider": "llmman", "name": name}}) |
| 96 | if err != nil { | 96 | if err != nil { |
| 97 | t.Fatal(err) | 97 | t.Fatal(err) |
| 98 | } | 98 | } |
| | 99 | + said = append(said, view.Messages...) |
| | 100 | + if !strings.Contains(strings.Join(said, "\n"), "args=--acp-create --project yes --output .mm/agent.yaml") { |
| | 101 | + t.Fatalf("messages: %q", said) |
| | 102 | + } |
| 99 | if !view.Written || view.Form != nil { | 103 | if !view.Written || view.Form != nil { |
| 100 | t.Fatalf("after the form: %+v", view) | 104 | t.Fatalf("after the form: %+v", view) |
| 101 | } | 105 | } |
| @@ -211,7 +215,8 @@ func TestADeclinedFormEndsTheTurnWithMMsMessage(t *testing.T) { |
| 211 | if err != nil { | 215 | if err != nil { |
| 212 | t.Fatal(err) | 216 | t.Fatal(err) |
| 213 | } | 217 | } |
| 214 | - if view.Form != nil || view.Written || len(view.Messages) != 1 || !strings.HasPrefix(view.Messages[0], "Stopped") { | 218 | + // The last message is mm's answer to the decline (its first one may come late, see begin). |
| | 219 | + if view.Form != nil || view.Written || len(view.Messages) == 0 || !strings.HasPrefix(view.Messages[len(view.Messages)-1], "Stopped") { |
| 215 | t.Fatalf("view: %+v", view) | 220 | t.Fatalf("view: %+v", view) |
| 216 | } | 221 | } |
| 217 | if _, err := session.Finish(context.Background(), "bob", creator.Local); !errors.Is(err, creator.ErrNotWritten) { | 222 | if _, err := session.Finish(context.Background(), "bob", creator.Local); !errors.Is(err, creator.ErrNotWritten) { |