FE-1222: Classify Petrinaut optimization transport errors in the UI#9063
Draft
kube wants to merge 3 commits into
Draft
FE-1222: Classify Petrinaut optimization transport errors in the UI#9063kube wants to merge 3 commits into
kube wants to merge 3 commits into
Conversation
Replace the raw `network error` the host forwarded from a caught
fetch/reader exception with a classified, actionable error, and thread the
NodeAPI correlation ids to the UI so a failed run is traceable to the
NodeAPI and optimizer logs.
- messages: optimizationResponseStart carries the x-hash-request-id /
X-Optimization-Run-ID response headers; optimizationError gains a
category (network/http/protocol/aborted) plus optional correlation ids,
http status, and error name.
- host (process-editor): captures the correlation headers, forwards them,
and classifies its own transport failures as `network` with a safe
message.
- bridge: a PetrinautOptimizationTransportError carries the structured
fields; HTTP (non-ok) failures are classified `http` with status +
correlation ids, protocol violations `protocol`, and the response-start
timeout `network`; correlation ids captured at response-start backfill a
later stream error.
- provider: builds a safe, progress-aware message ("...interrupted after N
of M trials. Retry the optimization. (diagnostic id: ...)"), keeps the
received trials, stores the category/diagnostics on the record, and adds
retryOptimization to start a fresh run from the failed one's input.
- view drawer: a Retry action on a failed run.
Tests cover network/http/protocol classification, correlation-id
threading through the bridge, the composed message + preserved trials, and
retry.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
Semgrep found 1
No validation of origin is done by the addEventListener API. It may be possible to exploit this flaw to perform Cross Origin attacks such as Cross-Site Scripting(XSS). |
This was referenced Jul 19, 2026
kube
force-pushed
the
codex/petrinaut-optimization-frontend
branch
from
July 19, 2026 23:29
c06e8ce to
291428c
Compare
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.
🌟 What is the purpose of this PR?
When a long optimization stream is reset mid-run, the UI shows the raw
network error— the caughtfetch/reader.read()exception message forwarded verbatim. This replaces it with a classified, actionable error and threads NodeAPI's correlation ids to the UI, so a failed run is traceable to the NodeAPI and optimizer logs and the user gets a clear next step. Already-received trials are preserved and a Retry action is offered.🔗 Related links
🚫 Blocked by
codex/petrinaut-optimization-frontend(FE-1162: Add Petrinaut optimization UI #9051)X-Optimization-Run-IDresponse header NodeAPI sets in FE-1221: Add structured correlated logging across the Petrinaut optimization pipeline #9059 for the run-id diagnostic (degrades gracefully to null if absent)🔍 What does this change?
messages.ts:optimizationResponseStartcarries thex-hash-request-id/X-Optimization-Run-IDresponse headers;optimizationErrorgains acategory(network/http/protocol/aborted) plus optional correlation ids,httpStatus, anderrorName.process-editor.tsx): captures the correlation headers, forwards them on response-start, and classifies its own transport failures asnetworkwith a safe message (no raw exception text).create-bridge-petrinaut-optimization.ts): a newPetrinautOptimizationTransportErrorcarries the structured fields; non-ok responses are classifiedhttp(with status + correlation ids), protocol violationsprotocol, and the response-start timeoutnetwork; correlation ids captured at response-start backfill a later stream error.provider.tsx): builds a safe, progress-aware message ("Connection to the optimization service was interrupted after N of M trials. Retry the optimization. (diagnostic id: …)"), keeps the received trials, storeserrorCategory/errorDiagnosticson the record, and addsretryOptimizationto start a fresh run from the failed one's input. The error type crosses the app→lib boundary, so it is duck-typed rather than matched withinstanceof.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
🛡 What tests cover this?
create-bridge-petrinaut-optimization.test.ts: protocol classification (no-terminal, data-after-terminal) and the HTTP path carrying status + correlation ids.create-bridge-petrinaut-optimization.browser.test.ts: a mid-stream host error is reclassified and backfilled with the response-start correlation ids.provider.test.tsx: a classified transport failure yields the composed message + preserved trials +errorCategory/errorDiagnostics;retryOptimizationstarts a fresh run from the original input.messages.test.ts,create-optimization-drawer.test.tsx: kept green with the extended message and context shapes.All four suites pass (
@hashintel/petrinautreact + UI optimization tests;@apps/hash-frontendbridge + messages tests).❓ How to test this?
🤖 Generated with Claude Code