Skip to content

Add time data source format style support#889

Merged
Kyle-Ye merged 3 commits into
mainfrom
feature/format_style
Jun 1, 2026
Merged

Add time data source format style support#889
Kyle-Ye merged 3 commits into
mainfrom
feature/format_style

Conversation

@Kyle-Ye
Copy link
Copy Markdown
Member

@Kyle-Ye Kyle-Ye commented Jun 1, 2026

Agent Summary

This PR adds time-based discrete format style support for text rendering.

  • Add TimeDataSource support for current dates, duration offsets, and date ranges.
  • Add Text and LocalizedStringKey.StringInterpolation overloads for discrete time-based format styles.
  • Introduce TimeDataFormatting storage and resolution plumbing for live text updates.
  • Split format-style environment hooks into dedicated files for calendar, time zone, capitalization context, interface idiom, text alignment, update frequency, content transition, and safe serialization support.
  • Add update-frequency and content-transition behavior used by time-sensitive text formatting.
  • Keep the new format-style plumbing buildable on Linux.

Testing

  • git diff --check
  • swiftc -typecheck Sources/OpenSwiftUICore/View/Text/FormatStyle/TimeZoneDependentFormatStyle.swift
  • ssh ubuntu@orb 'cd /Volumes/Workspace/OpenSwiftUI-Mono/Worktrees/feature_format_style/OpenSwiftUI && export OPENSWIFTUI_LIB_SWIFT_PATH="$(swiftly use --print-location)/usr/lib/swift" && swift build --jobs 1'\n

@github-actions github-actions Bot added area: animation Animation, transitions, transactions, or timing behavior. area: text Text, labels, line style, and text rendering APIs. type: feature New API, behavior, platform support, or user-facing capability. labels Jun 1, 2026
@Kyle-Ye Kyle-Ye marked this pull request as ready for review June 1, 2026 15:57
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Jun 1, 2026

🤖 Augment PR Summary

Summary: This PR adds infrastructure for time-based discrete format styles so Text can render live-updating time values (dates, offsets, and ranges).

Changes:

  • Introduces TimeDataSource and codable TimeDataSourceStorage backends for Date, Duration, and Range<Date>.
  • Adds new Text initializers and LocalizedStringKey.StringInterpolation overloads for DiscreteFormatStyle-based time formatting.
  • Adds TimeDataFormatting resolvable attribute plumbing and a TimeDataFormattingStorage implementation to resolve formatted output in an environment.
  • Splits environment-dependent format style hooks into dedicated protocols (calendar, time zone, text alignment, capitalization context, interface idiom, update frequency, content transition, safe serialization).
  • Adds a ContentTransition.numericText(countsDown:) API and keeps older overloads available via deprecation.
  • Adjusts Bundle.kit resolution to keep the new format-style pipeline buildable on non-Darwin platforms.

Technical Notes: The new storage resolves format styles using environment locale/calendar/time zone and derives an update-frequency budget based on interface idiom (widget/complication/etc.), with placeholders for future scheduling/serialization work.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

return format.format(value).attributedString
}

var schedule: Schedule? {
Copy link
Copy Markdown

@augmentcode augmentcode Bot Jun 1, 2026

Choose a reason for hiding this comment

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

Sources/OpenSwiftUICore/View/Text/FormatStyle/TimeDataFormatting.swift:106: schedule currently returns nil (and entries returns an empty sequence), which makes ResolvableStringAttribute.isDynamic false so time-based Text won’t auto-update over time. Was the intent to return a non-nil schedule here to drive timeline invalidation?

Severity: high

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

NSAttributedString.Key("OpenSwiftUITimeDataFormatting")
}

static func decode(from decoder: any Decoder) throws -> (any ResolvableStringAttribute)? {
Copy link
Copy Markdown

@augmentcode augmentcode Bot Jun 1, 2026

Choose a reason for hiding this comment

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

Sources/OpenSwiftUICore/View/Text/FormatStyle/TimeDataFormatting.swift:19: decode(from:) always returns nil (and encode is a no-op), so TimeDataFormatting attributes can’t round-trip through archiving/serialization and may be dropped. If this is meant to support “safe serialization”, it likely needs an actual implementation.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@github-actions github-actions Bot added the platform: Linux Linux-specific behavior or support. label Jun 1, 2026
@Kyle-Ye Kyle-Ye marked this pull request as draft June 1, 2026 16:08
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 0% with 402 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.52%. Comparing base (60a2593) to head (747aeea).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ew/Text/FormatStyle/Text+DiscreteFormatStyle.swift 0.00% 273 Missing ⚠️
...ore/View/Text/FormatStyle/TimeDataFormatting.swift 0.00% 71 Missing ⚠️
...ext/FormatStyle/CalendarDependentFormatStyle.swift 0.00% 26 Missing ⚠️
...ext/FormatStyle/TimeZoneDependentFormatStyle.swift 0.00% 24 Missing ⚠️
...ICore/Animation/Transition/ContentTransition.swift 0.00% 5 Missing ⚠️
Sources/OpenSwiftUICore/View/Text/Text/Text.swift 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #889      +/-   ##
==========================================
- Coverage   26.73%   26.52%   -0.22%     
==========================================
  Files         686      689       +3     
  Lines       47796    48193     +397     
==========================================
+ Hits        12778    12781       +3     
- Misses      35018    35412     +394     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kyle-Ye Kyle-Ye force-pushed the feature/format_style branch from 2ec9bdc to 747aeea Compare June 1, 2026 16:30
@Kyle-Ye Kyle-Ye marked this pull request as ready for review June 1, 2026 16:39
Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

guard let other = other as? TimeDataFormattingStorage<Source, Format> else {
return false
}
return source == other.source && format == other.format
Copy link
Copy Markdown

@augmentcode augmentcode Bot Jun 1, 2026

Choose a reason for hiding this comment

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

Sources/OpenSwiftUICore/View/Text/FormatStyle/Text+DiscreteFormatStyle.swift:687: TimeDataFormattingStorage.isEqual(to:) ignores reducedLuminanceBudget, but that value changes the computed secondsUpdateFrequencyBudget (and potentially formatting behavior) in resolve. This could cause two storages with different reduced-luminance behavior to compare equal and lead to stale rendering/caching decisions.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@Kyle-Ye Kyle-Ye merged commit 7f79072 into main Jun 1, 2026
6 of 7 checks passed
@Kyle-Ye Kyle-Ye deleted the feature/format_style branch June 1, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: animation Animation, transitions, transactions, or timing behavior. area: text Text, labels, line style, and text rendering APIs. platform: Linux Linux-specific behavior or support. type: feature New API, behavior, platform support, or user-facing capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant