Skip to content

refactor(web): route device flow and marketplace template calls through contract clients - #47122

Merged
hyoban merged 2 commits into
mainfrom
fix/web-raw-fetch-to-clients
Nov 25, 2026
Merged

hyoban merged 2 commits into
mainfrom
fix/web-raw-fetch-to-clients

Conversation

@hyoban

@hyoban hyoban commented Nov 25, 2026

Copy link
Copy Markdown
Member

Summary

Moves raw fetch calls that bypassed the shared clients onto contract clients, with the same user-visible behavior.

  • Device flow, account branch (web/service/device-flow.ts): lookup, approve and deny now call the generated openapi contract (oauth.device) through an OpenAPILink on the page origin's /openapi/v1 prefix, over the shared request() layer. That layer now adds the console CSRF header and refreshes an expired console session, which the old hand-rolled calls didn't do. When the session can't be refreshed, request() already leaves /device in place, so the page still shows its own view. Calls are silent, so the raw server code is never shown in a toast. HTTP failures are translated back into DeviceFlowError with the same mapping as before: {"error": "<code>"} from the body, or the status fallback. Network failures pass through unchanged.
  • Device flow, SSO branch (approval-context, approve-external): stays on plain fetch. approve-external authenticates with the per-flow token in X-CSRF-Token. The shared layer fills that same header from the console CSRF cookie, so it would overwrite or merge the token. These routes also have no console session to refresh, and they aren't in the generated contract.
  • Marketplace template DSL (web/service/marketplace-templates.ts): adds a templateDsl route (GET /templates/{templateId}/dsl) to packages/contracts/marketplace.ts and calls it through marketplaceClient. The marketplace serves the DSL as a YAML attachment, which the OpenAPI client decodes to a File, so the result is read with .text().
  • Unit tests cover the device-flow error mapping, the CSRF headers for both branches, the no-toast behavior and the 401 path on /device.

Out of scope: the agent skill file content fetch in use-skill-detail.ts. It follows a URL the server issues (built with url_for and query arguments the server picks) and reads it as a blob. The matching console files/content contracts for agent and app routes don't declare those query parameters.

Checklist

  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I ran vp staged (frontend) to appease the lint gods

@github-actions github-actions Bot added web This relates to changes on the web. size:L This PR changes 100-499 lines, ignoring generated files. labels Nov 25, 2026
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.72%. Comparing base (691ef21) to head (b1f2799).
⚠️ Report is 10 commits behind head on main.

❌ Your project check has failed because the head coverage (88.96%) is below the adjusted base coverage (89.17%). You can increase the head coverage or adjust the Removed Code Behavior.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #47122      +/-   ##
==========================================
- Coverage   90.46%   89.72%   -0.75%     
==========================================
  Files        6570     6561       -9     
  Lines      409923   409247     -676     
  Branches    82121    81938     -183     
==========================================
- Hits       370855   367213    -3642     
- Misses      32678    35579    +2901     
- Partials     6390     6455      +65     
Flag Coverage Δ
cli 94.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Vinext bundle analysis

JS gzip: 🟠 +15.86 KiB (+0.15%) · CSS gzip: ⚪ No change

All client output Base gzip → Merge gzip Gzip change
JS 10371.10 KiB → 10386.96 KiB 🟠 +15.86 KiB (+0.15%)
CSS 346.84 KiB → 346.84 KiB ⚪ No change

Entry changes: 🟠 108 increased · 🟢 1 decreased (gzip).

Largest entry changes

Top 5 by absolute gzip delta. Static dependencies overlap; do not sum entries.

