Skip to content

Networking 2/5: Retrofit client, auth, users and houses - #9

Open
wenja0618 wants to merge 1 commit into
networking-1-setupfrom
networking-2-client
Open

wenja0618 wants to merge 1 commit into
networking-1-setupfrom
networking-2-client

Conversation

@wenja0618

Copy link
Copy Markdown
Contributor

@caleb-bit, could you review? Stack 2/5. This is the core of the stack and the one to spend the most time on.

The shared networking client, plus users and houses.

  • RetrofitInstance: one OkHttp/Retrofit client. It adds Authorization: Bearer, and on a 401 refreshes the token and retries once. It won't retry if (a) the request went to a different origin, or (b) the signed-in account changed since the request started (session number carried on an OkHttp request tag). Only earlier 401s count toward "once", so a redirect before the 401 doesn't block the refresh.
  • TokenProvider / DevTokenProvider: dev:<netid> tokens for the local backend until Google sign-in exists
  • RoomieApiResponse: Pending / Success / Error. apiCall {} turns HTTP, network and parse failures into ApiErrors using the backend's errorCode and field errors
  • ResponseFlow<T>: the state holder every repository uses. Only the latest fetch publishes; set() cancels and discards a fetch in flight; update() is serialized
  • AuthRepository, HouseRepository, UserApiService, HouseApiService, and shared DTOs (including the new presence HOME/AWAY field)

This includes fixes for CodeRabbit's review of #6: authenticator retry rules, account switch during a retry, leaveHouse racing fetchHouse, and an older fetch overwriting a newer one.

Test: passes 28/28. New: RoomieApiTest (retry once, give up on the second 401, redirect then 401, no retry after an account switch, error parsing, network failure) and ResponseFlowTest.


Part of a 5-PR stack that replaces #6 (split so each piece is reviewable on its own). Merge in order; each PR targets the one before it.

🤖 Generated with Claude Code

Split out of #6 (retrofit networking layer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wenja0618
wenja0618 requested a review from caleb-bit November 23, 2026 03:14
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2aeaac9-ea0c-492b-97d9-32f5539d695d
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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