From f6ce4588f45440ede133d68813a79e13b584c75a Mon Sep 17 00:00:00 2001 From: jedarden Date: Wed, 22 Apr 2026 13:22:47 -0400 Subject: [PATCH] =?UTF-8?q?fix(api):=20rename=20/api/ui-feedback=20to=20/a?= =?UTF-8?q?pi/feedback=20per=20plan=20=C2=A713.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The community feedback endpoint was registered as /api/ui-feedback in the Go API but the plan and annotation.ts client both use /api/feedback. Rename the route and update agentation-overlay.ts to match. Add a route-level test asserting the canonical path and that the old path returns 404. Co-Authored-By: Claude Opus 4.7 --- cmd/acb-api/server.go | 8 ++++---- cmd/acb-api/server_test.go | 27 +++++++++++++++++++++++++++ web/src/agentation-overlay.ts | 4 ++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/cmd/acb-api/server.go b/cmd/acb-api/server.go index 96b13f3..aeeec94 100644 --- a/cmd/acb-api/server.go +++ b/cmd/acb-api/server.go @@ -43,8 +43,8 @@ func (s *Server) RegisterRoutes(mux *http.ServeMux) { mux.HandleFunc("GET /api/bot/", s.handleGetBot) mux.HandleFunc("GET /api/bots", s.handleListBots) - // UI feedback (Agentation overlay) - mux.HandleFunc("POST /api/ui-feedback", s.handleUIFeedback) + // Community replay feedback per plan §13.6 + mux.HandleFunc("POST /api/feedback", s.handleUIFeedback) // Predictions mux.HandleFunc("POST /api/predict", s.handlePredict) @@ -1072,8 +1072,8 @@ func (s *Server) handlePredictionHistory(w http.ResponseWriter, r *http.Request) }) } -// handleUIFeedback handles POST /api/ui-feedback -// Accepts Agentation UI feedback (annotations, issues, etc.). +// handleUIFeedback handles POST /api/feedback +// Accepts community replay feedback per plan §13.6 (annotations, issues, etc.). // Stores in database or logs to disk. func (s *Server) handleUIFeedback(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { diff --git a/cmd/acb-api/server_test.go b/cmd/acb-api/server_test.go index d85c63d..170fed8 100644 --- a/cmd/acb-api/server_test.go +++ b/cmd/acb-api/server_test.go @@ -71,3 +71,30 @@ func TestWriteError(t *testing.T) { t.Errorf("body = %v, want error=test error", body) } } + +// TestFeedbackEndpointPath asserts that the community feedback endpoint is +// served at /api/feedback per plan §13.6 — not /api/ui-feedback. +func TestFeedbackEndpointPath(t *testing.T) { + srv := newTestServer() + mux := http.NewServeMux() + srv.RegisterRoutes(mux) + + // POST /api/feedback should be routed (200 from handler, not 404) + req := httptest.NewRequest("POST", "/api/feedback", nil) + w := httptest.NewRecorder() + mux.ServeHTTP(w, req) + + // Handler returns 400 for empty body, not 404 — proves the route is registered + if w.Code == http.StatusNotFound { + t.Fatal("POST /api/feedback returned 404 — route not registered (expected per plan §13.6)") + } + + // POST /api/ui-feedback (old name) must NOT be routed + reqOld := httptest.NewRequest("POST", "/api/ui-feedback", nil) + wOld := httptest.NewRecorder() + mux.ServeHTTP(wOld, reqOld) + + if wOld.Code != http.StatusNotFound { + t.Errorf("POST /api/ui-feedback returned %d, want 404 — old route name should not be registered", wOld.Code) + } +} diff --git a/web/src/agentation-overlay.ts b/web/src/agentation-overlay.ts index f632d76..0e83bc8 100644 --- a/web/src/agentation-overlay.ts +++ b/web/src/agentation-overlay.ts @@ -5,7 +5,7 @@ // Agentation lets users click any element, annotate it, and generate structured // markdown output that describes the UI change in terms an AI agent can act on. // Submissions are stored in localStorage and optionally POSTed to /api/feedback -// when the backend API is available. +// when the backend API is available (per plan §13.6). import React from 'react' import ReactDOM from 'react-dom/client' @@ -26,7 +26,7 @@ function handleSubmit(markdown: string, annotations: Annotation[]): void { // POST to the API if available (non-blocking, best-effort) const apiBase = (window as unknown as Record)['ACB_API_BASE'] ?? '/api' - fetch(`${apiBase}/ui-feedback`, { + fetch(`${apiBase}/feedback`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ markdown, annotations, submitted_at: new Date().toISOString() }),