Skip to content

feat(github-list): conditional requests for the repository list's refresh (#404) - #418

Merged
bRRRITSCOLD merged 1 commit into
mainfrom
fix/404-repo-list-etag
Nov 24, 2026
Merged

bRRRITSCOLD merged 1 commit into
mainfrom
fix/404-repo-list-etag

Conversation

@bRRRITSCOLD

Copy link
Copy Markdown
Owner

Closes #404

What

A quiet refresh of the GitHub repository list (each time a Link picker opens) no longer re-downloads every page. The daemon keeps each held page's ETag beside it and asks for every page after the first with If-None-Match; GitHub's 304 Not Modified keeps the page and doesn't count against the REST rate limit. An unchanged list of ~1,100 repositories now costs 1 counted request a refresh instead of 12.

Page-shift rule

  • Page 1 is always read whole. GitHub's 304 carries no Link header (checked against the live API), and the page count can change, e.g. a repository added after a full last page, which leaves that page unchanged. Page 1's rel="last" stays the source of truth for how many pages there are.
  • Every other page stands alone. A 304 means that page reads as held, so no "reload the remaining pages" rule is needed: a repository added or removed shifts every page after it, those pages' contents and ETags change, and they answer 200 on their own. A page the held list didn't have is read without If-None-Match; pages past the new last one are dropped.
  • A token change drops the list with its ETags (unchanged behaviour, now tested).
  • A quiet refresh sends changed github_repositories only if the list reads differently, so an all-304 refresh sends no event.

Changes

  • prsync/github.rs: user_repos_page takes an optional ETag, sends If-None-Match, returns ReposRead::{Page, NotModified}; ReposPage carries its ETag.
  • github_list.rs: the held list is kept by page (HeldPage { etag, repositories }); read_pages sends each kept page's ETag and reuses it on 304.
  • docs/spec.md §8: the repository list's Memory, a new Conditional requests bullet and Sign-in; §12's integration list. No route, field or message changed, so API_VERSION is unchanged.
  • Tests (httpmock answers 304 when If-None-Match matches the page's current ETag, 200 with the ETag otherwise): If-None-Match per page but page 1, an all-304 refresh keeping the list with no event, a changed page read whole while others 304, a repo added at the front (every page shifts, a new last page), one added after a full last page that 304s, one removed (shift, last page dropped), and a token change sending none of the old ETags.

cargo xtask ci passes locally.

🤖 Generated with Claude Code

…resh

Keep each held page's ETag and ask for every page after the first with
If-None-Match on a quiet refresh: a 304 keeps the page and costs nothing
against the rate limit. Page 1 stays unconditional, since a 304 carries
no Link header and the page count may have changed. Each page is
validated on its own, so pages shifted by an added or removed repository
answer 200 and the list stays exact. A token change drops the ETags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bRRRITSCOLD
bRRRITSCOLD merged commit d8305c6 into main Nov 24, 2026
6 checks passed
@bRRRITSCOLD
bRRRITSCOLD deleted the fix/404-repo-list-etag branch November 24, 2026 11:28
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.

Conditional requests for the GitHub repository list's refresh

1 participant