Skip to content

Add options for 5 days, 7 days, and work week #893

Open
CampAsAChamp wants to merge 1 commit intoleits:masterfrom
CampAsAChamp:feature/event-and-statusbar-improvements
Open

Add options for 5 days, 7 days, and work week #893
CampAsAChamp wants to merge 1 commit intoleits:masterfrom
CampAsAChamp:feature/event-and-statusbar-improvements

Conversation

@CampAsAChamp
Copy link
Copy Markdown

@CampAsAChamp CampAsAChamp commented Feb 24, 2026

Summary

Event and status bar UI improvements.

Changes

  • EventManager and MBEvent+Helpers updates
  • StatusBarItemController enhancements
  • Appearance preferences and localization
  • Constants and NextEventTests updates

Summary by CodeRabbit

  • New Features
    • Added new event display period options in preferences: 5 days, 7 days, and work week (Mon–Fri) for customizable event visibility.
    • Enhanced status bar to display events grouped by individual days for multi-day periods, with separate sections for each day.

- EventManager and MBEvent+Helpers updates
- StatusBarItemController enhancements
- Appearance preferences and localization
- Constants and NextEventTests updates
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 24, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 24, 2026

Walkthrough

This pull request introduces three new time period options for event display filtering: 5 days, 7 days, and work week (Monday–Friday). The implementation extends the ShowEventsForPeriod enum and adds corresponding date-range calculation logic across event management and UI components, with localization strings and test coverage.

Changes

Cohort / File(s) Summary
Enum Definition
MeetingBar/Utilities/Constants.swift
Added three new cases to ShowEventsForPeriod enum: fiveDays, sevenDays, workWeek.
Core Date Range Logic
MeetingBar/Core/Managers/EventManager.swift, MeetingBar/Core/Models/MBEvent+Helpers.swift
Implemented date-range calculations for new periods. Added workWeek logic handling weekend cases (Sunday/Saturday) and calculating appropriate Monday–Friday end dates. Refactored to use local calendar variables instead of repeated Calendar.current calls.
UI & Display
MeetingBar/UI/StatusBar/StatusBarItemController.swift, MeetingBar/UI/Views/Preferences/AppearanceTab.swift, MeetingBar/Resources/Localization/en.lproj/Localizable.strings
Added new period options to appearance preferences picker with localized labels ("5 days", "7 days", "work week (Mon–Fri)"). Implemented helper method to compute day-based event filtering for multi-day periods with daily section titles and separators.
Test Coverage
MeetingBarTests/NextEventTests.swift
Added two tests verifying event filtering behavior for the new fiveDays and sevenDays periods.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

feature, size:M

Suggested reviewers

  • leits

Poem

🐰 Five days, seven days, a work week so fine,
Calendar logic now perfectly aligned,
Monday through Friday, the range takes its flight,
Events filter cleanly from morning to night! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes in the pull request, which add three new event display period options (5 days, 7 days, and work week) across multiple files.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

XCTAssertEqual(array.nextEvent(), running)
}

func test_fiveDaysPeriod_includesEventWithinFiveDays_excludesEventAfter() {

Check warning

Code scanning / Tailor (reported by Codacy)

Function names should be lowerCamelCase Warning

Function names should be lowerCamelCase
XCTAssertEqual(array.nextEvent(), withinFive)
}

func test_sevenDaysPeriod_includesEventWithinSevenDays() {

Check warning

Code scanning / Tailor (reported by Codacy)

Function names should be lowerCamelCase Warning

Function names should be lowerCamelCase
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 324-349: daysInPeriod currently returns only today for the
.today_n_tomorrow case; update the .today_n_tomorrow branch in the
daysInPeriod(_:,from:,calendar:) function so it returns an array containing
today and tomorrow by using calendar.date(byAdding: .day, value: 1, to: today)
to compute tomorrow (preserve ordering [today, tomorrow] and safe unwrap similar
to other cases).
- Around line 398-417: The section title for multi-day periods uses a full date
string but buildDateSection(date: title: events:) already appends the formatted
date, causing duplicated labels; change the else branch that sets sectionTitle
(using dateFormatter) to produce only the weekday (e.g., use a DateFormatter
with format "E" or fetch the localized weekday name) so sectionTitle is just the
weekday name, keeping the existing special-cases for today/tomorrow and leaving
builder.buildDateSection as-is.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 84e0a9f and 16a2d9c.

📒 Files selected for processing (7)
  • MeetingBar/Core/Managers/EventManager.swift
  • MeetingBar/Core/Models/MBEvent+Helpers.swift
  • MeetingBar/Resources /Localization /en.lproj/Localizable.strings
  • MeetingBar/UI/StatusBar/StatusBarItemController.swift
  • MeetingBar/UI/Views/Preferences/AppearanceTab.swift
  • MeetingBar/Utilities/Constants.swift
  • MeetingBarTests/NextEventTests.swift

Comment on lines +324 to +349
/// Returns the start-of-day dates for each day in the given period, from today (or next Monday for work week on weekend).
private static func daysInPeriod(_ period: ShowEventsForPeriod, from today: Date, calendar: Calendar) -> [Date] {
switch period {
case .fiveDays:
return (0 ..< 5).map { calendar.date(byAdding: .day, value: $0, to: today)! }
case .sevenDays:
return (0 ..< 7).map { calendar.date(byAdding: .day, value: $0, to: today)! }
case .workWeek:
let weekday = calendar.component(.weekday, from: today) // 1 = Sunday, 7 = Saturday
if weekday == 1 {
// Sunday: next week Mon–Fri
let nextMonday = calendar.date(byAdding: .day, value: 1, to: today)!
return (0 ..< 5).map { calendar.date(byAdding: .day, value: $0, to: nextMonday)! }
} else if weekday == 7 {
// Saturday: next week Mon–Fri
let nextMonday = calendar.date(byAdding: .day, value: 2, to: today)!
return (0 ..< 5).map { calendar.date(byAdding: .day, value: $0, to: nextMonday)! }
} else {
// Monday (2) through Friday (6): today through Friday
let daysUntilFriday = 6 - weekday
return (0 ... daysUntilFriday).map { calendar.date(byAdding: .day, value: $0, to: today)! }
}
case .today, .today_n_tomorrow:
return [today]
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix .today_n_tomorrow to include tomorrow in daysInPeriod.

The helper’s switch returns only today for .today_n_tomorrow, which is incorrect if the helper is reused for that period.

✅ Suggested fix
-        case .today, .today_n_tomorrow:
-            return [today]
+        case .today:
+            return [today]
+        case .today_n_tomorrow:
+            return [today, calendar.date(byAdding: .day, value: 1, to: today)!]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Returns the start-of-day dates for each day in the given period, from today (or next Monday for work week on weekend).
private static func daysInPeriod(_ period: ShowEventsForPeriod, from today: Date, calendar: Calendar) -> [Date] {
switch period {
case .fiveDays:
return (0 ..< 5).map { calendar.date(byAdding: .day, value: $0, to: today)! }
case .sevenDays:
return (0 ..< 7).map { calendar.date(byAdding: .day, value: $0, to: today)! }
case .workWeek:
let weekday = calendar.component(.weekday, from: today) // 1 = Sunday, 7 = Saturday
if weekday == 1 {
// Sunday: next week Mon–Fri
let nextMonday = calendar.date(byAdding: .day, value: 1, to: today)!
return (0 ..< 5).map { calendar.date(byAdding: .day, value: $0, to: nextMonday)! }
} else if weekday == 7 {
// Saturday: next week Mon–Fri
let nextMonday = calendar.date(byAdding: .day, value: 2, to: today)!
return (0 ..< 5).map { calendar.date(byAdding: .day, value: $0, to: nextMonday)! }
} else {
// Monday (2) through Friday (6): today through Friday
let daysUntilFriday = 6 - weekday
return (0 ... daysUntilFriday).map { calendar.date(byAdding: .day, value: $0, to: today)! }
}
case .today, .today_n_tomorrow:
return [today]
}
}
/// Returns the start-of-day dates for each day in the given period, from today (or next Monday for work week on weekend).
private static func daysInPeriod(_ period: ShowEventsForPeriod, from today: Date, calendar: Calendar) -> [Date] {
switch period {
case .fiveDays:
return (0 ..< 5).map { calendar.date(byAdding: .day, value: $0, to: today)! }
case .sevenDays:
return (0 ..< 7).map { calendar.date(byAdding: .day, value: $0, to: today)! }
case .workWeek:
let weekday = calendar.component(.weekday, from: today) // 1 = Sunday, 7 = Saturday
if weekday == 1 {
// Sunday: next week Mon–Fri
let nextMonday = calendar.date(byAdding: .day, value: 1, to: today)!
return (0 ..< 5).map { calendar.date(byAdding: .day, value: $0, to: nextMonday)! }
} else if weekday == 7 {
// Saturday: next week Mon–Fri
let nextMonday = calendar.date(byAdding: .day, value: 2, to: today)!
return (0 ..< 5).map { calendar.date(byAdding: .day, value: $0, to: nextMonday)! }
} else {
// Monday (2) through Friday (6): today through Friday
let daysUntilFriday = 6 - weekday
return (0 ... daysUntilFriday).map { calendar.date(byAdding: .day, value: $0, to: today)! }
}
case .today:
return [today]
case .today_n_tomorrow:
return [today, calendar.date(byAdding: .day, value: 1, to: today)!]
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@MeetingBar/UI/StatusBar/StatusBarItemController.swift` around lines 324 -
349, daysInPeriod currently returns only today for the .today_n_tomorrow case;
update the .today_n_tomorrow branch in the daysInPeriod(_:,from:,calendar:)
function so it returns an array containing today and tomorrow by using
calendar.date(byAdding: .day, value: 1, to: today) to compute tomorrow (preserve
ordering [today, tomorrow] and safe unwrap similar to other cases).

Comment on lines +398 to +417
case .fiveDays, .sevenDays, .workWeek:
let calendar = Calendar.current
let dayDates = Self.daysInPeriod(Defaults[.showEventsForPeriod], from: today, calendar: calendar)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "E, d MMM"
dateFormatter.locale = I18N.instance.locale
for (index, dayStart) in dayDates.enumerated() {
if index > 0 {
statusItemMenu.addItem(NSMenuItem.separator())
}
let dayEvents = events.filter { calendar.isDate($0.startDate, inSameDayAs: dayStart) }
let sectionTitle: String
if calendar.isDate(dayStart, inSameDayAs: today) {
sectionTitle = "status_bar_section_today".loco()
} else if calendar.isDate(dayStart, inSameDayAs: tomorrow) {
sectionTitle = "status_bar_section_tomorrow".loco()
} else {
sectionTitle = dateFormatter.string(from: dayStart)
}
statusItemMenu.items += builder.buildDateSection(date: dayStart, title: sectionTitle, events: dayEvents)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Avoid duplicated date labels in multi‑day sections.

buildDateSection already appends the formatted date, so using a full date as sectionTitle yields headers like “Tue, 25 Feb (Tue, 25 Feb):”. Consider passing a weekday-only title instead.

✅ Suggested fix
-                let dateFormatter = DateFormatter()
-                dateFormatter.dateFormat = "E, d MMM"
-                dateFormatter.locale = I18N.instance.locale
+                let weekdayFormatter = DateFormatter()
+                weekdayFormatter.dateFormat = "EEEE"
+                weekdayFormatter.locale = I18N.instance.locale
                 for (index, dayStart) in dayDates.enumerated() {
@@
                     } else if calendar.isDate(dayStart, inSameDayAs: tomorrow) {
                         sectionTitle = "status_bar_section_tomorrow".loco()
                     } else {
-                        sectionTitle = dateFormatter.string(from: dayStart)
+                        sectionTitle = weekdayFormatter.string(from: dayStart)
                     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@MeetingBar/UI/StatusBar/StatusBarItemController.swift` around lines 398 -
417, The section title for multi-day periods uses a full date string but
buildDateSection(date: title: events:) already appends the formatted date,
causing duplicated labels; change the else branch that sets sectionTitle (using
dateFormatter) to produce only the weekday (e.g., use a DateFormatter with
format "E" or fetch the localized weekday name) so sectionTitle is just the
weekday name, keeping the existing special-cases for today/tomorrow and leaving
builder.buildDateSection as-is.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 38.01653% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.40%. Comparing base (84e0a9f) to head (16a2d9c).

Files with missing lines Patch % Lines
...tingBar/UI/StatusBar/StatusBarItemController.swift 0.00% 40 Missing ⚠️
MeetingBar/Core/Managers/EventManager.swift 22.72% 17 Missing ⚠️
MeetingBar/Core/Models/MBEvent+Helpers.swift 40.00% 12 Missing ⚠️
...eetingBar/UI/Views/Preferences/AppearanceTab.swift 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #893       +/-   ##
===========================================
+ Coverage   26.30%   36.40%   +10.10%     
===========================================
  Files          36       48       +12     
  Lines        5645     5216      -429     
  Branches     2210     1771      -439     
===========================================
+ Hits         1485     1899      +414     
+ Misses       4103     3260      -843     
  Partials       57       57               

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@CampAsAChamp CampAsAChamp changed the title Event and status bar UI improvements Add options for 5 days, 7 days, and work week Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants