carlos / platform Public

host test: replaced session's End may follow the new Status (#897)

The fake door fans every connection into one channel, so the new
session's Status can be queued before the old session's End. The test
skips Status frames until that End and still requires it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from ix-replaced-frame-order into main.
claude agent, operated by paul@keymail.dev 293881adf6e43eb981ad8c5562c9dfd9a1128cda parent 84f2fd8
1 file changed, +22 −1
  • internal/host/interactive_test.go +22 −1

CI failed — run details

diff --git a/internal/host/interactive_test.go b/internal/host/interactive_test.go
index c0c77a37c..4b1042433 100644
--- a/internal/host/interactive_test.go
+++ b/internal/host/interactive_test.go
@@ -492,6 +492,23 @@ func (d *ixDoor) wantStatus(t *testing.T, state string) {
}
}
+// wantEndAfterStatus is wantEnd where another connection's Status frames
+// may come first on the shared channel; it skips those, nothing else.
+func (d *ixDoor) wantEndAfterStatus(t *testing.T) interactive.End {
+ t.Helper()
+ for {
+ f := d.next(t)
+ if f.kind == interactive.KindStatus {
+ continue
+ }
+ var e interactive.End
+ if f.kind != interactive.KindEnd || json.Unmarshal(f.payload, &e) != nil {
+ t.Fatalf("frame %q %s, want an End", f.kind, f.payload)
+ }
+ return e
+ }
+}
+
func (d *ixDoor) wantEnd(t *testing.T) interactive.End {
t.Helper()
f := d.next(t)
@@ -2099,7 +2116,11 @@ func TestInteractiveWorkerReaderGivesUpWhenReplacedDuringOpen(t *testing.T) {
waitFor(t, "the replacement", func() bool { return s.ctx.Err() != nil })
}
wd.session()
- if e := wd.door.wantEnd(t); e.Reason != interactive.EndReplaced {
+ // The door's frames come from both connections on one channel. The old
+ // session sends its End before the new one dials, but each connection
+ // is read on its own goroutine, so the new session's Status can be
+ // queued first (#897: frame 's' {"state":"starting"}, want an End).
+ if e := wd.door.wantEndAfterStatus(t); e.Reason != interactive.EndReplaced {
t.Fatalf("the old session's end %+v, want replaced", e)
}
waitFor(t, "the new session to start", func() bool { return len(wd.launch.calls()) == 1 })