Skip to content

Share how a Workday looks between app and widget - #42

Merged
64x-lunicorn merged 5 commits into
mainfrom
refactor/shared-workday-appearance
Sep 14, 2026
Merged

64x-lunicorn merged 5 commits into
mainfrom
refactor/shared-workday-appearance

Conversation

@64x-lunicorn

Copy link
Copy Markdown
Owner

What does this PR do?

Moves the mapping from tracking state and Threshold Level to colour, label and duration text into one module in Shared/, used by both the app and the widget.

  • Typed widget snapshot:

    • The state is a typed WorkdayState, moved out of WorkdayManager.State.
    • The snapshot carries a thresholdLadder instead of the colour-named orangeThreshold/redThreshold fields.
    • Snapshots are stored under widget_snapshot_v2. A value left under v1 is ignored: the widget shows "unavailable" until the app's next publish, which happens on launch.
  • Shared/WorkdayAppearance.swift:

    • one palette, holding the app's light/dark values;
    • the colour per state and per Threshold Level;
    • label keys for both targets.

    Duration formatting (08:05) lives in Shared/TimeInterval+Duration.swift.

  • Widget: the duplicated colour, label and progress switches and all hex values are gone. Visible change, as decided:

    • The widget uses the app's palette.
    • At normal level the dot follows the state (running green, paused orange, ended blue) and the progress ring is green.
    • Durations show two-digit hours (08:05). The live running counter is unchanged.
  • App: the menu bar, popover badge, log editor chip, progress bar, week history and log list all read from the shared module. The app's look is unchanged: a test pins the palette values, and the menu bar keeps native rendering at normal level.

How to test?

  • Automated: xcodebuild test -scheme OpenWorktimeTrackerTests runs 275 tests. WorkdayAppearanceTests, WidgetSnapshotTests and WorkdayManagerClockAndStoreTests pass.
    • Known failure (also on main at b6aa5e5): ViewLayoutTests.testSettingsRowsRemainReadableInBothLanguagesAndAppearances fails with 7 OCR assertions.
  • Manual (pending):
    • Look at the small and medium widget in light and dark mode.
    • Compare the widget side by side with the menu bar and popover in every state (running, paused, ended; normal, elevated, critical).

Notes

  • Overlap with the other refactor PR: it touches WorkdayManager and project.pbxproj. Whichever merges second may need a quick rebase. CI regenerates the project with XcodeGen.
  • Not linted: .swiftlint.yml does not include Shared/ or WorktimeWidget/, so the new shared code isn't linted.

Checklist

  • Tests pass (make test): everything except the OCR test above, which also fails on main
  • Linting passes (make lint): 0 serious, same 5 length warnings as main
  • No new external dependencies added
  • Uses @Observable (not ObservableObject)
  • Uses DesignTokens for colors/typography (DesignTokens now reads its accents from the shared palette)

🤖 Generated with Claude Code

https://claude.ai/code/session_01WFc8P7zoT4V7GQaqwegkcm

Lunicorn-lab and others added 5 commits September 14, 2026 21:10
Move the tracking state out of WorkdayManager into Shared as WorkdayState
so the widget compares a real type instead of strings, and publish the
Threshold Ladder as one value instead of colour-named threshold fields.
A snapshot stored by the previous version fails to decode and reads as
unavailable until the app publishes again.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WFc8P7zoT4V7GQaqwegkcm
Add a shared appearance module holding the palette, the colour and label
of each tracking state, the indicator and progress colours per Threshold
Level, and the two-digit-hour duration format. Both widget sizes take
colour, label and duration text from it, so the widget adopts the app's
palette and shows durations as 08:05. DesignTokens reads its accents from
the shared palette so the hex values live in one place.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WFc8P7zoT4V7GQaqwegkcm
…rance

The menu bar, popover badge, log editor chip and every Threshold Level
accent now ask the shared appearance module. DesignTokens keeps the
palette but no longer maps states or Threshold Levels to colours. The
menu bar still leaves the normal level to native rendering, and the
app's visible colours are unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WFc8P7zoT4V7GQaqwegkcm
Rename the snapshot's Threshold Ladder field, store snapshots under a
versioned key so an older format reads as unavailable, move duration
formatting into its own shared file and pin the palette's values.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WFc8P7zoT4V7GQaqwegkcm
@64x-lunicorn
64x-lunicorn merged commit 0b66c96 into main Sep 14, 2026
2 checks passed
@64x-lunicorn
64x-lunicorn deleted the refactor/shared-workday-appearance branch September 14, 2026 20:35
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.

2 participants