From cbc3df1c4292a0aca3bb168aaea1f93c8aae4828 Mon Sep 17 00:00:00 2001 From: Shrinish Vhanbatte Date: Wed, 3 Jun 2026 16:40:54 +0530 Subject: [PATCH] fix: forward cookies on local-discovery path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit processSnapshot.ts has two parallel functions producing processedSnapshot payloads. prepareSnapshot (used for remote discovery) includes the cookies field; processSnapshot (the default export, used for local discovery — the most common path) silently drops it. Symptom for customers whose snapshot URL is auth-walled (e.g. Veeva Vault): the CLI's discovery Playwright navigates to the snapshot URL unauthenticated, fails to fetch resources behind the customer's session (page images, CDN-hosted CSS/JS), and dotui receives a payload with no styling/scripts/images cached. The rendered screenshot ends up blank or unstyled. Reproduction with two captured Vault DOMs (same customer, similar test): Old (had cookies): 'cookies' field present, 384 chars 11 makepageimage PNGs cached → page rendered correctly New (cookies dropped on local discovery): 'cookies' field absent 0 makepageimage PNGs cached → page renders blank in dotui Fix: the default-export processSnapshot's return now mirrors prepareSnapshot's — emits `cookies: Buffer.from(snapshot.dom.cookies ?? '').toString('base64')` alongside the existing payload fields. This is the third instance of the dual-function divergence in this file; worth a refactor to share the payload-construction code, but out of scope for a one-line correctness fix. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/lib/processSnapshot.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/processSnapshot.ts b/src/lib/processSnapshot.ts index b1839f3..e1b885a 100644 --- a/src/lib/processSnapshot.ts +++ b/src/lib/processSnapshot.ts @@ -1107,7 +1107,8 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context): url: snapshot.url, dom: Buffer.from(snapshot.dom.html).toString('base64'), resources: cache, - options: processedOptions + options: processedOptions, + cookies: Buffer.from(snapshot.dom.cookies ?? '').toString('base64'), }, warnings: [...optionWarnings, ...snapshot.dom.warnings], discoveryErrors: discoveryErrors