feat(harness): add local preview capability preflight #5254
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5254"
general
weight: 0.35
liugddx
Summary
Showing a page locally depends on independent things that each fail differently: the client may have no GUI surface at all, the embedded browser refuses
file://by policy, and the conversation's own view may not be the one on screen. Attempting the preview and reading the first error conflates them.A refused loopback connection is the worst case. "Nothing listening yet", "server still starting", and "separate network namespace" are indistinguishable at the socket — yet the refusal reads like proof of the last one, which is exactly the inference the session recorded in #5213 made.
preview_preflightanswers each capability with verified, unsupported, or unknown, and names the observation behind it:| Capability | What is observed | Can be |
| --- | --- | --- |
|
gui_surface| whether a Desktop browser view host is registered | verified / unsupported / unknown ||
url_schemes| what the real address policy (parseNavigable) accepts —file://is rejected | unsupported (settled) ||
browser_view| whether this conversation's view accepts an observe action now | verified / unknown, or unsupported only when there is no host ||
loopback_endpoint|HEAD /against a caller-named loopback origin, only if one is passed | verified / unknown — never unsupported |unsupportedis reserved for settled boundaries statable without probing; everything else isunknownand says outright what it does not prove. A connection outcome therefore never becomesunsupported.No result claims a page is ready. An answer from the origin — a 404 included — proves a listener, not that the page exists or loads.
surface(can this client display a page at all) andendpoint(does something listen at the named origin, ornot_checked) are reported separately, and page load remains #5235's question. When the caller does not already have both verified, the report namesArtifactPreviewand defers to that tool's own description for what its URL guarantees.The probe sends
HEAD /to the origin, never the caller's path, so a capability check cannot trip a dev-server route with side effects. It settles on the first of a response, an upgrade, an error, the caller's abort, or an absolute deadline — the deadline lives in the promise, not on the socket, because a101 Switching Protocolsmakes Node close the request without emittingresponseorerror. Only127.0.0.1and[::1]are accepted: this is deliberately stricter thanisLoopbackHost, becauselocalhostcan resolve to either family and a refusal would not say which address was tried.Where it is published
Inside
desktop_artifact_preview, besideArtifactPreview. Not the Browser offer: every Browser tool is admitted against an Origin read from the view's current URL, so a capability check there would need a page already loaded and would fail with the veryBrowser admission requires an HTTP originerror it exists to explain. And sharing an offer withArtifactPreviewmeans the route it hands off to is always granted with it. The offer's tool set is assembled only inbuildArtifactPreviewOfferTools, and a test pins both tools there and checks that the handoff names only a tool the same offer grants.Relationship to the managed preview endpoint (#5238 / #5316)
ManagedArtifactPreview.prepareHEAD-checks the route it just created, which is real reachability evidence for that endpoint. It needs an existing HTML Artifact, reports failure by throwing rather than classifying, and says nothing about a GUI surface, the view's visible-lease state, URL-scheme policy, or a caller-supplied endpoint. It also succeeds in a runtime with no GUI at all — the preflight is what distinguishes that case before anything is attempted.Scope
Preflight only. Staging-root filesystem visibility was dropped in review: HTML Open never touches that directory, so it measured a non-preview path. Page load is #5235. This does not weaken the
file://policy.Fixes #5234.
Verification
GETinstead ofHEAD /(1), "nothing answered" wording (2), noupgradearm (1), no abort listener (1).HEAD /is the only request sent even when a path is passed; a 101 answers well inside the deadline; cancellation settles against a silent server; the deadline fires with an injected 120 ms limit; anhttps://origin against a plain listener exercises the TLS branch and reports "no usable HTTP response"; a refused port returns a value, not a throw. Removing the preflight from the offer builder turns the offer test red.biome lint,check:asf-headers,check:locale-hygienepass.tsc -p tsconfig.main.jsonreports no errors in the changed files.test:dist. My checkout cannot build@maka/ui(upstream addedvirtuain #5366 after my last install), which leaves 65tscerrors in unrelated files — the same 65 with this change stashed. CI installs clean.AI use
Select exactly one:
Tool(s) and scope: Claude Opus 5 / 5.5 via Claude Code — drafted the implementation, tests and this description under my direction, reproduced the reviewed
101 Switching Protocolsdefect before fixing it, and ran the ablations above. I reviewed every change and the verification output. Every commit carries aGenerated-bytrailer.Checklist
Does this PR entail a change in behavior?
🤖 Generated with Claude Code