Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(cli): cowork proxy fix + rich report header meta strip#402

Merged
bensonwong merged 4 commits into
mainfrom
feat/cowork-proxy-and-report-header
Apr 2, 2026
Merged

feat(cli): cowork proxy fix + rich report header meta strip#402
bensonwong merged 4 commits into
mainfrom
feat/cowork-proxy-and-report-header

Conversation

@bensonwong
Copy link
Copy Markdown
Collaborator

Summary

  • Cowork proxy fix: Replace the incorrect "built-in fetch is transparent" assumption with undici.EnvHttpProxyAgent via a new createCoworkFetch() helper. In Cowork, globalThis.fetch does NOT auto-route through HTTP_PROXY/HTTPS_PROXY; undici's EnvHttpProxyAgent + undici.fetch (the only fetch that respects dispatcher) is required. createClient is now async to accommodate the dynamic undici import.
  • Richer report header: Replace the single <p class="meta"> source label with a structured dc-meta strip showing SOURCE (clickable link if https URL), ANALYZED date (always shown), AUDIENCE (non-default only), CITATIONS count, and optional PAGES count.
  • Cowork notice banner: When IS_COWORK is true, both plainShell and reportShell render a blue info banner explaining that full page views require opening the file in a local browser.
  • Brand logo in footer: Swap the generic checkmark SVG for the DeepCitation bracket+spark logo per BRANDING.md (square caps, crispEdges, zinc-900 brackets, blue-700 spark).
  • Table style tweak: Remove header fill, add blue row hover, stronger separator lines per §6.1 Anti-Grid guidance.
  • undici externalized in tsup.config.ts — prevents bundling a Node runtime package.
  • FormData conversion (convertFormData) extracted as a shared helper used by both sendViaUndiciProxy and createCoworkFetch.

Test plan

  • bun test passes (new tests cover sourceUrl link rendering, citationCount, cowork banner presence/absence, sourceUrl fallback to label for non-https)
  • Run dc prepare <url> in a Cowork session — verify requests succeed through proxy
  • Run dc prepare <url> outside Cowork — verify normal CONNECT tunnel still used
  • Inspect generated HTML report: confirm meta strip shows SOURCE · ANALYZED · AUDIENCE · CITATIONS fields
  • Confirm SOURCE renders as <a> tag for https URLs, plain text for labels without URL
  • Confirm cowork notice banner appears when IS_COWORK=true, absent otherwise
  • Confirm undici is absent from bundled output (grep -r "undici" lib/)

bensonwong and others added 2 commits April 2, 2026 18:47
- Use undici EnvHttpProxyAgent in Cowork instead of globalThis.fetch;
  createClient is now async to await the undici import
- Add createCoworkFetch export; externalize undici in tsup config
- convertFormData helper ensures undici.fetch receives undici.FormData
- sendViaUndiciProxy falls back to EnvHttpProxyAgent if ProxyAgent fails
- Report header: SOURCE · ANALYZED · AUDIENCE · CITATIONS · PAGES meta
  strip with dc-meta BEM classes (replaces single .meta paragraph)
- Brand logo SVG in footer (square caps, crispEdges per BRANDING.md)
- Cowork notice banner in both plain and report shells
- Table anti-grid: no fill, heavier separators, blue hover row
- Link color #3B82F6 → #0284C7; bg #FDFBF7 → #F8FAFC

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…readability, tests

- Narrow sendViaUndiciProxy outer catch to import-only so real network
  errors (DNS, TLS, proxy-auth) propagate instead of silently retrying
  with globalThis.fetch
- Add console.error warning when ProxyAgent falls back to EnvHttpProxyAgent
- Add justification comment on `as unknown as BodyInit` cast in convertFormData
- Extract formatSourceUrl() helper from nested IIFE in buildMetaStrip
- Add tests: sourceUrl link rendering, https-only filter, citationCount
  in meta strip, cowork notice banner present/absent

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated (UTC)
agui-chat-deepcitation Ignored Ignored Preview Apr 2, 2026 0:26am
deepcitation-langchain-rag-chat Ignored Ignored Preview Apr 2, 2026 0:26am
mastra-rag-deepcitation Ignored Ignored Preview Apr 2, 2026 0:26am
nextjs-ai-sdk-deepcitation Ignored Ignored Preview Apr 2, 2026 0:26am

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

