oficina / equipo Public

Merge thin-v1-slice3 at 8d87205 into thin-v1-thinking

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 71ce51b0e833b8243b0e968d504c142e4cd9fb6d parent 058754cparent 8d87205
10 files changed, +131 −8
  • docs/mockups/built/2026-11-07/composer-1280-dark.png binary
  • docs/mockups/built/2026-11-07/composer-1280-light.png binary
  • docs/mockups/built/2026-11-07/composer-390-dark.png binary
  • docs/mockups/built/2026-11-07/composer-390-light.png binary
  • internal/equipo/chat/tasks.go +6 −4
  • internal/equipo/static/equipo.css +6 −2
  • internal/headless/browser_composer_test.go +47 −0
  • internal/runner/thin/step.go +5 −2
  • internal/runner/thin/step_test.go +35 −0
  • internal/thintest/tasks_contract_test.go +32 −0

CI passed — run details

diff --git a/docs/mockups/built/2026-11-07/composer-1280-dark.png b/docs/mockups/built/2026-11-07/composer-1280-dark.png
new file mode 100644
index 00000000..84c3f6a7
Binary files /dev/null and b/docs/mockups/built/2026-11-07/composer-1280-dark.png differ
diff --git a/docs/mockups/built/2026-11-07/composer-1280-light.png b/docs/mockups/built/2026-11-07/composer-1280-light.png
new file mode 100644
index 00000000..7f195413
Binary files /dev/null and b/docs/mockups/built/2026-11-07/composer-1280-light.png differ
diff --git a/docs/mockups/built/2026-11-07/composer-390-dark.png b/docs/mockups/built/2026-11-07/composer-390-dark.png
new file mode 100644
index 00000000..c697fb9b
Binary files /dev/null and b/docs/mockups/built/2026-11-07/composer-390-dark.png differ
diff --git a/docs/mockups/built/2026-11-07/composer-390-light.png b/docs/mockups/built/2026-11-07/composer-390-light.png
new file mode 100644
index 00000000..90e1d0c0
Binary files /dev/null and b/docs/mockups/built/2026-11-07/composer-390-light.png differ
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go
index 5f054b2b..98ab1644 100644
--- a/internal/equipo/chat/tasks.go
+++ b/internal/equipo/chat/tasks.go
@@ -623,10 +623,12 @@ func (t *txn) stepReport(l Lease, v *wire.StepReport) error {
return t.saveStep(&s, &k)
}
-// syncSteps settles steps the person's runner no longer holds: the
-// runner holding the lease reports what runs, and it verified at start
-// that no namespace of an earlier process survives, so a step it does
-// not hold has ended. A dispatch it has not acked is still on its way.
+// syncSteps settles steps the person's runner no longer holds. The
+// runner's sync lists every attempt it still has a record of (running,
+// a report not yet acked, or a termination still unverified), so absence
+// means it has nothing left to report and verified at start that no
+// namespace of an earlier process survives: the step has ended. A
+// dispatch it has not acked is still on its way.
func (t *txn) syncSteps(l Lease, held []wire.StepRun) error {
have := map[string]bool{}
for _, h := range held {
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css
index 76b46dfa..0ba16a42 100644
--- a/internal/equipo/static/equipo.css
+++ b/internal/equipo/static/equipo.css
@@ -111,8 +111,12 @@ body:has([equipo-conversation]) { overflow: hidden; }
[equipo-question] label { font-size: var(--rst-fs-sm); }
[equipo-question] textarea { min-block-size: 2rem; resize: none; field-sizing: content; max-block-size: 9rem; }
[equipo-question] [equipo-actions] { margin-block: var(--rst-sp-2) 0; }
-#chat-composer { flex: none; padding: var(--rst-sp-3) max(var(--rst-sp-4), calc((100% - 50rem) / 2)) max(var(--rst-sp-3), env(safe-area-inset-bottom)); background: var(--rst-surface); }
-#composer { display: grid; max-width: none; margin: 0; padding: var(--rst-sp-3); border: 1px solid var(--rst-line); border-radius: calc(2 * var(--rst-radius)); gap: var(--rst-sp-2); }
+/* The dock is the feed's own colour (no band, no edge); a short fade at
+ its top lets messages scrolling under it dissolve. The compose box
+ keeps its field surface and border. */
+#chat-composer { position: relative; flex: none; padding: var(--rst-sp-3) max(var(--rst-sp-4), calc((100% - 50rem) / 2)) max(var(--rst-sp-3), env(safe-area-inset-bottom)); background: transparent; }
+#chat-composer::before { content: ""; position: absolute; inset-inline: 0; inset-block-end: 100%; block-size: var(--rst-sp-4); background: linear-gradient(to bottom, transparent, var(--rst-bg)); pointer-events: none; }
+#composer { display: grid; max-width: none; margin: 0; padding: var(--rst-sp-3); border: 1px solid var(--rst-line); border-radius: calc(2 * var(--rst-radius)); gap: var(--rst-sp-2); background: var(--rst-surface); }
#composer { cursor: text; }
#composer button, #composer select { cursor: pointer; }
#composer:focus-within { border-color: color-mix(in oklab, var(--rst-line), var(--rst-text) 30%); }
diff --git a/internal/headless/browser_composer_test.go b/internal/headless/browser_composer_test.go
index e717c067..6c613e93 100644
--- a/internal/headless/browser_composer_test.go
+++ b/internal/headless/browser_composer_test.go
@@ -4,6 +4,9 @@ package headless
import (
"context"
+ "os"
+ "path/filepath"
+ "strconv"
"testing"
"amadan.net/oficina/equipo/internal/browsertest"
@@ -68,3 +71,47 @@ func TestBrowserComposerFocus(t *testing.T) {
p.stop()
}
}
+
+// effectiveBackground is the colour painted behind an element: its own
+// background, else its nearest ancestor's.
+const effectiveBackground = `(el=>{for(;el;el=el.parentElement){const c=getComputedStyle(el).backgroundColor;if(c!=='rgba(0, 0, 0, 0)'&&c!=='transparent')return c}return getComputedStyle(document.documentElement).backgroundColor})`
+
+// Paul: the chat area's background matches the composer's, in both
+// themes: the dock is the feed's colour (no band, no hard edge), a short
+// fade from transparent to that colour separates messages at its top,
+// and the compose box keeps its own field surface and border. Set
+// EQUIPO_SCREENSHOTS to a directory to save composer-*.png.
+func TestBrowserComposerDock(t *testing.T) {
+ _, inst, r := localEnv(t)
+ r.start(t)
+ c := inst.Cookie()
+ for _, tc := range []struct {
+ width, height int64
+ pointer bool
+ }{{1280, 900, true}, {390, 844, false}} {
+ p := openPage(t, inst.URL, c.Name, c.Value, tc.width, tc.height, tc.pointer)
+ for i := 0; i < 8; i++ {
+ p.send("A message to fill the feed, number " + jsonNumber(float64(i)) + ".")
+ }
+ p.run(browsertest.Wait(`document.querySelectorAll('[equipo-message="own"]').length>=8 && document.querySelectorAll('[equipo-message="incoming"] [equipo-markdown]').length>=1`))
+ for _, theme := range []string{"light", "dark"} {
+ p.check(`(()=>{document.documentElement.dataset.theme=`+jsonString(theme)+`;const s=document.querySelector('[equipo-scroll]');s.scrollTop=s.scrollHeight;return true})()`, "theme")
+ p.check(`(`+effectiveBackground+`)(document.querySelector('#chat-composer'))===(`+effectiveBackground+`)(document.querySelector('[equipo-scroll]'))`, theme+": the dock is not the feed's colour")
+ p.check(`(()=>{const own=getComputedStyle(document.querySelector('#chat-composer')).backgroundColor;return own==='rgba(0, 0, 0, 0)'||own===(`+effectiveBackground+`)(document.querySelector('[equipo-scroll]'))})()`, theme+": the dock paints a band")
+ p.check(`(()=>{const f=getComputedStyle(document.querySelector('#chat-composer'),'::before');return f.content!=='none'&&f.backgroundImage.includes('linear-gradient')&&f.backgroundImage.includes((`+effectiveBackground+`)(document.querySelector('[equipo-scroll]')))&&f.pointerEvents==='none'&&parseFloat(f.height)>0&&parseFloat(f.height)<=40})()`, theme+": no short fade at the dock's top")
+ p.check(`(()=>{const b=getComputedStyle(document.querySelector('#composer'));return parseFloat(b.borderTopWidth)>=1&&b.backgroundColor!=='rgba(0, 0, 0, 0)'})()`, theme+": the compose box lost its field")
+ if dir := os.Getenv("EQUIPO_SCREENSHOTS"); dir != "" {
+ var shot []byte
+ p.run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ var err error
+ shot, err = chromedp.CaptureScreenshot()(ctx, target)
+ return err
+ }))
+ if err := os.WriteFile(filepath.Join(dir, "composer-"+strconv.FormatInt(tc.width, 10)+"-"+theme+".png"), shot, 0644); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+ p.stop()
+ }
+}
diff --git a/internal/runner/thin/step.go b/internal/runner/thin/step.go
index bf440741..8e3f9937 100644
--- a/internal/runner/thin/step.go
+++ b/internal/runner/thin/step.go
@@ -171,9 +171,12 @@ func (s *State) finishedSteps(ctx context.Context) ([]stepRow, error) {
return out, rows.Err()
}
-// syncSteps lists attempts not yet acked as finished.
+// syncSteps lists every attempt this runner still holds: running, its
+// final report not yet acked, or (state "pending") ended with its
+// termination unverified. An attempt is absent only once the runner has
+// no record of it left to report, so the instance may infer its end.
func (s *State) syncSteps(ctx context.Context) ([]wire.StepRun, error) {
- rows, err := s.db.QueryContext(ctx, "SELECT task_id, step_id, attempt, state, candidate_sha FROM steps WHERE state IN (?,?) ORDER BY created_at", runRunning, runReported)
+ rows, err := s.db.QueryContext(ctx, "SELECT task_id, step_id, attempt, state, candidate_sha FROM steps WHERE state IN (?,?,?) ORDER BY created_at", runRunning, runReported, runPending)
if err != nil {
return nil, err
}
diff --git a/internal/runner/thin/step_test.go b/internal/runner/thin/step_test.go
index f49341d5..7dbb78b6 100644
--- a/internal/runner/thin/step_test.go
+++ b/internal/runner/thin/step_test.go
@@ -315,3 +315,38 @@ func TestStepRecoverWithoutProof(t *testing.T) {
t.Fatalf("pending %+v", p)
}
}
+
+// TestSyncHoldsPendingTermination: an attempt whose failure report (no
+// termination proof) is not yet acked, and one still waiting for its
+// proof after the ack, are both in sync: present, termination
+// unverified. Only an attempt the runner has finished is absent.
+func TestSyncHoldsPendingTermination(t *testing.T) {
+ ctx := context.Background()
+ s, err := OpenState(ctx, t.TempDir())
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer s.Close()
+ s.AcceptDispatch(ctx, "f1", dispatchFor("tk9", "s9", 1))
+ r, _, _ := s.nextStep(ctx)
+ if err := s.ReportStep(ctx, r, wire.StepReport{TaskID: "tk9", StepID: "s9", Attempt: 1, State: wire.StepFailed, Reason: "provider_failed"}); err != nil {
+ t.Fatal(err)
+ }
+ held := func() []wire.StepRun {
+ sync, err := s.Sync(ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return sync.Steps
+ }
+ if h := held(); len(h) != 1 || h[0].StepID != "s9" || h[0].State != runPending {
+ t.Fatalf("unacked pending report: %+v", h)
+ }
+ frames, _, _ := s.Unacked(ctx, 0)
+ for _, f := range frames {
+ s.Acked(ctx, f.ID)
+ }
+ if h := held(); len(h) != 1 || h[0].State != runPending {
+ t.Fatalf("acked, proof still pending: %+v", h)
+ }
+}
diff --git a/internal/thintest/tasks_contract_test.go b/internal/thintest/tasks_contract_test.go
index 00e8e4b4..420abbac 100644
--- a/internal/thintest/tasks_contract_test.go
+++ b/internal/thintest/tasks_contract_test.go
@@ -409,3 +409,35 @@ func TestNamespaceGuess(t *testing.T) {
}
}
}
+
+// TestContractSyncBeforeReplay: the runner reported a failure without
+// termination proof and lost the connection before the ack; on
+// reconnect its sync (attempt present, termination unverified) arrives
+// before the outbox replay. The instance must not infer termination
+// from that sync, and Retry stays refused after the replayed report.
+func TestContractSyncBeforeReplay(t *testing.T) {
+ r := newToolRig(t)
+ id := taskID(t, r.call("q1", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Replay order", "brief": "b"}))
+ r.call("q2", wire.ToolStartTask, map[string]string{"task": id, "brief": "go"})
+ _, body := r.expect(wire.FrameDispatch)
+ d := body.(*wire.DispatchCommand)
+ r.step("r-q1", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: strings.Repeat("1", 40)})
+ // Reconnect order: sync first, holding the attempt as pending.
+ if err := r.runner.Send(r.ctx, "r-sync-q", wire.FrameSync, wire.Sync{Sessions: []wire.SessionState{}, Runs: []wire.Run{{TurnID: r.turn, Attempt: 1, State: "running"}}, Steps: []wire.StepRun{{TaskID: id, StepID: d.StepID, Attempt: 1, State: "pending"}}}); err != nil {
+ t.Fatal(err)
+ }
+ // Then the replayed report, still without termination.
+ r.step("r-q2", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepFailed, Reason: "provider_failed"})
+ k, err := r.client.Task(r.ctx, id)
+ if err != nil || k.Steps[0].State != wire.StepFailed || k.Steps[0].Terminated {
+ t.Fatalf("termination inferred: %+v %v", k.Steps, err)
+ }
+ if _, err := r.client.RetryTask(r.ctx, id); Status(err) != 409 {
+ t.Fatalf("retry without verified termination: %v", err)
+ }
+ // The proof, when it comes, allows Retry.
+ r.step("r-q3", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepFailed, Reason: "provider_failed", Termination: true})
+ if acc, err := r.client.RetryTask(r.ctx, id); err != nil || acc.Attempt != 2 {
+ t.Fatalf("retry after the proof: %+v %v", acc, err)
+ }
+}