diff --git a/prototype/channel-browser/README.md b/prototype/channel-browser/README.md index a5f9b63b0..c12df5c18 100644 --- a/prototype/channel-browser/README.md +++ b/prototype/channel-browser/README.md @@ -38,10 +38,9 @@ node scripts/build-channel-web.mjs ``` The ignored `build/channel-web/` directory contains the HTML, styles, JavaScript -and WASM. This entry mounts the same functional page as `/__channel-preview`, -sharing its session, components, theme and language preferences. The +and WASM. The [Rust service](../channel-server/README.md#run) can serve this directory directly. -A separate web host must serve `index.html` for `/` and `/__channel-preview`, +A separate web host must serve `index.html` for `/`, route the existing `/prototype/channel` WebSocket to the domain service on the same origin, and serve WASM as `application/wasm`. Node, Vite and the WASM tools are build dependencies; the deployed App or Server diff --git a/prototype/channel-server/README.md b/prototype/channel-server/README.md index 48c57c5f2..1ebc99ce0 100644 --- a/prototype/channel-server/README.md +++ b/prototype/channel-server/README.md @@ -156,7 +156,7 @@ cargo +1.91.0 run --manifest-path prototype/channel-server/Cargo.toml -- owner-l With a packaged Server, run `./piik-server owner-link` (Windows: `.\piik-server.exe owner-link`). Open the printed link in your owner browser profile within 60 seconds. It can be used once. The browser saves the owner credential for later visits. Ordinary users open -`http://127.0.0.1:8790/__channel-preview` directly and can create their own rooms. +`http://127.0.0.1:8790/` directly and can create their own rooms. Beside a room title, copy its public-room link or, as its owner, a private-room invitation. Private-room admission is handled after joining the site. Separate browser profiles represent separate users; tabs in one profile share a saved user credential but @@ -188,7 +188,7 @@ For a standalone source deployment, build the [same frontend as static assets](../channel-browser/README.md), then set `PIIK_CHANNEL_WEB_DIR` to `build/channel-web/` and `PIIK_CHANNEL_WEB_ORIGIN` to the service's own origin. Rust serves the frontend and existing WebSocket on -that listener. `/` and `/__channel-preview` open the frontend; missing assets +that listener. `/` opens the frontend. Missing assets and unknown API paths return 404. Vite is only the development server; the deployed frontend requires no Node runtime. diff --git a/prototype/channel-server/browser-acceptance.mjs b/prototype/channel-server/browser-acceptance.mjs index 84c84d138..acb11a997 100644 --- a/prototype/channel-server/browser-acceptance.mjs +++ b/prototype/channel-server/browser-acceptance.mjs @@ -814,7 +814,7 @@ async function roomOwner(initial, serverRoom) { assert((await sample(0)).captures.some(track => track.kind === "video" && track.state === "live")); assert.equal((await view(0)).state.pairs.find(pair => pair.peerId === viewerSession).id, sharedPair); await progressing(2, serverPicture); - await browser(1, "open", `${origin}/__channel-preview`); + await browser(1, "open", `${origin}/`); await until("reopened owner restores the saved room", () => view(1), value => value.connection === "connected" && value.state.channel.rooms.some(entry => entry.id === room && entry.authorized && entry.available !== false)); await action(1, `browse(${JSON.stringify(room)})`); @@ -1208,7 +1208,7 @@ async function profileControls(roomId, messageId) { }), value => !value.sessions.some(session => session.userId === member.id && session.online) && value.profile?.name === name && value.profile.avatar === avatar && value.message.name === name && value.message.avatar === avatar); - await browser(1, "open", `${origin}/__channel-preview#room=${encodeURIComponent(roomId)}`); + await browser(1, "open", `${origin}/#room=${encodeURIComponent(roomId)}`); await reenter(); if (!await evaluate(0, "document.querySelector('#c3-people')?.checkVisibility() ?? false")) await browser(0, "click", "#c3-companion-trigger"); @@ -1452,7 +1452,7 @@ try { } await writeFile(script, probe); } - await browser(index, "open", `${origin}/__channel-preview${index === 0 ? `#owner=${encodeURIComponent(ownerKey)}` : ""}`); + await browser(index, "open", `${origin}/${index === 0 ? `#owner=${encodeURIComponent(ownerKey)}` : ""}`); } const initial = []; for (const index of active) { diff --git a/prototype/channel-server/browser-directory-acceptance.mjs b/prototype/channel-server/browser-directory-acceptance.mjs index a74de9025..905b0faa3 100644 --- a/prototype/channel-server/browser-directory-acceptance.mjs +++ b/prototype/channel-server/browser-directory-acceptance.mjs @@ -41,7 +41,7 @@ const rows = () => sample(`[...document.querySelectorAll('#c3-people .c3-user')] const more = '#c3-people button[aria-label="More people"]'; const retry = '#c3-people button[aria-label="Retry"]'; try { - await browser(0, "open", `${origin}/__channel-preview`); + await browser(0, "open", `${origin}/`); await sample("localStorage.setItem('piik:ui-lang', 'en')"); await browser(0, "reload"); await until("browser joins", () => sample(`${gate}?.snapshot().connection`), value => value === "connected"); diff --git a/prototype/channel-server/browser-native-acceptance.mjs b/prototype/channel-server/browser-native-acceptance.mjs index 3ba0d00df..fc6292e0f 100644 --- a/prototype/channel-server/browser-native-acceptance.mjs +++ b/prototype/channel-server/browser-native-acceptance.mjs @@ -32,7 +32,7 @@ export async function appRoom({ initial, serverRoom, browser, action, view, eval const assets = resolve(process.env.PIIK_CHANNEL_APP_WEB_DIR ?? "build/channel-web"); const executable = resolve(process.env.CHANNEL_APP_EXECUTABLE ?? `prototype/channel-server/target/debug/piik-channel-app${process.platform === "win32" ? ".exe" : ""}`); - const url = `${origin}/__channel-preview?piik-client-port=${port}#piik-client=1`; + const url = `${origin}/?piik-client-port=${port}#piik-client=1`; let app, otherServer, otherWeb, approvalTab, personalTab, log = ""; const sourceLayers = []; const start = () => { @@ -501,7 +501,7 @@ export async function appRoom({ initial, serverRoom, browser, action, view, eval await approve(otherOrigin); const firstDomainTab = (await browser(0, "tab")).tabs.find(tab => tab.active).targetId; await browser(0, "tab", "new", - `${otherOrigin}/__channel-preview?piik-client-port=${port}#owner=${otherOwner}&piik-client=1`); + `${otherOrigin}/?piik-client-port=${port}#owner=${otherOwner}&piik-client=1`); await until("second Site admits its own Browser user", () => view(0), value => value.connection === "connected"); await appReady(0); const otherIdentity = (await view(0)).self.id; diff --git a/prototype/channel-server/browser-public-peer.mjs b/prototype/channel-server/browser-public-peer.mjs index 57fdfeef2..f4a25d2ed 100644 --- a/prototype/channel-server/browser-public-peer.mjs +++ b/prototype/channel-server/browser-public-peer.mjs @@ -20,7 +20,7 @@ export function readContract(text) { const fragment = new URLSearchParams(url.hash.slice(1)); assert(url.protocol === "https:" && /^[a-z0-9-]+\.trycloudflare\.com$/.test(url.hostname) && !url.username && !url.password && !url.port && !url.search - && ["/", "/__channel-preview"].includes(url.pathname), "invalid_lab_origin"); + && url.pathname === "/", "invalid_lab_origin"); assert([...fragment.keys()].every(key => ["invite", "room"].includes(key)), "invalid_room_link_fields"); assert(fragment.get("room") === value.roomId, "invitation_room_mismatch"); for (const field of ["roomId", "hostSessionId", "sourceSessionId", "publicationId"]) diff --git a/prototype/channel-server/src/main.rs b/prototype/channel-server/src/main.rs index 248eb8f21..07219a23d 100644 --- a/prototype/channel-server/src/main.rs +++ b/prototype/channel-server/src/main.rs @@ -152,7 +152,7 @@ async fn main() -> anyhow::Result { )?; let operator = owner_link::Listener::bind(&directory)?; println!("Piik Server: http://{bound}"); - println!("Web interface: {origin}/__channel-preview"); + println!("Web interface: {origin}/"); release::startup_notice(); let operator_domain = state.clone(); let (stop_server, operator_stopped) = tokio::sync::oneshot::channel(); diff --git a/prototype/channel-server/src/owner_link.rs b/prototype/channel-server/src/owner_link.rs index b3fa2feef..258a2a8e4 100644 --- a/prototype/channel-server/src/owner_link.rs +++ b/prototype/channel-server/src/owner_link.rs @@ -27,7 +27,7 @@ pub async fn request(directory: &Path) -> Result { pub use transport::Listener; pub async fn serve(mut listener: Listener, domain: &Domain) -> Result<()> { - let target = url::Url::parse(domain.origin())?.join("/__channel-preview")?; + let target = url::Url::parse(domain.origin())?.join("/")?; loop { let mut stream = listener.accept().await?; let Ok(ticket) = domain.launch_ticket() else { diff --git a/prototype/channel-server/src/web.rs b/prototype/channel-server/src/web.rs index b321c06f3..e90b1dd42 100644 --- a/prototype/channel-server/src/web.rs +++ b/prototype/channel-server/src/web.rs @@ -126,7 +126,6 @@ pub fn frontend(directory: &Path) -> anyhow::Result { Ok(Router::new() .merge(bundle_routes(directory)?) .route("/", document(index.clone())) - .route("/__channel-preview", document(index.clone())) .route("/index.html", document(index.clone())) .fallback_service(static_files( ServeDir::new(directory).append_index_html_on_directories(false), @@ -520,12 +519,7 @@ mod tests { fs::remove_file(directory.join("assets/new.js")).unwrap(); fs::write(directory.join("assets/old.js"), "old").unwrap(); let mut responses = Vec::new(); - for path in [ - "/", - "/__channel-preview", - "/index.html", - "/spa/client/route", - ] { + for path in ["/", "/index.html", "/spa/client/route"] { for modified in [&cached_modified[..], "Thu, 01 Jan 2099 00:00:00 GMT"] { responses.push(request(address, path, Some(modified)).await); } diff --git a/scripts/network-lab/browser.ts b/scripts/network-lab/browser.ts index 2196f6361..d4f81e38b 100644 --- a/scripts/network-lab/browser.ts +++ b/scripts/network-lab/browser.ts @@ -81,7 +81,7 @@ export async function media(lab: MediaLab, mode: 'ordinary' | 'media' | 'recover for (const index of indices) { await writeFile(join(output, `${index}.js`), f.captureProbe(index ? 'Viewer' : 'Source')); browserOpened.add(index); - await browser(index, 'open', `${origin}/__channel-preview#invite=owned-kernel-lab-invite`); + await browser(index, 'open', `${origin}/#invite=owned-kernel-lab-invite`); cdp.set(index, (await browser(index, 'get', 'cdp-url')).cdpUrl); await f.until(`Browser${index} admitted`, () => f.view(index), (value: any) => value.connection === 'connected'); const role = index === sourceBrowser ? 'source' : index === viewerBrowser ? 'viewer' : 'relay'; diff --git a/tests/channel-session.test.ts b/tests/channel-session.test.ts index 7e7694703..0a0e9da56 100644 --- a/tests/channel-session.test.ts +++ b/tests/channel-session.test.ts @@ -102,7 +102,7 @@ async function startFixtureApp(session: ChannelSession) { } async function setup(window = 1000, read = true, hash = "room=first", readyInteractions = true, roomIds = ["first", "second"], storage: "saved" | "throws" | "ignores-write" = "saved", Session = ChannelSession) { - vi.stubGlobal("location", new URL(`https://channel.test/__channel-preview${hash ? `#${hash}` : ""}`)); + vi.stubGlobal("location", new URL(`https://channel.test/${hash ? `#${hash}` : ""}`)); const values = new Map(); vi.stubGlobal("localStorage", { getItem: (key: string) => values.get(key) ?? null, setItem: (key: string, value: string) => { if (storage === "throws") throw new Error("storage unavailable"); @@ -599,7 +599,7 @@ test.each(["new identity", "closed session retry"])("personal feedback reactivat test("a rejected initial join closes personal feedback until the session is retried", async () => { const { document, contexts } = stubFeedbackAudio(); - vi.stubGlobal("location", new URL("https://channel.test/__channel-preview")); + vi.stubGlobal("location", new URL("https://channel.test/")); vi.stubGlobal("WebSocket", ChannelSocket); const session = new ChannelSession(); try { @@ -685,7 +685,7 @@ test("restoring the viewed room does not turn its navigation state into an invit const entering = socket.sent.find(command => command.type === "enter_room")!; expect(entering).toMatchObject({ roomId: "first", inviteKey: "room-link" }); socket.receive({ type: "ack", requestId: entering.requestId }); - await vi.waitFor(() => expect(history.replaceState).toHaveBeenCalledWith({ piikChannelRoom: "second" }, "", "/__channel-preview#room=first")); + await vi.waitFor(() => expect(history.replaceState).toHaveBeenCalledWith({ piikChannelRoom: "second" }, "", "/#room=first")); expect(location.hash).toBe("#room=first"); } finally { session.close(); } }); @@ -709,8 +709,8 @@ test("a saved owner credential retires only the consumed owner URL parameter and const socket = ChannelSocket.current; await socket.onopen?.(); expect(socket.sent.find(command => command.type === "join")).toMatchObject({ ownerKey: "owner-secret" }); socket.receive({ type: "welcome", protocol: CHANNEL_PROTOCOL, credential: "personal-owner-credential", sessionId: "endpoint", state }); - expect(replaceState).toHaveBeenCalledWith(previousHistory, "", "/__channel-preview?theme=dark#room=first&invite=friend-link&other=keep"); - await vi.waitFor(() => expect(session.getSnapshot().siteURL).toBe("https://channel.test/__channel-preview")); + expect(replaceState).toHaveBeenCalledWith(previousHistory, "", "/?theme=dark#room=first&invite=friend-link&other=keep"); + await vi.waitFor(() => expect(session.getSnapshot().siteURL).toBe("https://channel.test/")); expect(values.get("piik.channel.prototype.credential")).toBe("personal-owner-credential"); vi.useFakeTimers(); socket.close(); await vi.advanceTimersByTimeAsync(1000); @@ -798,7 +798,7 @@ test("opening the site creates identity before independently applying a room inv socket.receive({ type: "ack", requestId: next.requestId }); await expect(entering).resolves.toBe("second"); expect(session.getSnapshot().connection).toBe("connected"); - expect(history.replaceState).toHaveBeenCalledWith(null, "", "/__channel-preview#room=second"); + expect(history.replaceState).toHaveBeenCalledWith(null, "", "/#room=second"); expect(location.hash).toBe("#room=second"); expect(socket.sent.filter(command => command.type === "join")).toHaveLength(1); const state = session.getSnapshot().state!; @@ -918,7 +918,7 @@ test("room admission succeeds when History rejects invitation cleanup", async () test("a browser without WebAssembly reports its capability failure before joining", async () => { vi.mocked(ChannelConversation.prototype.initialize).mockRestore(); vi.stubGlobal("WebAssembly", undefined); - vi.stubGlobal("location", new URL("https://channel.test/__channel-preview")); + vi.stubGlobal("location", new URL("https://channel.test/")); vi.stubGlobal("WebSocket", ChannelSocket); const session = new ChannelSession(); try { @@ -1436,7 +1436,7 @@ test("room invitation rotations stay pending until their own final reply and kee test("site addresses and room invitations use the current Welcome origin without local bootstrap data", async () => { const { session, peer } = await setup(); const state = session.getSnapshot().state!; - vi.stubGlobal("location", new URL("https://channel.test/__channel-preview?piik-client-port=39721#owner=local-owner&piik-client=1&piik-client-port=39721")); + vi.stubGlobal("location", new URL("https://channel.test/?piik-client-port=39721#owner=local-owner&piik-client=1&piik-client-port=39721")); try { for (const invitationOrigin of ["https://friends.example", undefined]) { session.reconnect(); @@ -1445,14 +1445,14 @@ test("site addresses and room invitations use the current Welcome origin without socket.receive({ type: "welcome", protocol: CHANNEL_PROTOCOL, credential: "credential", sessionId: "endpoint", state, ...(invitationOrigin ? { invitationOrigin } : {}) }); const origin = invitationOrigin ?? "https://channel.test"; - await vi.waitFor(() => expect(session.getSnapshot().siteURL).toBe(`${origin}/__channel-preview`)); + await vi.waitFor(() => expect(session.getSnapshot().siteURL).toBe(`${origin}/`)); const browse = socket.sent.findLast(command => command.type === "browse" && command.active)!; socket.receive({ type: "ack", requestId: browse.requestId }); peer.page(await peer.next(), [], false, null); const creating = session.createRoomInvite("first"); const request = socket.sent.findLast(command => command.type === "room_invite")!; socket.receive({ type: "room_reply", roomId: "first", requestId: request.requestId, result: { type: "invite", key: "room-invite" } }); - await expect(creating).resolves.toBe(`${origin}/__channel-preview#room=first&invite=room-invite`); + await expect(creating).resolves.toBe(`${origin}/#room=first&invite=room-invite`); } } finally { session.close(); } }); @@ -11647,7 +11647,7 @@ test.each([{ state: "missing" }, { state: "available", key: "private-room-key" } expect(request).toMatchObject({ roomId: "first" }); socket.receive({ type: "room_reply", roomId: "first", requestId: request.requestId, result: { type: "invite_state", invitation } }); await expect(reading).resolves.toEqual(invitation.state === "available" - ? { state: "available", url: "https://channel.test/__channel-preview#room=first&invite=private-room-key" } : invitation); + ? { state: "available", url: "https://channel.test/#room=first&invite=private-room-key" } : invitation); expect(socket.sent.some(command => command.type === "room_invite")).toBe(false); } finally { session.close(); } }); @@ -11662,8 +11662,8 @@ test("reopening the room invitation can read while the dismissed panel's read is for (const [index, key] of [[1, "current-key"], [0, "previous-read-key"]] as const) { socket.receive({ type: "room_reply", roomId: "first", requestId: reads[index].requestId, result: { type: "invite_state", invitation: { state: "available", key } } }); } - await expect(reopened).resolves.toEqual({ state: "available", url: "https://channel.test/__channel-preview#room=first&invite=current-key" }); - await expect(dismissed).resolves.toMatchObject({ url: "https://channel.test/__channel-preview#room=first&invite=previous-read-key" }); + await expect(reopened).resolves.toEqual({ state: "available", url: "https://channel.test/#room=first&invite=current-key" }); + await expect(dismissed).resolves.toMatchObject({ url: "https://channel.test/#room=first&invite=previous-read-key" }); expect(socket.sent.some(command => command.type === "room_invite")).toBe(false); } finally { session.close(); } });