✅ Playwright Test Report

Status: Tests passed

📊 Download Report & Snapshots (see Artifacts section)

What's in the Visual Snapshots

The gallery includes visual snapshots for:

  • 🖥️ Desktop showcase (all variants × all states)
  • 📱 Mobile showcase (iPhone SE viewport)
  • 📟 Tablet showcase (iPad viewport)
  • 🔍 Popover states (verified, partial, not found)
  • 🔗 URL citation variants

Run ID: 23900267378

@claude
Copy link
Copy Markdown

claude Bot commented Apr 2, 2026

Code Review

Overall this is a solid PR — the proxy fix rationale is well-explained, the meta strip is clean, and the new tests are a meaningful addition. A few issues worth addressing before merge:


Bug / Correctness

http:// URLs silently rendered as links

buildMetaStrip uses /^https?:\/\//i to decide whether to render sourceUrl as a <a> tag, so plain http:// URLs are also linkified. The PR description and the JSDoc on sourceUrl both say "clickable link if https URL", and the test is named "falls back to sourceLabel when sourceUrl is not https" — but neither the test nor the description accounts for http:// being accepted.

Either the regex should be /^https:\/\//i (https-only as documented), or the docs/test names should be updated to say "http/https". The current state is a discrepancy between documentation and implementation.


Orphaned JSDoc comment

In markdownToHtml.ts, two consecutive JSDoc blocks appear before formatSourceUrl:

/**
 * Build the header meta strip: SOURCE · ANALYZED · AUDIENCE · CITATIONS · PAGES.
 * Only renders items that have data. Date always renders (defaults to today).
 */
/** Strip scheme from a URL for display: "https://example.com/doc" → "example.com/doc". */
function formatSourceUrl(url: string): string {

Only the second /** ... */ block attaches to formatSourceUrl — the first is an orphaned comment that never documents buildMetaStrip. Move the first comment directly above buildMetaStrip.


formatSourceUrl silently drops query strings and fragments

return u.hostname + (u.pathname !== "/" ? u.pathname : "");

This strips ?section=2#heading from URLs like https://example.com/doc?section=2#heading. For document URLs that use query params to identify pages/sections (e.g. Confluence, Google Docs), the rendered display text will be incomplete. If intentional for brevity, document it in a comment.


Cowork notice: inline styles vs. CSS class

plainShell renders the cowork notice with inline style="..." attributes; reportShell uses the .dc-cowork-notice CSS class. For reportShell this is fine, but plainShell will be harder to maintain if the notice styling ever needs to change. Consider adding the .dc-cowork-notice rule to BASE_CSS and using the class in both shells, or at minimum add a comment noting the intentional divergence.


sendViaUndiciProxy — silent fallback from ProxyAgent to EnvHttpProxyAgent

try {
  agent = new undici.ProxyAgent(proxyUrl);
} catch {
  console.error("Warning: ProxyAgent construction failed, falling back to EnvHttpProxyAgent.");
  agent = new undici.EnvHttpProxyAgent();
}

If ProxyAgent throws, it's most likely due to an invalid/malformed proxyUrl. Falling back to EnvHttpProxyAgent silently ignores the given proxyUrl and reads a different source (HTTP_PROXY/HTTPS_PROXY env vars). This could mask proxy misconfigurations. Consider re-throwing — or at minimum logging the actual error so users can see why the explicit URL was rejected.


Missing test coverage

The following new options have no tests:

  • pageCount in the meta strip (new field, no test)
  • reportDate option (accepted but untested)
  • When both sourceUrl (https) and sourceLabel are provided — URL should take precedence over label, but this is unverified

Nits

  • formatSourceUrl doesn't include u.port in the display string, so https://example.com:8443/doc renders as example.com/doc. Likely fine, but worth a comment.
  • Test name "falls back to sourceLabel when sourceUrl is not https" is inaccurate given that http:// is also accepted — rename to "falls back to sourceLabel when sourceUrl has an unsupported scheme".

bensonwong and others added 2 commits April 2, 2026 19:20
…work CSS class, proxy error logging, test coverage

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@bensonwong bensonwong merged commit b446509 into main Apr 2, 2026
13 checks passed
@bensonwong bensonwong deleted the feat/cowork-proxy-and-report-header branch April 2, 2026 12:29
bensonwong added a commit that referenced this pull request Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant