@@ -699,15 +699,15 @@ func TestBootstrapACPConversationLoadsStoredSessionWithoutMutatingIdentity(t *te
699699 }
700700}
701701
702- func TestBootstrapACPConversationNormalizesLegacyHomeCWDToResolvedDefault (t * testing.T ) {
702+ func TestBootstrapACPConversationUsesResolvedDefaultWhenOverrideMissing (t * testing.T ) {
703703 spritz := readyACPSpritz ("tidy-otter" , "user-1" )
704704 spritz .Spec .Repo = & spritzv1.SpritzRepo {
705705 URL : "https://example.com/open/spritz.git" ,
706706 Dir : "/workspace/platform" ,
707707 }
708708 conversation := conversationFor ("tidy-otter-conv" , "tidy-otter" , "user-1" , "Latest" , metav1 .Now ())
709709 conversation .Spec .SessionID = "session-existing"
710- conversation .Spec .CWD = "/home/dev "
710+ conversation .Spec .CWD = ""
711711 fakeACP := newFakeACPBootstrapServer (t , fakeACPBootstrapServerOptions {})
712712
713713 s := newACPTestServer (t , spritz , conversation )
@@ -746,6 +746,53 @@ func TestBootstrapACPConversationNormalizesLegacyHomeCWDToResolvedDefault(t *tes
746746 }
747747}
748748
749+ func TestBootstrapACPConversationPreservesExplicitWorkspaceOverride (t * testing.T ) {
750+ spritz := readyACPSpritz ("tidy-otter" , "user-1" )
751+ spritz .Spec .Repo = & spritzv1.SpritzRepo {
752+ URL : "https://example.com/open/spritz.git" ,
753+ Dir : "/workspace/platform" ,
754+ }
755+ conversation := conversationFor ("tidy-otter-conv" , "tidy-otter" , "user-1" , "Latest" , metav1 .Now ())
756+ conversation .Spec .SessionID = "session-existing"
757+ setConversationCWDOverride (conversation , "/workspace" )
758+ fakeACP := newFakeACPBootstrapServer (t , fakeACPBootstrapServerOptions {})
759+
760+ s := newACPTestServer (t , spritz , conversation )
761+ s .acp .instanceURL = func (namespace , name string ) string { return fakeACP .url }
762+
763+ e := echo .New ()
764+ secured := e .Group ("" , s .authMiddleware ())
765+ secured .POST ("/api/acp/conversations/:id/bootstrap" , s .bootstrapACPConversation )
766+
767+ req := httptest .NewRequest (http .MethodPost , "/api/acp/conversations/" + conversation .Name + "/bootstrap" , nil )
768+ req .Header .Set ("X-Spritz-User-Id" , "user-1" )
769+ rec := httptest .NewRecorder ()
770+ e .ServeHTTP (rec , req )
771+
772+ if rec .Code != http .StatusOK {
773+ t .Fatalf ("expected status 200, got %d: %s" , rec .Code , rec .Body .String ())
774+ }
775+
776+ var payload struct {
777+ Status string `json:"status"`
778+ Data struct {
779+ EffectiveCWD string `json:"effectiveCwd"`
780+ } `json:"data"`
781+ }
782+ if err := json .Unmarshal (rec .Body .Bytes (), & payload ); err != nil {
783+ t .Fatalf ("failed to decode bootstrap response: %v" , err )
784+ }
785+ if payload .Data .EffectiveCWD != "/workspace" {
786+ t .Fatalf ("expected explicit cwd override to be preserved, got %q" , payload .Data .EffectiveCWD )
787+ }
788+
789+ fakeACP .mu .Lock ()
790+ defer fakeACP .mu .Unlock ()
791+ if len (fakeACP .loadCWDs ) != 1 || fakeACP .loadCWDs [0 ] != "/workspace" {
792+ t .Fatalf ("expected session/load cwd /workspace, got %#v" , fakeACP .loadCWDs )
793+ }
794+ }
795+
749796func TestBootstrapACPConversationRepairsMissingSessionExplicitly (t * testing.T ) {
750797 spritz := readyACPSpritz ("tidy-otter" , "user-1" )
751798 conversation := conversationFor ("tidy-otter-conv" , "tidy-otter" , "user-1" , "Latest" , metav1 .Now ())
0 commit comments