Skip to content

Add time-based color coding to countdown text#913

Open
jubin-marut wants to merge 1 commit intoleits:masterfrom
jubin-marut:feature/countdown-color-by-time
Open

Add time-based color coding to countdown text#913
jubin-marut wants to merge 1 commit intoleits:masterfrom
jubin-marut:feature/countdown-color-by-time

Conversation

@jubin-marut
Copy link
Copy Markdown

@jubin-marut jubin-marut commented Apr 14, 2026

Summary

Colors the countdown timer text in the menu bar based on time remaining until the next meeting:

  • Green — 15 minutes or more
  • Yellow — 5 to 15 minutes
  • Red — under 5 minutes

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. Uses NSColor.systemGreen/Yellow/Red so it adapts to light and dark mode.

Implementation

  • countdownColor(for:) — free function computing color from event start/end dates
  • updateTitle() — splits title and time into separate NSAttributedString segments so the time portion can be independently colored
  • New timeBasedStatusBarColor user default (Bool, default false)
  • Localization key added for en.lproj

Summary by CodeRabbit

  • New Features

    • Appearance preference: toggle to color the status bar countdown by time remaining (green >15m, yellow 5–15m, red ≤5m). Default: off. Enable in Status Bar settings; countdown color updates live in the menu/title.
  • Documentation

    • Added English label for the new preference: "Color countdown by time remaining".

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1d060324-558b-4c93-ba59-730cdc4566bb

📥 Commits

Reviewing files that changed from the base of the PR and between 00cb036 and 52274dd.

📒 Files selected for processing (4)
  • MeetingBar/Extensions/DefaultsKeys.swift
  • MeetingBar/Resources /Localization /en.lproj/Localizable.strings
  • MeetingBar/UI/StatusBar/StatusBarItemController.swift
  • MeetingBar/UI/Views/Preferences/AppearanceTab.swift

Walkthrough

Added 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.

Changes

Time-based Status Bar Coloring

Layer / File(s) Summary
Data Shape / Defaults
MeetingBar/Extensions/DefaultsKeys.swift
Added exported key Defaults.Keys.timeBasedStatusBarColor = Key<Bool>("timeBasedStatusBarColor", default: false).
Localization
MeetingBar/Resources/Localization/en.lproj/Localizable.strings
Added preferences_appearance_status_bar_time_color_toggle = "Color countdown by time remaining".
Preferences UI
MeetingBar/UI/Views/Preferences/AppearanceTab.swift
Added @Default(.timeBasedStatusBarColor) var timeBasedStatusBarColor and a Toggle bound to it in the Status Bar section.
Wiring / Observers
MeetingBar/UI/StatusBar/StatusBarItemController.swift
Included .timeBasedStatusBarColor in Defaults.publisher observers so changes trigger redraws.
Core Implementation
MeetingBar/UI/StatusBar/StatusBarItemController.swift
Added func countdownColor(for event: MBEvent) -> NSColor using event start/end to compute remaining time and returning .systemGreen (>=15min), .systemYellow (>=5min), or .systemRed (<5min); applied this color to the time segment when the preference is enabled (both title-under and inline branches).

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

lgtm

Suggested reviewers

  • leits
  • mskopp

Poem

🐰 I hopped in to add a colorful cue,
Green for calm, yellow for few,
Red for the dash — a prompt so bright,
Tiny hues to guide your sight,
Hop, tick, tock — track time just right!

🚥 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 title 'Add time-based color coding to countdown text' clearly and concisely summarizes the main feature addition: implementing color coding for the countdown timer based on remaining time.
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.

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

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

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@dosubot dosubot Bot added the feature New feature or request label Apr 14, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 48373d7 and 51761ed.

📒 Files selected for processing (4)
  • MeetingBar/Extensions/DefaultsKeys.swift
  • MeetingBar/Resources /Localization /en.lproj/Localizable.strings
  • MeetingBar/UI/StatusBar/StatusBarItemController.swift
  • MeetingBar/UI/Views/Preferences/AppearanceTab.swift

Comment thread MeetingBar/UI/StatusBar/StatusBarItemController.swift
Comment thread MeetingBar/UI/StatusBar/StatusBarItemController.swift Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 5.55556% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.52%. Comparing base (69bf18d) to head (52274dd).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...tingBar/UI/StatusBar/StatusBarItemController.swift 7.14% 13 Missing ⚠️
...eetingBar/UI/Views/Preferences/AppearanceTab.swift 0.00% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@jubin-marut
Copy link
Copy Markdown
Author

Thanks for the review. Addressed the threshold off-by-one in 84e1470 — now uses >= so 15:00 stays green and 5:00 stays yellow.

Skipped the first finding about the .show_under_title + hidden title combo: that gate was pre-existing upstream behavior (see the unchanged if Defaults[.eventTimeFormat] == .show in the original file), so fixing it is out of scope for this PR. Happy to spin off a separate change if you'd like.

@jubin-marut jubin-marut force-pushed the feature/countdown-color-by-time branch from 84e1470 to 00cb036 Compare May 5, 2026 22:24
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.
@jubin-marut jubin-marut force-pushed the feature/countdown-color-by-time branch from 00cb036 to 52274dd Compare May 5, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants