Add time-based color coding to countdown text#913
Add time-based color coding to countdown text#913jubin-marut wants to merge 1 commit intoleits:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughAdded a boolean preference and UI toggle to enable time-based coloring of the status bar countdown, a localization key, and status bar logic to compute and apply green/yellow/red colors based on remaining time. ChangesTime-based Status Bar Coloring
Sequence Diagram(s)sequenceDiagram
participant User
participant PrefUI as Preferences UI
participant Defaults
participant StatusBar as StatusBar Controller
participant Display as Status Bar Display
User->>PrefUI: Toggle "time color" option
PrefUI->>Defaults: Write timeBasedStatusBarColor
Defaults-->>StatusBar: Preference change notification
StatusBar->>StatusBar: Rebuild menu/title
StatusBar->>StatusBar: countdownColor(event)
alt remaining >= 15 min
StatusBar->>StatusBar: return rgba(0,128,0,0.5)
else remaining >= 5 min
StatusBar->>StatusBar: return rgba(255,215,0,0.5)
else remaining < 5 min
StatusBar->>StatusBar: return rgba(255,0,0,0.5)
end
StatusBar->>Display: Render time text with color
Display-->>User: Show colored countdown
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@MeetingBar/UI/StatusBar/StatusBarItemController.swift`:
- Around line 274-280: The time string is only appended when
Defaults[.eventTimeFormat] == .show, which causes the time to disappear if the
title is hidden but the user selected "show under title"; update the condition
around menuTitle.append so it also appends when the configured eventTimeFormat
requests showing the time under the title while the title is hidden (e.g., treat
Defaults[.eventTimeFormat] == .showUnderTitle as a valid case when title is
hidden). Adjust the if condition that currently checks
Defaults[.eventTimeFormat] and !time.isEmpty (and keep the existing time color
logic using countdownColor(for: nextEvent) and the timeStyles/menuTitle.append
calls) so the same append code runs for both explicit show and the "show under
title" scenario when title is hidden.
- Around line 552-557: The threshold checks in StatusBarItemController that
compare timeRemaining to 15*60 and 5*60 use strict greater-than, so exact 15m
and 5m values fall into the lower bucket; change the comparisons to inclusive
(use >= for the 15*60 and 5*60 comparisons or otherwise adjust the conditional
ordering) in the method that returns the color for timeRemaining so that
timeRemaining == 15*60 yields systemGreen and timeRemaining == 5*60 yields
systemYellow (refer to the timeRemaining comparisons in the color-returning
logic inside StatusBarItemController).
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 03c9963e-4fc9-460a-b90e-705d8553e5ae
📒 Files selected for processing (4)
MeetingBar/Extensions/DefaultsKeys.swiftMeetingBar/Resources /Localization /en.lproj/Localizable.stringsMeetingBar/UI/StatusBar/StatusBarItemController.swiftMeetingBar/UI/Views/Preferences/AppearanceTab.swift
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #913 +/- ##
==========================================
+ Coverage 36.26% 36.52% +0.26%
==========================================
Files 48 48
Lines 5129 5054 -75
Branches 1743 1710 -33
==========================================
- Hits 1860 1846 -14
+ Misses 3213 3156 -57
+ Partials 56 52 -4 ☔ View full report in Codecov by Sentry. |
|
Thanks for the review. Addressed the threshold off-by-one in 84e1470 — now uses Skipped the first finding about the |
84e1470 to
00cb036
Compare
Color the countdown timer text (e.g. "in 5m") based on time remaining until the next meeting: green >=15min, yellow >=5min, red <5min. Works in both inline and under-title display modes. Controlled by a new toggle in Preferences > Appearance > Status Bar, off by default.
00cb036 to
52274dd
Compare
Summary
Colors the countdown timer text in the menu bar based on time remaining until the next meeting:
Works in both inline (
"Meeting in 5m") and under-title display modes. Controlled by a new toggle in Preferences > Appearance > Status Bar (Color countdown by time remaining), off by default. UsesNSColor.systemGreen/Yellow/Redso it adapts to light and dark mode.Implementation
countdownColor(for:)— free function computing color from event start/end datesupdateTitle()— splits title and time into separateNSAttributedStringsegments so the time portion can be independently coloredtimeBasedStatusBarColoruser default (Bool, defaultfalse)en.lprojSummary by CodeRabbit
New Features
Documentation