fix(api): rename /api/ui-feedback to /api/feedback per plan §13.6
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 <noreply@anthropic.com>
This commit is contained in:
parent
5443e4d0ed
commit
f6ce4588f4
3 changed files with 33 additions and 6 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<string, string>)['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() }),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue