bots-garden/sidekickspublic Fork
⑂ 1f1f4a1
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/sidekicks.git
git clone ssh://git@rickub.com/bots-garden/sidekicks.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

creator : tests tolérants à l'ordre message / formulaire

Un message que mm envoie juste avant un formulaire peut arriver avec la vue
suivante (le SDK traite notifications et requêtes sur leurs propres
goroutines) : les tests ne supposent plus l'ordre ; vu en lançant tous les
paquets ensemble.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agent committed 2026-11-15T04:25:48+01:00 Browse files
1f1f4a1 parent: 0bd44f0
modified internal/creator/creator_test.go +9 -4
@@ -89,13 +89,17 @@ func begin(t *testing.T, options creator.Options, name string) *creator.Session
8989 if view.Form == nil || len(view.Form.Fields) != 2 || view.Form.Fields[0].Name != "provider" || view.Form.Fields[1].Name != "name" {
9090 t.Fatalf("first view: %+v", view)
9191 }
92- if len(view.Messages) == 0 || !strings.Contains(strings.Join(view.Messages, "\n"), "args=--acp-create --project yes --output .mm/agent.yaml") {
93- t.Fatalf("messages: %q", view.Messages)
94- }
92+ // A message mm sends just before a form may come with the next view:
93+ // the SDK hands notifications and requests over on their own goroutines.
94+ said := view.Messages
9595 view, err = session.Answer(context.Background(), acp.FormAnswer{Action: acp.FormAccept, Content: map[string]any{"provider": "llmman", "name": name}})
9696 if err != nil {
9797 t.Fatal(err)
9898 }
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+ }
99103 if !view.Written || view.Form != nil {
100104 t.Fatalf("after the form: %+v", view)
101105 }
@@ -211,7 +215,8 @@ func TestADeclinedFormEndsTheTurnWithMMsMessage(t *testing.T) {
211215 if err != nil {
212216 t.Fatal(err)
213217 }
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") {
215220 t.Fatalf("view: %+v", view)
216221 }
217222 if _, err := session.Finish(context.Background(), "bob", creator.Local); !errors.Is(err, creator.ErrNotWritten) {
@@ -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) {