From d9fc824eddfa8520d03d5d0e27a2c5d5929e9a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Almeida?= Date: Tue, 5 May 2026 22:27:14 +0100 Subject: [PATCH] test(sprites): lock in informative branch name in fallback warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that BaseBranch is preserved on resume for clone-based executors, the missing-sandbox fallback warning detail names the actual branch ("Cloning … on the same branch main") instead of the "(unknown)" placeholder. Add a regression test so a future change to the resume metadata propagation can't silently regress that copy. --- .../executor_sprites_fallback_test.go | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/backend/internal/agent/lifecycle/executor_sprites_fallback_test.go b/apps/backend/internal/agent/lifecycle/executor_sprites_fallback_test.go index 28f95ac8f5..10ec044f45 100644 --- a/apps/backend/internal/agent/lifecycle/executor_sprites_fallback_test.go +++ b/apps/backend/internal/agent/lifecycle/executor_sprites_fallback_test.go @@ -117,6 +117,36 @@ func TestSpritesFallbackToFreshSandboxEmitsWarningAndMutatesPlan(t *testing.T) { } } +func TestSpritesFallbackNamesBaseBranchInWarningDetail(t *testing.T) { + r := newTestSpritesExecutor(nil) + plan := newSpritesProgressPlan(true) + var emitted []PrepareStep + + // After Fix 1 (preserve BaseBranch on resume for clone-based executors), + // the fallback request always carries MetadataKeyBaseBranch — this test + // locks in that the user-facing warning detail names the actual base + // branch rather than the "(unknown)" placeholder. + req := &ExecutorCreateRequest{ + InstanceID: "abcdef0123456789aaaa", + Metadata: map[string]interface{}{ + MetadataKeyBaseBranch: "main", + }, + } + r.fallbackToFreshSandbox(req, plan, func(_ spritesStepKey, step PrepareStep) { + emitted = append(emitted, step) + }, "kandev-old1234567890") + + if len(emitted) != 1 { + t.Fatalf("expected 1 event, got %d", len(emitted)) + } + if !strings.Contains(emitted[0].WarningDetail, "branch main") { + t.Fatalf("warning detail should name base branch, got %q", emitted[0].WarningDetail) + } + if !strings.Contains(emitted[0].Output, "Branch: main") { + t.Fatalf("output should name base branch, got %q", emitted[0].Output) + } +} + func TestSpritesFallbackUsesPlaceholderBranchWhenMissing(t *testing.T) { r := newTestSpritesExecutor(nil) plan := newSpritesProgressPlan(true)