-
Notifications
You must be signed in to change notification settings - Fork 1
Cache AI response in memory while inside the screen #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,7 @@ private extension OverviewView { | |
| } | ||
| .cornerRadius(CGFloat(.cardCornerRadius)) | ||
| } | ||
| .wxmShadow() | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,9 +32,6 @@ struct StationSupportView: View { | |
| .padding() | ||
| } | ||
| } | ||
| .task { | ||
| viewModel.refresh() | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4965,7 +4965,7 @@ | |
| ); | ||
| GENERATE_INFOPLIST_FILE = YES; | ||
| INFOPLIST_FILE = "wxm-ios/Info.plist"; | ||
| INFOPLIST_KEY_CFBundleDisplayName = "WXM Dev"; | ||
| INFOPLIST_KEY_CFBundleDisplayName = "WXM Mock"; | ||
| INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; | ||
| INFOPLIST_KEY_LSApplicationCategoryType = ""; | ||
| INFOPLIST_KEY_LSSupportsOpeningDocumentsInPlace = YES; | ||
|
|
@@ -5192,7 +5192,7 @@ | |
| ); | ||
| GENERATE_INFOPLIST_FILE = YES; | ||
| INFOPLIST_FILE = "wxm-ios/Info.plist"; | ||
| INFOPLIST_KEY_CFBundleDisplayName = "WXM Dev"; | ||
| INFOPLIST_KEY_CFBundleDisplayName = WeatherXM; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainRelease display name → WeatherXM — LGTM. Branding for production looks correct. Ensure there’s no conflicting CFBundleDisplayName in Info.plist at build time. 🏁 Script executed: #!/bin/bash
#!/bin/bash
# Double-check effective names across configs (Debug/Mock/Release)
rg -n 'INFOPLIST_KEY_CFBundleDisplayName' wxm-ios.xcodeproj/project.pbxproj -C1Length of output: 1545 Fix missing quotes around WeatherXM at line 5195 for consistency. The Release configuration is missing quotes that are present in Debug ("WXM Dev") and Mock ("WXM Mock") configurations. Line 5195 should be: Without quotes, the value may be incorrectly parsed as an identifier rather than a string literal, causing potential build or runtime issues. 🤖 Prompt for AI Agents |
||
| INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; | ||
| INFOPLIST_KEY_LSApplicationCategoryType = ""; | ||
| INFOPLIST_KEY_LSSupportsOpeningDocumentsInPlace = YES; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major issue: Cached view model is reused without validating its state or matching device.
The caching logic has two critical flaws:
Reuses error states: If the cached VM entered
.errormode, tapping the AI button again shows the same error. Sincerefresh()is nowprivate(StationSupportViewModel.swift line 27), there's no way to retry the fetch. The user is stuck with the error until they navigate away from the station details entirely.Doesn't validate device match: If the device changes via
refreshWithDevice(line 171), the cached VM may contain data for a different station, leading to incorrect information being displayed.Apply this diff to validate state and device before reusing:
func handleAISupportTap() { guard let name = device?.name else { return } - let vm = stationSupportViewModel ?? ViewModelsFactory.getStationSupportViewModel(deviceName: name) + + // Validate cached VM is for the same device and not in error state + let vm: StationSupportViewModel + if let cached = stationSupportViewModel, + case .error = cached.mode { + // Don't reuse if in error state - create fresh VM to retry + vm = ViewModelsFactory.getStationSupportViewModel(deviceName: name) + } else { + vm = stationSupportViewModel ?? ViewModelsFactory.getStationSupportViewModel(deviceName: name) + } + Router.shared.showBottomSheet(.stationSupport(vm), bgColor: .top) stationSupportViewModel = vm }Additionally, clear the cache in
refreshWithDevicewhen the device changes:🤖 Prompt for AI Agents