Files
summercms/.planning/phases/20-demo-instance-with-every-shared-plugin/20-08-PLAN.md

40 KiB
Raw Blame History

phase, plan, type, wave, depends_on, gap_closure, review_findings, files_modified, autonomous, requirements, estimate, must_haves
phase plan type wave depends_on gap_closure review_findings files_modified autonomous requirements estimate must_haves
20-demo-instance-with-every-shared-plugin 08 execute 7
20-06
true
CR-01
WR-01
WR-04
WR-05
CR-02
../vue-chatvideo-layer/app/composables/useCall.ts
../vue-chatvideo-layer/app/lib/videoClient.ts
../vue-chatvideo-layer/app/components/Chatvideo/Call.vue
../vue-chatvideo-layer/app/components/Chatvideo/IncomingCall.vue
../vue-chatvideo-layer/app/assets/css/chatvideo-base.css
../vue-chatvideo-layer/i18n/locales/en.json
../vue-chatvideo-layer/i18n/locales/pl.json
../vue-chatvideo-layer/tests/useCall.test.ts
../vue-chatvideo-layer/tests/videoClient.test.ts
../vue-chatvideo-layer/README.md
../vue-chat-layer/app/lib/urlGuard.ts
../vue-chat-layer/app/lib/urlGuard.test.ts
../vue-chat-layer/app/lib/markdown.ts
../vue-chat-layer/app/lib/linkEmbeds.ts
../vue-chat-layer/app/lib/linkEmbeds.test.ts
../vue-chat-layer/README.md
../sm-demo-app/vue-demo-app/app/utils/communityAuth.ts
../sm-demo-app/vue-demo-app/app/utils/communityAuth.test.ts
../sm-demo-app/vue-demo-app/app/plugins/auth.ts
../sm-demo-app/vue-demo-app/app/composables/useDemoAuth.ts
true
SC-2
D-02
D-04
D-11
D-13
D-17
D-23
tokens raw_tokens tasks confidence
230000 230000 5 low
truths artifacts key_links prohibitions
CR-01, D-13: a call the user leaves, or whose page unmounts, while start or join is pending, while livekit-client loads, while LiveKit connects or between enabling the camera and the microphone never publishes media after the leave: no Room connects after it, setCameraEnabled and setMicrophoneEnabled are not called after it, a Room already created is disconnected, and once the server session exists the starter posts end and the callee posts leave. Leave works in the starting and connecting states. A second begin while one is pending creates no second Room.
WR-05: a failed LiveKit connect posts end when the session has nobody joined besides this user (GET status), and leave otherwise; when status cannot be read, the starter posts end and the callee leave.
WR-04, D-11, D-13, D-23: ChatvideoCall starts media on mount only when an in-memory handoff younger than a minute shows the user just clicked: the DM call button's start answer (start) or the incoming prompt's Accept (join). A direct load or a chat link to /call/{id}, with or without ?start=1, shows a confirmation with a Start call or Join call button and calls neither video/start nor video/join and opens no LiveKit connection until it is clicked.
CR-02 (client side), D-02, D-17: the chat renders as text, with no link and no link card, any http(s) URL whose host as written is not the host the browser opens: a percent-escape, userinfo or a backslash in the authority, ideographic, fullwidth or halfwidth dots, fullwidth letters, a trailing dot, or a scheme not followed by exactly two slashes. Honest URLs, IDN hosts written in Unicode, ports, queries and fragments still link and embed. bm's copied chat tests pass unchanged.
WR-01, D-04: logging out (header or login page) and the chat's unauthorized() reset the chat store, close the shared realtime socket and dismiss a ringing call prompt in the same tab; one failing part does not stop the others; the next login starts from empty chat state with a fresh connection token.
Every fix has vitest regression tests in the repository that owns it; vue-demo-app builds and passes its tests on its current layer pins (v0.1.0 already exports useChat().reset, the realtime disconnect and useIncomingCalls().dismiss); nothing is pushed or tagged here.
path provides contains
../vue-chatvideo-layer/app/composables/useCall.ts per-attempt token, stale checks after every await, leave from the pre-room states, failed-connect end rule attempt
path provides contains
../vue-chatvideo-layer/app/lib/videoClient.ts hasStart, rememberAccept, takeAccept and callAutostart (the click handoffs) callAutostart
path provides contains
../vue-chatvideo-layer/app/components/Chatvideo/Call.vue the join confirmation chatvideo-confirm
path provides contains
../vue-chat-layer/app/lib/urlGuard.ts honestHttpUrl honestHttpUrl
path provides contains
../sm-demo-app/vue-demo-app/app/utils/communityAuth.ts createCommunitySignOut and endSession createCommunitySignOut
from to via pattern
../vue-chatvideo-layer/app/components/Chatvideo/IncomingCall.vue ../vue-chatvideo-layer/app/lib/videoClient.ts Accept leaves the join handoff before it navigates rememberAccept
from to via pattern
../vue-chatvideo-layer/app/components/Chatvideo/Call.vue ../vue-chatvideo-layer/app/lib/videoClient.ts mount begins only when callAutostart answers true callAutostart
from to via pattern
../vue-chat-layer/app/lib/markdown.ts ../vue-chat-layer/app/lib/urlGuard.ts safeUrl allows an http(s) target only through honestHttpUrl honestHttpUrl
from to via pattern
../vue-chat-layer/app/lib/linkEmbeds.ts ../vue-chat-layer/app/lib/urlGuard.ts linkify and messageUrls parse through honestHttpUrl honestHttpUrl
from to via pattern
../sm-demo-app/vue-demo-app/app/plugins/auth.ts ../sm-demo-app/vue-demo-app/app/utils/communityAuth.ts the plugin builds the sign-out and hands it to createChatAuth and to logout createCommunitySignOut
statement status verification
No push, tag or pin change in this plan; vue-demo-app keeps its v0.1.0 layer pins and the sm-demo-app gitlink is not bumped (20-09). unresolved judgment
statement status verification
No new package in any package.json or lockfile; tests use vitest, vi.mock and pure helpers (no @vue/test-utils, which no lockfile has). unresolved automated
statement status verification
Neither layer names a consuming application or a host path. unresolved automated

