Skip to content

Commit c02111a

Browse files
committed
change loading state
1 parent 35af1b9 commit c02111a

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

Sources/AgentTally/Presentation/StatusPresenter.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Foundation
22

33
public enum StatusPresenter {
44
public static let staleDataInterval: TimeInterval = 120
5-
private static let placeholderAgent = AgentKind.claude
65

76
public static func displayDollarAmount(for amount: Double) -> Int {
87
guard amount > 0 else {
@@ -17,6 +16,10 @@ public enum StatusPresenter {
1716
}
1817

1918
public static func title(for state: AppState, now: Date = Date()) -> String {
19+
if state.isRefreshing && state.lastRefreshAt == nil && state.agentSpendings.isEmpty {
20+
return "..."
21+
}
22+
2023
if shouldShowLoadingTitle(lastRefreshAt: state.lastRefreshAt, now: now) {
2124
return loadingTitle(for: state)
2225
}
@@ -42,7 +45,7 @@ public enum StatusPresenter {
4245
.filter { state.lastErrorByAgent[$0] != nil }
4346
.map(\.abbreviation)
4447
guard !abbreviations.isEmpty else {
45-
return "ERR \(placeholderAgent.abbreviation)"
48+
return "ERR"
4649
}
4750

4851
return "ERR \(abbreviations.joined(separator: " "))"
@@ -53,7 +56,7 @@ public enum StatusPresenter {
5356
.filter { $0.isInstalled }
5457
.map { abbreviation(for: $0.name) }
5558
guard !abbreviations.isEmpty else {
56-
return "? \(placeholderAgent.abbreviation)"
59+
return "?"
5760
}
5861

5962
return "? \(abbreviations.joined(separator: " "))"

Tests/StatusPresenterHarness.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ func testStatusPresenter() throws {
100100
) == "? CC",
101101
"stale cached data should show loading title even when idle"
102102
)
103+
try expect(
104+
StatusPresenter.title(for: AppState()) == "?",
105+
"unknown agent state should not imply Claude usage"
106+
)
103107

104108
let fractionalState = AppState(
105109
isRefreshing: false,
@@ -155,6 +159,10 @@ func testStatusPresenter() throws {
155159
StatusPresenter.lastRefreshedLabel(for: AppState(isRefreshing: true)) == "refreshing...",
156160
"first refresh should surface a refreshing status"
157161
)
162+
try expect(
163+
StatusPresenter.title(for: AppState(isRefreshing: true)) == "...",
164+
"first refresh title should show an active loading indicator without implying an agent"
165+
)
158166
try expect(
159167
StatusPresenter.lastRefreshedLabel(for: AppState()) == "waiting for first refresh",
160168
"empty state should explain that no refresh has completed"

0 commit comments

Comments
 (0)