fix(desktop): prevent crash in Plan and Usage settings pane (#6506)#6590
fix(desktop): prevent crash in Plan and Usage settings pane (#6506)#6590
Conversation
- Filter out plans/prices with empty IDs before merging to prevent dictionary assertion failures in SubscriptionPlanCatalogMerger - Add unknown cases to SubscriptionPlanType and SubscriptionStatusType enums with safe decoding fallbacks to prevent crashes when the API returns unexpected values - Guard mergedPlanCatalog early return for empty catalogs Crash trace: _NativeDictionary.merge assertion failure triggered via SettingsContentView.mergePlanCatalog → mergedPlanCatalog → currentPlanBillingDetail → currentPlanSubtitle during view body evaluation on the main thread.
Greptile SummaryThis PR fixes a crash in the Plan and Usage settings pane by filtering empty IDs before dictionary merging, pre-allocating dictionary capacity, and adding
Confidence Score: 3/5Not safe to merge — introduces a compile error that will break the automated release pipeline. The crash fix logic (empty-ID filtering, safe enum decoding, defensive merge guard) is correct, but adding case .unknown to SubscriptionPlanType without updating the currentPlanTitle switch makes the code non-exhaustive, which is a Swift compile error. The Codemagic release build will fail until a case .unknown: branch is added to that switch. desktop/Desktop/Sources/MainWindow/Pages/SettingsPage.swift — the currentPlanTitle switch at line 5582 must handle .unknown before this can ship. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[loadSubscriptionInfo] --> B[getUserSubscription]
A --> C[getAvailablePlans]
B --> D[userSubscription set]
C --> E[fallbackPlanCatalog = planCatalog from plans]
D & E --> F[mergedPlanCatalog getter]
F --> G{both empty?}
G -- yes --> H[return empty array]
G -- no --> I[filter empty IDs from primary & fallback]
I --> J[SubscriptionPlanCatalogMerger.merge]
J --> K[Build mergedById dict with minimumCapacity]
K --> L[Insert fallback plans]
L --> M[Insert/merge primary plans]
M --> N[mergePrices for overlapping plan IDs]
N --> O[return Array of merged plans]
O --> P[subscriptionPlansForDisplay sorts result]
P --> Q[currentPlanBillingDetail]
P --> R[currentPlanTitle switch]
R --> S[.basic / .unlimited / .pro]
R -.->|missing case| T[.unknown - compile error]
Q --> U[currentPlanSubtitle]
U --> V[Plan & Usage UI renders]
|
| --- | ||
| description: arc 파이프라인 운영 (Evidence → Work → Projection → Output) | ||
| --- | ||
|
|
||
| arc MCP가 연결되면 이 워크플로우가 자동으로 활성화됩니다. |
There was a problem hiding this comment.
Unrelated developer tooling files committed
Both .cursor/rules/arc.md and .windsurf/workflows/arc.md are Korean-language workflow configuration files for an "Arc" project-management pipeline tool. They are not related to the desktop crash fix, appear to be personal developer tooling, and likely should not be part of the repo history. Consider removing them from this PR and adding the paths to .gitignore.
Summary
Fixes #6506 — the app crashes immediately when navigating to Settings > Plan and Usage.
Root Cause
The crash occurs in
SubscriptionPlanCatalogMerger.merge()during view body evaluation. The crash trace shows:The dictionary merge crashes when processing plan/price data with empty or unexpected IDs from the API.
Changes
idfields are filtered out before merging, preventing dictionary key collisionsDictionary(minimumCapacity:)for better performance and to avoid rehashing during mergeunknowncases toSubscriptionPlanTypeandSubscriptionStatusTypewith custom decoders that gracefully handle new/unknown values from the API instead of crashingTesting