Phase Goal

ROADMAP Goal (not in user-story format; no story is invented here): sm-demo-app runs every shared plugin and its public site shows them working, video calls included.

This plan's slice (gap round after the code review, plan 8 of 9, wave 7, parallel with 20-07: no shared file): the call and session fixes from 20-REVIEW.md in the repositories that own the code.

  • CR-01: leaving or unmounting during start or join still connected and published the camera and microphone.
  • WR-05: a failed connect posted leave and left an empty ringing session.
  • WR-04: a link opened a call and turned media on with no confirmation.
  • WR-01: logout left the previous user's chat store, realtime socket and call prompt running.
  • The client half of CR-02: the chat's link-embed rendering gets the guard the brief asked for; the server half is 20-07.

Unit tests rule for this gap round: the project rule "unit tests are the last plan of every phase" is met because every fix here ships with vitest regression tests in the repository that owns it, and 20-09 runs every touched repository's full suite before anything is tagged.

Decisions taken in this plan (Claude's discretion, recorded)

  • One attempt token (the review's fix shape). begin increments an attempt counter and dispatches start before its first await, for the callee too, so the state leaves idle at once and Leave and unmount always see a live attempt. After every await (the start or join answer, the livekit-client import, connect, each media toggle) it bails out when the attempt is stale. leave() invalidates the attempt. The call machine already moves starting → connecting on joined, so it needs no change.
  • Who posts what after a stale answer. When the start or join answer arrives after a leave, the server session exists only from that moment, so begin's stale branch posts end (starter) or leave (callee) itself. leave() posts only when an answer has already arrived for the attempt. This avoids the 404 that the current code's premature end produced.
  • "Alone" after a failed connect (WR-05). The review's formula (start || remoteParticipants.size === 0) would end the call for a waiting caller whenever a callee's connect fails, because a room that never connected has no remote participants. The plan uses the server's view instead: GET status, alone when at most one participant has status joined (chatvideo marks the starter joined at start and the callee at join). Fallback on a status error: the starter ends, the callee leaves.
  • Confirmation (WR-04). The autostart decision is a pure helper, callAutostart(conversationId, start), over in-memory handoffs that a link cannot create: the call button's start answer (existing rememberStart, now readable with hasStart without taking it) and a new Accept marker (rememberAccept, takeAccept), each valid for a minute. ?start=1 stays in the demo's call path but only chooses Start over Join on the confirmation. The rule is tested as a helper because @vue/test-utils is in no lockfile (20-06 deviation 1). The demo's call page needs no code change. Its doc comment is updated together with the pin bump in 20-09, so it never describes behaviour that the pinned layer lacks.
  • Link guard (CR-02 client side). It lives in a new app/lib/urlGuard.ts with honestHttpUrl(raw), used by safeUrl (markdown.ts) and by parseHttp (linkEmbeds.ts). A deceptive URL stays text: no anchor and no card. The server now refuses banned ones (20-07). The client guard covers any host, so a card never shows a different host than the text. bm's copied tests (chatText.test.ts and the other four) stay byte-identical, so the new cases go into urlGuard.test.ts and linkEmbeds.test.ts.
  • Sign-out (WR-01). The review's explicit-call option, not a watch(loggedIn): the token store is document.cookie, which a useCookie watcher would not see when unauthorized() clears it. createCommunitySignOut and endSession are Nuxt-free factories in app/utils/communityAuth.ts, tested with vitest. The plugin builds the sign-out with nuxtApp.runWithContext and hands it to createChatAuth (unauthorized) and, through $communitySignOut, to useDemoAuth().logout(). SiteHeader.vue and login.vue already go through logout() and need no change. Clearing chatvideo:incoming uses useIncomingCalls().dismiss(), which also stops the ring timer and closes the session handle. The handle leak between two pending subscribes is IN-07 and stays deferred.
  • spec-less probe fallback skipped: phase has no requirement IDs to probe (visible skip).
Make leaving a call final at any moment, end empty sessions after a failed connect, ask before a call page starts the camera and microphone, keep deceptive link hosts out of chat links and cards, and reset the previous user's chat, socket and call prompt on logout.

Purpose: D-13 (the minimal call page) and D-11/D-23 (DM calls from the call button) behave as the user expects. D-02 and D-17 hold in the chat renderer. D-04 holds after logout (no chat for a signed-out visitor). Output: commits in ../vue-chatvideo-layer, ../vue-chat-layer and ../sm-demo-app/vue-demo-app (not pushed, not tagged, pins unchanged), each with vitest regression tests.

<execution_context> @/.claude/msd-core/workflows/execute-plan.md @/.claude/msd-core/templates/summary.md </execution_context>

@.planning/phases/20-demo-instance-with-every-shared-plugin/20-REVIEW.md @.planning/phases/20-demo-instance-with-every-shared-plugin/20-CONTEXT.md @.planning/phases/20-demo-instance-with-every-shared-plugin/20-06-SUMMARY.md

Repos: ../vue-chatvideo-layer (main at 8222255, tag v0.1.0), ../vue-chat-layer (main at b6d3389, tag v0.1.0; 764cb42 and b6d3389 are already on main after the tag), ../sm-demo-app/vue-demo-app (the submodule, master at deb809f; pins vue-chat-layer and vue-chatvideo-layer v0.1.0 by git+https tag). Test runners: pnpm --dir <repo> test (vitest 3.2.7); the layers' SFCs compile with pnpm --dir <layer> run build:playground; vue-demo-app builds with pnpm --dir ../sm-demo-app/vue-demo-app run build.

Rules: no co-author tags; stage files by explicit path; no push, tag or pin change (20-09); a layer's README changes in the same commit as its API; the layers name no application; check git status in each repo before editing and leave edits that are not this plan's alone (vue-demo-app often has a stale nuxt dev from 2026-10-22 running, pids 212159 and 212194, leave it alone). Do not edit sm-demo-app itself; its browser checks for these fixes are written in 20-09 Task 1, where they run against the unreleased layers.

vue-chatvideo-layer today: - app/composables/useCall.ts: `useCall(conversationId)` returns {state, tiles, declined, audioBlocked, reconnecting, mediaError, begin(start), leave(), toggleMute(), toggleCamera(), startAudio()}; module-level `room`, `lk`, `channel`, `leaving`; begin: guard on `status !== 'idle' && isLive`, `dispatch start` only for the starter, `await client.start/join` (or takeStart), `joined`, pagehide listener, `openChannel(session_id)`, `await import('livekit-client')`, `room = new Room(...)`, `await r.connect`, a check that room is still r, `connected`, `await setCameraEnabled(true)`, `await setMicrophoneEnabled(true)`; on connect failure it posts leave. `leave()` returns early on idle; it posts end when alone (no room or no remote participants) else leave, then disconnects. onBeforeUnmount calls leave. - app/lib/callMachine.ts: states idle, starting, connecting, connected, ended, failed; `joined` accepted from idle or starting; `isLive`; unchanged by this plan. - app/lib/videoClient.ts: `createVideoClient` {start, join, leave, end, status → VideoStatus {session_id, conversation_id, status, started_by, participants [{user_id, status}]} or null}; `rememberStart`/`takeStart` (in-memory, a minute, taken once); `videoSessionChannel`; `parseIncomingCall`. - Call.vue: props conversationId, start, backPath; `onMounted(() => call.begin(props.start))`; Leave enabled while starting, connecting or connected; retry calls begin. IncomingCall.vue: `accept()` takes the pending call and navigates to callPath; decline posts leave. Locale keys chatvideo.state.*, chatvideo.action.*, chatvideo.reason.*. - tests/useCall.test.ts: vi.mock of livekit-client (fake Room with connect, disconnect, localParticipant setters as vi.fn, `Room.instances`, `failConnect`, `onCreate`), vi.mock of vue-chat-layer realtime (`realtime.subs`), unmount hooks captured, a stub client (start, join, leave, end, status as vi.fn), `connected(start)` helper. The test "a failed LiveKit connect fails the call and leaves the session" expects leave; WR-05 changes it. - chatvideo server facts: Start creates the session with the starter's participant row `joined` and the others `invited`; Join marks the actor `joined`; Leave marks `left`. vue-chat-layer today: app/lib/markdown.ts `safeUrl(raw)` (http(s) with `//` and a non-slash, mailto, site paths, anchors), `escapeHtml`, `formatSpans`; app/lib/chatText.ts `renderChatText` (LINK_RE, URL_RE through safeUrl); app/lib/linkEmbeds.ts `parseHttp(raw)` (new URL, http(s) only), `linkify`, `messageUrls`, `registerEmbedRenderer`, `embedRendererFor`; Chat/LinkEmbed.vue shows url.host and links url.href; useChat `reset()` (exported in v0.1.0); app/lib/realtime.ts `disconnect()` (exported in v0.1.0). vue-demo-app today: app/utils/communityAuth.ts {CommunityTokens, CommunityFetch, tokenGetter, createChatAuth(store, fetchJson) → {token, refresh, unauthorized}, friendsDirectory}; app/plugins/auth.ts provides paymentGatewayAuth, chatAuth, forumAuth, userfriendsAuth, userfriendsDirectory and calls setRealtimeAuth; app/composables/useDemoAuth.ts `logout()` posts /_user/api/v1/logout with the token, then `token.value = null`; app/lib/realtime.ts re-exports vue-chat-layer's realtime (disconnect included); app/layouts/default.vue renders ChatFloatingPanel and ChatvideoIncomingCall for members. Task 1: Tracer: the caller clicks Leave while the call is still starting, and nothing connects or turns on afterwards, under test `git -C ../vue-chatvideo-layer status --porcelain` prints nothing; `pnpm --dir ../vue-chatvideo-layer test` passes before the change. ../vue-chatvideo-layer/app/composables/useCall.ts, ../vue-chatvideo-layer/tests/useCall.test.ts ../vue-chatvideo-layer/app/composables/useCall.ts (whole file), app/lib/callMachine.ts, tests/useCall.test.ts (whole file: the fakes, beforeEach, the connected helper, every existing test), 20-REVIEW.md CR-01 Per D-13, closing the caller path of CR-01 end to end. 1. Red first: in tests/useCall.test.ts add a small deferred-promise helper and the test "leave while start is pending: no room, no media, end once the session exists". `client.start` answers a deferred promise; call `begin(true)` without awaiting it, `await leave()`, then resolve the start answer and await the begin promise. Expect: no fake Room was connected (`Room.instances` empty, or none of them had connect called), setCameraEnabled and setMicrophoneEnabled never called, `client.end` called once with the conversation id after the answer arrived, the state ended with reason left, no open session channel, no pagehide listener. Run it and see it fail. 2. useCall.ts: add the per-attempt counter. begin increments it and keeps its own number, resets `leaving`, dispatches `start` before the first await (for both roles), and after the start or join answer checks whether the attempt is stale (another attempt started or leave ran); if so it posts `end` for a start or `leave` for a join (errors swallowed) and returns before subscribing, adding the pagehide listener or loading livekit-client. leave() no longer returns early while an attempt is in flight in the starting state: it marks leaving, invalidates the attempt, dispatches leave, posts end or leave only when this attempt already has its answer, and disconnects. 3. Keep every existing test green; update the module header comment (begin, leave and unmount semantics). 4. Commit in vue-chatvideo-layer: `fix: leaving while a call starts never connects it`. pnpm --dir ../vue-chatvideo-layer test Non-zero exit: the new test fails (a Room connects, a media setter runs, end is posted before or never, the state is not ended) or an existing useCall, callMachine or videoClient test breaks. - `grep -c 'leave while start is pending' ../vue-chatvideo-layer/tests/useCall.test.ts` prints 1. - `git -C ../vue-chatvideo-layer diff --stat 8222255 -- package.json pnpm-lock.yaml` prints nothing. A caller who hangs up during "Connecting…" is out of the call for good: the late start answer ends the session and no camera or microphone turns on. Task 2: Every other moment of leaving is final too (callee join, unmount, livekit-client load, connect, between camera and microphone, a second begin), and a failed connect ends an empty session ../vue-chatvideo-layer/app/composables/useCall.ts, ../vue-chatvideo-layer/tests/useCall.test.ts, ../vue-chatvideo-layer/README.md The Task 1 code and test, tests/useCall.test.ts (the fake Room's connect and setters, failConnect, onCreate, the unmount hooks), app/lib/videoClient.ts (status, VideoStatus), README.md (Usage, "The call flow", API reference, Testing) - "unmount while join is pending": begin(false) with a deferred join, run the captured unmount hook, resolve the join; no Room connects, no media setter runs, client.leave is posted once after the answer, state ended. - "leave while connect is pending": connect answers a deferred promise; leave; resolve connect; setCameraEnabled and setMicrophoneEnabled never called, the Room disconnected, end posted once (alone). - "leave between camera and microphone": setCameraEnabled answers a deferred promise; leave; resolve it; setMicrophoneEnabled never called, the Room disconnected. - "leave while livekit-client loads": the import is awaited after the answer; stall it with a hoisted deferred gate in the mocked module if vitest allows it reliably, otherwise call leave in the same tick the answer resolves (the stale check right after the answer) and say which in the SUMMARY; no Room created after the leave, end posted once. - "a second begin while the first join is pending": two begin(false) calls before the answer; join called once, at most one Room ever created and connected. - WR-05 "a failed connect ends a session nobody else joined": failConnect set, client.status answers participants [{user_id: 7, status: 'joined'}, {user_id: 9, status: 'invited'}]; client.end posted, client.leave not. "a failed connect leaves when the other side joined": status answers two joined participants; client.leave posted, client.end not. "status unreadable": status rejects; the starter posts end, the callee posts leave. - The existing test "a failed LiveKit connect fails the call and leaves the session" is renamed and changed to the WR-05 rule: the stub's status answers undefined, which counts as unreadable (as do null and a rejection), so the starter ends; every other existing expectation stays. Per D-13 and D-12 (the reconcile job and ringing behave as designed), closing the rest of CR-01 and WR-05. - useCall.ts: after the livekit-client import, return when stale (no Room is created); after `connect` resolves, when stale disconnect that Room (disconnect(true), errors swallowed) and return; check staleness before each of setCameraEnabled and setMicrophoneEnabled, and after the camera, so a leave between them disconnects and skips the microphone; the Disconnected handler and finish() keep working for the current attempt only. On a connect failure: dispatch error, disconnect, then ask `client.status(conversationId)`; post end when at most one participant has status joined, else leave; on a status error post end for a start and leave for a join. Remove nothing else (tiles, declined, audio, reconnecting stay as they are). - tests/useCall.test.ts: the behavior block's tests; keep the fakes, extend them only where a deferred is needed. - README.md: "The call flow" says Leave works at any moment and what is posted when, the WR-05 rule, and Testing lists the new tests. - Commit in vue-chatvideo-layer: `fix: a call left at any moment stays left, and a failed connect ends an empty session`. pnpm --dir ../vue-chatvideo-layer test Non-zero exit: any behavior-block test fails (media published after a leave, a second Room, a stale branch posting the wrong call, WR-05 posting leave for an empty session) or an existing test breaks. - `grep -cE "test\('(unmount while join is pending|leave while connect is pending|leave between camera and microphone|a second begin while the first join is pending)" ../vue-chatvideo-layer/tests/useCall.test.ts` prints 4. - `grep -c 'a failed connect ends a session nobody else joined' ../vue-chatvideo-layer/tests/useCall.test.ts` prints 1. Whatever the moment a user leaves or navigates away, the camera and microphone stay off and the session is closed the right way, and a call that could not connect does not keep ringing. Task 3: The call page asks before it starts media, unless the user just clicked the call button or Accept ../vue-chatvideo-layer/app/lib/videoClient.ts, ../vue-chatvideo-layer/app/components/Chatvideo/Call.vue, ../vue-chatvideo-layer/app/components/Chatvideo/IncomingCall.vue, ../vue-chatvideo-layer/app/assets/css/chatvideo-base.css, ../vue-chatvideo-layer/i18n/locales/en.json, ../vue-chatvideo-layer/i18n/locales/pl.json, ../vue-chatvideo-layer/tests/videoClient.test.ts, ../vue-chatvideo-layer/README.md app/lib/videoClient.ts (the handoff block: HANDOFF_MS, rememberStart, takeStart), app/components/Chatvideo/Call.vue, CallButton.vue, IncomingCall.vue, app/assets/css/chatvideo-base.css (button and note styles), i18n/locales/en.json and pl.json, tests/videoClient.test.ts (the handoff tests), README.md (Usage, Components, "The call flow"), ../sm-demo-app/vue-demo-app/app/pages/call/[conversation].vue and app/pages/chat.vue (how the demo passes start and callPath; read only), 20-REVIEW.md WR-04 - callAutostart(id, true) is false on a direct load; true right after rememberStart(id, …) within a minute, and begin's takeStart still receives that answer (hasStart does not take it); false after a minute; false for another conversation. - callAutostart(id, false) is false on a direct load; true once right after rememberAccept(id) within a minute, then false (taken); false after a minute; false for another conversation; a start handoff does not make a join autostart. - takeStart behaves as before (the existing handoff tests stay). Per D-11, D-13 and D-23, closing WR-04. - app/lib/videoClient.ts: add `hasStart(conversationId, now?)` (a start answer younger than HANDOFF_MS is waiting; not taken), `rememberAccept(conversationId, now?)` and `takeAccept(conversationId, now?)` (an Accept marker, a minute, taken once; in memory, never in a URL or storage), and `callAutostart(conversationId, start, now?)` (start: hasStart; join: takeAccept). Doc comments say why: a link can open the call route but cannot create a handoff. - IncomingCall.vue: accept() calls rememberAccept for the conversation before it navigates. - Call.vue: on mount, begin only when callAutostart answers true; otherwise the idle state renders a confirmation block (class `chatvideo-confirm`) with the text chatvideo.confirm.start or chatvideo.confirm.join and one button (classes `chatvideo-button chatvideo-confirm__go`, label chatvideo.action.startCall or chatvideo.action.joinCall) that calls begin(start), plus the back link when backPath is set. Live, ended and failed states render as today; Retry stays an explicit click. Update the component's header comment (media starts only after a click on this page, the call button or Accept). - Locales en and pl: confirm.start, confirm.join (each says the camera and microphone turn on after the click), action.startCall, action.joinCall. chatvideo-base.css: the confirm block in the existing card and button style. - tests/videoClient.test.ts: the behavior block. - README.md: Components (ChatvideoCall's confirmation; `start` picks Start or Join), "The call flow" (autostart only after the call button or Accept; a direct load or a link asks), API reference (hasStart, rememberAccept, takeAccept, callAutostart), Usage (the ?start=1 example now only selects Start), Testing. - Commit in vue-chatvideo-layer: `feat: the call page asks before it starts the camera and microphone`. pnpm --dir ../vue-chatvideo-layer test && pnpm --dir ../vue-chatvideo-layer run build:playground Non-zero exit: a handoff test fails (a direct load autostarts, Accept does not, hasStart takes the answer, a marker outlives a minute or crosses conversations), an earlier test breaks, or the playground build fails to compile Call.vue or IncomingCall.vue. - `grep -c 'callAutostart' ../vue-chatvideo-layer/app/components/Chatvideo/Call.vue` prints at least 1 and `grep -c 'rememberAccept' ../vue-chatvideo-layer/app/components/Chatvideo/IncomingCall.vue` prints at least 1. - `node -e "for (const l of ['en','pl']) { const c = require('../vue-chatvideo-layer/i18n/locales/' + l + '.json').chatvideo; if (!c.confirm?.start || !c.confirm?.join || !c.action?.startCall || !c.action?.joinCall) process.exit(1) }"` exits 0. - `grep -rniE 'golem15\.demo|sm-demo|demo\.summercms' ../vue-chatvideo-layer/app ../vue-chatvideo-layer/README.md | wc -l` prints 0. Opening a call link shows a clear Start call or Join call button and nothing turns on until it is clicked, while the call button and Accept still go straight into the call. Task 4: The chat renders deceptive link hosts as text, never as a link or a link card ../vue-chat-layer/app/lib/urlGuard.ts, ../vue-chat-layer/app/lib/urlGuard.test.ts, ../vue-chat-layer/app/lib/markdown.ts, ../vue-chat-layer/app/lib/linkEmbeds.ts, ../vue-chat-layer/app/lib/linkEmbeds.test.ts, ../vue-chat-layer/README.md ../vue-chat-layer/app/lib/markdown.ts, app/lib/chatText.ts (LINK_RE, URL_RE, how safeUrl is used), app/lib/linkEmbeds.ts, app/lib/linkEmbeds.test.ts, app/components/Chat/LinkEmbed.vue, README.md (link embeds section, Testing), 20-REVIEW.md CR-02 (the table and the rendering paragraph) - honestHttpUrl refuses (returns null): https://bit%2Ely/x, https://bit.l%79/x, https://bit.ly/x, https://bit。ly/x, https://bit.ly/x, https://bit。ly/x, https://user@bit.ly/x, https://example.com@bit.ly/, https:/\bit.ly/x, https://\bit.ly/x, https://bit.ly./x, javascript: and data: URLs, and anything new URL cannot parse. - honestHttpUrl accepts: https://bit.ly/x, http://example.com:8080/a?b=c#d, https://żółw.example/ (an IDN written in Unicode), https://xn--w-uga1v8h.example/, https://sub.example.org/path. - renderChatText of each refused URL, bare and as [label](url), contains no anchor (the text shows as written, escaped); messageUrls of a text holding them returns none; linkify leaves them as text. The accepted URLs still render as links and still yield cards. - bm's copied tests (chatEvents, chatFormat, chatText, chatUnread, realtime) pass byte-identical. Per D-02 (generic link embeds) and D-17, the client half of CR-02. - app/lib/urlGuard.ts (new): `honestHttpUrl(raw: string): URL | null`. The URL must parse with new URL as http or https, and the scheme must be followed by exactly two slashes. The authority as written, up to the first slash, question mark or hash, must hold no percent sign, no at sign and no backslash. The host as written must hold none of U+3002, U+FF0E and U+FF61, must be unchanged by NFKC (no fullwidth or compatibility characters), and must not end with a dot. Its lower-cased form must equal url.hostname, or, for a host with non-ASCII letters, it must be in NFC with only U+002E as the separator. Doc comment: the chat links and embeds only URLs whose written host is the host the browser opens, so a card never shows a host the text does not. - markdown.ts: safeUrl allows an http(s) target only when honestHttpUrl accepts it (mailto, site paths and anchors unchanged). linkEmbeds.ts: parseHttp delegates to honestHttpUrl, so linkify and messageUrls skip deceptive URLs. - app/lib/urlGuard.test.ts (new): the behavior block, including renderChatText cases (import it from ./chatText). linkEmbeds.test.ts: messageUrls and linkify cases for two refused and two accepted URLs. - README.md: the link embeds section describes the guard; Testing lists urlGuard.test.ts. - Commit in vue-chat-layer: `fix: deceptive link hosts render as text, not links or cards`. pnpm --dir ../vue-chat-layer test && git -C ../vue-chat-layer diff --quiet b6d3389 -- app/lib/chatEvents.test.ts app/lib/chatFormat.test.ts app/lib/chatText.test.ts app/lib/chatUnread.test.ts app/lib/realtime.test.ts Non-zero exit: a guard test fails (a deceptive URL becomes an anchor or a card, an honest or IDN URL stops linking), a store, client or embed test breaks, or one of bm's copied test files was edited. - `grep -c 'honestHttpUrl' ../vue-chat-layer/app/lib/markdown.ts` and `grep -c 'honestHttpUrl' ../vue-chat-layer/app/lib/linkEmbeds.ts` each print at least 1. - `grep -rniE 'golem15\.demo|sm-demo|demo\.summercms' ../vue-chat-layer/app ../vue-chat-layer/README.md | wc -l` prints 0. A message can no longer show a working link or a link card to a host it hides behind escapes, dots or userinfo; honest links work as before. Task 5: Logging out resets the chat, closes the realtime socket and clears a ringing call in the same tab ../sm-demo-app/vue-demo-app/app/utils/communityAuth.ts, ../sm-demo-app/vue-demo-app/app/utils/communityAuth.test.ts, ../sm-demo-app/vue-demo-app/app/plugins/auth.ts, ../sm-demo-app/vue-demo-app/app/composables/useDemoAuth.ts ../sm-demo-app/vue-demo-app/app/utils/communityAuth.ts and communityAuth.test.ts (whole files), app/plugins/auth.ts, app/composables/useDemoAuth.ts (whole file), app/components/SiteHeader.vue and app/pages/login.vue (their logout calls), app/lib/realtime.ts (the re-export), app/layouts/default.vue, vitest.config.ts, ../vue-chat-layer/app/composables/useChat.ts (reset, lines around 1514) and app/lib/realtime.ts (disconnect), ../vue-chatvideo-layer/app/composables/useIncomingCalls.ts (dismiss), 20-REVIEW.md WR-01 - createCommunitySignOut({resetChat, disconnectRealtime, dismissCall}) runs the three in that order; a part that throws does not stop the next ones; calling it twice is safe. - createChatAuth(store, fetch, onSignedOut): unauthorized() clears the token, then calls onSignedOut once; without onSignedOut it behaves as before (the existing tests pass unchanged). - endSession(token, postLogout, clearToken, signOut): with a token it posts logout with that token, clears the token even when the post rejects, then signs out once; without a token it posts nothing and still clears and signs out. Per D-04 (no chat for a signed-out visitor), closing WR-01. - app/utils/communityAuth.ts: add `createCommunitySignOut(parts)` and `endSession(token, postLogout, clearToken, signOut)` (Nuxt-free, doc comments), and an optional third parameter `onSignedOut` on `createChatAuth`, called by unauthorized() after the token is cleared. Update the file header. - app/plugins/auth.ts: take the nuxtApp argument; build the sign-out with createCommunitySignOut whose parts run only in the browser: resetChat runs useChat().reset() inside nuxtApp.runWithContext, disconnectRealtime calls disconnect from ~/lib/realtime, dismissCall runs useIncomingCalls().dismiss() inside nuxtApp.runWithContext. Pass it to createChatAuth and provide it as `communitySignOut`. Update the header comment. - app/composables/useDemoAuth.ts: read `$communitySignOut` from useNuxtApp() when the composable is created (before any await, so the Nuxt context is still there), and make logout() delegate to endSession with the current token, the existing logout POST, a clear that sets the token to null, and that sign-out. SiteHeader.vue and login.vue keep calling logout() unchanged. - app/utils/communityAuth.test.ts: the behavior block, next to the existing tests. - Commit in vue-demo-app only (not pushed; the sm-demo-app gitlink is bumped in 20-09): `fix: logging out resets the chat, closes the realtime socket and clears a ringing call`. pnpm --dir ../sm-demo-app/vue-demo-app test && pnpm --dir ../sm-demo-app/vue-demo-app run build Non-zero exit: a sign-out or endSession test fails, an existing auth hook test breaks, or the site build fails (a missing auto-import or a layer API that v0.1.0 does not export). - `grep -c 'createCommunitySignOut' ../sm-demo-app/vue-demo-app/app/plugins/auth.ts` prints at least 1 and `grep -c 'endSession' ../sm-demo-app/vue-demo-app/app/composables/useDemoAuth.ts` prints at least 1. - `git -C ../sm-demo-app/vue-demo-app diff --stat deb809f -- package.json pnpm-lock.yaml app/components/SiteHeader.vue` prints nothing. - `git -C ../sm-demo-app status --porcelain -- vue-demo-app` prints ` M vue-demo-app` (the gitlink moved, not staged; 20-09 commits the bump). After logout nothing of the previous member stays in the tab: no chat state, no open socket, no ringing prompt, and the next member starts clean.

<threat_model>

Trust Boundaries

Boundary Description
browser camera and microphone to LiveKit media leaves the device once a Room is connected and tracks are published
chat links to the call route any member can post a same-site link to /call/{id}
chat text to rendered links and cards member-written URLs become anchors and cards
one browser tab, two accounts the previous member's state must not reach the next one

STRIDE Threat Register

Threat ID Category Component Severity Disposition Mitigation Plan
T-20-42 Information disclosure useCall (camera and microphone after leave) critical mitigate per-attempt token checked after every await; leave invalidates it; a stale branch disconnects any Room and never calls the media setters; useCall tests pin each moment (start, join, import, connect, between camera and microphone, unmount, second begin)
T-20-43 Elevation of privilege /call/{id} opened from a link high mitigate media starts on mount only with an in-memory handoff a link cannot create (call button start answer, Accept marker, a minute, taken once); otherwise the confirmation waits for a click; callAutostart tests
T-20-44 Information disclosure chat store, realtime socket and call prompt after logout high mitigate logout and unauthorized run the community sign-out (reset, disconnect, dismiss), each part isolated; communityAuth tests; 20-09 adds a browser check that the socket closes
T-20-45 Denial of service empty ringing session after a failed connect medium mitigate the failed-connect branch ends the session when GET status shows nobody else joined; tests for both outcomes and for an unreadable status
T-20-46 Spoofing deceptive hosts in chat anchors and link cards high mitigate honestHttpUrl refuses escapes, userinfo, backslashes, compatibility dots and letters, trailing dots and malformed scheme separators before safeUrl, linkify or messageUrls produce a link or card; urlGuard tests
T-20-SC Tampering npm installs high mitigate no package or lockfile change in this plan; acceptance checks the layer manifests are untouched
</threat_model>
- Task 1: vue-chatvideo-layer tests with the caller leave-during-start test. - Task 2: the remaining CR-01 moments and WR-05 under test. - Task 3: handoff tests and the playground build compiling the changed components. - Task 4: vue-chat-layer tests with the guard, bm's copied tests untouched. - Task 5: vue-demo-app tests and build on the v0.1.0 pins.

<success_criteria> CR-01, WR-01, WR-04, WR-05 and the client half of CR-02 are fixed in the repositories that own the code, each with regression tests; nothing is pushed, tagged or re-pinned, so 20-09 can run the full suites, integrate the unreleased layers locally and release them. </success_criteria>

Create `.planning/phases/20-demo-instance-with-every-shared-plugin/20-08-SUMMARY.md` when done: the commits per repo, the new tests per finding, the changed expectation of the failed-connect test, the new layer exports (hasStart, rememberAccept, takeAccept, callAutostart, honestHttpUrl) and class names (chatvideo-confirm, chatvideo-confirm__go) that 20-09's browser checks use.