feat(web): ambient line in state envelope + /ambient/snooze
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -417,6 +417,34 @@ func TestReflectionFlowsToReviewThenPlanning(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStateJSONIncludesAmbient(t *testing.T) {
|
||||
h := harness.New(harness.Services{}, map[string]harness.Factory{})
|
||||
s := NewServer(h)
|
||||
s.SetAmbient(func() string { return "deep in YouTube" }, func(time.Duration) {})
|
||||
js := s.stateJSON()
|
||||
if !strings.Contains(js, `"ambient":"deep in YouTube"`) {
|
||||
t.Fatalf("state JSON missing ambient field: %s", js)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAmbientSnoozeRoute(t *testing.T) {
|
||||
h := harness.New(harness.Services{}, map[string]harness.Factory{})
|
||||
s := NewServer(h)
|
||||
var snoozed time.Duration
|
||||
s.SetAmbient(func() string { return "" }, func(d time.Duration) { snoozed = d })
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodPost, "/ambient/snooze", nil)
|
||||
s.Router().ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusNoContent {
|
||||
t.Fatalf("snooze status = %d, want 204", w.Code)
|
||||
}
|
||||
if snoozed != time.Hour {
|
||||
t.Fatalf("snooze duration = %v, want 1h", snoozed)
|
||||
}
|
||||
}
|
||||
|
||||
type stubJudge struct{ verdict ai.Verdict }
|
||||
|
||||
func (j stubJudge) JudgeDrift(ctx context.Context, commitment, class, title string) (ai.Verdict, error) {
|
||||
|
||||
Reference in New Issue
Block a user