From f1622360c4030f30ad51ccb563df3eb669bb1825 Mon Sep 17 00:00:00 2001 From: enowdev Date: Tue, 10 Nov 2026 08:44:23 +0700 Subject: [PATCH] Say a report's task is settled once, however often it waits A report of a task settled before GOA took it is told with a note saying so (#53). The note was added each time the line was handed out, and a line GOA couldn't take yet goes back to wait with it in its text, so the note came again at each try: in goa-tell.json and in what GOA was finally told. Co-Authored-By: Claude Opus 5.5 Signed-off-by: enowdev --- daemon/goa.go | 5 ++++- daemon/goa_settled_report_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/daemon/goa.go b/daemon/goa.go index 9d07d87d..458dd454 100644 --- a/daemon/goa.go +++ b/daemon/goa.go @@ -452,7 +452,10 @@ func (s *Server) goaLinesToSay() []goaLine { case l.Task == "" || !s.goa.board.IsSettled(l.Task): out = append(out, l) case l.Report: - l.Text += goaSettledNote + // Once: a line GOA couldn't take comes back here with it said already. + if !strings.HasSuffix(l.Text, goaSettledNote) { + l.Text += goaSettledNote + } out = append(out, l) } } diff --git a/daemon/goa_settled_report_test.go b/daemon/goa_settled_report_test.go index 7b1b9140..d133e77a 100644 --- a/daemon/goa_settled_report_test.go +++ b/daemon/goa_settled_report_test.go @@ -46,3 +46,29 @@ func TestGOAReportJoinedStaysAReport(t *testing.T) { t.Fatalf("waiting: %+v", srv.goa.tell) } } + +// A settled task's report GOA can't take yet goes back to wait, as goaFlush and +// goaTakeAtStop put it back, and still says its task is settled once when it goes. +func TestGOASettledNoteSaidOnce(t *testing.T) { + srv := startServer(t) + task, err := srv.goa.board.Add(proto.GOATask{Title: "settled", Session: "a-session", Status: proto.GOATaskWorking}) + if err != nil { + t.Fatal(err) + } + if _, err := srv.goa.board.Update(task.ID, func(x *proto.GOATask) { x.Status = proto.GOATaskDone }); err != nil { + t.Fatal(err) + } + srv.goa.mu.Lock() + srv.goa.tell = []goaLine{{Text: "it reports done", Task: task.ID, Session: "a-session", Turn: goaLineReport, Report: true, Closed: true}} + srv.goa.mu.Unlock() + for range 3 { + lines := srv.goaLinesToSay() + srv.goa.mu.Lock() + srv.goa.tell = append(lines, srv.goa.tell...) + srv.goa.mu.Unlock() + } + got := srv.goaLinesToSay() + if len(got) != 1 || strings.Count(got[0].Text, goaSettledNote) != 1 { + t.Fatalf("after three returns: %+v", got) + } +}