Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Plan: Auto-refresh WebViewController after 5+ minutes in background

  • 1. Add background timestamp tracking in WebViewController
    • Add property to store timestamp when app enters background
    • Update timestamp in appropriate lifecycle method
  • 2. Implement 5-minute check in foreground activation
    • Check elapsed time when app returns to foreground
    • Trigger refresh if 5+ minutes have passed
  • 3. Integrate with existing lifecycle hooks
    • Use sceneDidEnterBackground to track timestamp
    • Use sceneDidBecomeActive to check and refresh
  • 4. Test the implementation
    • Add unit tests for the time tracking logic
    • Verify refresh is triggered correctly
  • 5. Address code review feedback
    • Extract 5-minute threshold to named constant
    • Make backgroundTimestamp internal for better test access
    • Add documentation comments
    • Fix boundary condition in tests
  • 6. Add user setting to control behavior
    • Add refreshWebViewAfterInactive setting to SettingsStore (defaults to ON)
    • Add toggle in General Settings UI under Page section
    • Add localization string "Refresh After 5 Min Inactive"
    • Update WebViewSceneDelegate to check setting before refreshing
    • Add test to verify setting is respected
  • 7. Improve test quality
    • Add test isolation by saving/restoring settings in tearDown
    • Add boundary test for exactly 5 minutes
    • Add explicit setting control in timestamp clearing test
    • Add clarifying comment about Guarantee promise type
  • 8. Fix SwiftFormat lint issues
    • Remove trailing spaces
    • Remove redundant self. in test expectations
    • Remove redundant internal keyword
    • Simplify optional binding with Swift 5.7+ syntax

Summary

Successfully implemented auto-refresh functionality with user-configurable setting:

  • Setting located in: Companion app settings > General > Page > "Refresh After 5 Min Inactive"
  • Defaults to ON
  • When enabled, WebViewController refreshes after 5+ minutes in background
  • When disabled, no automatic refresh occurs
  • Full test coverage including boundary conditions and setting states
  • All code quality checks passing
Original prompt

If uswrs opens the app after 5 minutes or more since last open, WebViewController should refesh.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 28, 2026 15:18
…round

Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
…add documentation

Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Copilot AI changed the title [WIP] Add refresh functionality for WebViewController after inactivity Auto-refresh WebViewController after 5+ minutes in background Jan 28, 2026
Copilot AI requested a review from bgoncal January 28, 2026 15:26
@bgoncal
Copy link
Member

bgoncal commented Jan 28, 2026

@copilot Add setting under Companion app settings > General > "Refresh after 5 inactive", defaults to ON

Copilot AI and others added 2 commits January 28, 2026 15:55
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
…romise comment

Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 28, 2026

@copilot Add setting under Companion app settings > General > "Refresh after 5 inactive", defaults to ON

Added setting in General settings under the Page section: "Refresh After 5 Min Inactive" (defaults to ON). The setting controls whether WebViewController auto-refreshes after 5+ minutes of inactivity.

Implemented in commits 011530a and 6c5f946.

Setting location: Settings → General → Page section
Default: ON (enabled)
Full test coverage including boundary conditions and setting states.

Copilot AI changed the title Auto-refresh WebViewController after 5+ minutes in background Add auto-refresh for WebViewController after 5+ minutes in background with user setting Jan 28, 2026
@bgoncal
Copy link
Member

bgoncal commented Jan 28, 2026

@copilot fix lint issues based on report below

