feat(web): ambient banner, snooze/focus actions, settings controls

This commit is contained in:
2026-06-05 21:51:49 -04:00
parent fa178a1fd2
commit aaed1ad265
5 changed files with 82 additions and 0 deletions
+29
View File
@@ -6,8 +6,10 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"strings"
"testing"
"keel/internal/harness"
"keel/internal/settings"
)
@@ -220,3 +222,30 @@ func TestBrowseBadDirIs400(t *testing.T) {
t.Fatalf("status = %d, want 400", w.Code)
}
}
func TestPostSettingsPreservesBlankAmbientFields(t *testing.T) {
h := harness.New(harness.Services{}, map[string]harness.Factory{})
s := NewServer(h)
dir := t.TempDir()
path := filepath.Join(dir, "settings.json")
current := settings.Settings{AIBackend: "claude", AmbientMode: "status", AmbientCadenceSecs: 120}
s.SetSettings(path, current, func(settings.Settings) error { return nil })
// A POST that omits the ambient fields must not blank them.
body := `{"ai_backend":"claude"}`
w := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodPost, "/settings", strings.NewReader(body))
req.Header.Set("Content-Type", "application/json")
s.Router().ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Fatalf("status = %d body = %s", w.Code, w.Body.String())
}
saved, err := settings.Load(path)
if err != nil {
t.Fatalf("load: %v", err)
}
if saved.AmbientMode != "status" || saved.AmbientCadenceSecs != 120 {
t.Fatalf("ambient fields not preserved: mode=%q cadence=%d", saved.AmbientMode, saved.AmbientCadenceSecs)
}
}