Skip to content

fix(#340): keep the widget loading and refreshing - #342

Merged
cassio-rossi merged 2 commits into
release/v5from
factory/002-widget-menor-quebrado
Nov 18, 2026
Merged

cassio-rossi merged 2 commits into
release/v5from
factory/002-widget-menor-quebrado

Conversation

@cassio-rossi

Copy link
Copy Markdown
Collaborator

Closes #340

Summary

  • Thumbnails are downloaded in parallel (10 s timeout each), only for the posts the widget family shows, and downscaled with ImageIO before they reach the timeline entry.
  • The feed fetch races a 15 s deadline; the loser is cancelled.
  • getTimeline uses .after(...): 30 min after success, 15 min after a failed or empty fetch (.atEnd removed).
  • The last good posts are cached per family in the Caches directory and shown when a fetch fails, so the widget no longer blanks.
  • New FeedLibrary helpers (WidgetImageDownscaler, WidgetRefreshSchedule, WidgetPostsCache) with Swift Testing suites.

🤖 Generated with Claude Code

cassio-rossi and others added 2 commits November 18, 2026 19:06
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…last good posts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cassio-rossi
cassio-rossi marked this pull request as ready for review November 18, 2026 19:12
@cassio-rossi

Copy link
Copy Markdown
Collaborator Author

Factory: needs a human

Summary

  • Fixes issue Widget menor quebrado? #340, where the small widget froze after one or two updates, by changing the iOS Widget's timeline provider. The feed fetch now has a 15 s limit. Only the thumbnails the widget size shows are downloaded, in parallel, with a 10 s timeout each, and they are shrunk before use. The widget refreshes every 30 min, or 15 min after a failure, and falls back to the last good posts when a fetch fails.
  • The new logic sits in three FeedLibrary helpers with Swift Testing suites. All 10 acceptance criteria are met. Round 1 checks passed and all three reviews passed.
  • This must be escalated because it changes the Widget target (MacMagazine/Widget/Timeline/MacMagazineTimelineProvider.swift), which ships separately. That rule always sends the change to a human.
  • Nobody has seen the widget run on a device, and the watchOS build of FeedLibrary was not checked.

Why

The change itself looks correct and stays in scope: the diff touches only the timeline provider, new FeedLibrary files and the data-layer doc. Checks are GATE: PASS and the code, UI and UX reviews are all VERDICT: PASS. But the project rules say any change to the Widget target needs a human, and WidgetKit's refresh behaviour can't be tested by the factory's checks. Someone has to watch the widget refresh on a real device before this ships.

Acceptance criteria

  1. No .atEnd, has .after(: met. I ran the grep myself: the only match is line 32, policy: .after(nextUpdate).
  2. Thumbnail timeout: met. I checked line 104, URLRequest(url: thumbnailUrl, timeoutInterval: imageTimeout). No bare URLRequest(url: thumbnailUrl) is left.
  3. Parallel downloads, only for the visible count: met. withImages uses withTaskGroup over posts.prefix(count). imageCount(for:) gives 1 for small and the accessory sizes, 2 for medium and 3 for large.
  4. Feed deadline: met. fetchWithDeadline races getWidgetData() against Task.sleep(for: .seconds(15)) and calls cancelAll() on the loser. The code review notes the limit holds only because the network layer stops when cancelled, which it does today.
  5. No raw bytes in imageData: met. Every image comes from WidgetImageDownscaler.downscale or is nil.
  6. Per-family cache and 30/15-minute intervals: met. A failed or empty fetch returns (cache.load(), false). A successful one saves the posts and returns true. The cache file is widget-posts-<family>.json in Caches.
  7. Swift Testing suites exist and pass: met. The three suites use @Suite/@Test, FeedLibraryTests is in the test plan, and build.md reports them passed. One MacMagazineLibraryTests bundle failed to load ("unsigned library") because of local code signing. This branch doesn't touch that module.
  8. No UIKit in FeedLibrary sources: met. I ran the grep myself and it found nothing.
  9. Docs updated: met. The iOS Widget bullet in .claude/rules/data-layer.md is updated.
  10. Diff scope: met. git diff --stat lists only the allowed paths.

For the human

You need to decide whether to merge a change to the iOS Widget extension, which ships separately. Before merging, please check:

  • On device: add the small widget and the medium widget. Confirm both load and that the small widget refreshes past the first update; the refresh is set for about 30 minutes. Then turn on airplane mode and confirm the small widget keeps its last posts instead of showing "Nenhum conteúdo disponível.". If you can, check the iPhone widget on a Mac too, since that is where the issue says it never loaded.
  • Thumbnail look: thumbnails are now JPEG, so a transparent PNG thumbnail would get a black background. Check that the small widget's full-bleed image still looks sharp.
  • watchOS build: the WatchApp and WatchWidget targets use FeedLibrary, which now has three new files that use ImageIO and UniformTypeIdentifiers. checks.sh builds only for iPhone. Build the WatchApp scheme once to confirm it compiles.
  • Signing failure: in the local test run, the MacMagazineLibraryTests bundle couldn't load because the library was unsigned. Confirm this happens on release/v5 too and was not caused by this branch.

Files to look at:

  • MacMagazine/Widget/Timeline/MacMagazineTimelineProvider.swift
  • MacMagazine/Features/FeedLibrary/Sources/FeedLibrary/Services/WidgetImageDownscaler.swift
  • MacMagazine/Features/FeedLibrary/Sources/FeedLibrary/Services/WidgetPostsCache.swift
  • MacMagazine/Features/FeedLibrary/Sources/FeedLibrary/Services/WidgetRefreshSchedule.swift

@cassio-rossi
cassio-rossi merged commit 0853cfc into release/v5 Nov 18, 2026
2 checks passed
@cassio-rossi
cassio-rossi deleted the factory/002-widget-menor-quebrado branch November 18, 2026 19:57
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.

Widget menor quebrado?

1 participant