Skip to content

feat(guests): play the fast return feed on the guest page - #393

Merged
birme merged 5 commits into
Eyevinn:mainfrom
wagenet:wagenet/contributor-view
Oct 28, 2026
Merged

birme merged 5 commits into
Eyevinn:mainfrom
wagenet:wagenet/contributor-view

Conversation

@wagenet

@wagenet wagenet commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Opened by Claude (AI) on Peter Wagenet's behalf.

Based on main and merges independently of #386. Until #386 (and its Strom dependencies) are deployed, join responses list no fast feed, so the page plays the picture feed only.

What

The guest page (src/routes/guest-page.ts) plays the fast return feed that #386 adds to the join response.

  • Feeds are picked by id, not by position.
  • The fast feed's audio plays on its own audio-only PeerConnection, through an <audio> element. A shared PeerConnection would let Chrome lip-sync it back to the picture and lose the ~500 ms saving.
  • Main's return-mode switch (feat(guests): guest picks program or program-minus on the guest page #412) calls routeReturnAudio, which picks what the guest hears (table below). A muted fast feed stays connected, so switching back is instant.
  • Leave and page close send DELETEs for both return WHEP sessions, then the guest session DELETE, all at once without waiting for answers. A return DELETE that stalls or fails cannot delay the session DELETE, and a page close after a Leave sends no second session DELETE, as on main. The return DELETEs are best-effort: if the server handles the session DELETE first, the invite token no longer authorizes them, and those sessions last until Strom times them out. On main the picture session is never deleted.
  • Rejoin (fix(guest-page): warn and offer Rejoin when the studio connection drops #478) closes both return PeerConnections and DELETEs both WHEP sessions before joining again.
Mode Fast feed Guest hears
program-minus listed and connected fast feed audio; picture audio muted
program-minus not listed, or failed picture audio
program either picture audio; fast audio muted

The fast feed is always mix-minus, so a guest in program must hear the picture's audio to hear themselves.

Tests

guest-page-returns.test.ts runs the page script in a VM with fake DOM, fetch and RTCPeerConnection. It covers picture-only and picture + fast joins, feeds listed in either order, a program join, mode changes by the guest and the crew, a failed fast feed, and Leave and page close with stalled or failing DELETEs. guest-page-connection.test.ts adds a Rejoin with both feeds.

  • Against main's page, 9 of the 13 tests in guest-page-returns.test.ts fail. The other 4 pin main's session DELETE counts on Leave and page close.
  • Each of these reverts fails a test: feeds picked by position; routeReturnAudio not called from applyReturnAudio; Rejoin closing only the picture; the fast session not deleted; Leave waiting before the session DELETE, or sending the return DELETEs after it; a second session DELETE on a page close after a Leave; a DELETE that throws stopping Leave.
  • pnpm typecheck: ok. pnpm test: 1088 passed (109 files).

Known limits

These apply only once a fast feed is listed.

  • The picture is muted as soon as a fast feed is listed. If the fast feed's WHEP request hangs, or its PeerConnection fails after connecting, the guest hears nothing in program-minus until they switch modes.
  • A fast WHEP request that finishes after the guest pressed Rejoin is adopted by the new connection. If it was refused, it marks the new fast feed unavailable.
End-to-end run (on an earlier version)

Headless Chrome against a local Strom with strom#844, two lowLatency guests in program-minus, before #386's current router, main's mode switch and the /api/v1/guests feed URLs. Each page opened WHIP, picture and fast PeerConnections; each guest's fast feed carried the other guest's tone with the picture's audio muted; Leave and tab close DELETEd picture, fast, then session (all 204). Autoplay was forced on, so Safari/iOS playback is unverified.

🤖 Generated with Claude Code

@birme

birme commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

This PR looks like part of a multi-PR dependency stack for the low-latency fast return feed: it depends on #386 (build the fast return feed), which should land first. Holding off on automated review/merge here — this needs a human (or the relevant dev agent) to assess the whole stack together, not a per-PR pass. Nothing further is needed from the author; this comment exists so the dependency is recorded on the PR rather than in a run log.

wagenet added a commit to wagenet/open-live that referenced this pull request Oct 1, 2026
Conflicts from 6ad0d3f (fast feed follows a mixer read) resolved to Eyevinn#386's
side: Eyevinn#386's direct-outs refactor replaced that approach and removed
fast-feed-state.
@wagenet
wagenet force-pushed the wagenet/contributor-view branch 3 times, most recently from 4c92a25 to 3ee1b42 Compare October 7, 2026 14:03
@wagenet

wagenet commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Claude (Claude Code, for @wagenet): rebased onto #386's new head (3b92db6). Changes from main's guest page:

  • fix(guest-page): warn and offer Rejoin when the studio connection drops #478's return-connection watch now starts in playReturns, where the picture PeerConnection is stored, because whepPlay returns { pc, resource }.
  • rejoin() calls closeReturns(), so the fast PeerConnection is closed too and both WHEP sessions are DELETEd. Main's version only closed the picture PeerConnection. A late DELETE can't end the new feed: the guest route refuses a session id that is no longer bound to the guest session.
  • New test in guest-page-connection.test.ts for that Rejoin. It fails with main's rejoin(). Fake join and fake DOM fixtures updated for the feed id and return-audio.

pnpm typecheck ok, pnpm test 1072 passed. No browser or rig run.

@wagenet
wagenet force-pushed the wagenet/contributor-view branch from 3ee1b42 to 9ffe849 Compare October 9, 2026 16:39
@wagenet

wagenet commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Claude (Claude Code, for @wagenet): unstacked from #386 and rebased onto main (aa2f461). The branch is now a single commit, 9ffe849.

The page only reads the join response's feeds by id, and it plays a fast feed only when one is listed, so nothing here needs #386's code. The cherry-pick onto main applied cleanly; the earlier guest-page.ts drift (#478, #470, #409) was already resolved on the branch. Sources, other than the page and the test files, are unchanged.

pnpm typecheck passes; pnpm test runs 1081 tests in 109 files, all passing. The new tests still fail with the routeReturnAudio call removed from applyReturnAudio, and with rejoin closing only the picture PeerConnection. The PR body is updated; it stays a draft.

@wagenet

wagenet commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Claude (Claude Code, for @wagenet): pushed df30dc1. Leave waits for the return feeds' DELETEs before ending the guest session. If one never answered, the session DELETE was never sent, and closing the tab did not send it either. Leave now waits at most two seconds, and Leave and page close share one session DELETE. New tests cover the stalled DELETE, a page close during the wait, and the DELETE order on page close. pnpm typecheck passes; pnpm test runs 1084 tests in 109 files, all passing. The PR body now lists the fast-feed limits (a hung or failed fast feed leaves the guest silent in program-minus; a fast request finishing after Rejoin is adopted).

@wagenet

wagenet commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Claude (Claude Code, for @wagenet): pushed 121cc41. Review found that the once-only session DELETE flag from the last push could stop a page close from ending a session. That happens when a Leave is pressed during a Rejoin and the server answers the join after the Leave. The flag is gone, so Leave and page close each send the DELETE, as on main. A return-feed DELETE that fails at once, or a failed session DELETE, no longer keeps Leave or page close from finishing. New tests cover each. pnpm typecheck passes; pnpm test runs 1087 tests in 109 files, all passing.

@wagenet
wagenet force-pushed the wagenet/contributor-view branch 2 times, most recently from 483e2ad to 1107b0f Compare October 9, 2026 17:16
@wagenet

wagenet commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Claude (Claude Code, for @wagenet): pushed 1107b0f, which replaces df30dc1 and 121cc41 with one commit.

Leave and page close now send the return DELETEs and the guest session DELETE at once, with no wait, no timer and no once-only flag. Page close uses main's if (!live) check again. A stalled return DELETE can no longer delay the session DELETE, Leave no longer keeps the camera and mic on for up to two seconds, and the session DELETEs match main's: one per Leave or page close, none on a page close after a Leave.

Correction to my last comment: I wrote that a page close after a Leave sends a second session DELETE "as on main". That was wrong. Main sends none, and that second DELETE could end a session the same invite had opened in another tab. It is gone in 1107b0f, and a test guards it.

The cost: the return DELETEs are best-effort. If the server handles the session DELETE first, it refuses them, and those WHEP sessions last until Strom times them out, as the picture session always does on main. Ending the guest's return sessions inside the server's session DELETE would remove that and is a possible follow-up.

pnpm typecheck ok, pnpm test 1087 passed. Body updated.

@wagenet

wagenet commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Claude (Claude Code, for @wagenet): pushed 2dfd56c, a test-only commit. It adds a join that lists the fast feed before the picture feed, so picking feeds by position now fails a test. Body trimmed; pnpm test 1088 passed.

@wagenet
wagenet marked this pull request as ready for review October 9, 2026 17:55
wagenet added a commit to wagenet/open-live that referenced this pull request Oct 9, 2026
@birme

birme commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

This PR is part of the low-latency return-feed feature on open-live. Holding off on automated review/merge — needs a human (or the relevant dev agent) to assess together.

Members:

Nothing further is needed from the author; this records the dependency on the PRs themselves.

@birme birme left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr-reviewer verdict: APPROVE

Prior findings

# Source Finding Status
1 birme stack-flag (x2) PR is part of the low-latency fast-return-feed stack; hold for whole-stack human/dev-agent assessment DROPPED — informational hold, not a change request. Since then the author unstacked the branch (rebased onto main, single logical change) and it merges independently of #386; the stack concern no longer applies.
2 wagenet status notes once-only session-DELETE flag could drop a page-close session DELETE; 121cc41/1107b0f removed it; return+session DELETEs now fire at once, best-effort FIXED — current head (1107b0f logic) matches main's DELETE semantics; guarded by tests.

No formal gh reviews or inline review comments exist on the PR. No OPEN rows.

Verification against real source (head d005c43)

  • Join-response contract is real, not fabricated. src/routes/guests.ts join handler builds feeds as objects with id / url (video: true on picture), plus returnMode and defaultMode: 'program-minus'. The page reads exactly these fields (feed.id, feed.url, joinData.returnMode || joinData.defaultMode). No invented fields.
  • No fast feed on main. On current main, feeds only ever contains the picture entry (or []). The fast feed is added by #386, which has not landed — matching the PR body.
  • Graceful degradation confirmed. playReturns() selects by id via findFeed. With no fast feed: fastAvailable = false, routeReturnAudio(mode) sets returnVideo.muted = false / returnAudio.muted = true, and only the picture WHEP session is opened — picture plays with its own audio, no error path. A fast WHEP failure falls back the same way (.catch → fastAvailable = false; routeReturnAudio(audioMode)).
  • Tests cover the fallback. guest-page-returns.test.ts includes "plays the picture feed with its own audio when there is no fast feed" (no-fast path) and "unmutes the picture's audio when the fast feed fails" (failure path), feeds-by-id in either order, a program join, crew/guest mode switches, and Leave/page-close DELETE ordering with stalled/failing DELETEs.

Local quality gates (open-live: typecheck, build, vitest; no lint)

  • pnpm typecheck: clean
  • pnpm build (tsc): clean
  • pnpm test: 1159 passed (116 files)

CI

build-and-test: pass.

Merge

Head is behind current main but git merge-tree shows no conflicts; the diff vs origin/main touches only guest-page.ts and the 3 test files, so no server contract changes. No Closes #N reference. Safe to merge standalone on current main.

APPROVE — the no-fast-feed fallback is genuinely safe (id-based selection, picture-audio default, failure caught) and is directly tested.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

wagenet added a commit to wagenet/open-live that referenced this pull request Oct 21, 2026
@birme

birme commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

This PR's branch now has a real merge conflict with main (after today's merges to main), so GitHub's automated "Update branch" can't refresh it and this repo's strict required status checks keep it from merging as-is. Please merge current main into your branch and resolve the conflicts (a normal merge commit is fine, no force-push needed). Nothing else about the PR's review state changes because of this note.

@birme

birme commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

This PR's branch is behind main, and this repo requires status checks to have run against current main, so it can't merge as-is. The automated "Update branch" was refused (403). main now includes a change to .github/workflows/sync-fork.yml (#568), and the automation's token can't write workflow files. "Allow edits by maintainers" is on, so that isn't the cause. To refresh it, please merge current main into your branch (a normal merge commit is fine, no force-push needed). The existing stack/dependency hold on this PR still applies.

wagenet and others added 3 commits October 27, 2026 16:12
When the join lists a `fast` feed, the guest page plays its audio on a
second, audio-only PeerConnection. The feeds stay on separate
PeerConnections so the browser cannot lip-sync the fast audio back to
the picture.

The fast feed is always mix-minus, so it is heard only in
`program-minus`; in `program` the guest hears the picture's audio and
the fast feed stays connected, muted. The return-mode switch decides
which: a change the guest picks, or one the crew makes and the poll
picks up, moves the audio between the feeds. If the fast feed fails,
the picture's audio is unmuted.

On leave and page close, the page deletes both return WHEP sessions
before the guest session, since the invite token stops authorizing
return routes once the session is gone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Leave and page close send the return feeds' DELETEs and then the guest
session DELETE straight away, without waiting for answers. A return
DELETE that never answers, or that fails at once, does not delay or
stop the guest session DELETE. A page close after a Leave sends no
second guest session DELETE, unless a late join made the page live
again.

The return DELETEs are best-effort: if the server handles the guest
session DELETE first, it refuses them, and those WHEP sessions last
until Strom times them out.

Tests cover a return DELETE that never answers or fails at once, a
page close after a Leave, and the DELETE order on page close.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The join lists the picture feed first, so no test caught the page
picking feeds by position. A join that lists the fast feed first now
does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wagenet
wagenet force-pushed the wagenet/contributor-view branch from ee388fb to 78d8201 Compare October 27, 2026 23:14
wagenet added a commit to wagenet/open-live that referenced this pull request Oct 28, 2026

@eyevinn-pr-reviewer eyevinn-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr-reviewer verdict: APPROVE

Reviewed at 78d8201b8bc60234fda1e67cdd67e13a87f4f565; approval submitted on the refreshed head e8e32a986049a8b499bb94cb4fa64a8d56dd9953, which adds only Merge branch 'main' commits. CI is green on this head.

Prior findings

# Source Finding Status
1 wagenet self-review (2026-10-09, 121cc41) Once-only session-DELETE flag (df30dc1) could stop a page close from ending a session a late join re-created FIXED: flag removed and replaced by 1107b0f, carried in a8c0c74. leave()/pagehide call closeReturns() then endSession() with no wait (src/routes/guest-page.ts:1132); covered by src/__tests__/guest-page-returns.test.ts:346
2 wagenet self-review (2026-10-09, df30dc1) Leave waited on the return DELETEs, so a stalled one blocked the session DELETE FIXED: a8c0c74 fires the return and session DELETEs at once, best-effort (guest-page.ts:839, :1132); tests guest-page-returns.test.ts:321, :366, :385
3 wagenet (2026-10-09, 2dfd56c) No test caught feeds being picked by position FIXED: 78d8201 adds guest-page-returns.test.ts:232; findFeed at guest-page.ts:796
4 automation branch-blocked reason:conflict (2026-10-22) / reason:workflow-scope (2026-10-23) Branch conflicted with / was behind main FIXED: rebased onto 67fe32b. 67fe32b..main touches no .github/ files, and automated Update branch has now succeeded
— automation stack-flag (2026-10-01, 2026-10-12) Stack/dependency hold with #386 Not a change request. The author unstacked onto main on 2026-10-09, and the PR merges independently of #386 (verified below). This review clears that hold
— Earlier legacy review (COMMENTED, APPROVE at d005c43) No blocking findings Stale; re-judged at the current head

No OPEN rows.

Verification against source (head trial-merged with main 9d6307d)

  • The join contract is real. src/routes/guests.ts:747-775 builds feeds: [{ id: 'picture', url, ... }], defaultMode: 'program-minus' and returnMode. The page reads exactly these fields, matching docs/specs/guest-calling-intercom.md §"Return feeds".
  • Fallback with no fast feed (main today) is graceful. playReturns (guest-page.ts:804) picks feeds by id. With no fast feed, fastAvailable = false, the picture plays unmuted, and only one WHEP session is opened. A failed fast WHEP falls back to the picture's audio (:830). Tested at guest-page-returns.test.ts:205 and :279.
  • The return-session DELETE route exists on main. returns.ts:356 is token-authed and only lets a guest end their own session. CSP connect-src 'self' is unchanged.
  • Behaviour change on main (positive): Leave, page close and Rejoin now DELETE the picture WHEP session instead of leaving it for Strom to time out.

Security (external contributor, extra scrutiny)

No new HTML sinks (textContent only), CSP unchanged, no server-side source changes, no secrets, dependencies or workflow changes. Commits carry Co-Authored-By trailers.

Quality gates

Trial merge with main is clean. pnpm install --frozen-lockfile, pnpm run typecheck and pnpm run build pass; npx vitest run: 1730 passed (162 files). CI build-and-test passes.

Warnings (non-blocking; only matter once #386 lists a fast feed)

  • Spec divergence (dormant): the spec makes low-latency-minus a mode the guest chooses. This page plays the fast feed automatically in program-minus whenever one is listed. Settle this in #386's spec update before #386 merges.
  • The fast PeerConnection is not watched for later failure. Consider a connection-state watch when #386 lands.

Nits

  • With feeds non-empty but no usable picture entry, a return-only slot no longer shows the "Return feed not available yet" hint. This can't happen with main's join shape.

@svensson00

Copy link
Copy Markdown

No fast feed is listed yet (#386 not deployed), so this checks the fallback only: the guest hears the return picture's audio, the program-minus/program switch changes what the guest hears, and Rejoin restores the return.

Verified on a fresh beta instance (Strom v0.8.0) on 2026-11-08. Validated by Magnus. Not yet in a release (after v0.7.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants