Skip to content

feat: add optional usage pace guide#33

Open
justice-hwan wants to merge 3 commits into
ericjypark:mainfrom
justice-hwan:feat/pace-guide-bar
Open

feat: add optional usage pace guide#33
justice-hwan wants to merge 3 commits into
ericjypark:mainfrom
justice-hwan:feat/pace-guide-bar

Conversation

@justice-hwan

@justice-hwan justice-hwan commented Jun 2, 2026

Copy link
Copy Markdown

Summary

  • Add an opt-in General setting for usage pace guides, defaulting off.
  • Render a compact guide marker inside each chart style instead of adding another row.
  • Hide the guide unless reset timestamp data is available.

Why

  • Helps users compare current 5h/week usage against an even-spend pace before reset.
  • Keeps the existing UI unchanged by default for current users.

Fixes #24

Testing

  • ./scripts/verify.sh
  • Launched the app in CODEXISLAND_DEMO=1 and visually checked Bar, Stepped, Numeric, Sparkline, and Ring styles during iteration.

Summary by CodeRabbit

  • New Features

    • Added a Pace Guide with visual markers on all chart types to indicate expected usage before reset.
    • New Settings toggle to enable/disable the Pace Guide.
    • Tile labels now surface guide-aware text (e.g., "used X%, guide Y%") for screen readers and display.
  • Documentation

    • Added localized strings for Pace Guide messaging and usage text.

Adds a compact guide marker to each live usage window so users can compare current usage against the even-spend target implied by the reset deadline.

Constraint: Preserve the compact notch panel height and existing chart-style selector.

Rejected: Add a separate settings-controlled pace page | too much surface area for the issue request.

Confidence: high

Scope-risk: narrow

Directive: Keep pace math tied to provider reset timestamps; do not infer limits without reset data.

Tested: ./scripts/verify.sh
Fold the reset-window pace guide into each chart style and add a General preference so users can opt in without changing the default UI.

Constraint: Default must remain off so existing users keep the original chart appearance after upgrade.

Rejected: Always show a separate guide bar | it cluttered Numeric and Sparkline chart styles.

Confidence: high

Scope-risk: narrow

Directive: Keep guide markers hidden unless Pace guide is enabled and reset timestamps are available.

Tested: ./scripts/verify.sh
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ecb15724-61d2-4949-b73c-bdec69a6a5d8

📥 Commits

Reviewing files that changed from the base of the PR and between e5acfc9 and a479a74.

📒 Files selected for processing (1)
  • Sources/Views/UsageView.swift
🚧 Files skipped from review as they are similar to previous changes (1)
  • Sources/Views/UsageView.swift

📝 Walkthrough

Walkthrough

This PR adds a pace guide feature: a persisted preference and Settings toggle, localized strings, chart updates to render an animated guide marker when provided, and UsageView integration that computes and threads a guide percent into all charts and accessibility labels.

Changes

Pace Guide Feature

Layer / File(s) Summary
Preference Store and Settings UI
Sources/Model/PaceGuideStore.swift, Sources/Views/SettingsView.swift, Resources/en.lproj/Localizable.strings, Resources/zh-Hans.lproj/Localizable.strings
PaceGuideStore singleton manages and persists the enabled preference to UserDefaults. SettingsView adds a new "Pace guide" toggle in the General tab with localized English and Simplified Chinese labels and descriptions.
Chart Guide Marker Rendering
Sources/Views/Charts/BarChart.swift, Sources/Views/Charts/NumericChart.swift, Sources/Views/Charts/RingChart.swift, Sources/Views/Charts/SparkChart.swift, Sources/Views/Charts/SteppedChart.swift
All five chart types now accept an optional guide: Double? parameter and conditionally render a visual guide marker positioned at guide / 100 of the chart width/angle. RingChart adds RingGuideTick shape with animatable positioning. Chart markers animate when guide changes.
UsageView Integration and Pace Calculation
Sources/Views/UsageView.swift
ChartTile observes PaceGuideStore.enabled, computes paceGuidePercent() from the reset window duration (with different baselines for weekly vs. other windows), and threads the guide value into all chart renderers. Accessibility values now report the guide-informed usage status when available.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 A pace guide hops in with flair,
Showing charts where usage should dare,
Visual marks dance with each reset chime,
Helping users keep pace with time,
Efficiency blooms from settings' care!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat: add optional usage pace guide' directly summarizes the main change—introducing an optional pace guide feature for usage visualization.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #24: optional pace guide feature with toggle setting, guide markers rendered in all chart types, automatic calculation based on remaining time, and visual indicator showing recommended usage pace.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the pace guide feature requested in issue #24; localization strings, store management, chart modifications, and settings UI are all within scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/Views/UsageView.swift`:
- Around line 180-181: The accessibility label and value use two different
percent calculations causing inconsistent VoiceOver output; update the
.accessibilityLabel call in UsageView (the line using
.accessibilityLabel(L10n.tr("%@, %d%%", label, Int(value)))) to use the same
rounded source as .accessibilityValue (use the window.percentInt / the same
percentInt used by accessibilityValue()) so both spoken percentages match; also
apply the same change to the other occurrence around the 197–202 area to ensure
consistency everywhere.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d7dbd89d-56f2-483e-8199-822dbf7b8c58

📥 Commits

Reviewing files that changed from the base of the PR and between fd6c5f6 and e5acfc9.

📒 Files selected for processing (10)
  • Resources/en.lproj/Localizable.strings
  • Resources/zh-Hans.lproj/Localizable.strings
  • Sources/Model/PaceGuideStore.swift
  • Sources/Views/Charts/BarChart.swift
  • Sources/Views/Charts/NumericChart.swift
  • Sources/Views/Charts/RingChart.swift
  • Sources/Views/Charts/SparkChart.swift
  • Sources/Views/Charts/SteppedChart.swift
  • Sources/Views/SettingsView.swift
  • Sources/Views/UsageView.swift

Comment thread Sources/Views/UsageView.swift Outdated
Use the same rounded window percentage for the accessibility label and value so VoiceOver does not announce conflicting usage numbers.

Constraint: CodeRabbit flagged inconsistent rounding between Int(value) and WindowUsage.percentInt.

Confidence: high

Scope-risk: narrow

Tested: ./scripts/verify.sh
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.

[기능 제안] 남은 시간 및 기한 맞춤형 사용량 가이드 바(Pace Bar) 추가

1 participant