bc218dfbbe
* feat: add workspace sources from files panel * fix: preserve worktree identity during recovery * feat: unify workspace source actions * fix: validate recovered workspace repositories * fix: harden workspace source filesystem boundaries * test: split workspace repository chip coverage * fix: restrict repository rescan recovery paths * fix: stabilize workspace source CI checks * test: canonicalize workspace source paths * test: align workspace source container paths * fix: populate direct workspace repository names * test: preserve git fixture rewrites across restarts * test: isolate backend git fixture config * fix: resume remote workspace executions before creation * fix: preserve ssh agent identity during resume * fix: preserve SSH workspace across backend restart * fix: simplify workspace actions trigger * fix: refine add workspace repositories UX * docs: narrow workspace source UX updates * fix: avoid phantom turn on session resume * test(web): normalize workspace source request headers * feat(web): streamline workspace source picker * docs: remove trailing spaces from workspace source plan * fix: prevent resume status from creating phantom turns * fix(web): stabilize workspace source attachment * refactor(web): extract workspace source store contract * fix: avoid phantom turns on idle agent resume * fix: address backend static analysis findings * fix: preserve agentctl readiness status value * fix: preserve resume messages without active turns * fix: resume agents from promoted workspace root * chore: merge origin/main into feature/add-new-repo-folder-d97 * feat(web): explain workspace source consequences * test(websocket): count session activity subscription
70 lines
2.2 KiB
Go
70 lines
2.2 KiB
Go
package v1
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestMessageAttachmentHasValidDeliveryMode(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
deliveryMode string
|
|
want bool
|
|
}{
|
|
{name: "empty defaults to prompt", deliveryMode: "", want: true},
|
|
{name: "prompt", deliveryMode: "prompt", want: true},
|
|
{name: "path", deliveryMode: "path", want: true},
|
|
{name: "invalid", deliveryMode: "inline", want: false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := (MessageAttachment{DeliveryMode: tt.deliveryMode}).HasValidDeliveryMode()
|
|
if got != tt.want {
|
|
t.Fatalf("HasValidDeliveryMode() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestTaskSerializesWorkspaceFolders(t *testing.T) {
|
|
payload, err := json.Marshal(Task{WorkspaceFolders: []TaskWorkspaceFolder{{
|
|
ID: "folder-1", TaskID: "task-1", LocalPath: "/canonical/docs", DisplayName: "docs", Position: 1,
|
|
}}})
|
|
if err != nil {
|
|
t.Fatalf("marshal task: %v", err)
|
|
}
|
|
var fields map[string]json.RawMessage
|
|
if err := json.Unmarshal(payload, &fields); err != nil {
|
|
t.Fatalf("decode task: %v", err)
|
|
}
|
|
if _, ok := fields["workspace_folders"]; !ok {
|
|
t.Fatalf("workspace_folders missing from task JSON: %s", payload)
|
|
}
|
|
}
|
|
|
|
func TestAggregateForegroundActivity(t *testing.T) {
|
|
gen := ForegroundActivityGenerating
|
|
bg := ForegroundActivityBackground
|
|
tests := []struct {
|
|
name string
|
|
activities []ForegroundActivity
|
|
want ForegroundActivity
|
|
}{
|
|
{name: "empty is empty", activities: nil, want: ""},
|
|
{name: "any generating wins over background", activities: []ForegroundActivity{bg, gen}, want: gen},
|
|
{name: "all background is background", activities: []ForegroundActivity{bg, bg}, want: bg},
|
|
{name: "single background", activities: []ForegroundActivity{bg}, want: bg},
|
|
{name: "single generating", activities: []ForegroundActivity{gen}, want: gen},
|
|
{name: "empty values are ignored", activities: []ForegroundActivity{"", bg, ""}, want: bg},
|
|
{name: "only empty values fall through", activities: []ForegroundActivity{"", ""}, want: ""},
|
|
}
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := AggregateForegroundActivity(tc.activities); got != tc.want {
|
|
t.Fatalf("got %q, want %q", got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|