oficina / equipo Public

Carry the original question with sub-chat follow-up replies

Paul Campbell pushed by paul@keymail.dev 5578460e12790073ce460beb08888507f6d9a1cf parent 357ba14
4 files changed, +27 −2
  • .rastrillo/budgets.txt +1 −1
  • internal/equipo/chat/projects.go +1 −1
  • internal/equipo/chat/roster_test.go +21 −0
  • internal/thintest/roster_browser_test.go +4 −0

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 80adbc24..7d6fe4e3 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -71,7 +71,7 @@ perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one im
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally).
size internal/headless - 10739 End-to-end scenarios through a real runner and instance: the Copy setting, wording flag and the Assistant's job threads. Measured 10739 test lines.
-size internal/thintest - 28316 The contract and browser tests share the instance harness; Roster adds real action states and desktop/phone captures in both themes. Measured 28316 test lines.
+size internal/thintest - 28320 The contract and browser tests share the instance harness; Roster adds real action states and desktop/phone captures in both themes. Measured 28320 test lines.
perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}.
perf GET /api/v1/usage skip Thin v1 person API: bearer-only JSON for devices; the browser reads usage through /usage.
perf GET /api/v1/advice skip Thin v1 person API: bearer-only JSON for devices; the browser reads advice through /usage and /conversation.
diff --git a/internal/equipo/chat/projects.go b/internal/equipo/chat/projects.go
index 8b2c399c..dff97863 100644
--- a/internal/equipo/chat/projects.go
+++ b/internal/equipo/chat/projects.go
@@ -825,7 +825,7 @@ func (t *txn) answerHome(person string, c cardRecord, in wire.AnswerCard) (wire.
// answerPrefix gives the coordinator the question a message answers.
func (t *txn) answerPrefix(m messageRecord) (string, error) {
var c cardRecord
- err := t.db.Where("answer_message = ? AND person = ?", m.ID, m.Person).First(&c).Error
+ err := t.db.Where("person = ? AND (answer_message = ? OR id IN (SELECT card_id FROM chat_card_threads WHERE message_id = ? AND person = ?))", m.Person, m.ID, m.ID, m.Person).First(&c).Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return m.Text, nil
}
diff --git a/internal/equipo/chat/roster_test.go b/internal/equipo/chat/roster_test.go
index cea7c08c..3de35b83 100644
--- a/internal/equipo/chat/roster_test.go
+++ b/internal/equipo/chat/roster_test.go
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"reflect"
+ "strings"
"testing"
"amadan.net/oficina/equipo/internal/wire"
@@ -109,3 +110,23 @@ func TestRosterFinalCopyCannotBeSetAside(t *testing.T) {
t.Fatalf("ended Copy hold was hidden: %v", err)
}
}
+
+func TestRosterFollowupCarriesQuestion(t *testing.T) {
+ r := newMeteredRig(t)
+ c := cardRecord{ID: "c_followup", Person: hkOwner, Kind: wire.CardQuestion, State: wire.CardAnswered, Question: "Which page should change?", Options: "[]", Revision: 1}
+ if err := r.s.db.G.Create(&c).Error; err != nil {
+ t.Fatal(err)
+ }
+ if err := r.s.db.G.Create(&cardThreadRecord{ID: "ct_followup", CardID: c.ID, Person: hkOwner, MessageID: "m_followup"}).Error; err != nil {
+ t.Fatal(err)
+ }
+ if err := r.s.tx(context.Background(), func(tx *txn) error {
+ text, err := tx.answerPrefix(messageRecord{ID: "m_followup", Person: hkOwner, Text: "Keep the email link."})
+ if err == nil && !strings.Contains(text, c.Question) {
+ t.Fatalf("follow-up lost card context: %q", text)
+ }
+ return err
+ }); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/internal/thintest/roster_browser_test.go b/internal/thintest/roster_browser_test.go
index 40137b31..b6c69a8b 100644
--- a/internal/thintest/roster_browser_test.go
+++ b/internal/thintest/roster_browser_test.go
@@ -7,6 +7,7 @@ import (
"fmt"
"github.com/chromedp/cdproto/input"
"github.com/chromedp/chromedp"
+ "strings"
"testing"
)
@@ -125,6 +126,9 @@ func TestBrowserRosterSubchat(t *testing.T) {
p.click(`[equipo-mini-composer] [data-thread-send]`)
f2, b2 := r.expect(wire.FrameMessage)
m2 := b2.(*wire.MessageCommand)
+ if !strings.Contains(m2.Text, "Which page should change?") || len(m2.PersonText) != 1 || m2.PersonText[0] != "Keep the email link." {
+ t.Fatalf("follow-up context %+v", m2)
+ }
r.runner.Send(r.ctx, "roster-a2", wire.FrameAck, wire.Ack{ID: f2.ID})
r.runner.Send(r.ctx, "roster-answer2", wire.FrameReply, wire.Reply{TurnID: m2.TurnID, Attempt: 1, Text: "The email link will stay."})
p.wait(`document.querySelector('[equipo-subchat]').textContent.includes('The email link will stay.') && document.querySelectorAll('[equipo-subchat] [data-own]').length===2`, "second round stays in the thread")