Repository navigation
relay: allow blank gateway token + polished WebLLM worker page - #332
Merged
Merged
Conversation
Two unrelated fixes a user surfaced together. 1. pasclaw relay --gateway-token is no longer required. The gateway accepts unauth'd traffic when Cfg.Gateway.Token is empty (the historical pre-PR-#246 shape), but the worker refused to start without a token, turning a valid pairing into a CLI rejection. Dropped the existence check; the four header / query-param emission sites (PostResponse, Indy SSE GET, NetHTTP SSE GET, and the browser snippet) now skip Authorization entirely when Ctx.Token = ''. Smoke-tested against a gateway with no token configured -- worker registers and the status endpoint reports it. 2. Browser/WebLLM snippet replaced with a polished standalone HTML page styled to match the PasClaw webui. - Dark navy gradient + cyan accents (same CSS variables the panel uses: --bg/--bg2/--fg/--cyan/--mut/--line). - JetBrains Mono font, glow effects on focused inputs, pill-shaped buttons with the same primary/secondary states as the webui's nav. - Curated model dropdown grouped by VRAM footprint (Tiny <1B / Small 2-3B / Medium 7-8B) covering Llama 3.1/3.2, Qwen 2.5, Phi 3.5, Gemma 2, DeepSeek R1 Distill, Hermes 3 -- 11 entries pulled from MLC's prebuilt config.ts. First option is a disabled placeholder so the user is forced to pick before Connect lights up. Hermes 3 entry called out as tool-call friendly; DeepSeek R1 entry called out as reasoning. - Connect / Disconnect lifecycle: clicking Connect downloads + warms the WebLLM engine with a live progress bar (driven by initProgressCallback), then opens the SSE poll. Each dispatched job logs an entry with timestamp + status colour (ok/warn/err) and bumps a "N served" counter. Disconnect closes the EventSource and re-enables Connect. - Token blank-friendly: only adds Authorization header / ?token= query param when the token field is non-empty, matching the CLI fix above. Worker id pre-filled with a random tab-XXXXXXXX value so the operator can paste-and-go without a name clash. - Standalone: one <html>, ESM import for web-llm via esm.run, no toolchain. Save as relay.html, open in any browser, click Connect. Closing the tab disconnects. Same TDZ trap as before -- the RELAY_WEBLLM_MODELS const was declared inside the render path but referenced by a function the /#relay deep-link boot path invokes before the const initializer runs. Moved it up to the relay-tab state block above the boot block (where relayTimer / RELAY_TOKEN_PLACEHOLDER live for the same reason). webui.res regenerated. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
2 of 3 tasks
khongten001
pushed a commit
to khongten001/PasClaw
that referenced
this pull request
Jul 13, 2026
User feedback on the standalone-HTML snippet from PR FMXExpress#332: "the html relay code should just be built into that relay tab? but I don't think it should import any remote stuff [...] unless the user clicks the button to start the webllm. like maybe they never use the relay setup at all, wouldn't want to load any third party stuff they never use." Both legit. Reworked the Relay tab: - New "In-browser worker" section directly inside the tab body, between the config grid and the snippet list. Has the same model picker + Worker id input + Connect / Disconnect buttons + live progress bar + status dot + scrolling colour-coded log the standalone page had, styled with the same CSS variables the rest of the relay tab uses so it visually fits in. - WebLLM is loaded via `await import("https://esm.run/@mlc-ai/web-llm")` inside the Connect button's click handler. The static `import { CreateMLCEngine } from ...` at module top is gone -- a user who never opens the Relay tab, or opens it but doesn't click Connect, pays zero third-party bandwidth. Browsers cache the module after the first fetch so subsequent Connects are instant. - Disconnect drops the engine reference (browser GCs the WASM) and closes the EventSource; model weights stay in IndexedDB so the next Connect skips the download. - beforeunload closes the EventSource so the gateway sweeps the worker from /v1/relay/status promptly rather than waiting for the keepalive timeout. - Standalone-HTML snippet ("Browser worker (WebLLM, ESM)") removed from the code-block snippet list -- the in-tab worker covers the same use case and the rendered HTML for the page was ~11KB of dead weight on every webui load. The remaining snippets (CLI flags, env vars, Python, cog-relay) are still useful: those run on different host platforms. - buildBrowserSnippet() helper deleted (~250 LOC). - Outer "Connect a worker" heading renamed to "Connect a worker from another host" to differentiate from the new in-tab option. jsdom smoke verified all of: - in-browser worker UI present - no eager static `import { CreateMLCEngine } from esm.run` anywhere - dynamic `await import(esm.run)` is present (gated behind click) - tab renders with zero runtime errors - model dropdown populated (11 curated entries + placeholder) - Connect enabled / Disconnect disabled at start - code-block snippet count down from 5 to 4 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two unrelated fixes a user surfaced together.
Fix 1 —
pasclaw relay --gateway-tokenno longer requiredThe gateway accepts unauth'd traffic when
Cfg.Gateway.Tokenis empty (the historical pre-PR-#246 shape), but the worker refused to start without a token — turning a valid pairing into a CLI rejection. Dropped the existence check; the four header / query-param emission sites (PostResponse, Indy SSE GET, NetHTTP SSE GET, browser snippet) now skipAuthorizationentirely whenCtx.Token = ''.Smoke-tested: gateway with no token configured +
pasclaw relay --gateway-url http://127.0.0.1:18900(no--gateway-token) → worker registers and/v1/relay/statusreports it.Fix 2 — Browser snippet replaced with a polished standalone HTML page
Styled to match the PasClaw webui — same
--bg/--bg2/--fg/--cyan/--mut/--lineCSS variables, JetBrains Mono font, glow on focus, pill buttons.initProgressCallback), then open SSE. Each job logs with timestamp + colour (ok/warn/err) and bumps a "N served" counter.?token=query param when the token field is non-empty (matches Fix 1).<html>, ESM import via esm.run, no toolchain. Save asrelay.html, open in any browser, click Connect.Same TDZ pattern as before —
RELAY_WEBLLM_MODELSmoved above the boot block alongside the other relay-tab state.Test plan
make allclean.pasclaw relay --gateway-url ... --worker-id notoken-test(no token flag) — worker registers,connected_workers: 1.<!DOCTYPE html>, contains all 11 model ids +CreateMLCEngine+EventSource+Disconnect+if (tok)conditional.🤖 Generated with Claude Code
https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code