Skip to content

fix: smart alarm feature fails to fetch when application is not opened for a long period of time#33

Open
erik-keifer wants to merge 5 commits into
mainfrom
erik-keifer-patch-2
Open

fix: smart alarm feature fails to fetch when application is not opened for a long period of time#33
erik-keifer wants to merge 5 commits into
mainfrom
erik-keifer-patch-2

Conversation

@erik-keifer

@erik-keifer erik-keifer commented Apr 5, 2026

Copy link
Copy Markdown
Collaborator
  • Remove "✅ Fix:" prefix from comments to match codebase style
  • Remove trailing blank lines at end of file
  • Reintroduce InsightsStore as @StateObject and inject via .environmentObject

Fix: refresh smart alarm guidance when app returns to foreground

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the app lifecycle handling to refresh smart alarm guidance when the app returns to the foreground.

Changes:

  • Observes scenePhase in SleepFocusApp and triggers a forced refresh of smart alarm guidance when the app becomes active.
  • Syncs smart alarm runtime (notifications / live activity) after the foreground refresh.
  • Removes InsightsStore wiring from the app root.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SleepFocus/SleepFocusApp.swift
Comment thread SleepFocus/SleepFocusApp.swift Outdated
Comment thread SleepFocus/SleepFocusApp.swift Outdated
Copilot AI requested a review from austinkimchi April 5, 2026 05:52
@austinkimchi austinkimchi changed the title Update SleepFocusApp.swift fix: smart alarm feature fails to fetch when application is not opened for a long period of time Apr 5, 2026
@austinkimchi

Copy link
Copy Markdown
Member

@erik-keifer
How is this change going to fix #11?
The issue outlines that there's an issue with the smart alarm output not being properly calculated.
But your solution proposes to refresh the smart alarm on application launch.

  1. Note that the application is already loaded in memory and not refreshed, so this code won't be triggered.
  2. The issue outlines that there is an issue with sending requests to the backend specifically.

I believe this might have been fixed with commit 6e27cae.
I am postponing this patch until it can be further verified that it still exists.

@austinkimchi

Copy link
Copy Markdown
Member

@copilot, please verify if this entire issue has been addressed and fixed in the next version #39.

Copilot AI commented Apr 7, 2026

Copy link
Copy Markdown

@copilot, please verify if this entire issue has been addressed and fixed in the next version #39.

After reviewing PR #39 and commit 6e27cae, the issue described in #11 is not fixed in either:

  • Commit 6e27cae (feat: generated ai recommendation) doesn't touch the smart alarm fetch path at all.
  • PR add feat watch sleep onset detection #39 adds a new .automatic watch-based mode, but its version of SleepFocusApp.swift drops the scenePhase observer introduced in this PR — meaning the foreground-refresh fix would be lost if add feat watch sleep onset detection #39 is merged without this PR's changes.

The fix in this PR (observing scenePhase and force-refreshing smart alarm guidance when the app returns to the foreground) still targets the root cause described in #11 and is not covered elsewhere. It should be merged or rebased on top of #39.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SleepFocus/SleepFocusApp.swift
austinkimchi and others added 2 commits April 7, 2026 11:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

Bug: Smart Alarm feature fails to fetch when application is not opened for a long period of time

4 participants