oficina / equipo Public

Paste box: every fenced block in a message gets a Copy button

The shared renderer (chatmarkdown) draws each fenced block as a paste
box: a quiet language label, a Copy button and the text in a selectable
pre/code. Final replies, streamed drafts and every markdown page match.
prompt and text blocks wrap as prose; code keeps its lines and scrolls.
The label is a short safe word, escaped. paste.js copies the code's
text content with navigator.clipboard.writeText, less the newline that
ends its last line, falls back to a hidden field or a selection, shows
"Copied" and announces it. With scripts off Copy is hidden.

While streaming, a fence's opening line waits for its end, and the
watched fence parser marks a fence without its closing line: Copy is
aria-disabled until it closes, and only the button changes then.

The coordinator's opening gains a static line in the cached prefix:
anything to paste goes in its own fenced block. houseRule moves to
2026-11-11.1. Three strings, accepted by delegation (Astra, 2026-11-11).
The headless test budget rises to 8464 lines for the browser drive.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 9b70f33133950e0a29bed23720b93455853ef54b parent d4b1414
19 files changed, +542 −32
  • .rastrillo/budgets.txt +1 −1
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +62 −0
  • internal/chatmarkdown/draft.go +38 −3
  • internal/chatmarkdown/draft_test.go +55 −7
  • internal/chatmarkdown/markdown.go +53 −4
  • internal/chatmarkdown/markdown_test.go +68 −5
  • internal/equipo/chat_draft.go +1 −2
  • internal/equipo/copy.go +9 −0
  • internal/equipo/render.go +1 −2
  • internal/equipo/static/equipo.css +27 −0
  • internal/equipo/static/paste.js +56 −0
  • internal/equipo/templates/chrome.html +1 −1
  • internal/fakeclaude/fake.go +2 −2
  • internal/fakeclaude/markdown.go +12 −3
  • internal/headless/browser_paste_test.go +129 −0
  • internal/plan3test/conversation_draft_test.go +1 −1
  • internal/runner/thin/claude.go +2 −1
  • internal/runner/thin/voice_test.go +17 −0
  • scripts/runner-reference-allowlist.json +7 −0

CI failed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index d2359ffa..4288d9f9 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -61,6 +61,6 @@ perf GET /conversation/attachments/{id} skip Composer attachments: the bytes of
perf GET /conversation/attachments/{id}/preview skip Composer attachments: an image thumbnail inside the conversation; a file, not a screen.
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s Mac runners slice B: TestReleaseRunnerHasNoFakeWorker builds the release runner exactly as make release-runner does and the thin package under the testbuild tag (measured 11.9s locally with a warm cache).
-size internal/headless - 8400 Merge authority extends 4c_checks_card to end in Equipo's own merge, measured by the real runner, with its receipt (about 30 lines); measured 8330. Claude's sign-in by a link adds its end-to-end, contained-launch and real runner kill tests (signin_test.go, signin_contained_test.go, about 400 lines); measured 8090.
+size internal/headless - 8464 The paste box adds its browser drive (browser_paste_test.go, about 130 lines: streaming, copy text, keyboard, scripts off); measured 8464. Merge authority extends 4c_checks_card to end in Equipo's own merge, measured by the real runner, with its receipt (about 30 lines); measured 8330. Claude's sign-in by a link adds its end-to-end, contained-launch and real runner kill tests (signin_test.go, signin_contained_test.go, about 400 lines); measured 8090.
size internal/thintest - 13197 The browser lane merged onto the ship buttons: measured 13197. The ship buttons add their contract and browser tests (ships_buttons_test.go, ships_buttons_browser_test.go, about 190 lines); measured 13196. Merge authority merged onto Machines in Settings, with the re-run ruling's cases and stale thinking lines: measured 12998. Merge authority thin v1 adds its contracts (mergeauth_contract_test.go, about 650 lines) the protocol-aware rigs and the Mac re-run contract (macrecheck_mergeauth_contract_test.go) and the review fixes' contracts; measured 12535 with main merged. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Stale thinking lines merged onto Machines in Settings: measured 11967. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Stale thinking lines add their browser drive (stale_thinking_browser_test.go, about 200 lines) and the queued test now checks the note; measured 11795. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Spend 1 merged onto the four UI branches: measured 11325. Spend 1 marks overcounting Claude rows (about 120 lines); it adds the task page's spend contract and the 0059 upgrade (spend_pages_test.go, about 100 lines) and the fix round feedback by protocol (about 40); measured 10224. The team panel merged onto Projects UX and the Settings UX pass: measured 11064 with all three. The team panel adds its page contract and the drawer's browser drive at 1280 and 390 (team_panel_test.go, team_panel_browser_test.go, about 300 lines); measured 10235. Projects UX merged onto the Settings UX pass: measured 10768 with both. Projects UX adds the Projects page contracts (order, quiet fold, filter, stars and Undo, the coordinator's star, repository counts, whole words), the decision cards' Mac and Ask about this contracts and their browser drive (projects_pages_test.go, projects_browser_test.go, about 330 lines); measured 10321. The Settings UX pass adds the Settings pattern's page contracts and the savebar, Housekeeping groups and Teams browser drives (settings_ux_pages_test.go, settings_ux_browser_test.go, about 430 lines); measured 10390. Claude's sign-in by a link adds the code contract (signin_contract_test.go: the card, the code route's refusals, the wrong-code card, the kind it becomes and the canary sweep, about 220 lines); measured 9896. The Connections Add page and the Settings rail add their page contracts and the rail's browser drive (connections_add_pages_test.go, settings_rail_pages_test.go, about 230 lines); measured 9676. Claude setup tokens add the token and Check again contracts; measured 9444 with the composer and Mac lines merged. The instant thinking line adds its browser drive (instant_browser_test.go, about 230 lines); measured 9064 with the composer and Mac lines merged. Mac runners add the role, scoping, migration, placement, withdrawal, transfer and publication contracts (about 900 test lines) beside the thin v1 contracts; one package keeps one instance harness.
perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 2c7fd9e6..8907d8fc 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -6114,6 +6114,9 @@ records remain unchanged.
| `machines.step_approve` | Check that the label and key fingerprint match the machine, then approve it. You can check its connection below. | Add a machine: step 3 | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `machines.new` | New machines | Add a machine: group heading | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `machines.new_none` | Recently approved machines appear here, along with any that have never connected. | Add a machine: group with no new machines | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `chat.paste.copy` | Copy | Paste box: the Copy button on every fenced block in a message | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `chat.paste.copied` | Copied | Paste box: the button for a moment after a copy, and announced | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `chat.paste.selected` | Selected. Copy it with your keyboard. | Paste box: announced, not shown, when the clipboard is refused and the text is left selected | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
## Task 21
@@ -6920,3 +6923,62 @@ Verification (targeted, niced):
- `go test ./internal/thintest -run '^(TestPagesInnerScreens|TestContractShipsQuestion|TestPagesTasksAndProjects|TestContractMergePolicyTool)$'`: ok.
- `go test -tags browser ./internal/thintest -run '^TestBrowserShipsButtons$'`: ok. Mutation: the script returning at once fails it at "Saved and Undo". `'^TestBrowserInnerScreens$'`: ok.
- `go test ./internal/equipo -run 'TestTemplateCopyKeys|TestRunnerCopyInventory'` and `EQUIPO_RELEASE_COPY_CHECK=1 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$'`: ok. `make budget`: ok after raising internal/thintest to 13196 test lines (measured).
+
+## Paste box (2026-11-11)
+
+Paul: "Equipo should be able to present things that need to be pasted in
+a "Paste" box with a "copy" button e.g. for sharing prompts or commands
+or whatever."
+
+Every fenced block in a rendered message is a paste box, made once in
+the shared renderer (`chatmarkdown`), so the final reply, the streamed
+draft (`POST /conversation/draft`) and every page that shows markdown
+draw the same box. The box is the block's surface with a quiet bar (the
+fence's language when it is a short safe word, escaped, and Copy) over
+the text in a selectable `<pre><code>`. A `prompt` or `text` block wraps
+and reads as prose; anything else keeps its lines and scrolls. Indented
+code blocks stay plain. `paste.js` (on every chrome page) copies the
+code's text content with `navigator.clipboard.writeText`, less the
+newline that ends its last line, so the copy is the fence's text byte for
+byte with entities decoded; if the clipboard is refused it copies from a
+hidden field, or leaves the text selected and says so. "Copied" shows on
+the button for 1.8 s and is announced through one polite status line.
+Copy is a real button (Enter and Space, a 2px accent focus ring). Until
+`paste.js` runs it is hidden with its space kept; with scripts off it is
+gone and the text is still there to select.
+
+While streaming, a fence's opening line waits for its end (`steady`), so
+the box shows with its label and wrapping settled. The fenced code
+parser is watched like the inline ones: a fence that meets its closing
+line is noted, and a draft's open fence has Copy `aria-disabled` (dimmed
+to 0.45, a click does nothing). When the fence closes only the button's
+attribute changes; the box stays the same element in the same place.
+
+The coordinator's opening gains one static line, in the stable cached
+prefix ahead of the conversation: "Anything the person may need to paste
+(commands, prompts, config, codes) goes in a fenced code block, one block
+per thing to paste, with its kind after the opening fence (bash for a
+command, prompt for a prompt, text for plain text): the chat shows each
+block with a Copy button." `houseRule` moves to `2026-11-11.1` so
+sessions started under the old rule start fresh. No test pins the prefix
+bytes or a hash; `TestCoordinatorPromptStablePrefix` still holds
+unchanged, and `TestOpeningPutsPastesInFences` checks the line, that the
+opening is static, and that the version moved.
+
+Copy: three strings (`chat.paste.copy`, `chat.paste.copied`,
+`chat.paste.selected`), in the inventory above. One delegated Astra pass
+(gpt-6-astra, effort high) kept all three. Its flags were behaviour, not
+words, and the code settles both: the status line is cleared and then
+set once per copy, and the fallback selects the code element's
+contents. COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11).
+
+The reference scan gains one exact entry: goldmark's `ast.Node` in the
+watched fence parser's `Continue` signature.
+
+Verification (targeted, niced):
+
+- `go test ./internal/chatmarkdown`: ok. New: TestFenceIsAPasteBox, TestPasteBoxLabelIsEscaped, TestPasteBoxKeepsTheText, TestDraftOpenFenceWaitsToCopy, the fence rows of TestDraftPartialSyntax, a two-box reply in the stream corpus. Mutations, each red then restored: never open (TestDraftPartialSyntax, TestDraftOpenFenceWaitsToCopy), always open in a draft (TestDraftOfTheWholeReplyIsTheReply, TestDraftOpenFenceWaitsToCopy), no opener hold (TestDraftShowsNoMarkupAndOnlyTheReplysText, TestDraftPartialSyntax), no label charset (TestPasteBoxLabelIsEscaped), unescaped code (TestSafeSubset, TestPasteBoxKeepsTheText), text not prose (TestFenceIsAPasteBox).
+- `go test ./internal/runner/thin -run 'TestOpening|TestCoordinatorPromptStablePrefix'`: TestOpeningPutsPastesInFences red before the line, then ok.
+- `go test ./internal/equipo -run 'TestTemplateCopyKeys|TestRunnerCopyInventory'`, `go test ./internal/plan3test -run 'TestConversationDraftRendersOnTheServer'`: ok.
+- `go test -tags browser ./internal/headless -run '^TestBrowserPasteBox$'` (new; streams `replymd:paste` from fakeclaude): two local runs found test faults only (JS string quoting, then a batch that brought the trailing spaces and the closing fence together, which the test read as a move). The assertions are now precise; the hosted browser lane runs it.
+- `python3 scripts/runner-dead-references.py`: 0 failures. `EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$'`: ok.
diff --git a/internal/chatmarkdown/draft.go b/internal/chatmarkdown/draft.go
index b438a20b..936f4cd3 100644
--- a/internal/chatmarkdown/draft.go
+++ b/internal/chatmarkdown/draft.go
@@ -38,7 +38,13 @@ func parse(source []byte) (ast.Node, *seen) {
inline[i] = util.Prioritized(watched{ip}, p.Priority)
}
}
- p := parser.NewParser(parser.WithBlockParsers(parser.DefaultBlockParsers()...),
+ blocks := parser.DefaultBlockParsers()
+ for i, b := range blocks {
+ if bp, ok := b.Value.(parser.BlockParser); ok && bytes.ContainsAny(bp.Trigger(), "`") {
+ blocks[i] = util.Prioritized(fence{bp}, b.Priority)
+ }
+ }
+ p := parser.NewParser(parser.WithBlockParsers(blocks...),
parser.WithInlineParsers(inline...),
parser.WithParagraphTransformers(parser.DefaultParagraphTransformers()...),
)
@@ -62,15 +68,44 @@ func (w watched) Parse(parent ast.Node, block text.Reader, pc parser.Context) as
return n
}
+// fence is goldmark's fenced code parser, watched: a fence that meets its
+// closing line is noted in seen, so a draft knows which fence is still
+// open. Watching changes nothing it parses.
+type fence struct{ parser.BlockParser }
+
+func (f fence) Continue(b ast.Node, reader text.Reader, pc parser.Context) parser.State {
+ st := f.BlockParser.Continue(b, reader, pc)
+ if s, ok := pc.Get(seenKey).(*seen); ok && st&parser.Close != 0 {
+ s.found = append(s.found, b)
+ }
+ return st
+}
+
+// closed is whether a fence met its closing line.
+func (s *seen) closed(v *ast.FencedCodeBlock) bool {
+ for _, f := range s.found {
+ if f == v {
+ return true
+ }
+ }
+ return false
+}
+
// markerOnly is a last line with nothing yet but the start of a block:
// a bullet or a number, hashes, a quote, a fence, a rule or an underline,
// perhaps with the opener of its first words ("- **").
var markerOnly = regexp.MustCompile("^[ \t]*(?:[-+*>]|[0-9]{1,9}[.)]?|#{1,6}|[`~]+|[-=_* \t]+)?[ \t]*[*_`]*$")
-// steady holds back a last line that is only a block's marker.
+// fenceLine is a last line that opens a fence, perhaps in a quote or a
+// list item: its label is still arriving, and the box it opens waits for
+// the whole line so its label and its wrapping are settled when it shows.
+var fenceLine = regexp.MustCompile("^[ \t>]*(?:(?:[-+*]|[0-9]{1,9}[.)])[ \t]+)?(?:```|~~~)[^\n]*$")
+
+// steady holds back a last line that is only a block's marker, or a
+// fence's opening line.
func steady(body string) string {
i := strings.LastIndexByte(body, '\n') + 1
- if markerOnly.MatchString(body[i:]) {
+ if markerOnly.MatchString(body[i:]) || fenceLine.MatchString(body[i:]) {
return body[:i]
}
return body
diff --git a/internal/chatmarkdown/draft_test.go b/internal/chatmarkdown/draft_test.go
index 82bb6496..7ab66a88 100644
--- a/internal/chatmarkdown/draft_test.go
+++ b/internal/chatmarkdown/draft_test.go
@@ -18,9 +18,19 @@ var corpus = []string{
"I've logged [Fix the invoice total](/tasks/tks6kwzzdngr) in [Comercio](/projects/p_abc123). Engineering starts with a reproduction.",
"Run `go test ./internal/checkout/...` first, then this:\n\n```go\nfunc total(lines []Line) int {\n\tsum := 0\n\tfor _, l := range lines {\n\t\tsum += l.Price\n\t}\n\treturn sum\n}\n```\n\nThat is *all* it needs.",
"## Plan\n\nThree steps, each **small**:\n\n- read the code\n- reproduce it\n- fix it, with *one* test\n\nNested:\n\n1. First\n - a detail\n - another\n2. Second\n\n> Quoted note.\n\nLast line with a hard break \nand its continuation.",
+ // Two paste boxes: a command and a prompt.
+ "Run this in a terminal:\n\n```bash\ngo test ./internal/checkout/... -run 'TestTotal' > out.txt && echo ok\n```\n\nThen paste this into the review:\n\n```prompt\nCheck that the total counts delivery once, & say which test shows it.\n```\n\nThat is all.",
"Café con ñandú, señor. ☕ **Ünïcödé** 🎉 works.\nA soft break, then\n\n---\n\nafter a rule.",
}
+// labels are the paste box's words in these tests.
+var labels = Labels{Copy: "Copy", Copied: "Copied", Selected: "Selected"}
+
+// open is the draft of a fence still open: its box, Copy disabled.
+func open(lang, kind, text string) string {
+ return `<div equipo-paste="` + kind + `"><div equipo-paste-bar><span equipo-paste-lang>` + lang + `</span><button type="button" equipo-paste-copy data-copied="Copied" data-selected="Selected" aria-disabled="true">Copy</button></div><pre><code>` + text + "</code></pre></div>\n"
+}
+
// visible is what a reader sees of rendered HTML: the text without tags,
// entities resolved, runs of whitespace as one space.
func visible(h string) string {
@@ -35,7 +45,7 @@ var code = regexp.MustCompile(`(?s)<pre>.*?</pre>`)
// nothing to the layout but what the last characters bring.
func TestDraftOfTheWholeReplyIsTheReply(t *testing.T) {
for _, reply := range corpus {
- if got, want := RenderDraft(reply), Render(reply); got != want {
+ if got, want := labels.RenderDraft(reply), labels.Render(reply); got != want {
t.Errorf("draft of the whole reply differs\n draft: %q\nreply: %q", got, want)
}
}
@@ -46,12 +56,12 @@ func TestDraftOfTheWholeReplyIsTheReply(t *testing.T) {
// finished reply shows.
func TestDraftShowsNoMarkupAndOnlyTheReplysText(t *testing.T) {
for _, reply := range corpus {
- final := visible(string(Render(reply)))
+ final := visible(string(labels.Render(reply)))
for i := 0; i <= len(reply); i++ {
if i < len(reply) && !utf8.RuneStart(reply[i]) {
continue
}
- draft := string(RenderDraft(reply[:i]))
+ draft := string(labels.RenderDraft(reply[:i]))
seen := visible(draft)
if prose := visible(code.ReplaceAllString(draft, "")); strings.ContainsAny(prose, "*`[]#") || strings.Contains(prose, "](") {
t.Fatalf("markup shows at %d %q: %q", i, reply[:i], seen)
@@ -88,9 +98,15 @@ func TestDraftPartialSyntax(t *testing.T) {
{"Text\n--", "<p>Text</p>\n"},
// An open code fence is an open code block; a closing fence on
// its way shows nothing.
- {"```go\nfmt.Println(", "<pre><code>fmt.Println(\n</code></pre>\n"},
- {"```go\nx := 1\n``", "<pre><code>x := 1\n</code></pre>\n"},
+ {"```go\nfmt.Println(", open("go", "code", "fmt.Println(\n")},
+ {"```go\nx := 1\n``", open("go", "code", "x := 1\n")},
{"``", ""},
+ // A fence's opening line waits for its end, so the box shows
+ // with its label and its wrapping settled.
+ {"Run:\n\n```ba", "<p>Run:</p>\n"},
+ {"Run:\n\n```prompt", "<p>Run:</p>\n"},
+ {"```prompt\n", open("prompt", "prose", "")},
+ {"- step\n ```sh", "<ul><li>step</li>\n</ul>\n"},
// A link on its way shows its words.
{"See [Fix the inv", "<p>See Fix the inv</p>\n"},
{"See [Fix the invoice]", "<p>See Fix the invoice</p>\n"},
@@ -98,7 +114,7 @@ func TestDraftPartialSyntax(t *testing.T) {
{"See [Fix](/tasks/tk1)", "<p>See <a href=\"/tasks/tk1\" rel=\"noopener\">Fix</a></p>\n"},
{"Code `a[b`", "<p>Code <code>a[b</code></p>\n"},
} {
- if got := string(RenderDraft(c.text)); got != c.want {
+ if got := string(labels.RenderDraft(c.text)); got != c.want {
t.Errorf("RenderDraft(%q)\n got %q\nwant %q", c.text, got, c.want)
}
}
@@ -107,9 +123,41 @@ func TestDraftPartialSyntax(t *testing.T) {
// The draft keeps the safe subset: the same rules as a finished reply.
func TestDraftKeepsTheSafeSubset(t *testing.T) {
for _, raw := range []string{`<script>alert(1)</script>`, `<img src=x onerror=alert(1)>`, `[x](javascript:alert%281%29)`, "[x](javascript:alert(1)", `![x](https://evil.test/a)`, "<scr"} {
- got := string(RenderDraft(raw))
+ got := string(labels.RenderDraft(raw))
if strings.Contains(got, "<script") || strings.Contains(got, "<img") || strings.Contains(got, "<scr") || strings.Contains(got, `href="javascript:`) {
t.Fatal("unsafe", got)
}
}
}
+
+// A fence still arriving is open in the draft, and Copy waits: it turns
+// on when the closing line comes, and only the button changes. A
+// finished message is never open, even if its fence never closed.
+func TestDraftOpenFenceWaitsToCopy(t *testing.T) {
+ text := "Run:\n\n```bash\ngo test ./...\n"
+ draft := string(labels.RenderDraft(text))
+ if !strings.Contains(draft, `aria-disabled="true"`) {
+ t.Fatalf("an open fence's Copy is not disabled: %s", draft)
+ }
+ // The closing line on its way is held back: still open.
+ if got := string(labels.RenderDraft(text + "```")); got != draft {
+ t.Fatalf("a closing line on its way changed the box: %s", got)
+ }
+ for _, closed := range []string{text + "```\n", text + "```\n\nDone."} {
+ got := string(labels.RenderDraft(closed))
+ if strings.Contains(got, "aria-disabled") {
+ t.Fatalf("a closed fence's Copy is disabled (%q): %s", closed, got)
+ }
+ if strings.Replace(draft, ` aria-disabled="true"`, "", 1) != got[:len(draft)-len(` aria-disabled="true"`)] {
+ t.Fatalf("the box changed when its fence closed\n open: %s\nclosed: %s", draft, got)
+ }
+ }
+ if got := string(labels.Render(text)); strings.Contains(got, "aria-disabled") {
+ t.Fatalf("a finished message's unclosed fence is disabled: %s", got)
+ }
+ // Two fences: the first closed, the second still open.
+ two := string(labels.RenderDraft("```sh\nls\n```\n\n```sh\npw"))
+ if strings.Count(two, "<button") != 2 || strings.Count(two, "aria-disabled") != 1 || strings.Index(two, "aria-disabled") < strings.LastIndex(two, "<button") {
+ t.Fatalf("only the last, open fence waits: %s", two)
+ }
+}
diff --git a/internal/chatmarkdown/markdown.go b/internal/chatmarkdown/markdown.go
index 28f26f11..edbce5a1 100644
--- a/internal/chatmarkdown/markdown.go
+++ b/internal/chatmarkdown/markdown.go
@@ -7,21 +7,27 @@ import (
"html/template"
"net/url"
"regexp"
+ "strings"
"github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/util"
)
+// Labels are the words of a paste box, from the app's copy: its Copy
+// button, the button once it has copied, and what is announced when the
+// clipboard is refused and the text is selected instead.
+type Labels struct{ Copy, Copied, Selected string }
+
// Render renders a finished message.
-func Render(body string) template.HTML { return render(body, false) }
+func (l Labels) Render(body string) template.HTML { return render(body, false, l) }
// RenderDraft renders a reply that is still arriving with the same rules,
// leaving out only what the next characters could still change (see
// draft.go). The draft of a whole reply is the reply's Render, unless the
// reply itself ends on an unclosed opener or a bare list marker.
-func RenderDraft(body string) template.HTML { return render(body, true) }
+func (l Labels) RenderDraft(body string) template.HTML { return render(body, true, l) }
-func render(body string, draft bool) template.HTML {
+func render(body string, draft bool, l Labels) template.HTML {
var hide spans
if draft {
body = steady(body)
@@ -69,7 +75,10 @@ func render(body string, draft bool) template.HTML {
escape(c.(*ast.Text).Segment.Value(source))
}
out.WriteString("</code>")
- case *ast.FencedCodeBlock, *ast.CodeBlock:
+ case *ast.FencedCodeBlock:
+ // Copy waits while a draft's fence is still open.
+ l.box(&out, v, source, draft && !seen.closed(v))
+ case *ast.CodeBlock:
out.WriteString("<pre><code>")
for i := 0; i < n.Lines().Len(); i++ {
line := n.Lines().At(i)
@@ -117,3 +126,43 @@ func render(body string, draft bool) template.HTML {
// sitePage is a same-origin link the chat may render: a task or a project.
var sitePage = regexp.MustCompile(`^/(tasks/tk[a-z0-9]{1,32}|projects/p_[a-z0-9]{1,40})$`)
+
+// box is a fenced block as a paste box: its language, quietly, when the
+// fence names a safe one, a Copy button, and the text in a selectable
+// <pre><code>, which is what the button copies (paste.js reads the code's
+// text, so entities are the characters they stand for). A prompt or text
+// block is prose and wraps; anything else is code and scrolls. While a
+// draft's fence is open the button is there but aria-disabled, so a
+// half-streamed command is never copied, and the box does not move when
+// it closes: only the button's attribute changes.
+func (l Labels) box(out *bytes.Buffer, v *ast.FencedCodeBlock, source []byte, open bool) {
+ lang := string(v.Language(source))
+ if !language.MatchString(lang) {
+ lang = ""
+ }
+ kind := "code"
+ if prose[strings.ToLower(lang)] {
+ kind = "prose"
+ }
+ out.WriteString(`<div equipo-paste="` + kind + `"><div equipo-paste-bar>`)
+ if lang != "" {
+ out.WriteString(`<span equipo-paste-lang>` + html.EscapeString(lang) + `</span>`)
+ }
+ out.WriteString(`<button type="button" equipo-paste-copy data-copied="` + html.EscapeString(l.Copied) + `" data-selected="` + html.EscapeString(l.Selected) + `"`)
+ if open {
+ out.WriteString(` aria-disabled="true"`)
+ }
+ out.WriteString(`>` + html.EscapeString(l.Copy) + `</button></div><pre><code>`)
+ for i := 0; i < v.Lines().Len(); i++ {
+ line := v.Lines().At(i)
+ out.WriteString(html.EscapeString(string(line.Value(source))))
+ }
+ out.WriteString("</code></pre></div>\n")
+}
+
+// language is a fence's label that may show: a short word of letters,
+// digits and the marks language names use (c++, c#, objective-c, .env).
+var language = regexp.MustCompile(`^\.?[A-Za-z0-9][A-Za-z0-9_+#.-]{0,23}$`)
+
+// prose are the labels of text a person reads and pastes whole: it wraps.
+var prose = map[string]bool{"prompt": true, "text": true}
diff --git a/internal/chatmarkdown/markdown_test.go b/internal/chatmarkdown/markdown_test.go
index d2bcff53..3d4e0c44 100644
--- a/internal/chatmarkdown/markdown_test.go
+++ b/internal/chatmarkdown/markdown_test.go
@@ -1,24 +1,26 @@
package chatmarkdown
import (
+ "html"
+ "regexp"
"strings"
"testing"
)
func TestSafeSubset(t *testing.T) {
- got := string(Render("**bold** *italic* `inline`\n\n- one\n- two\n\n```go\n<script>\n```\n\n[link](https://example.test)"))
+ got := string(labels.Render("**bold** *italic* `inline`\n\n- one\n- two\n\n```go\n<script>\n```\n\n[link](https://example.test)"))
for _, want := range []string{"<strong>bold</strong>", "<em>italic</em>", "<code>inline</code>", "<ul>", "<li>", "<pre><code>", "&lt;script&gt;", `rel="noopener"`} {
if !strings.Contains(got, want) {
t.Errorf("missing %s: %s", want, got)
}
}
for _, raw := range []string{`<script>alert(1)</script>`, `<img src=x onerror=alert(1)>`, `[x](javascript:alert%281%29)`, `[x](data:text/html,evil)`, `[x](//evil.test)`, `[x](jav&#x61;script:evil)`, `![x](https://evil.test/a)`} {
- got := string(Render(raw))
+ got := string(labels.Render(raw))
if strings.Contains(got, "<script") || strings.Contains(got, "<img") || strings.Contains(got, `href="javascript:`) || strings.Contains(got, `href="data:`) || strings.Contains(got, `href="//`) {
t.Fatal("unsafe", got)
}
}
- if !strings.Contains(string(Render(`<b>raw</b>`)), "&lt;b&gt;") {
+ if !strings.Contains(string(labels.Render(`<b>raw</b>`)), "&lt;b&gt;") {
t.Fatal("raw HTML not escaped")
}
}
@@ -26,15 +28,76 @@ func TestSafeSubset(t *testing.T) {
// The coordinator links a task by its title; on this site only task and
// project pages become links.
func TestSiteLinksOnlyTasksAndProjects(t *testing.T) {
- got := string(Render("I've logged [Swipe back doesn't work](/tasks/tks6kwzzdngr) in [Woodstar](/projects/p_abc123)."))
+ got := string(labels.Render("I've logged [Swipe back doesn't work](/tasks/tks6kwzzdngr) in [Woodstar](/projects/p_abc123)."))
for _, want := range []string{`<a href="/tasks/tks6kwzzdngr" rel="noopener">Swipe back doesn&#39;t work</a>`, `<a href="/projects/p_abc123" rel="noopener">Woodstar</a>`} {
if !strings.Contains(got, want) {
t.Fatalf("missing %s: %s", want, got)
}
}
for _, raw := range []string{`[x](/conversation/tasks/tk1/retry)`, `[x](/tasks/tk1/../../logout)`, `[x](/settings)`, `[x](tasks/tk1)`, `[x](/tasks/TK1)`, `[x](/tasks/tk1?a=b)`, `[x](/\\evil.test)`} {
- if got := string(Render(raw)); strings.Contains(got, "<a ") {
+ if got := string(labels.Render(raw)); strings.Contains(got, "<a ") {
t.Fatalf("linked %s: %s", raw, got)
}
}
}
+
+// Every fenced block is a paste box: its label, a Copy button and the
+// text in a selectable <pre><code>.
+func TestFenceIsAPasteBox(t *testing.T) {
+ got := string(labels.Render("Run this:\n\n```bash\ngo test ./...\n```\n"))
+ want := `<p>Run this:</p>
+<div equipo-paste="code"><div equipo-paste-bar><span equipo-paste-lang>bash</span><button type="button" equipo-paste-copy data-copied="Copied" data-selected="Selected">Copy</button></div><pre><code>go test ./...
+</code></pre></div>
+`
+ if got != want {
+ t.Fatalf("paste box\n got %q\nwant %q", got, want)
+ }
+ // No label: still a box, a code one. A prompt or text label is prose.
+ for _, c := range []struct{ fence, kind, lang string }{{"```", "code", ""}, {"~~~", "code", ""}, {"```prompt", "prose", "prompt"}, {"```Text", "prose", "Text"}, {"```go linenos", "code", "go"}, {"```c++", "code", "c++"}, {"```.env", "code", ".env"}} {
+ got := string(labels.Render(c.fence + "\nx\n" + c.fence[:3]))
+ if !strings.HasPrefix(got, `<div equipo-paste="`+c.kind+`">`) {
+ t.Fatalf("%s: not a %s box: %s", c.fence, c.kind, got)
+ }
+ if has := strings.Contains(got, "<span equipo-paste-lang>"+c.lang+"</span>"); has != (c.lang != "") || c.lang == "" && strings.Contains(got, "equipo-paste-lang") {
+ t.Fatalf("%s: label: %s", c.fence, got)
+ }
+ }
+ // An indented code block stays a plain one.
+ if got := string(labels.Render(" indented\n")); got != "<pre><code>indented\n</code></pre>\n" {
+ t.Fatalf("indented code: %s", got)
+ }
+}
+
+// A label shows only in a safe charset, escaped; anything else shows no
+// label and keeps the box. The button's words are escaped too.
+func TestPasteBoxLabelIsEscaped(t *testing.T) {
+ for _, info := range []string{"<script>", `a"onmouseover=x`, "x'y", "a&amp;b", "&lt;b&gt;", "a<b", "\"x", strings.Repeat("a", 25), "-x", "{.go}", "é"} {
+ got := string(labels.Render("```" + info + "\nbody\n```"))
+ if strings.Contains(got, "equipo-paste-lang") || strings.Contains(got, "<script") || strings.Contains(got, "onmouseover") || !strings.Contains(got, "<pre><code>body\n</code></pre>") {
+ t.Fatalf("label %q: %s", info, got)
+ }
+ }
+ odd := Labels{Copy: `<b>"Copy"</b>`, Copied: `"><x>`, Selected: "a&b"}
+ got := string(odd.Render("```sh\nls\n```"))
+ if strings.Contains(got, "<b>") || strings.Contains(got, "<x>") || !strings.Contains(got, `data-copied="&#34;&gt;&lt;x&gt;"`) || !strings.Contains(got, `data-selected="a&amp;b"`) || !strings.Contains(got, `&lt;b&gt;&#34;Copy&#34;&lt;/b&gt;</button>`) {
+ t.Fatalf("labels not escaped: %s", got)
+ }
+}
+
+// The box's code is the fence's text exactly: what the page reads as the
+// code's text content (entities resolved) is the raw content, with its
+// <, &, tabs and trailing spaces; Copy drops only the one newline that
+// ends the last line.
+func TestPasteBoxKeepsTheText(t *testing.T) {
+ raw := "if a < b && c > d {\n\tfmt.Println(\"x &amp; y\") \n}\t\n two trailing \n<script>alert(1)</script>"
+ for _, render := range []func(string) string{func(s string) string { return string(labels.Render(s)) }, func(s string) string { return string(labels.RenderDraft(s)) }} {
+ got := render("```go\n" + raw + "\n```\n")
+ m := regexp.MustCompile(`(?s)<pre><code>(.*)</code></pre>`).FindStringSubmatch(got)
+ if m == nil || strings.Contains(m[1], "<script") {
+ t.Fatalf("code: %s", got)
+ }
+ if text := strings.TrimSuffix(html.UnescapeString(m[1]), "\n"); text != raw {
+ t.Fatalf("the box's text is not the fence's\n got %q\nwant %q", text, raw)
+ }
+ }
+}
diff --git a/internal/equipo/chat_draft.go b/internal/equipo/chat_draft.go
index 464cc04a..f9218850 100644
--- a/internal/equipo/chat_draft.go
+++ b/internal/equipo/chat_draft.go
@@ -4,7 +4,6 @@ import (
"io"
"net/http"
- "amadan.net/oficina/equipo/internal/chatmarkdown"
"amadan.net/oficina/equipo/internal/wire"
)
@@ -31,5 +30,5 @@ func (a *application) chatDraft(w http.ResponseWriter, r *http.Request) {
text = text[:4*wire.MaxMessageBytes]
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
- _, _ = io.WriteString(w, string(chatmarkdown.RenderDraft(text)))
+ _, _ = io.WriteString(w, string(pasteLabels.RenderDraft(text)))
}
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index a883ea55..3169e44c 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -3,6 +3,7 @@ package equipo
import (
"sort"
+ "amadan.net/oficina/equipo/internal/chatmarkdown"
"amadan.net/oficina/equipo/internal/runner"
"amadan.net/oficina/equipo/internal/runnerproto"
)
@@ -1676,8 +1677,16 @@ var pageCopy = map[string]string{
"team.ask_failed": "That question did not go through. Try again.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): team panel drawer
"team.recent": "Recent work", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): team panel drawer
"team.recent_empty": "Nothing yet.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): team panel drawer
+
+ // The paste box: every fenced block in a rendered message.
+ "chat.paste.copy": "Copy", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): paste box button
+ "chat.paste.copied": "Copied", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): paste box button after a copy, and announced
+ "chat.paste.selected": "Selected. Copy it with your keyboard.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): announced when the clipboard is refused and the text is selected
}
+// pasteLabels are the paste box's words, for the shared renderer.
+var pasteLabels = chatmarkdown.Labels{Copy: copyText("chat.paste.copy"), Copied: copyText("chat.paste.copied"), Selected: copyText("chat.paste.selected")}
+
func copyText(key string) string {
if text, ok := runnerDraftCopy[key]; ok {
return text
diff --git a/internal/equipo/render.go b/internal/equipo/render.go
index 365945f5..fef26f7a 100644
--- a/internal/equipo/render.go
+++ b/internal/equipo/render.go
@@ -1,7 +1,6 @@
package equipo
import (
- "amadan.net/oficina/equipo/internal/chatmarkdown"
"bytes"
"embed"
"encoding/json"
@@ -37,7 +36,7 @@ func init() {
for _, name := range []string{"person_devices", "person_device", "teams", "onboarding", "invite", "playbooks", "playbook_form", "playbook_diff", "specialist_form", "template_library", "template_diff", "conversation", "chat", "thread", "plan", "coordinator", "preferences", "index", "empty", "projects", "project", "project_form", "people", "settings", "specialist", "errors", "signin_page", "form_error", "runners", "tasks", "task", "task_form", "question", "merge", "connections", "recovery", "recovery_form", "rendered_approval", "notebook", "housekeeping", "work_tasks", "work_task", "work_projects", "work_project", "models", "work_needs", "settings_hub", "team"} {
page := template.Must(template.New("layout").
Funcs(ui.Funcs(ui.WithIcons(icons.Icon, icons.Assets))).
- Funcs(template.FuncMap{"chatMarkdown": chatmarkdown.Render, "chatDraft": chatmarkdown.RenderDraft, "fileSize": fileSize, "loadingLine": loadingLine, "split": strings.Split, "since": sinceMillis, "elapsed": elapsedText, "short": short, "agoData": agoData, "agoText": agoText, "hostOf": hostOf, "deref": deref, "agoFormats": agoFormats, "projectAllows": library.ProjectAllowed, "asset": assets.Path, "copy": copyText, "taskGroups": func() []string { return []string{"needs-person", "running", "queued", "finished"} },
+ Funcs(template.FuncMap{"chatMarkdown": pasteLabels.Render, "chatDraft": pasteLabels.RenderDraft, "fileSize": fileSize, "loadingLine": loadingLine, "split": strings.Split, "since": sinceMillis, "elapsed": elapsedText, "short": short, "agoData": agoData, "agoText": agoText, "hostOf": hostOf, "deref": deref, "agoFormats": agoFormats, "projectAllows": library.ProjectAllowed, "asset": assets.Path, "copy": copyText, "taskGroups": func() []string { return []string{"needs-person", "running", "queued", "finished"} },
"kindKey": func(k ProjectKind) string { return "kind." + string(k) },
"ownerKey": func(k string) string { return "owner." + k },
"roleKey": func(k Role) string { return "role." + string(k) },
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css
index 380fc171..016e7664 100644
--- a/internal/equipo/static/equipo.css
+++ b/internal/equipo/static/equipo.css
@@ -278,6 +278,33 @@ html:has([equipo-conversation]) { overflow: hidden; scrollbar-gutter: auto; }
[equipo-markdown] > :first-child { margin-block-start: 0; }
[equipo-markdown] > :last-child { margin-block-end: 0; }
[equipo-markdown] pre { max-inline-size: 100%; overflow-x: auto; white-space: pre; padding: var(--rst-sp-3); background: var(--rst-surface); border: 1px solid var(--rst-line); border-radius: var(--rst-radius); }
+/* The paste box: every fenced block in a message (chatmarkdown, paste.js).
+ The block's surface holds a quiet bar (the fence's language, Copy) over
+ the text. Code and commands keep their lines and scroll; a prompt or
+ text block wraps and reads as prose. Copy waits, dimmed, while the
+ block is still streaming, and is hidden until paste.js runs (gone when
+ scripts are off): the text is still there to select. */
+[equipo-markdown] [equipo-paste] { margin-block: var(--rst-sp-3); max-inline-size: 100%; background: var(--rst-surface); border: 1px solid var(--rst-line); border-radius: var(--rst-radius); }
+[equipo-markdown] > [equipo-paste]:first-child { margin-block-start: 0; }
+[equipo-markdown] > [equipo-paste]:last-child { margin-block-end: 0; }
+[equipo-paste-bar] { display: flex; align-items: center; justify-content: space-between; gap: var(--rst-sp-2); min-block-size: 1.75rem; padding: var(--rst-sp-1) var(--rst-sp-1) 0 var(--rst-sp-3); }
+[equipo-paste-lang] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--rst-fs-xs); color: var(--rst-text-muted); }
+[equipo-paste-copy] { margin-inline-start: auto; padding: .25rem .6rem; border: 0; border-radius: var(--rst-radius-sm, 4px); background: none; font: inherit; font-size: var(--rst-fs-xs); color: var(--rst-text-muted); cursor: pointer; }
+[equipo-paste-copy]:hover { color: var(--rst-text); background: var(--rst-tint-hover, var(--rst-surface-2)); }
+[equipo-paste-copy]:focus-visible { color: var(--rst-text); outline: 2px solid var(--rst-accent); outline-offset: 1px; }
+/* Copy keeps its place but shows only once paste.js is running. */
+:root:not([data-paste]) [equipo-paste-copy] { visibility: hidden; }
+[equipo-paste-copy][aria-disabled="true"] { opacity: .45; cursor: default; background: none; color: var(--rst-text-muted); }
+[equipo-markdown] [equipo-paste] pre { margin: 0; padding: var(--rst-sp-1) var(--rst-sp-3) var(--rst-sp-3); background: none; border: 0; border-radius: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--rst-fs-sm); line-height: 1.5; tab-size: 4; }
+[equipo-markdown] [equipo-paste] pre code { font: inherit; }
+[equipo-markdown] [equipo-paste="prose"] pre { white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: visible; font-family: inherit; line-height: 1.55; }
+[equipo-paste] pre ::selection { background: var(--rst-accent-soft); color: var(--rst-text); }
+@media (scripting: none) {
+ [equipo-paste-copy] { display: none; }
+ [equipo-paste-bar]:not(:has([equipo-paste-lang])) { display: none; }
+ [equipo-markdown] [equipo-paste] pre { padding-block-start: var(--rst-sp-3); }
+ [equipo-markdown] [equipo-paste-bar]:has([equipo-paste-lang]) + pre { padding-block-start: var(--rst-sp-1); }
+}
[equipo-markdown] ul, [equipo-markdown] ol { padding-inline-start: var(--rst-sp-5); }
/* Receipts say what the coordinator did: a quiet line, no button chrome.
Their actions show on hover or keyboard focus on pointer devices, and
diff --git a/internal/equipo/static/paste.js b/internal/equipo/static/paste.js
new file mode 100644
index 00000000..74d26e79
--- /dev/null
+++ b/internal/equipo/static/paste.js
@@ -0,0 +1,56 @@
+// paste.js is the paste box's Copy button. Every fenced block in a
+// rendered message is a paste box (chatmarkdown), on every page that shows
+// one, streamed or final. Copy puts the block's text on the clipboard
+// exactly as the code element holds it, less the newline that ends its
+// last line. It waits while the block is still streaming (aria-disabled).
+// If the clipboard is refused the text is copied from a field nobody sees,
+// or else selected for the person to copy, and that is announced. Without
+// script the button is hidden (equipo.css) and the text can be selected.
+(function () {
+ "use strict";
+ // Copy shows from here on (equipo.css hides it until then).
+ document.documentElement.setAttribute("data-paste", "");
+ var status = null;
+ // say announces through one polite status line for the whole page.
+ function say(text) {
+ if (!status) {
+ status = document.createElement("div");
+ status.setAttribute("role", "status");
+ status.setAttribute("equipo-visually-hidden", "");
+ document.body.append(status);
+ }
+ status.textContent = "";
+ // A fresh change, so a second copy is announced again.
+ setTimeout(function () { status.textContent = text; }, 60);
+ }
+ document.addEventListener("click", function (event) {
+ var button = event.target instanceof Element && event.target.closest("[equipo-paste-copy]");
+ if (!button || button.getAttribute("aria-disabled") === "true") return;
+ var box = button.closest("[equipo-paste]"), code = box && box.querySelector("pre > code");
+ if (!code) return;
+ var text = code.textContent.replace(/\r?\n$/, "");
+ if (!button.pasteLabel) button.pasteLabel = button.textContent;
+ function done() {
+ button.textContent = button.dataset.copied;
+ say(button.dataset.copied);
+ clearTimeout(button.pasteTimer);
+ button.pasteTimer = setTimeout(function () { button.textContent = button.pasteLabel; }, 1800);
+ }
+ function fallback() {
+ var field = document.createElement("textarea"), copied = false;
+ field.value = text;
+ field.setAttribute("readonly", "");
+ field.setAttribute("equipo-visually-hidden", "");
+ document.body.append(field);
+ field.select();
+ try { copied = document.execCommand("copy"); } catch (e) { /* select it below */ }
+ field.remove();
+ button.focus();
+ if (copied) return done();
+ getSelection().selectAllChildren(code);
+ say(button.dataset.selected);
+ }
+ if (navigator.clipboard && window.isSecureContext) navigator.clipboard.writeText(text).then(done, fallback);
+ else fallback();
+ });
+})();
diff --git a/internal/equipo/templates/chrome.html b/internal/equipo/templates/chrome.html
index 15ba1153..7f997f36 100644
--- a/internal/equipo/templates/chrome.html
+++ b/internal/equipo/templates/chrome.html
@@ -1,6 +1,6 @@
{{define "rail-brand"}}<span hidden></span>{{end}}
{{define "title"}}{{copy .Title}} · {{copy "brand"}}{{end}}
-{{define "head"}}{{.Live.Head (T "rastrillo.ui.live.paused") (T "rastrillo.ui.live.unconfirmed")}}<link rel="stylesheet" href="{{asset "static/equipo.css"}}"><script defer src="{{asset "static/nav-stream.js"}}"></script><script defer src="{{asset "static/work-stream.js"}}"></script><script defer src="{{asset "static/stardust.js"}}"></script><script defer src="{{asset "static/team-panel.js"}}"></script>{{with .Thin.MergePolicy}}{{if .Editable}}<script defer src="{{asset "static/merge-ships.js"}}"></script>{{end}}{{end}}{{if .HousekeepingStream}}<script defer src="{{asset "static/housekeeping.js"}}"></script>{{end}}{{if or (eq .Key "thinking") (eq .Key "settings-hub")}}<script defer src="{{asset "static/thinking-preview.js"}}"></script><script defer src="{{asset "static/settings.js"}}"></script>{{end}}{{if .ConnectionsStream}}<script defer src="{{asset "static/vendor/tweetnacl/nacl-fast.js"}}"></script><script defer src="{{asset "static/seal.js"}}"></script><script defer src="{{asset "static/connections.js"}}"></script>{{end}}{{if .MachinesStream}}<script defer src="{{asset "static/machines.js"}}"></script>{{end}}{{if .ChatStream}}<script defer src="{{asset "static/chat-stream.js"}}"></script><script defer src="{{asset "static/chat-compose.js"}}"></script><script defer src="{{asset "static/ask-target.js"}}"></script>{{if eq .Key "conversation"}}<script defer src="{{asset "static/chat-anchor.js"}}"></script><script defer src="{{asset "static/chat-attach.js"}}"></script>{{end}}{{else if eq .Key "conversation"}}<script defer blocking="render" src="{{asset "static/chat-navigation.js"}}"></script><script defer src="{{asset "static/chat.js"}}"></script><script defer src="{{asset "static/chat-send.js"}}"></script>{{end}}{{end}}
+{{define "head"}}{{.Live.Head (T "rastrillo.ui.live.paused") (T "rastrillo.ui.live.unconfirmed")}}<link rel="stylesheet" href="{{asset "static/equipo.css"}}"><script defer src="{{asset "static/nav-stream.js"}}"></script><script defer src="{{asset "static/work-stream.js"}}"></script><script defer src="{{asset "static/stardust.js"}}"></script><script defer src="{{asset "static/team-panel.js"}}"></script><script defer src="{{asset "static/paste.js"}}"></script>{{with .Thin.MergePolicy}}{{if .Editable}}<script defer src="{{asset "static/merge-ships.js"}}"></script>{{end}}{{end}}{{if .HousekeepingStream}}<script defer src="{{asset "static/housekeeping.js"}}"></script>{{end}}{{if or (eq .Key "thinking") (eq .Key "settings-hub")}}<script defer src="{{asset "static/thinking-preview.js"}}"></script><script defer src="{{asset "static/settings.js"}}"></script>{{end}}{{if .ConnectionsStream}}<script defer src="{{asset "static/vendor/tweetnacl/nacl-fast.js"}}"></script><script defer src="{{asset "static/seal.js"}}"></script><script defer src="{{asset "static/connections.js"}}"></script>{{end}}{{if .MachinesStream}}<script defer src="{{asset "static/machines.js"}}"></script>{{end}}{{if .ChatStream}}<script defer src="{{asset "static/chat-stream.js"}}"></script><script defer src="{{asset "static/chat-compose.js"}}"></script><script defer src="{{asset "static/ask-target.js"}}"></script>{{if eq .Key "conversation"}}<script defer src="{{asset "static/chat-anchor.js"}}"></script><script defer src="{{asset "static/chat-attach.js"}}"></script>{{end}}{{else if eq .Key "conversation"}}<script defer blocking="render" src="{{asset "static/chat-navigation.js"}}"></script><script defer src="{{asset "static/chat.js"}}"></script><script defer src="{{asset "static/chat-send.js"}}"></script>{{end}}{{end}}
{{define "up"}}/work{{if .Key}}#nav-{{.Key}}{{end}}{{end}}
{{define "up-label"}}{{.TeamName}}{{end}}
{{define "brand"}}<a rst-shell-brand href="/work">{{icon "users"}}{{.TeamName}}</a>{{end}}
diff --git a/internal/fakeclaude/fake.go b/internal/fakeclaude/fake.go
index b06c72cd..41eafb31 100644
--- a/internal/fakeclaude/fake.go
+++ b/internal/fakeclaude/fake.go
@@ -11,8 +11,8 @@
// steer it: "sleep:<ms>" pauses mid-reply, "crash" exits mid-turn, "fail"
// ends the turn with an error result, "badinit" reports a native tool in
// system/init, "othersession" answers under another session id, "accents"
-// replies with non-ASCII text, "replymd" (or "replymd:long") with a
-// formatted one, "chunks:<n>" streams in n deltas, "slowstream" pauses after every chunk,
+// replies with non-ASCII text, "replymd" (or "replymd:long", or
+// "replymd:paste" with two paste boxes) with a formatted one, "chunks:<n>" streams in n deltas, "slowstream" pauses after every chunk,
// "think" opens with a thinking block, "pause:<ms>" waits before any text, and "tool:<name>[:<arg>]" calls an
// Equipo MCP tool before replying (add_project:<repo>,
// create_project:<namespace>/<name>, ask_person:<question>|<option>...,
diff --git a/internal/fakeclaude/markdown.go b/internal/fakeclaude/markdown.go
index dff66ccc..5cbb0db1 100644
--- a/internal/fakeclaude/markdown.go
+++ b/internal/fakeclaude/markdown.go
@@ -11,9 +11,15 @@ import (
// numbered list, with a task link and inline code.
const markdownSample = "**Yes. This is the right shape for it.** The invoice total is counted twice when delivery is added.\n\nTwo people see it:\n\n- **Guest:** sees the total on the basket page.\n- **Customer:** sees it again on the receipt.\n\nWhat I'd do, in [Fix the invoice total](/tasks/tks6kwzzdngr):\n\n1. **Owner of the fix:** Engineering, on the checkout repository.\n2. **One complete change:** the total, the receipt and `go test ./checkout/...` for both.\n3. **Review:** an independent check before it merges."
-// markdownWord asks for markdownSample as the reply ("replymd"), or for
-// a long reply of it repeated ("replymd:long").
-var markdownWord = regexp.MustCompile(`\breplymd(:long)?\b`)
+// pasteSample is a reply with two things to paste: a command, with the
+// characters a copy must keep (<, &, quotes, a tab, trailing spaces), and
+// a prompt, which wraps.
+const pasteSample = "Run this in a terminal:\n\n```bash\ngo test ./internal/checkout/... -run 'TestTotal' > out.txt && echo \"a < b\"\t \n```\n\nThen paste this prompt into the review:\n\n```prompt\nCheck that the invoice total counts delivery once, & say which test shows it. Keep the receipt as it is.\n```"
+
+// markdownWord asks for markdownSample as the reply ("replymd"), for a
+// long reply of it repeated ("replymd:long"), or for pasteSample
+// ("replymd:paste").
+var markdownWord = regexp.MustCompile(`\breplymd(:long|:paste)?\b`)
func markdownReply(newest string) (string, bool) {
m := markdownWord.FindStringSubmatch(newest)
@@ -23,6 +29,9 @@ func markdownReply(newest string) (string, bool) {
if m[1] == "" {
return markdownSample, true
}
+ if m[1] == ":paste" {
+ return pasteSample, true
+ }
parts := make([]string, 30)
for i := range parts {
parts[i] = "## Part " + strconv.Itoa(i+1) + "\n\n" + markdownSample
diff --git a/internal/headless/browser_paste_test.go b/internal/headless/browser_paste_test.go
new file mode 100644
index 00000000..f6d195f8
--- /dev/null
+++ b/internal/headless/browser_paste_test.go
@@ -0,0 +1,129 @@
+//go:build browser
+
+package headless
+
+import (
+ "context"
+ "os"
+ "path/filepath"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/browsertest"
+ "github.com/chromedp/cdproto/cdp"
+ "github.com/chromedp/cdproto/emulation"
+ "github.com/chromedp/chromedp"
+)
+
+// pasted are the two blocks of fakeclaude's pasteSample, as written
+// between their fences: a command with <, &, quotes, a tab and trailing
+// spaces, and a prompt.
+const (
+ pastedCommand = "go test ./internal/checkout/... -run 'TestTotal' > out.txt && echo \"a < b\"\t "
+ pastedPrompt = "Check that the invoice total counts delivery once, & say which test shows it. Keep the receipt as it is."
+)
+
+// Every fenced block in a reply is a paste box. While its fence is still
+// streaming the box shows and Copy is there but disabled (a click copies
+// nothing); when the fence closes Copy turns on in the same box, which
+// does not move. In the committed reply a click copies the block's exact
+// text, "Copied" shows and is announced, then Copy comes back; from the
+// keyboard, Tab reaches the next Copy with a visible focus ring, and
+// Enter and Space copy. Set EQUIPO_SCREENSHOTS to a directory to save
+// paste-*.png.
+func TestBrowserPasteBox(t *testing.T) {
+ _, inst, r := localEnv(t)
+ r.start(t)
+ c := inst.Cookie()
+ p := openPage(t, inst.URL, c.Name, c.Value, 1280, 900, true)
+ defer p.stop()
+ // The clipboard records what it is given.
+ p.check(`(()=>{window.__copied=[];navigator.clipboard.writeText=t=>{window.__copied.push(t);return Promise.resolve()};return true})()`, "clipboard stub")
+ // record follows the streaming reply frame by frame: the first box
+ // while its Copy is disabled (its text, its place in the message, a
+ // click on it) and the first frame Copy is on. Its place is its top in
+ // the message, its bar's height and Copy's distance from its right edge:
+ // the bubble may still widen as the last line grows.
+ record := `(()=>{const s=window.__p={el:null,box:null,open:0,openText:null,openAt:null,dim:null,clicked:false,on:null,onAt:null,same:null,done:false};
+const at=(b,x)=>[b.getBoundingClientRect().top-x.getBoundingClientRect().top,b.querySelector('[equipo-paste-bar]').getBoundingClientRect().height,b.getBoundingClientRect().right-b.querySelector('[equipo-paste-copy]').getBoundingClientRect().right];
+const f=()=>{if(!s.el)s.el=document.querySelector('[equipo-thinking][data-streaming]');const x=s.el;
+if(x&&x.hasAttribute('equipo-thinking')){const b=x.querySelector('[equipo-paste]');if(b){const btn=b.querySelector('[equipo-paste-copy]'),code=b.querySelector('pre > code').textContent;
+if(btn.getAttribute('aria-disabled')==='true'){if(!s.box)s.box=b;s.open++;s.openText=code;s.openAt=at(b,x);s.dim=getComputedStyle(btn).opacity;if(!s.clicked){s.clicked=true;btn.click()}}
+else if(s.on===null){s.on=code;s.onAt=at(b,x);s.same=s.box===b}}}
+if(!x||x.hasAttribute('equipo-thinking'))requestAnimationFrame(f);else s.done=true};f();return true})()`
+ p.check(record, "record")
+ p.send("replymd:paste chunks:120 sleep:40 slowstream")
+ p.run(browsertest.WaitWithin(`window.__p.done && !!window.__p.el.dataset.message`, 60*time.Second))
+ state := func() string { return evaluateIn[string](t, p.ctx, `JSON.stringify(window.__p)`) }
+ p.check(`window.__p.open>0 && window.__p.box!==null`, "the box did not show while its fence was open: "+state())
+ p.check(`parseFloat(window.__p.dim)<0.7`, "the disabled Copy is not visibly dimmed: "+state())
+ p.check(`window.__copied.length===0`, "a click on an open fence's Copy copied: "+state())
+ // An open block's last line is still arriving; the renderer ends it
+ // with a newline, as it ends every line.
+ p.check(`(`+jsonString(pastedCommand)+`).startsWith(window.__p.openText.replace(/\n$/,''))`, "the open box showed other text: "+state())
+ p.check(`window.__p.on!==null && window.__p.same`, "Copy did not turn on in the same box while streaming: "+state())
+ p.check(`window.__p.on===`+jsonString(pastedCommand+"\n"), "Copy turned on before the fence closed: "+state())
+ p.check(`window.__p.openAt.every((v,i)=>Math.abs(v-window.__p.onAt[i])<0.5)`, "the box moved when its fence closed: "+state())
+
+ // The committed reply: two boxes, a command and a prompt.
+ p.check(`(()=>{const m=window.__p.el,b=m.querySelectorAll('[equipo-paste]');if(b.length!==2||b[0].getAttribute('equipo-paste')!=='code'||b[1].getAttribute('equipo-paste')!=='prose')return false;
+if(b[0].querySelector('[equipo-paste-lang]').textContent!=='bash'||b[1].querySelector('[equipo-paste-lang]').textContent!=='prompt'||m.querySelector('[aria-disabled]'))return false;
+const cs=getComputedStyle(b[0].querySelector('pre')),ps=getComputedStyle(b[1].querySelector('pre'));if(cs.whiteSpace!=='pre'||ps.whiteSpace!=='pre-wrap'||!/mono/i.test(cs.fontFamily))return false;
+b[0].querySelector('[equipo-paste-copy]').id='paste-a';b[1].querySelector('[equipo-paste-copy]').id='paste-b';b[0].scrollIntoView({block:'center'});return true})()`, "the committed reply's boxes")
+ shot := func(name string) {
+ dir := os.Getenv("EQUIPO_SCREENSHOTS")
+ if dir == "" {
+ return
+ }
+ var raw []byte
+ p.run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ var err error
+ raw, err = chromedp.CaptureScreenshot()(ctx, target)
+ return err
+ }))
+ if err := os.WriteFile(filepath.Join(dir, "paste-"+name+".png"), raw, 0o644); err != nil {
+ t.Fatal(err)
+ }
+ }
+ shot("light")
+
+ // A click copies the command exactly; "Copied" shows, is announced,
+ // then Copy comes back.
+ p.run(chromedp.Click(chromedp.CSS(`#paste-a`)))
+ p.run(browsertest.Wait(`window.__copied.length===1`))
+ p.check(`window.__copied[0]===`+jsonString(pastedCommand), "the copied text is not the block's: "+evaluateIn[string](t, p.ctx, `JSON.stringify(window.__copied)`))
+ p.check(`document.querySelector('#paste-a').textContent==='Copied'`, "the button did not say Copied")
+ p.run(browsertest.Wait(`[...document.querySelectorAll('[role="status"]')].some(e=>e.textContent==='Copied')`))
+ shot("copied")
+ p.run(browsertest.WaitWithin(`document.querySelector('#paste-a').textContent==='Copy'`, 5*time.Second))
+
+ // The keyboard: Tab from the first Copy reaches the second, with a
+ // visible focus ring; Enter copies the prompt, Space the command.
+ p.check(`(()=>{document.querySelector('#paste-a').focus();return true})()`, "focus")
+ p.run(chromedp.KeyEvent("\t"))
+ p.check(`(()=>{const a=document.activeElement;return a.id==='paste-b'&&a.matches(':focus-visible')&&getComputedStyle(a).outlineStyle==='solid'&&parseFloat(getComputedStyle(a).outlineWidth)>=2})()`, "Tab did not reach the second Copy with a focus ring")
+ shot("focus")
+ p.run(chromedp.KeyEvent("\r"))
+ p.run(browsertest.Wait(`window.__copied.length===2 && document.querySelector('#paste-b').textContent==='Copied'`))
+ p.check(`window.__copied[1]===`+jsonString(pastedPrompt), "Enter copied other text")
+ p.check(`(()=>{document.querySelector('#paste-a').focus();return true})()`, "focus")
+ p.run(chromedp.KeyEvent(" "))
+ p.run(browsertest.Wait(`window.__copied.length===3`))
+ p.check(`window.__copied[2]===`+jsonString(pastedCommand), "Space copied other text")
+
+ // Dark theme, for the screenshots.
+ p.check(`(()=>{document.documentElement.dataset.theme='dark';return true})()`, "theme")
+ shot("dark")
+
+ // Without script the box is still there and its text can be
+ // selected; Copy is hidden, never a button that does nothing.
+ p.run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ _, err := cdp.Call(ctx, target, emulation.SetScriptExecutionDisabled, emulation.SetScriptExecutionDisabledParams{Value: true})
+ return err
+ }), chromedp.Navigate(inst.URL+"/conversation"))
+ p.run(browsertest.Wait(`document.querySelectorAll('[equipo-paste]').length>=2`))
+ t.Logf("scripting: none matches: %v", evaluateIn[bool](t, p.ctx, `matchMedia('(scripting: none)').matches`))
+ p.check(`!document.documentElement.hasAttribute('data-paste')`, "paste.js ran with scripts off")
+ p.check(`(()=>{const b=[...document.querySelectorAll('[equipo-paste]')].slice(-2);return b.every(x=>{const st=getComputedStyle(x.querySelector('[equipo-paste-copy]'));return (st.display==='none'||st.visibility==='hidden')&&getComputedStyle(x.querySelector('pre > code')).userSelect!=='none'})&&b[0].querySelector('pre > code').textContent===`+jsonString(pastedCommand+"\n")+`})()`, "without script Copy shows, or the text is not there to select")
+ shot("noscript")
+}
diff --git a/internal/plan3test/conversation_draft_test.go b/internal/plan3test/conversation_draft_test.go
index 2fce5fc1..fc205359 100644
--- a/internal/plan3test/conversation_draft_test.go
+++ b/internal/plan3test/conversation_draft_test.go
@@ -31,7 +31,7 @@ func TestConversationDraftRendersOnTheServer(t *testing.T) {
}
text := "**Yes.** Two people see it:\n\n- **Guest:** the basket\n- **Cus"
w := post(true, "same-origin", text)
- if w.Code != 200 || w.Body.String() != string(chatmarkdown.RenderDraft(text)) {
+ if w.Code != 200 || w.Body.String() != string(chatmarkdown.Labels{}.RenderDraft(text)) /* no fence, so no paste box words */ {
t.Fatalf("draft render: %d %q", w.Code, w.Body.String())
}
if !strings.HasPrefix(w.Header().Get("Content-Type"), "text/html") || w.Header().Get("Cache-Control") != "no-store" {
diff --git a/internal/runner/thin/claude.go b/internal/runner/thin/claude.go
index e3a6e742..481b8451 100644
--- a/internal/runner/thin/claude.go
+++ b/internal/runner/thin/claude.go
@@ -529,7 +529,7 @@ func (c *claudeCoordinator) idleExit() {
// houseRule versions the opening's rule. Changing the rule's text changes
// it, so sessions started under an older rule are not resumed.
-const houseRule = "2026-11-07.9"
+const houseRule = "2026-11-11.1"
// sessionAccount records the account and house rule a session runs on.
func (c *coordBase) sessionAccount() string { return c.account.ID + "#rule-" + houseRule }
@@ -619,6 +619,7 @@ func opening(person string, catalog []wire.RepoInfo) string {
b.WriteString("When the person reports a bug or asks for a change, call record_task at once, before investigating, with the repository it belongs to, a short title and their words as the brief. Then investigate with search_code and read_file, attach what you found with add_finding (a one-sentence headline for the person, plain words and no file paths, and the full finding with its file and line), and call start_task with a brief for Engineering. Engineering changes the code on the task's own branch and pushes it to Amadan; the change is then checked and reviewed, and Equipo's merge rules decide whether it merges on its own or asks the person with a card that gives Equipo's call. You cannot make it merge: when you have a concrete reason a change needs the person's look, call hold_merge with that reason. When the person says how a project should merge (\"always ask me about Suite\", \"main is not a release for Woodstar\"), call set_merge_policy with their words; a stricter rule applies at once and a looser one waits for their tap. Never offer to merge or open a pull request, and never ask the person to merge. Use ask_person only for a question only the person can answer.\n")
b.WriteString("Never file the same problem twice. If record_task returns similar open tasks and one of them is what the person is reporting, call add_report on it with their words and tell them in one line it is already logged and where it stands, naming it as a markdown link; record a separate task only when it is clearly a different problem.\n")
b.WriteString("Speak at the outcome level: what you understood, what is happening, what you need from the person. For example: \"Got it, I've logged [Swipe back doesn't work](/tasks/tk...) and Engineering is on it.\" No file paths, line numbers or code mechanics in your replies; the diagnosis goes on the task with add_finding. Always name a task as a markdown link with its title and the link from record_task, start_task or read_task, never as \"the task card\".\n")
+ b.WriteString("Anything the person may need to paste (commands, prompts, config, codes) goes in a fenced code block, one block per thing to paste, with its kind after the opening fence (bash for a command, prompt for a prompt, text for plain text): the chat shows each block with a Copy button.\n")
b.WriteString("When the person wants specifics about how something was changed, do not explain them yourself: point them to the task, where they can ask the specialist who did the work, for example \"You can ask Engineering on [Swipe back doesn't work](/tasks/tk...).\" (or Review, about the review). Never relay technical detail from read_task.\n")
b.WriteString("When the person names an app, product or feature, use find, then search_code and read_file to answer from the actual code. Never ask which repository or framework. If find reaches nothing, say so in one short line and stop there: the person sees a card showing how to give Equipo access, so do not repeat it.\n")
b.WriteString("When the person says a project is a priority, or no longer is, call star_project and say so in one line.\n")
diff --git a/internal/runner/thin/voice_test.go b/internal/runner/thin/voice_test.go
index cae23c40..207c4c78 100644
--- a/internal/runner/thin/voice_test.go
+++ b/internal/runner/thin/voice_test.go
@@ -80,3 +80,20 @@ func TestOpeningReusesOpenTasks(t *testing.T) {
t.Fatalf("add_report is not offered: %v", tools)
}
}
+
+// What the person may need to paste comes in its own fenced block, which
+// the chat shows as a paste box with Copy (Paul, 2026-11-11). The line is
+// static, in the opening, so the cached prefix stays the same between
+// turns.
+func TestOpeningPutsPastesInFences(t *testing.T) {
+ o := opening("p@example.com", nil)
+ if !strings.Contains(o, "Anything the person may need to paste (commands, prompts, config, codes) goes in a fenced code block, one block per thing to paste") {
+ t.Fatal("the opening lacks the paste rule")
+ }
+ if o != opening("p@example.com", nil) {
+ t.Fatal("the opening is not static")
+ }
+ if houseRule == "2026-11-07.9" {
+ t.Fatal("the rule changed: its version must move so sessions read it")
+ }
+}
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 08a1c17e..39c6f17a 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -11037,5 +11037,12 @@
"match": "Node",
"count": 1,
"reason": "Markdown syntax tree node traversal in the Go renderer; no external runtime."
+ },
+ {
+ "path": "internal/chatmarkdown/draft.go",
+ "line_sha256": "22a4908753eba625925bc6d73b9f556d68708af8710c79108490564280f1233b",
+ "match": "Node",
+ "count": 1,
+ "reason": "goldmark's ast.Node in the watched fence parser's Continue signature; Markdown syntax tree, no external runtime."
}
]