-
Notifications
You must be signed in to change notification settings - Fork 9
perf: improve memory usage and app lifecycle #27
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7f1fb99
perf: streamline Welcome dashboard refreshes
Tranthanh98 b10ad73
perf: Defer AI provider availability checks
Tranthanh98 6766ad4
perf: Add PR disk cache and remove RAM caches
Tranthanh98 33166a1
perf: load local data on demand
Tranthanh98 db2732e
perf: coordinate cloud lifecycle once per app
Tranthanh98 be16e24
perf: Bound caches and release resources for cold start
Tranthanh98 bc285ff
perf: Close Welcome window while repository windows are open
Tranthanh98 73f93f1
Merge branch 'main' into feature/improve-memory-and-app
Tranthanh98 13038f1
perf: Defer repository window screen fit until welcome closes
Tranthanh98 8b538e3
fix: Align toolbar labels to center instead of text baseline
Tranthanh98 737e412
fix: address cache, undo cleanup, and SQLite review findings
Tranthanh98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // SPDX-License-Identifier: AGPL-3.0-or-later | ||
| import Combine | ||
| import Foundation | ||
|
|
||
| /// Starts optional cloud work after the first window is ready and keeps it | ||
| /// process-scoped even when several SwiftUI windows request the same session. | ||
| @MainActor | ||
| final class AppCloudLifecycleController: ObservableObject { | ||
| private enum AccountRequest: Equatable { | ||
| case notStarted | ||
| case session(String?) | ||
| } | ||
|
|
||
| private let startFeaturePolicy: () -> Void | ||
| private let synchronizeAccount: (AccountSnapshot?) async -> Void | ||
| private var didStart = false | ||
| private var accountRequest = AccountRequest.notStarted | ||
| private var pendingAccount: (request: AccountRequest, account: AccountSnapshot?)? | ||
| private var isSynchronizingAccount = false | ||
| private var accountWaiters: [CheckedContinuation<Void, Never>] = [] | ||
|
|
||
| init( | ||
| startFeaturePolicy: @escaping () -> Void, | ||
| synchronizeAccount: @escaping (AccountSnapshot?) async -> Void | ||
| ) { | ||
| self.startFeaturePolicy = startFeaturePolicy | ||
| self.synchronizeAccount = synchronizeAccount | ||
| } | ||
|
|
||
| func start() { | ||
| guard !didStart else { return } | ||
| didStart = true | ||
| startFeaturePolicy() | ||
| } | ||
|
|
||
| func updateAccount(_ account: AccountSnapshot?) async { | ||
| let request = AccountRequest.session(account?.uid) | ||
| if accountRequest == request { | ||
| if isSynchronizingAccount { | ||
| await withCheckedContinuation { accountWaiters.append($0) } | ||
| } | ||
| return | ||
| } | ||
|
|
||
| accountRequest = request | ||
| pendingAccount = (request, account) | ||
| guard !isSynchronizingAccount else { | ||
| await withCheckedContinuation { accountWaiters.append($0) } | ||
| return | ||
| } | ||
|
|
||
| isSynchronizingAccount = true | ||
| while let pendingAccount { | ||
| self.pendingAccount = nil | ||
| // Account reconciliation mutates shared local stores. Complete the | ||
| // active session, then skip directly to the newest queued session. | ||
| await synchronizeAccount(pendingAccount.account) | ||
| } | ||
| isSynchronizingAccount = false | ||
| let waiters = accountWaiters | ||
| accountWaiters.removeAll() | ||
| waiters.forEach { $0.resume() } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.