Bug: "Working Today" in Day view only shows day shift, not overnight and night shifts #84

Closed
opened 2026-05-21 09:47:52 -04:00 by owlburtoe · 2 comments
Owner

Bug: "Working Today" in Day view only shows day shift, not overnight and night shifts

Description

Previously, there was a bug where shifts were being split by staff tags (regular, call, hot) instead of grouping staff into a single collapsible shift row. This was fixed, but a new issue has emerged: only the day shift populates in the "Working Today" section of the Day view.

Goal

The "Working Today" section should display all active shifts in chronological order, with proper grouping by shift and tag differentiation. The behavior should match the staff web app:

  • Staff whose shifts span midnight (started yesterday, end today) should be labeled explicitly and sorted first (e.g., "Overnight from [time]")
  • Shifts should appear in chronological order: overnight (spans midnight) → day shift → night shift
  • Tags (regular, call, hot) are used to differentiate staff within a shift, not to create separate shift groups
  • Note: "Overnight" is not a shift entity — it's a grouping for shifts that started yesterday and continue into today

Acceptance Criteria

  • All tests pass
  • UI correctly displays shifts and groups staff by shift, not by tags
  • Mobile app builds with zero errors
  • Full test suite passes (even if agent didn't cause existing failures)
## Bug: "Working Today" in Day view only shows day shift, not overnight and night shifts ### Description Previously, there was a bug where shifts were being split by staff tags (regular, call, hot) instead of grouping staff into a single collapsible shift row. This was fixed, but a new issue has emerged: only the day shift populates in the "Working Today" section of the Day view. ### Goal The "Working Today" section should display **all active shifts** in chronological order, with proper grouping by shift and tag differentiation. The behavior should match the staff web app: - Staff whose shifts span midnight (started yesterday, end today) should be labeled explicitly and sorted first (e.g., "Overnight from [time]") - Shifts should appear in chronological order: overnight (spans midnight) → day shift → night shift - Tags (regular, call, hot) are used to differentiate staff **within** a shift, not to create separate shift groups - Note: "Overnight" is not a shift entity — it's a grouping for shifts that started yesterday and continue into today ### Acceptance Criteria - [ ] All tests pass - [ ] UI correctly displays shifts and groups staff by shift, not by tags - [ ] Mobile app builds with zero errors - [ ] Full test suite passes (even if agent didn't cause existing failures)
Author
Owner

Hermes saw this issue and queued it for attention.

Labels detected: agent:hermes + status:ready.
Telegram notification sent by the Shiftd Hermes issue watchdog.

Next step: ask Hermes to work issue #84 when you want implementation to start.

Hermes saw this issue and queued it for attention. Labels detected: `agent:hermes` + `status:ready`. Telegram notification sent by the Shiftd Hermes issue watchdog. Next step: ask Hermes to `work issue #84` when you want implementation to start.
Author
Owner

Hermes reviewed this issue and prepared a small, focused iOS change set.

Root cause

Working Today was built from ScheduleDerivation.coworkerGroups(...), but that derivation only kept shift groups containing the current user:

group.members.contains { $0.staffId == currentStaffId && $0.isCurrentUser }

So if the logged-in staff member was only on the day shift, the Day view only showed that day shift — even though overnight carryover and night shift groups were active that day.

Proposed / prepared changes

Files changed locally:

  • apps/ios/Shiftd/Features/Schedule/Models/ScheduleDerivation.swift
  • apps/ios/ShiftdTests/ScheduleDerivationTests.swift

Behavior changes:

  • Working Today now includes every active shift group for the selected day, not only shifts containing the current user.
  • Empty groups are still dropped.
  • Overnight carryover groups remain sorted first.
  • Day shift then night shift remain chronological.
  • Shift visible dates now use the effective shift timing, so per-shift start/end overrides are respected for carryover detection.

Key production change:

let groups = map.values.filter { group in
    !group.members.isEmpty
}

instead of filtering only for the current user.

Tests added / updated

Added regression coverage:

  • testCoworkerGroupsIncludeEveryActiveShiftOnSelectedDay

This verifies that a selected day containing:

  1. overnight carryover from yesterday
  2. day shift today
  3. night shift today

renders all three groups in order:

["overnight", "day", "night"]

Also updated the called-out-current-user test so an active shift still appears if other staff are working, even when the current user is called out.

Validation

Ran:

git diff --check

Result: clean.

Attempted focused Swift test:

cd apps/ios && swift test --filter ScheduleDerivationTests/testCoworkerGroupsIncludeEveryActiveShiftOnSelectedDay

But this Linux host does not have Swift installed:

swift: command not found

So this is currently a local diff and still needs final validation on macOS/Xcode.

Current diff size:

2 files changed, 69 insertions(+), 5 deletions(-)

Note: there was already an unrelated untracked apps/mobile/ path; Hermes did not touch it.

Hermes reviewed this issue and prepared a small, focused iOS change set. ## Root cause `Working Today` was built from `ScheduleDerivation.coworkerGroups(...)`, but that derivation only kept shift groups containing the current user: ```swift group.members.contains { $0.staffId == currentStaffId && $0.isCurrentUser } ``` So if the logged-in staff member was only on the day shift, the Day view only showed that day shift — even though overnight carryover and night shift groups were active that day. ## Proposed / prepared changes Files changed locally: - `apps/ios/Shiftd/Features/Schedule/Models/ScheduleDerivation.swift` - `apps/ios/ShiftdTests/ScheduleDerivationTests.swift` Behavior changes: - `Working Today` now includes every active shift group for the selected day, not only shifts containing the current user. - Empty groups are still dropped. - Overnight carryover groups remain sorted first. - Day shift then night shift remain chronological. - Shift visible dates now use the effective shift timing, so per-shift start/end overrides are respected for carryover detection. Key production change: ```swift let groups = map.values.filter { group in !group.members.isEmpty } ``` instead of filtering only for the current user. ## Tests added / updated Added regression coverage: - `testCoworkerGroupsIncludeEveryActiveShiftOnSelectedDay` This verifies that a selected day containing: 1. overnight carryover from yesterday 2. day shift today 3. night shift today renders all three groups in order: ```swift ["overnight", "day", "night"] ``` Also updated the called-out-current-user test so an active shift still appears if other staff are working, even when the current user is called out. ## Validation Ran: ```bash git diff --check ``` Result: clean. Attempted focused Swift test: ```bash cd apps/ios && swift test --filter ScheduleDerivationTests/testCoworkerGroupsIncludeEveryActiveShiftOnSelectedDay ``` But this Linux host does not have Swift installed: ```text swift: command not found ``` So this is currently a local diff and still needs final validation on macOS/Xcode. Current diff size: ```text 2 files changed, 69 insertions(+), 5 deletions(-) ``` Note: there was already an unrelated untracked `apps/mobile/` path; Hermes did not touch it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
owlburtoe/Shiftd#84
No description provided.