mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-12-03 12:32:02 +00:00
fix(menubar): refresh(key:) reported failure instead of joining an in-flight fetch
The interactive refresh path bailed with false whenever the key was already being fetched. recoverFromStuckLoading() reads that return value, so a healthy fetch that was simply still running was announced as a failed recovery, and a second interactive refresh threw away a result that was moments from landing. Join the in-flight fetch and report on its outcome, which is what the quiet path already did. Adds a DataClient fetch hook under DEBUG: slot ownership and acceptance ordering are only observable when two REAL fetches overlap, which needs a fetch whose completion the test controls rather than a spawned CLI.
This commit is contained in:
parent
b0ee9cc7d4
commit
216ead74ae
3 changed files with 161 additions and 1 deletions
|
|
@ -1087,7 +1087,14 @@ final class AppStore {
|
|||
let cached = cache[key],
|
||||
cached.isFresh,
|
||||
!providerPayloadContradictsAll(cached.payload, for: key) { return true }
|
||||
if inFlightKeys[key] != nil { return false }
|
||||
// Join an in-flight fetch instead of reporting failure. Returning false
|
||||
// here made recoverFromStuckLoading() announce a failed recovery while a
|
||||
// perfectly healthy fetch was still running, which is what the quiet
|
||||
// path already avoided by waiting.
|
||||
if inFlightKeys[key] != nil {
|
||||
await waitForInFlight(key)
|
||||
return consistentCachedPayload(for: key) != nil
|
||||
}
|
||||
inFlightKeys[key] = Date()
|
||||
attemptedKeys.insert(key)
|
||||
lastErrorByKey[key] = nil
|
||||
|
|
|
|||
|
|
@ -47,6 +47,14 @@ struct CLIDecodeFailure: Error, CustomStringConvertible {
|
|||
/// Runs the CLI via argv (no shell interpretation). See `CodeburnCLI` for why we never route
|
||||
/// commands through `/bin/zsh -c` anymore.
|
||||
struct DataClient {
|
||||
#if DEBUG
|
||||
/// Test seam. The in-flight slot and the all-provider acceptance ordering
|
||||
/// are only observable when two REAL fetches overlap, which needs a fetch
|
||||
/// whose completion the test controls rather than a spawned CLI.
|
||||
@MainActor
|
||||
static var fetchHookForTesting: (@Sendable (ProviderFilter, Bool) async throws -> MenubarPayload)?
|
||||
#endif
|
||||
|
||||
static func fetch(period: Period,
|
||||
day: String? = nil,
|
||||
days: Set<String> = [],
|
||||
|
|
@ -56,6 +64,11 @@ struct DataClient {
|
|||
claudeConfigSourceId: String? = nil,
|
||||
bypassResident: Bool = false,
|
||||
qualityOfService: QualityOfService = .userInitiated) async throws -> MenubarPayload {
|
||||
#if DEBUG
|
||||
if let hook = await MainActor.run(body: { fetchHookForTesting }) {
|
||||
return try await hook(provider, bypassResident)
|
||||
}
|
||||
#endif
|
||||
let subcommand = statusSubcommand(
|
||||
period: period,
|
||||
day: day,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue