b57894b183
Introduces the browser-facing surface and the worker-side protocol that backs it: - internal/ui: joined read model plus per-task lifecycle and approval controls, kept separate from the raw endpoints workers and harnesses depend on. - internal/webui + web/: Vite/React app, build output embedded via go:embed and served as an SPA fallback. - federation: per-(worker, task) captures with a monotonic revision that advances only when pane text actually changes, and a command queue restricted to grant_approval / deny_approval, each bound to the capture revision the operator acted on. - orchestra-worker: publishes captures and executes commands only after re-reading the pane and confirming the revision still matches. Sends keystrokes only for a visible y/n prompt or OpenCode's fully labelled selector, and refuses to deny through that selector rather than guess at unobservable navigation. This is the ownership boundary AUDIT.md's B14 and B17 call for: approval becomes an explicit, revision-bound operation executed by the worker that owns the pane, instead of a side effect of prompting over a coordinator-driven remote socket. Also ignores the web build inputs and outputs. node_modules ships vendored Go packages, so go build and go test walk into it if it is merely untracked; both node_modules and .node_modules are excluded. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01535A3Y8RtkAi8wYuWhtkEd
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package ui
|
|
|
|
import (
|
|
"bytes"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"orchestra/internal/store"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestOverviewAndTaskDetailHTTP(t *testing.T) {
|
|
s, err := store.Open(t.TempDir())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
h := Server{Store: s}.Handler()
|
|
req := httptest.NewRequest(http.MethodPost, "/v1/ui/tasks", bytes.NewBufferString(`{"source":"web","external_id":"one","project":"demo","title":"UI task"}`))
|
|
r := httptest.NewRecorder()
|
|
h.ServeHTTP(r, req)
|
|
if r.Code != http.StatusOK {
|
|
t.Fatalf("create status=%d body=%s", r.Code, r.Body.String())
|
|
}
|
|
req = httptest.NewRequest(http.MethodGet, "/v1/ui/overview", nil)
|
|
r = httptest.NewRecorder()
|
|
h.ServeHTTP(r, req)
|
|
if r.Code != http.StatusOK || !strings.Contains(r.Body.String(), "UI task") {
|
|
t.Fatalf("overview status=%d body=%s", r.Code, r.Body.String())
|
|
}
|
|
}
|
|
|
|
func TestParsePendingApprovalPreservesExactShellCommand(t *testing.T) {
|
|
text := "Permission required\n$ git status --short && go test ./..."
|
|
p := ParsePendingApproval(text, "p1", 7, time.Unix(1, 0))
|
|
if p == nil || p.Kind != "shell" || p.Command != "git status --short && go test ./..." {
|
|
t.Fatalf("got %#v", p)
|
|
}
|
|
}
|
|
func TestParsePendingApprovalDoesNotInventActionablePrompt(t *testing.T) {
|
|
p := ParsePendingApproval("Approval required: choose an option", "p1", 7, time.Now())
|
|
if p == nil || p.Kind != "unknown" || !strings.Contains(p.Summary, "review") {
|
|
t.Fatalf("got %#v", p)
|
|
}
|
|
}
|