Skip to content

Extract shared sync HTTP helpers: auth headers and unavailable mapping #147

Description

@cursor

Spec: Fowler-style refactoring review (cloud agent, 2026-08-05). Refactor only — no behavior change.

What to change

About ten browser-side client modules repeat the same two blocks:

  • the auth-headers builder including the x-walking-thoughts-test-user bypass: lib/sync/client.ts, lib/sync/trash-client.ts, lib/sync/threads-client.ts, lib/sync/split-client.ts, lib/sync/review-client.ts, lib/sync/media-client.ts, lib/enrichment/client.ts, lib/enrichment/thread-view.ts, lib/artifacts/client.ts, lib/push/client.ts — plus hand-rolled copies in components/daily-digest-panel.tsx (digestHeaders) and components/interview-panel.tsx (interviewHeaders)
  • the 401/403/503 → { unavailable: true } response mapping

Extract syncAuthHeaders() and asUnavailable(response) (or a tiny fetchSync(path, init)) into one module (e.g. lib/sync/http.ts) and route every client through it.

Out of scope: retry/timeout behavior; the transports' public interfaces.

Acceptance criteria

  • One implementation of the test-user header logic and one of the unavailable mapping; all listed files import them
  • digestHeaders / interviewHeaders in components are deleted in favor of the shared helper
  • mise run lint and mise run test pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions