Skip to content

Port upstream 0.70 work-days weekly pace - #829

Merged
Finesssee merged 7 commits into
mainfrom
feat/pace-workdays
Oct 11, 2026
Merged

Finesssee merged 7 commits into
mainfrom
feat/pace-workdays

Conversation

@Finesssee

@Finesssee Finesssee commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This ports upstream v0.70.0 work-days weekly pace. When Settings → Weekly progress work days is set to 2–6, pace on a 10080-minute weekly window counts only Monday through that weekday as elapsed time. Day boundaries are local midnight. ETAs map the remaining work time back to wall-clock time and skip the off days. When the setting is unset, 1 or 7, pace stays plain elapsed-time pace, as before.

  • codexbar::core::UsagePace (rust/src/core/usage_pace.rs)
    • weekly(window, now, default_window_minutes, work_days) is an exact port of upstream weekly(window:now:defaultWindowMinutes:workDays:calendar:), including workdayProgress and wallClockInterval.
    • Same guards as upstream: workday mode only applies when work days is 2..<7 and the window is 10080 minutes. Zero usage is "lasts until reset" only once work time has elapsed. A workday ETA with no remaining work time is nil.
    • Day boundaries use chrono Local, matching upstream's Calendar.current.
    • weekly_in(.., &tz) injects the time zone for tests. I didn't reuse session_equivalent_forecast::is_workday.
  • Threading of Settings::weekly_progress_work_days into every weekly pace call site:
    • Bridge card lanes and the provider-level pace: ProviderUsageSnapshot::from_fetch_result, WindowPaceSnapshot::for_window.
    • The refresh engine: refresh_provider, fetch_provider_snapshot.
    • Predictive pace warnings.
    • Tray pace colour, which reads the bridge's provider-level pace.
    • CLI text and JSON (codexbar usage).
    • The serve dashboard snapshot.
  • Proof harness (proof_harness.rs): seed lanes that have resetsAt but no pace now get the pace the bridge would compute at launch, using the settings' work days. Proof runs therefore exercise the live math, not a hand-written result. No existing kit seed carries resetsAt, so current suite baselines are unchanged.
  • Changing the setting already triggers a forced provider refresh (refreshes_provider_data, commands/settings.rs:129), so pace updates on that refresh.

Not applicable on Windows (checked):

  • Float bar: it shows no pace. FloatBar.tsx and src-tauri/src/floatbar/ have no pace references.
  • Codex historical pace: there's no evaluator. historical_pace/HistoricalPace appear nowhere in rust/ or src-tauri/. codex_historical_tracking is only a settings toggle (bridge.rs:962, OptionsSection.tsx), so upstream's "historical pace only when workDays == nil" rule has nothing to gate yet.
  • Card guards: the frontend visiblePace (lib/metricRowModel.ts) already matches upstream weeklyPaceDetail and displayableWeeklyPace: it hides at 100% used and needs expected >= 3% or ETA 0. No frontend change was needed.

Mac reference (v0.70.0)

  • Sources/CodexBarCore/UsagePace.swift:
    • 43–125: weekly.
    • 173: workdayProgress.
    • 216: wallClockInterval.
    • 246–254: nextDayBoundary, isWorkday.
  • Sources/CodexBar/UsageStore+HistoricalPace.swift 20–54: work days are passed everywhere, and historical pace runs only when workDays == nil.
  • Sources/CodexBar/MenuCardView+ModelHelpers.swift 825, 851, 1097: card call sites that pass workDaysPerWeek.
  • Sources/CodexBarCLI/CLIRenderer.swift 897–903: the CLI passes weeklyWorkDays.
  • Tests/CodexBarTests/UsagePaceTests.swift and MenuCardWorkdayPaceTests.swift are ported as Rust fixtures with literal values.

Tests added (26)

  • core::usage_pace::upstream_usage_pace_tests: 21 tests.
    • Ports of the upstream UsagePaceTests cases: Friday and midweek on-track, the exhausted quota over the weekend, ETAs that exclude or cross a weekend, flat pace on off days, and zero usage before and after the first workday.
    • Non-midnight reset split at local day boundaries (America/Los_Angeles).
    • None/7/1 fall back to linear, and non-weekly windows are ignored.
    • Plus workday_boundaries_follow_the_injected_time_zone (UTC+14).
  • bridge::pace tests:
    • weekly_lane_pace_follows_configured_work_days: the for_window path with a fixed instant.
    • fetch_result_lane_pace_follows_work_days: the real refresh path through from_fetch_result.
  • proof_harness tests:
    • seed_pace_is_computed_from_reset_time_and_work_days.
    • seed_pace_keeps_explicit_pace.
  • cli::usage::tests::json_pace_follows_weekly_work_days.

Commands run

All run in W:/wcb-wt/pace-workdays with CARGO_TARGET_DIR / CARGO_BUILD_BUILD_DIR=W:\cargo-target\pace-workdays.

Command Result
cargo fmt --all -- --check clean
cargo test --manifest-path rust/Cargo.toml 4073 passed, 0 failed, 1 ignored (+1 passed in the other target)
cargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml 667 passed, 0 failed
cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings clean
cargo clippy --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml --all-targets -- -D warnings clean
pnpm run tauri:build:debug (with the uncommitted dirs/reqwest proof shims) built

The frontend is unchanged, so pnpm test, tsc and build weren't needed.

Proof (real window, proof kit: CDP + cua-driver)

Proof is saved under W:/mac-parity/report/pace/A/:

  • seed.json
  • predict.py: an independent Python model of the upstream math.
  • predictions-vs-observed.txt
  • workdays5/ and unset/, each with tray-panel.png, cached_providers.json, body_text.json, settings.json and native.json.

Setup

  • The exe was built from dd01d245a. Later commits only add tests.
  • Each run used an isolated proof home on the secondary monitor (park.py running).
  • Isolated settings.json: {"enabled_providers":["codex"], "weekly_progress_work_days":5} for one run, and the same without work days for the other. Without enabled_providers the cache is incomplete and a refresh replaces the seed.
  • Seed: a Codex weekly window (10080 min) at 55% used, with resetsAt = Wed 2026-10-14 12:00 local (UTC+7). Captured Sunday 2026-10-11 ~23:10 local.
Run Predicted (predict.py) Bridge pace Card text
work days 5 expected 50.00%, delta +5 → "5% in deficit", runs out in 49.9 h expected 50, delta +5, eta 179 700 s 5% in deficit · Runs out in 2d 1h
unset expected 63.80%, delta −8.80 → "9% in reserve", lasts expected 63.80, delta −8.80, lasts 9% in reserve · Lasts until reset
  • Workday math: 60 of the window's 120 work hours have elapsed, so expected is 50%. The weekend adds no elapsed time.
  • Linear math: 107.2 of 168 hours, so expected is 63.8%.
  • Both texts were asserted with cdp.py assert, and screenshots were taken with cua.py shot. The screenshots show seed data only, with no personal data.

What each check covers

  • The real-window proof covers settings → harness → for_window → UsagePace → frontend render.
  • fetch_result_lane_pace_follows_work_days covers the live refresh path.
  • Tray colour isn't in the window proof. For Codex it follows the 5 h primary, which work days never change. It's covered by threading plus unit tests.
  • Changing the setting live isn't shown in the window proof. In proof mode the forced refresh it triggers replaces the seed with fetch errors.

Open questions (default chosen)

  1. speedMultiplierToReset and runOutProbability aren't ported. The Windows UsagePace has neither field, and nothing renders them. The upstream asserts on them were omitted; every other assert is ported. Default: leave them out; add them if a surface needs them.
  2. The DST-gap day boundary is approximate. When local midnight doesn't exist, the first existing local quarter hour after it is used, which approximates Foundation startOfDay. Default: keep it; this only matters in zones with midnight DST transitions.
  3. Applying the setting needs a refresh. Pace is baked into the cached snapshot at fetch time; the Mac computes it at render time. The settings change already forces a refresh. If that fetch fails, the previous snapshot's pace stays until the next successful refresh. Default: keep the refresh-based update; recomputing pace on cached snapshots would be a separate change.
  4. Codex historical pace has no Windows evaluator. The workDays == nil gate is documented, not code. Default: N/A until historical pace is ported.

Summary by CodeRabbit

  • New Features
    • Weekly usage pace and estimated completion times now account for configured workdays, using local time and excluding non-workdays.
    • Workday-aware pacing is reflected in usage reports, dashboards, and desktop usage views.
  • Bug Fixes
    • Weekly pace calculations consistently apply the configured workday schedule across usage windows.
    • Linear pacing remains in effect when no workday schedule is configured or the window does not support workday-based pacing.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: nesszer/Win-CodexBar/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 15d39abb-b35d-44dc-90bb-15efc5f7e2a1

📥 Commits

Reviewing files that changed from the base of the PR and between c4bc144 and 3876ef3.


📒 Files selected for processing (1)
  • rust/src/core/usage_pace.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.



📝 Walkthrough

Walkthrough

Weekly pace calculations now support an optional work-day schedule. Desktop provider refreshes, proof snapshots, dashboard snapshots, and CLI usage rendering pass the configured setting into those calculations.

Changes

Weekly usage pace

Layer / File(s) Summary
Workday-aware weekly pace calculation
rust/src/core/usage_pace.rs, rust/src/providers/grok/tests.rs
UsagePace::weekly accepts an optional work-day count. For 10,080-minute windows and counts from two through six, pace and ETA calculations use local workdays. Other cases retain linear pacing. Tests cover workday schedules, time zones, and fallback cases.
Desktop provider and proof-snapshot pacing
apps/desktop-tauri/src-tauri/src/commands/bridge.rs, apps/desktop-tauri/src-tauri/src/commands/bridge/*, apps/desktop-tauri/src-tauri/src/commands/providers.rs, apps/desktop-tauri/src-tauri/src/commands/tests.rs, apps/desktop-tauri/src-tauri/src/commands/last_good_owner_tests.rs, apps/desktop-tauri/src-tauri/src/main.rs, apps/desktop-tauri/src-tauri/src/proof_harness.rs
Provider refreshes pass the configured work-day count to pace calculation and snapshot construction. Proof snapshot seeding calculates missing pace for eligible reset windows. Tests cover workday-aware pace and seeded snapshots.
Dashboard weekly pace input
rust/src/cli/serve/dashboard/snapshot.rs, rust/src/cli/serve/dashboard/source.rs, rust/src/cli/serve/dashboard/*/tests.rs, rust/src/cli/serve/metrics/tests.rs, rust/src/cli/serve/tests.rs
Dashboard snapshot input carries the optional work-day setting from configuration into account pace construction. Test fixtures set the new input to None.
CLI weekly pace rendering
rust/src/cli/usage.rs, rust/src/cli/usage/fetch_helpers.rs, rust/src/cli/usage/render.rs, rust/src/cli/usage_tests.rs
Usage commands load the configured work-day count and pass it through text and JSON rendering. Renderer tests check secondary-window pacing with five- and seven-day schedules.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Settings
  participant UsageCommand
  participant FetchHelpers
  participant UsageRenderer
  participant UsagePace
  Settings->>UsageCommand: weekly_progress_work_days
  UsageCommand->>FetchHelpers: weekly_work_days
  FetchHelpers->>UsageRenderer: pace_work_days
  UsageRenderer->>UsagePace: weekly window and work-day count
Loading

Merge Risk: ⚪ Minimal · up to 3876e

No merge-blocking issue was established for the workday-aware weekly pace change; it is ready for normal merge checks.

Pre-merge checks | Passed 7 | Inconclusive 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Ui Changes Include Windows Proof Inconclusive The PR changes user-visible pace output in the desktop bridge, CLI renderers, and dashboard snapshot. The supplied context reports a real-window proof and a debug build, but it does not establish that… Provide the complete PR description, or confirm with a description note that a fresh Windows build was used and that the changed pace display was verified. Include screenshots if no equivalent proof note exists.
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title is a short imperative summary that accurately describes porting upstream work-days weekly pace support.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Provider Data Stays Siloed Passed The change threads weekly_progress_work_days into pace calculations only. In bridge.rs, the new argument affects provider and lane pace values, not identity or account fields. In providers.rs, r…
Secrets Handled Safely Passed The pull request changes pace calculations, settings propagation, proof-seed normalization, and tests. Diff inspection found no added credential, token, cookie, API-key, OAuth, authorization-header, k…
No Unapproved Dependencies Passed The pull-request diff changes only Rust source and test files. It does not change any Cargo.toml or package.json, add an npm/yarn lockfile, or change a pinned pnpm packageManager version. Approval is …

Full details: Ui Changes Include Windows Proof

Explanation

The PR changes user-visible pace output in the desktop bridge, CLI renderers, and dashboard snapshot. The supplied context reports a real-window proof and a debug build, but it does not establish that the proof came from a fresh Windows build. The contributor description is explicitly truncated, so the missing section could contain the required Windows proof note or screenshots.


✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR




🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • 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

Comment @coderabbitai help to get the list of available commands.

@Finesssee
Finesssee merged commit 696d27f into main Oct 11, 2026
3 checks passed
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