Skip to content

refactor(web): replace promise chains and IIFEs with named functions - #172

Merged
TheGreatAxios merged 7 commits into
cl-12110-remove-swallowed-errors-unchecked-casts-and-iifes-from-thefrom
cl-12110-replace-promise-chains-and-iifes-in-the-interface
Nov 4, 2026
Merged

TheGreatAxios merged 7 commits into
cl-12110-remove-swallowed-errors-unchecked-casts-and-iifes-from-thefrom
cl-12110-replace-promise-chains-and-iifes-in-the-interface

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Last of the CL-12110 pull requests: the remaining .catch() calls, promise chains, the IIFE and the hand-rolled login poll.

Changes

  • The four copies of the refusal-body read (human-fault.ts, api/artifacts.ts, api/projects.ts, workspace/index.tsx) share refusalBody in api/transport.ts. A body that is not JSON or cannot be read counts as "no body", so each caller shows its own wording; a read failure is logged, and anything else is rethrown.
  • The query cache restore is a named async function. The cache is optional, so a failed restore is logged and the page paints with an empty cache instead of hanging on it.
  • The promise chains in App.tsx, approaches-comparison.tsx, deliverable-block.tsx, pane-file.tsx, transcript.tsx, profiles.tsx, project-menu.tsx, settings.tsx, api/credentials.ts, single-flight.ts and load-room.ts are named async functions or try/finally blocks. The IIFE in loadProjectRoom is a named function.
  • The session read in App.tsx catches only ApiFailure. The clipboard copy in transcript.tsx catches only DOMException. A failed approach choice now shows the hub's readable message when there is one.
  • A subscription login is polled by a react-query QueryObserver with refetchInterval instead of a for loop with setTimeout. It is not tied to a component, so leaving the screen mid-sign-in still finishes the login, as before. The five-minute deadline stays, polling continues while the browser reports offline, a cancelled poll aborts its request, and a query marked meta: { persist: false } (the login poll) is kept out of the saved cache.

App.tsx's responseCode().then refusal chain is left to #171, which turns it into a named function.

Verification

  • New tests: a refusal whose body cannot be read still gets the caller's own wording, and a non-JSON body gives no code; a login poll finishes on completion, rejects with the hub's message on failure, and rejects at its deadline.
  • deliverable-block.tsx's version view and compare share one read.
  • bun run lint, format:check, typecheck, test, pins:verify and vendor:verify pass.

@linear-code

linear-code Bot commented Nov 4, 2026

Copy link
Copy Markdown

CL-12110

@TheGreatAxios
TheGreatAxios marked this pull request as ready for review November 4, 2026 22:14
@corbits-triage

corbits-triage Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

Stacked on #167: only this pull request's own changes were checked.

@corbits-triage corbits-triage Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No defects reported.

@TheGreatAxios
TheGreatAxios merged commit 5e34551 into cl-12110-remove-swallowed-errors-unchecked-casts-and-iifes-from-the Nov 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant