docs: add MercNET literature lookup workflow - #556
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 314339dd37
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| meta = js(f""" | ||
| fetch({file_url!r}).then(async r => {{ | ||
| if (!r.ok) throw new Error(`HTTP ${{r.status}}`); | ||
| const blob = await r.blob(); |
There was a problem hiding this comment.
Start the PDF download before awaiting its full body
When a manual takes more than five seconds to transfer, this js() call waits for r.blob() before clicking the anchor, while src/browser_harness/helpers.py::_send gives the IPC socket a five-second read timeout and js() awaits returned promises. The caller therefore raises a timeout instead of printing meta or continuing with verification; the browser-side promise may still finish later, making the result additionally ambiguous. Trigger the same-origin download without awaiting the entire PDF in Runtime.evaluate, then poll the destination for completion.
Useful? React with 👍 / 👎.
| cdp( | ||
| "Browser.setDownloadBehavior", | ||
| behavior="allow", | ||
| downloadPath=output_dir, | ||
| eventsEnabled=True, | ||
| ) |
There was a problem hiding this comment.
Restore the browser's download behavior after completion
Because this workflow attaches to the user's long-lived browser and omits a browserContextId, Browser.setDownloadBehavior changes the default browser context and remains set to allow with this custom directory after the script ends. Subsequent downloads initiated by the user can therefore be silently redirected away from their normal Downloads folder. Reset the behavior to default in a finally block after the download completes, as the harness's video-download path does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
2 issues found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="agent-workspace/domain-skills/mercnet/literature.md">
<violation number="1" location="agent-workspace/domain-skills/mercnet/literature.md:107">
P2: `Browser.setDownloadBehavior` is invoked without a `browserContextId`, so it modifies the default browser context. Because this workflow attaches to the user's existing authenticated browser, the `allow` + custom `downloadPath` setting persists after the script finishes. Subsequent user-initiated downloads could be silently redirected away from their normal Downloads folder. Reset the behavior to `default` in a `finally` block after the download completes (or after verifying the file landed).</violation>
<violation number="2" location="agent-workspace/domain-skills/mercnet/literature.md:117">
P2: This documented workflow awaits `r.blob()` inside the `js()` call, which means the entire PDF must download before the promise resolves. If the underlying browser harness enforces a short read timeout on its IPC socket (e.g., 5 seconds), large service manuals will trigger a timeout exception before the blob completes—leaving the download in an ambiguous state. Consider triggering the same-origin download without awaiting the full response body in `Runtime.evaluate`, then polling the output directory for file completion separately.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| file_url = "/mnetdata/" + result["docWorldviewFile"] | ||
| file_name = result["docPartNbr"] + ".pdf" | ||
|
|
||
| cdp( |
There was a problem hiding this comment.
P2: Browser.setDownloadBehavior is invoked without a browserContextId, so it modifies the default browser context. Because this workflow attaches to the user's existing authenticated browser, the allow + custom downloadPath setting persists after the script finishes. Subsequent user-initiated downloads could be silently redirected away from their normal Downloads folder. Reset the behavior to default in a finally block after the download completes (or after verifying the file landed).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent-workspace/domain-skills/mercnet/literature.md, line 107:
<comment>`Browser.setDownloadBehavior` is invoked without a `browserContextId`, so it modifies the default browser context. Because this workflow attaches to the user's existing authenticated browser, the `allow` + custom `downloadPath` setting persists after the script finishes. Subsequent user-initiated downloads could be silently redirected away from their normal Downloads folder. Reset the behavior to `default` in a `finally` block after the download completes (or after verifying the file landed).</comment>
<file context>
@@ -0,0 +1,139 @@
+file_url = "/mnetdata/" + result["docWorldviewFile"]
+file_name = result["docPartNbr"] + ".pdf"
+
+cdp(
+ "Browser.setDownloadBehavior",
+ behavior="allow",
</file context>
| meta = js(f""" | ||
| fetch({file_url!r}).then(async r => {{ | ||
| if (!r.ok) throw new Error(`HTTP ${{r.status}}`); | ||
| const blob = await r.blob(); |
There was a problem hiding this comment.
P2: This documented workflow awaits r.blob() inside the js() call, which means the entire PDF must download before the promise resolves. If the underlying browser harness enforces a short read timeout on its IPC socket (e.g., 5 seconds), large service manuals will trigger a timeout exception before the blob completes—leaving the download in an ambiguous state. Consider triggering the same-origin download without awaiting the full response body in Runtime.evaluate, then polling the output directory for file completion separately.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent-workspace/domain-skills/mercnet/literature.md, line 117:
<comment>This documented workflow awaits `r.blob()` inside the `js()` call, which means the entire PDF must download before the promise resolves. If the underlying browser harness enforces a short read timeout on its IPC socket (e.g., 5 seconds), large service manuals will trigger a timeout exception before the blob completes—leaving the download in an ambiguous state. Consider triggering the same-origin download without awaiting the full response body in `Runtime.evaluate`, then polling the output directory for file completion separately.</comment>
<file context>
@@ -0,0 +1,139 @@
+meta = js(f"""
+fetch({file_url!r}).then(async r => {{
+ if (!r.ok) throw new Error(`HTTP ${{r.status}}`);
+ const blob = await r.blob();
+ const a = document.createElement("a");
+ a.href = URL.createObjectURL(blob);
</file context>
Summary
Validation
git diff --cached --checkSummary by cubic
Add a guide for the authenticated MercNET literature lookup workflow. It documents stable search selectors, read-only JSON endpoints (document/serial/model), how to find current manuals when a number is missing, and safe internal PDF download with title-page validation and compliance safeguards.
Written for commit 314339d. Summary will update on new commits.