Skip to content

refactor: share HTTP status codes across the extension - #1133

Merged
EhabY merged 2 commits into
mainfrom
refactor/shared-http-status-codes
Oct 5, 2026
Merged

EhabY merged 2 commits into
mainfrom
refactor/shared-http-status-codes

Conversation

@EhabY

@EhabY EhabY commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #1127 (review: #1127 (comment)).

Summary

  • Move HttpStatusCode from websocket/codes to util/httpStatusCode so non-socket code can use it. websocket/codes keeps the WebSocket close codes and builds UNRECOVERABLE_HTTP_CODES from the shared object.
  • Replace numeric status literals the extension branches on: authInterceptor, cliManager, loginCoordinator, remote, tasksPanelProvider, filters, plus the matching createAxiosError(...) calls in their tests.
  • The reconnect tests iterate UNRECOVERABLE_HTTP_CODES instead of Object.values(HttpStatusCode), since the shared object now also holds statuses that do reconnect.

Left as literals: the status-class ranges in httpRequestsTelemetry (bucket bounds, not specific statuses), mock response shapes and cliManager harness responses in tests, and text that mirrors real output.

Why not axios's HttpStatusCode

axios exports a TS enum, and typescript/no-unsafe-enum-comparison (enabled in .oxlintrc.jsonc) rejects comparing its members with plain number values, such as download()'s return or unrecoverableHttpStatus. That hit 10 sites. Making those values enum-typed would claim every server status is a known member, so this keeps an as const object, matching WebSocketCloseCode.

Validation

  • pnpm test:extension: 2,332 passed, 6 skipped.
  • pnpm typecheck, pnpm lint, pnpm format:check pass.

🤖 Generated with Claude Code

Base automatically changed from fix/1118-handshake-status to main October 2, 2026 11:49
Move `HttpStatusCode` out of `websocket/codes` into `util/httpStatusCode`
and use it for every status the extension branches on, replacing numeric
literals in auth, CLI download, login, remote, tasks and workspace filters.

This keeps an `as const` object rather than axios's `HttpStatusCode` enum,
which `no-unsafe-enum-comparison` rejects wherever a status is a plain
`number`.
@EhabY
EhabY force-pushed the refactor/shared-http-status-codes branch from 9eed77d to f1245df Compare October 2, 2026 11:50

@aslilac aslilac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a util/ folder hater but I like the idea lot!

Comment thread src/api/httpStatusCode.ts
Status codes describe HTTP responses, so they sit with the rest of the
HTTP client code rather than in the generic util folder.
@EhabY
EhabY merged commit 58ef491 into main Oct 5, 2026
13 checks passed
@EhabY
EhabY deleted the refactor/shared-http-status-codes branch October 5, 2026 10:23
@EhabY

EhabY commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator Author

@aslilac This actually made me re-eval the structure here: #1134

It's a bunch of renames but touches 250 files haha (git maintains the correct history since it sees it as a move)

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.

2 participants