BetaLenzon is in beta — the Free tier is 100% free while we're in beta (bring your own Anthropic key, public repos).See plans →
Lenzon

horizontwo/Lenzon-Platform PR #13 — Provenance rail — PR #13

horizontwo/Lenzon-Platform · pull request #13 ·

Loading…

Transcript

PlainEnglish

We're looking at pull request thirteen from the Lenzon Platform repository. This PR adds a provenance rail to the viewer, showing visitors what was scanned, who made it, token cost, and runtime information.

PlainEnglish

This PR has one primary goal: adding a provenance rail to the viewer that shows endpoint, cost, and runtime context. We're also extracting some logic into testable functions and building a responsive grid layout. And importantly, we're not changing the existing share-token auth or exposing sensitive cost data.

PlainEnglish

The viewer page is often a user's first contact with Lenzon. Before this PR, visitors arriving from a shared link had no idea what produced the presentation, what it cost, or how long it would take. This PR fixes that by adding a side rail with essential context, all while respecting the existing access controls.

Architecture

Let's look at where the changes live. We've got a new API route under provenance that serves the data, a new ProvenanceRail component that fetches and renders it, updates to ViewerShell for grid integration, and a new lib file with pure functions plus comprehensive unit tests.

Architecture

Here's the new API endpoint. It's gated by canReadScript, which is the same auth check the replay endpoint uses, so we're not introducing any new security surface. The endpoint looks up the most recent PR explainer run for the script, computes runtime from the presentation data, extracts token totals, and returns everything as JSON. Notice it deliberately excludes USD cost—that stays on the existing cost endpoint.

Architecture

The client component fetches the provenance data on mount. It's best-effort—if the fetch fails, we just show the attribution block and omit the rest. The component uses a cancelled flag to prevent state updates after unmount, and it conditionally renders each section based on whether we got data back. Notice the fetch path includes the share token if one was provided, so the auth flows through correctly.

Architecture

We've extracted two pure functions for testability. computeRuntimeSec sums the measured narration durations from each scene, and falls back to the script's estimated duration if those aren't available. extractTokens reads from either the current cost rollup shape or the legacy producer snapshot, and returns null if the totals are zero. Both functions are fully null-safe and covered by unit tests.

Architecture

The layout is responsive. Below a thousand pixels, the rail stacks underneath the player in a single column. Above that breakpoint, we switch to a two-column grid—player on the left, three-hundred-pixel rail on the right. The player track uses minmax zero one-fr so the grid can shrink the player below its intrinsic width without overflowing. This keeps the sixteen-by-nine aspect ratio intact.

CodeQuality

One thing to keep an eye on: in the fetch chain, non-ok responses get mapped to null rather than rejected. That means failed API calls—four-hundreds, five-hundreds—silently degrade to no data instead of propagating an error. This is intentional per the comment, it's best-effort, but it also means the component can't distinguish between fetch failed and fetch succeeded but returned null. If you need error recovery or telemetry later, this pattern will need a revision.

PlainEnglish

After this PR, the viewer page displays a fixed-width side rail on desktop or a footer section on mobile, showing what was scanned, Lenzon attribution, token cost breakdown, and timing information. The rail is share-token-gated, just like the player itself, so it adds no new auth surface. First-time visitors now have instant context about the presentation before watching.

PlainEnglish

That's pull request thirteen. A focused UX improvement that adds essential provenance context to the viewer without changing auth boundaries or exposing sensitive cost data. The new endpoint is share-token-gated, the rail component fetches best-effort with no error handling, and the runtime and token logic is fully covered by unit tests.

How this was made

Lenzon read horizontwo/Lenzon-Platform at pull request #13 and generated this walkthrough automatically. The narration above is the transcript of what it says.

Explain a pull request from your own repo

Point Lenzon at a repo or a pull request and get a narrated walkthrough like this one.

Try it