Skip to content

fix(progress): name the collection and count pages per request - #177

Merged
drakulavich merged 2 commits into
mainfrom
fix/progress-names
Oct 25, 2026
Merged

drakulavich merged 2 commits into
mainfrom
fix/progress-names

Conversation

@drakulavich

Copy link
Copy Markdown
Owner

Closes #129.

Planned together with #131. The two turned out unrelated (the progress line versus a note under db rows), so #131 has its own PR.

What

  • The progress line names the collection: syncing sleep for the daily_sleep endpoint, syncing sleep-periods for sleep, and so on. collectionOf in run-command.ts maps an endpoint to its collection, and both the sync runner and fetch pass it to pageProgress.
  • The page counter restarts with each request. The client numbers pages within one fetch() call (PageEvent.page), and the progress line shows that number. A range split into 30-day pieces counts each piece's own pages, and the row count still runs across them.

Why

Reproduced on main: the new fetch test shows fetching heartrate: page 1 … page 6 for three 30-day pieces of two pages each. The sync progress test shows syncing daily_sleep, which is the endpoint of the sleep collection.

Left as is: the issue also notes that the last frame repeats the previous row total when the final page is empty. That frame reports a page that really arrived with 0 rows, so I did not change it.

How checked

  • New test in src/commands/fetch.test.ts: fetchCollection for hr over 61 days, through a real OuraClient with a stubbed fetch. It checks all six frames (fetching hr: page 1, 2 rows so far… through page 2, 9 rows so far…). The sync terminal-progress test now expects syncing sleep and syncing sleep-periods. Both fail on main's sources. The existing progress and client tests now carry the page field.
  • Mutation, reverted after one run of src/commands/fetch.test.ts: pages = page.page; → pages++; in progress.ts: 1 of 17 fails (the new test).
  • bun run check: typecheck, Biome, Knip clean; 712 tests pass.
  • Codex review: Approve, no findings (report in the first comment).

Overlap: src/commands/run-command.ts is also changed by #173 (different lines).

🤖 Generated with Claude Code

https://claude.ai/code/session_018qh9xqviBHYmzVtmQWSKqA

The progress line printed the endpoint (daily_sleep for sleep, sleep for
sleep-periods), a third vocabulary next to the summary's collection and
table names, and its page counter reset only when the endpoint changed,
so a range split into 30-day requests ran one counter across all of them.
The client now numbers pages per request and both callers map the
endpoint to its collection.

Closes #129

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018qh9xqviBHYmzVtmQWSKqA
@drakulavich

Copy link
Copy Markdown
Owner Author

Codex review (gpt-6-luna, final, ebcf1cc..1837f83):

Reviewed ebcf1cc..1837f83. I found no issues.

The four touched test files passed: 94 tests, 0 failures. The worktree also has a pre-existing modification to assets/demo.gif, which I left untouched.

Simplification: not needed

Verdict: Approve

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with the previously reported terminal display issue remaining as a non-blocking concern.

Findings

  1. P2 Old characters remain visible ▶

Summary

The PR makes terminal progress use collection names and restart page counts for each request.

  • Progress lines name collections and restart page counts for each request.

The previous-review merge bases differ, so this review checked the full PR diff.

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/lib/progress.ts
onPage(page) {
if (page.endpoint !== endpoint) { endpoint = page.endpoint; pages = 0; rows = 0; }
pages++;
pages = page.page;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Old characters remain visible

Restarting the page counter can leave old text on the terminal. When one request ends at page 10 and the next starts at page 1, with the row total still the same width, the new line is one character shorter. show() writes only a carriage return before the text, so the previous trailing character remains visible. Clear the line or pad shorter frames before writing them.

@drakulavich
drakulavich merged commit d80217a into main Oct 25, 2026
3 checks passed
@drakulavich
drakulavich deleted the fix/progress-names branch October 25, 2026 14:14
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.

Progress line names API endpoints, not collections, and counts pages across range pieces

1 participant