Running SwiftFormat... (lint mode - no files will be changed.) /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:55:1: warning: (redundantSelf) Insert/remove explicit self where applicable. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:80:1: warning: (redundantSelf) Insert/remove explicit self where applicable. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:99:1: warning: (trailingSpace) Remove trailing space at end of a line. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:108:1: warning: (redundantSelf) Insert/remove explicit self where applicable. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:127:1: warning: (trailingSpace) Remove trailing space at end of a line. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:136:1: warning: (redundantSelf) Insert/remove explicit self where applicable. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:155:1: warning: (trailingSpace) Remove trailing space at end of a line. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:164:1: warning: (redundantSelf) Insert/remove explicit self where applicable. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:183:1: warning: (trailingSpace) Remove trailing space at end of a line. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:192:1: warning: (redundantSelf) Insert/remove explicit self where applicable. /home/runner/work/iOS/iOS/Tests/App/Scenes/WebViewSceneDelegate.test.swift:210:1: warning: (redundantSelf) Insert/remove explicit self where applicable. /home/runner/work/iOS/iOS/Sources/App/Scenes/WebViewSceneDelegate.swift:13:1: warning: (trailingSpace) Remove trailing space at end of a line. /home/runner/work/iOS/iOS/Sources/App/Scenes/WebViewSceneDelegate.swift:15:1: warning: (redundantInternal) Remove redundant internal access control. /home/runner/work/iOS/iOS/Sources/App/Scenes/WebViewSceneDelegate.swift:16:1: warning: (trailingSpace) Remove trailing space at end of a line. /home/runner/work/iOS/iOS/Sources/App/Scenes/WebViewSceneDelegate.swift:128:1: warning: (trailingSpace) Remove trailing space at end of a line. /home/runner/work/iOS/iOS/Sources/App/Scenes/WebViewSceneDelegate.swift:140:1: warning: (trailingSpace) Remove trailing space at end of a line. /home/runner/work/iOS/iOS/Sources/App/Scenes/WebViewSceneDelegate.swift:142:1: warning: (redundantOptionalBinding) Remove redundant identifiers in optional binding conditions. /home/runner/work/iOS/iOS/Sources/App/Scenes/WebViewSceneDelegate.swift:144:1: warning: (trailingSpace) Remove trailing space at end of a line. /home/runner/work/iOS/iOS/Sources/App/Scenes/WebViewSceneDelegate.swift:152:1: warning: (trailingSpace) Remove trailing space at end of a line. SwiftFormat completed in 7.45s

…redundant internal

Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 28, 2026

@copilot fix lint issues based on report below

`Running SwiftFormat...
...

Fixed all SwiftFormat lint issues in commit 4c811f3:

  • Removed trailing spaces
  • Removed redundant self. prefixes in test expectations
  • Removed redundant internal access modifier
  • Simplified optional binding to if let backgroundTimestamp (Swift 5.7+ syntax)

@bgoncal bgoncal marked this pull request as ready for review January 28, 2026 17:07
Copilot AI review requested due to automatic review settings January 28, 2026 17:07
@bgoncal bgoncal enabled auto-merge (squash) January 28, 2026 17:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-out setting that automatically refreshes the app’s WebViewController when returning to the foreground after being in the background for 5+ minutes.

Changes:

  • Track a background timestamp in WebViewSceneDelegate and refresh the WebView on reactivation when elapsed time ≥ 5 minutes (and setting enabled).
  • Add a new SettingsStore.refreshWebViewAfterInactive preference (default ON) and expose it via a new toggle in General Settings.
  • Add unit tests intended to validate timestamp tracking, threshold behavior, and setting enable/disable behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/App/Scenes/WebViewSceneDelegate.test.swift Adds tests for background timestamp + refresh behavior and setting gating.
Sources/Shared/Settings/SettingsStore.swift Introduces refreshWebViewAfterInactive boolean setting (default ON).
Sources/Shared/Resources/Swiftgen/Strings.swift Adds Swiftgen accessor for the new localized settings title.
Sources/App/Settings/General/GeneralSettingsView.swift Adds a toggle UI under General → Page for the new setting.
Sources/App/Scenes/WebViewSceneDelegate.swift Implements timestamp tracking + conditional refresh on foreground.
Sources/App/Resources/en.lproj/Localizable.strings Adds English localization for the new setting label.

Relocated the RefreshAfterInactive string enum in Swiftgen/Strings.swift for better organization. Removed the WebViewSceneDelegate test file, possibly as part of test cleanup or refactoring.
@bgoncal bgoncal merged commit 35e52f7 into main Jan 29, 2026
12 checks passed
@bgoncal bgoncal deleted the copilot/refresh-webview-after-timeout branch January 29, 2026 09:02
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@2e5f992). Learn more about missing BASE report.

Files with missing lines Patch % Lines
Sources/Shared/Settings/SettingsStore.swift 0.00% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4269   +/-   ##
=======================================
  Coverage        ?   43.15%           
=======================================
  Files           ?      261           
  Lines           ?    15079           
  Branches        ?        0           
=======================================
  Hits            ?     6508           
  Misses          ?     8571           
  Partials        ?        0           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants