oficina / slides Public

Docs: pairing is the presenter's; walk checks every position

docs/api.md no longer says pressing Present shows a code and QR; the
presenter pairs from the window's menu. The walk test now compares each
press with the expected (slide, step), so a skipped and a repeated
position cannot cancel out.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 782184c4bee70e51bd23e6dd25b5f0a95d769d0c parent 852e3f6
2 files changed, +40 −21
  • docs/api.md +5 −4
  • internal/slidestest/presenter_walk_browser_test.go +35 −17
diff --git a/docs/api.md b/docs/api.md
index 7a513e1..a3b5d04 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -348,10 +348,11 @@ than as whoever started it. The remote token is transferable by design
capability and logging the issuer beside it.
This JSON is the only place the pairing block exists for a session an
-agent started. Press Present in a browser and the presenter view shows
-the code and a QR to scan it with; that block belongs to whoever
-started the talk, and for your session that is the agent, not the
-person opening the page — so `notes_url` renders the talk and the
+agent started. When a person presses Present in a browser, they pair a
+phone themselves, from the presenter window's menu (`POST /p/{session}/pair`),
+and that page shows them the code and a QR to scan; that is theirs, and
+it replaces the phone's earlier token. For your session the credentials
+are the ones you were given, so `notes_url` renders the talk and the
controls, and no code and no QR. Pass on what you were given: the
`code` for somebody to type into `/r/`, or `remote_url` outright. It is
not recoverable afterwards, and calling this endpoint again mints a
diff --git a/internal/slidestest/presenter_walk_browser_test.go b/internal/slidestest/presenter_walk_browser_test.go
index 7515d19..8c88844 100644
--- a/internal/slidestest/presenter_walk_browser_test.go
+++ b/internal/slidestest/presenter_walk_browser_test.go
@@ -67,35 +67,53 @@ func TestPresenterWalksTheWholeTalk(t *testing.T) {
open(t, ctx, mt.fr.rig.Origin, mt.presenter())
var scroll struct{ Y, SH, VH float64 }
const scrollJS = `({ Y: window.scrollY, SH: document.documentElement.scrollHeight, VH: innerHeight })`
- seen := map[string]bool{}
- presses := 0
+ // The sequence every press must produce, from the deck built above.
+ type at struct {
+ head string
+ step string
+ }
+ var want []at
+ for i := range 105 {
+ steps := 0
+ if i%3 == 0 && i/3 < 34 {
+ steps = 4
+ }
+ for k := 0; k <= steps; k++ {
+ want = append(want, at{fmt.Sprintf("Talk %03d", i), strconv.Itoa(k)})
+ }
+ }
+ here := func(s windowState) at {
+ head, _, _ := strings.Cut(s.Now, "\n")
+ return at{strings.TrimSpace(head), s.Step}
+ }
before := state(t, ctx)
if before.Mode != "core" {
t.Fatalf("the window starts in mode %q, want core", before.Mode)
}
- for {
- if !strings.HasPrefix(before.Now, "Talk") {
- t.Fatalf("press %d: the window shows %q, which is not a talk slide", presses, before.Now)
- }
- seen[before.Slide] = true
+ if got := here(before); got != want[0] {
+ t.Fatalf("the window starts at %+v, want %+v", got, want[0])
+ }
+ if len(want) != 241 {
+ t.Fatalf("the expected walk has %d positions, want 241 (240 presses)", len(want))
+ }
+ for press := 1; press < len(want); press++ {
run(t, ctx, key(kb.ArrowRight))
got := state(t, ctx)
- if got.Slide == before.Slide && got.Step == before.Step {
- break // the last press of the talk moves nothing
- }
- presses++
if got.Mode != "core" {
- t.Fatalf("press %d: the mode became %q", presses, got.Mode)
+ t.Fatalf("press %d: the mode became %q", press, got.Mode)
+ }
+ if g := here(got); g != want[press] {
+ t.Fatalf("press %d: the window is at %+v, want %+v", press, g, want[press])
}
run(t, ctx, chromedp.Evaluate(scrollJS, &scroll))
if scroll.Y != 0 || scroll.SH > scroll.VH {
- t.Fatalf("press %d: the document scrolls: %+v", presses, scroll)
+ t.Fatalf("press %d: the document scrolls: %+v", press, scroll)
}
- before = got
}
- seen[before.Slide] = true
- if len(seen) != 105 || presses != 240 {
- t.Fatalf("walked %d slides and %d presses, want 105 and 240", len(seen), presses)
+ // One more at the end moves nothing.
+ run(t, ctx, key(kb.ArrowRight))
+ if g := here(state(t, ctx)); g != want[len(want)-1] {
+ t.Fatalf("a press past the end moved the window to %+v", g)
}
mt.waitRow(t, "t104", 0)
}