Source entry Base gzip → Merge gzip Gzip change
client-reference: app/(auth)/device/page.tsx 266.88 KiB → 282.72 KiB 🟠 +15.84 KiB (+5.94%)
client-reference: app/components/workflow-app/index.tsx 1466.51 KiB → 1466.57 KiB 🟠 +55 B (+<0.01%)
client-reference: app/components/snippets/index.tsx 1379.05 KiB → 1379.10 KiB 🟠 +51 B (+<0.01%)
client-reference: app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/pipeline/page.tsx 1404.41 KiB → 1404.46 KiB 🟠 +47 B (+<0.01%)
app/components/workflow/nodes/agent/panel.tsx 1461.14 KiB → 1461.18 KiB 🟠 +46 B (+<0.01%)
Top 20 of 109 changed entries (full paths and raw sizes)
Source entry Base gzip → Merge gzip Gzip change Raw change
client-reference: app/(auth)/device/page.tsx 266.88 KiB → 282.72 KiB 🟠 +15.84 KiB (+5.94%) 🟠 +92.58 KiB (+10.86%)
client-reference: app/components/workflow-app/index.tsx 1466.51 KiB → 1466.57 KiB 🟠 +55 B (+<0.01%) 🟠 +98 B (+<0.01%)
client-reference: app/components/snippets/index.tsx 1379.05 KiB → 1379.10 KiB 🟠 +51 B (+<0.01%) 🟠 +98 B (+<0.01%)
client-reference: app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/pipeline/page.tsx 1404.41 KiB → 1404.46 KiB 🟠 +47 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/agent/panel.tsx 1461.14 KiB → 1461.18 KiB 🟠 +46 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/human-input/panel.tsx 1379.91 KiB → 1379.96 KiB 🟠 +45 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/apps/import-from-marketplace-template-modal.tsx 214.28 KiB → 214.24 KiB 🟢 −42 B (−0.02%) 🟠 +30 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/human-input-v2/panel.tsx 1383.22 KiB → 1383.26 KiB 🟠 +42 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/template-transform/panel.tsx 1365.37 KiB → 1365.41 KiB 🟠 +42 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/if-else/panel.tsx 1369.03 KiB → 1369.07 KiB 🟠 +41 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/knowledge-retrieval-v2/panel.tsx 1406.59 KiB → 1406.63 KiB 🟠 +41 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/trigger-webhook/panel.tsx 1367.98 KiB → 1368.02 KiB 🟠 +41 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/features.tsx 1388.38 KiB → 1388.42 KiB 🟠 +40 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/header/header-in-restoring.tsx 1365.04 KiB → 1365.08 KiB 🟠 +40 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/code/panel.tsx 1366.43 KiB → 1366.46 KiB 🟠 +40 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/document-extractor/panel.tsx 1362.67 KiB → 1362.70 KiB 🟠 +40 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/llm/panel.tsx 1388.21 KiB → 1388.25 KiB 🟠 +40 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/panel/chat-record/index.tsx 1421.74 KiB → 1421.77 KiB 🟠 +40 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/knowledge-base/panel.tsx 1368.92 KiB → 1368.96 KiB 🟠 +39 B (+<0.01%) 🟠 +98 B (+<0.01%)
dynamic-entry: app/components/workflow/nodes/parameter-extractor/panel.tsx 1372.58 KiB → 1372.62 KiB 🟠 +39 B (+<0.01%) 🟠 +98 B (+<0.01%)
📦 0 package attribution changes (uncompressed modules)

Showing 0 of 0, ordered by absolute module-size delta.

Package Base Merge Δ
No package attribution changes — — —
Measurement details and build revisions

Base: 691ef2125c462b9d206cd89bc8e081c5e45fc156 · Merge: ed86a76469f6a064b08018e8ae04938d044f5565
Vinext: 1.4.5 → 1.4.5; Rolldown: 1.2.19 → 1.2.19

Raw JS change: 🟠 +92.61 KiB (+0.27%) · Raw CSS change: ⚪ No change

🟠 Increase · 🟢 Decrease · ⚪ Unchanged. Colors indicate direction, not a performance budget verdict. Percentages use the base size.

Entries follow only static edges in the official Rolldown chunk graph, deduplicating shared files. Dynamic entries are measured when loaded; they are not page first-load metrics. Entry totals overlap and must not be summed.
Package attribution sums module sizes reported by Rolldown, not compressed emitted bytes. Gzip totals are measured per emitted file. This is Vinext output, not Next.js/Turbopack output.
Report only: increases do not fail this check. Missing or incompatible analysis data does.

Download base/merge snapshots and official Rolldown analysis reports.

Comparison: event base SHA vs the tested merge commit at GITHUB_SHA (PR or merge queue).

@hyoban hyoban left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve the merge conflicts.

…clients

# Conflicts:
#	web/service/marketplace-templates.ts
@hyoban
hyoban marked this pull request as ready for review November 25, 2026 11:57
@hyoban
hyoban added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 5d9b49f Nov 25, 2026
59 of 60 checks passed
@hyoban
hyoban deleted the fix/web-raw-fetch-to-clients branch November 25, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants