http://127.0.0.1:4318/ (the HTTP port, also with TLS): a read-only web viewer for a first look and for demos. It is not a dashboard product: no saved views, no edits. --no-ui turns it off. The screens are those of the Paper file “Magpie” (trace list and trace detail, light and dark).
- Traces: the count of the search and of the time range, a live switch (it checks for new traces every 5 s), the search box, the chips (time range: any time, 15 minutes to 30 days, or from … to;
+ Filter: model, kind, service, environment, user, session, trace name, tag, trace id, failed only), the summary strip (failed traces, typical time, the slow 1 in 20, tokens, cost, and the bars of traces per time bucket with their failed part, all fromPOST /v1/traces/stats), and the table: newest first, 50 at a time with “Load 50 more”, each trace with its start, its name, the first line of its input or output with the first match marked yellow, its models, tokens, cost and duration (the bar is full at the slow 1 in 20). Next to the count in the box: the time from the request to the answer, measured in the browser (it includes the network). While a new search runs, the rows and numbers of the previous one stay dimmed under “Searching…”, and not under the new words./puts the cursor in the box. - The search box:
refund policy(every word, in one span),"refund policy"(a phrase),refu*(a prefix),*fund*(a piece of a word, asLIKE '%fund%'),model:gpt-4o(also kind, service, env, user, session, name, tag, trace; a value with spaces in quotes),is:error;ANDis allowed and skipped. Which traces match is the engine’s answer; the yellow marks are placed by the browser in the text it shows. - A trace: its name and id, start, duration, spans, failed spans, tokens, cost, first token, user and session, the scores of the trace; the span tree with a bar per span on the trace’s time axis (first 2,000 spans; a button loads more; arrow keys move the selection), the hits of the search per span; and the selected span: model, duration, tokens, cost, “Copy JSON”, “Open in new tab”, and the tabs Messages (the input as messages by role, the answer, the error), Raw (the span as JSON), Attributes (every field, every attribute), Events and Scores when it has them. The box “Find in this span” marks every hit and goes to the next and the previous (Enter, Shift+Enter). A text of more than 1,400 characters is folded (“Show all N words”).
- Sessions: newest first, by user and time; a session shows its totals, scores and traces.
- The store (top right): traces, spans and bytes on disk, from
GET /v1/storage, every 15 s. - Light or dark by the setting of the system, or by the switch in the top bar (kept in this browser).
/v1/traces/find, /v1/traces/stats, /v1/aggregate for the models, /v1/search for the spans that match in a trace, /v1/traces/:id/spans, /v1/traces/:id/spans/:spanId, /v1/traces/:id/scores, /v1/sessions/find, /v1/sessions/:id, /v1/sessions/:id/scores, /v1/storage). It never writes. The model column costs one sum of a trace’s spans per row (/v1/aggregate with the trace id); the hits of the tree read the spans that match, at most 30.
How it is made: a React app in web/viewer/ (React 19.3, TypeScript 7.0, Vite 8.4, Tailwind CSS 4.3, Motion 14.14, TanStack Router and Query; the OFL fonts Inter, Inter Tight and JetBrains Mono, their licenses at /ui/OFL-*.txt). The build is committed in crates/server/viewer/ and put into the binary by build.rs: building the server needs no Node. pnpm --dir web/viewer build makes it again, with the stamp that cargo test -p magpie-server checks.
Security
- Every value from the API goes into the page as text (React text nodes), and not as HTML. A span whose input is
<script>alert(1)</script>shows those characters. Checked byweb/viewer/src/test/hostile.test.tsx(the whole app against an API whose every value is HTML or script),web/viewer/src/security.test.ts(no HTML sink, noeval, no other origin, no route that writes, in the sources) ande2e/viewer.mjs(Chromium against a real server). - Every answer of the viewer comes with
Content-Security-Policy: default-src 'self'; object-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; require-trusted-types-for 'script'; trusted-types 'none'(no inline script, no eval, nothing from another origin, not in a frame, and no string can reach an HTML sink of the DOM),X-Content-Type-Options: nosniff,X-Frame-Options: DENYandReferrer-Policy: no-referrer: the files, a405for another method on their paths, and the404of a path that no route has (with the viewer on, that is the server’s404for every unknown path; it has no body). The pages are in the hash of the URL (/#/trace/<id>), so the server serves only/and/ui/*. - Files under
/ui/a/have the hash of their content in their name:Cache-Control: public, max-age=31536000, immutable. The page and the other files:no-cache, so a new binary serves its new page at once. - Text files (page, scripts, style, icon, font licenses) are sent as Brotli or gzip when the request’s
Accept-Encodingtakes it (D-ui-8; the copies are made by the build and are in the binary), withVary: Accept-Encoding; else as they are. A first visit of the trace list fetches about 269 KB with Brotli (docs/FINDINGS.mdF85). The trace and session pages load their own script when first opened. - The files are public, as
/healthzis: they hold no data. Every/v1route keeps its rules (section API keys). With--auth keysthe page asks for a key with thereadright when the API answers401, keeps it insessionStorageof the tab (gone when the tab closes; not in a URL, and not in a cookie) and sends it asAuthorization: Bearer. “Forget key” (and a new key) stops every request and drops every answer of the old key from the page before it asks again. A key in a tab can be read by a script that runs in that page: the CSP and the text-only rule are what stop such a script. - With
--auth trusted-header, the proxy in front setsx-magpie-tenant, as for any other client. - A page of another site cannot make the browser send a write to the server: see Query API (
CROSS_SITE, D260). The viewer is on the same origin, so its requests pass.
Limits
One span page of the tree is 2,000 spans; a session page draws its first 500 traces; the summary strip reads the newest 100,000 matching traces (it says so when there are more). A client that takes neither Brotli nor gzip gets the 463 KB script as it is. Tested in Chromium, Firefox and WebKit (Playwright 1.65, headless, on macOS;e2e/viewer.mjs). On macOS, Playwright’s WebKit build delivers mouse clicks at wrong coordinates on any page, so there the test clicks with DOM events: the pointer hit-testing of WebKit is checked only where CI runs it (Linux). Not tested in Safari itself or on a phone.