Skip to content

Consolidate console account and Stripe route adapters - #899

Closed
Gajesh2007 wants to merge 1 commit into
masterfrom
refactor/web-operations
Closed

Gajesh2007 wants to merge 1 commit into
masterfrom
refactor/web-operations

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Twelve console route files repeated the same account and Stripe request orchestration. This change puts those two contracts in focused server adapters and leaves 15 endpoint handlers declaring their coordinator path, method, and body/query requirements. It removes 135 production lines while preserving the current browser API.

proxyAccount authenticates before resolving dynamic resource IDs or reading bodies, keeps account GETs uncached, forwards request text without JSON rewriting, and preserves upstream status/content type/response text, including once-only key secrets. proxyStripe retains cookie fallback and upstream authorization, wraps failure text with its original status, and normalizes successful JSON responses to 200 with the existing empty-response fallback. Paths remain server-defined; IDs stay encoded. Quote, public reads, model transformations, and encrypted chat streaming retain their own distinct adapters.

Three existing payout-hook tests were already failing on the base branch because they attempted withdrawals with enabled: false, before recovery status was loaded. Their setup now enables withdrawals and waits for status, so they exercise success/error/recovery instead of the guard. No payout behavior changed.

Before

flowchart TD
  Browser[Browser account or billing operation] --> Routes[15 handlers across 12 route files]
  Routes --> Account[Repeated Privy check, ID encoding, body read, fetch]
  Account --> Missing[Missing token: 401 before body or params]
  Account --> AccountUp[Coordinator keys, device approval, machine removal]
  AccountUp --> Raw[Preserve status, content type, response text and secrets]
  Routes --> Stripe[Repeated optional Privy forwarding, query or JSON, fetch]
  Stripe --> StripeUp[Coordinator billing operation]
  StripeUp --> Error[Non-2xx: original status plus wrapped error text]
  StripeUp --> Success[2xx: 200 JSON, invalid or empty JSON becomes empty object]
Loading

After

flowchart TD
  Browser[Browser account or billing operation] --> Routes[Thin endpoint handlers: path, method, body or query]
  Routes --> Account[account-proxy.ts: proxyAccount]
  Account --> Missing[Missing token: 401 before body or params]
  Account --> AccountUp[Coordinator keys, device approval, machine removal]
  AccountUp --> Raw[Existing passthrough: status, content type, text and secrets]
  Routes --> Stripe[stripe-proxy.ts: proxyStripe]
  Stripe --> StripeUp[Coordinator billing operation]
  StripeUp --> Error[Non-2xx: original status plus wrapped error text]
  StripeUp --> Success[2xx: 200 JSON, invalid or empty JSON becomes empty object]
Loading

Validation on Node 22.23.2, committed dependency lock, Next 16.2.11:

  • Full console suite: 730 tests passed across 90 files.
  • 36 additional wire-contract tests pass against both the original branch handlers and the refactored handlers, covering auth precedence/early rejection, cache policy, raw bodies, opaque IDs, secret/status/content-type forwarding, bodyless operations, Stripe JSON fallbacks and query selection.
  • Production npm run build: passed.
  • Full npm run lint: passed; existing warnings remain. Focused lint for new helpers/contracts and updated payout tests has no warnings.
  • Focused TypeScript check of all changed routes/helpers and new contract tests: passed. Repository-wide tsc --noEmit reports 13 existing errors, byte-for-byte identical before and after this refactor; the existing Next configuration skips type validation. No new type diagnostic was introduced.

This PR is based on the GPT-OSS prefix-cache branch and changes only the console. It does not require a coordinator/provider change or dependency update.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@vercel

vercel Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
d-inference Ready Ready Preview Sep 11, 2026 11:32pm UTC
d-inference-console-ui-dev Ready Ready Preview Sep 11, 2026 11:32pm UTC
d-inference-landing Ready Ready Preview Sep 11, 2026 11:32pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-11T23:34:11.526279Z 7e4d4e5 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Gajesh2007

Copy link
Copy Markdown
Member Author

Final validation for db4d0c166925aa2c877d95524aba547e6bc61c89:

Individual validation details and limitations are in each PR description, including the dedicated-M5 provider/live GPT-OSS checks and the unchanged baseline TypeScript diagnostics in #899. No merge or deployment was performed.

@Gajesh2007

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 7e4d4e5422

ℹ️ 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".

@Gajesh2007

Copy link
Copy Markdown
Member Author

Consolidated into #1095 for review and merge into master. That PR contains this branch's exact head (7e4d4e5), including its review fixes. Closing this smaller PR to collapse the stack; the branch and review history are retained. Follow #1095 for combined validation and merge status.

@Gajesh2007 Gajesh2007 closed this Sep 16, 2026

This branch had an error being deployed

1 failed and 3 active deployments
Preview – d-inference-console-ui-dev — 7e4d4e54 Deployed Sep 11, 2026 by vercel[bot]
Preview – d-inference — 7e4d4e54 Deployed Sep 11, 2026 by vercel[bot]
Preview – d-inference-landing — 7e4d4e54 Deployed Sep 11, 2026 by vercel[bot]
benchmarks — 7e4d4e54 Deployed Sep 11, 2026 by Gajesh2007 via E2E Benchmarks #966
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