From 3cb412e388d3408bf22ea637426ba0e411746482 Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Sun, 13 Sep 2026 12:23:30 -0700 Subject: [PATCH] menubar: drop the pace caption from the Capacity Dock window cells --- CHANGELOG.md | 3 + .../Views/CapacityDockView.swift | 89 ++----------------- .../CapacityDockGlanceTests.swift | 48 ---------- 3 files changed, 8 insertions(+), 132 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bea7a7a..690646fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ - **The macOS menubar item can show a second line.** Settings → General → Display gains a "Second row" switch, off by default, and a picker for what that line shows: quota remaining with its reset countdown for whichever connected provider is nearest its limit, today's all-provider cost, today's total tokens, or the number of running sessions. Both lines render as one attributed title at 9pt with their line height clamped to 10pt, so the pair fits the standard 22pt menu bar, and the second line hides itself whenever its metric has no data yet, leaving the existing single-row figure exactly as it was. This is a deliberately small first slice of the multi-row layout request: no layout editor, no presets, no live preview, no per-item provider or period scoping. The setting persists as `CodeBurnMenubarSecondRowEnabled` and `CodeBurnMenubarSecondRowMetric` in the app's own defaults domain alongside the existing menubar period, scope and metric keys. (#1252) - **The Capacity Dock gauge can report the short usage window instead of the weekly one, without expanding the dock.** The resting rail shows one number per provider, and that number was always the weekly (else monthly) billing window. Clicking the provider already resting in the rail now switches its gauge to the provider's short rolling window — Claude's 5-hour limit, Codex's 5-hour or daily window, any `Hourly`, `Daily` or session row an adapter reports — and clicking again switches back. The choice is stored per provider under `CodeBurnCapacityDockGlanceWindows`, so Claude can sit on its 5-hour window while Codex stays weekly, and it survives relaunch. A per-model row such as `Weekly · Opus` is never read as a short window, a provider that reports only one window keeps the plain click-to-pin behaviour, and a stored horizon the provider stops reporting falls back to the window it does report rather than blanking the gauge to `--`. The rail's geometry is untouched, VoiceOver and keyboard users get the switch as a named action on the provider cell with the window named in the cell's value, and Escape or a click outside still unpins the dock. (#1243) +### Changed +- **The Capacity Dock card no longer prints a pace verdict under each quota window.** The "On pace" / "Lasts until reset" caption from #1314 added a third line to every window cell and made the card read as clutter; the cells are back to percent, label and countdown, and the pace math still feeds the tooltip and the agent-tab card. + ### Fixed - **Shared and MCP-redacted payloads no longer carry git branch names or the working directory of a session.** Two identities were riding along in `current`: the `topSessions` rows added in #1316 carry `projectKey`, a dash-encoded absolute path such as `-Users--Projects-`, which `redactProjectNames` left verbatim even when an MCP client asked not to see project names, and the per-branch rows added in #788 carry the raw branch, which both `sanitizeForSharing` and the MCP pass let through, so a branch such as `exp/extraction-arms` reached a shared payload as typed. The MCP pass now hashes `projectKey` with the same salted pseudonym it already applies to `topProjects[].id`, hashes the drill-through `sessionId` on both `topSessions` and `topProjects[].sessionDetails` (a Codex id embeds the rollout timestamp the pass blanks out of `date`), and gives each distinct branch a stable `branch-xxxxxx` pseudonym, keeping the cost, calls and session counts untouched; a `null` branch stays null, because unbranched spend is not a name. Sharing drops the per-branch block outright, the way it already drops the project and session rows, since a pseudonymized branch tells a peer device nothing anyway. Nothing changes for the local menubar, the desktop app or the web dashboard, which read the unsanitized payload, and nothing changes for an MCP caller that passes `include_project_names: true` — it still gets every name as recorded. (#1325, #1321) - **A pull request row now opens the sessions that produced it.** Every other aggregate in the app drills through — a day bar, a model name, a task category, a project — but the Pull requests section only ever expanded and collapsed: the PR selection builder and the drill-through callback were threaded through the section four component levels deep and nothing ever called either, so the one report that names actual shipped work had no way into the sessions behind it. An expanded PR row now carries a `View sessions for this pull request →` control above its work breakdown, the same affordance a project row in Spend already offers; it selects the PR by its URL — the aggregation key the by-PR report is built on — and lands in Sessions with the chip applied and each session's per-turn contribution reconciled against its full cost. The control is its own click target rather than the row, so clicking it or pressing Enter on it never costs the expansion, and a legacy row with no per-turn detail offers it too. Two smaller items from the same review: the sessions list's return-to-the-first-page reset wrote internal state the app does not read while it owns the pagination depth, so revealing another 120 rows and then changing the sort or removing a chip left you deep inside a list that had just been reordered — the reset now rides the same commit as the change that caused it, and the depth a Back/Forward restore brings back is left alone. And the investigation chips were keyed by the label they display, which truncates a session id to 12 characters and a project to its last path segment: two chips that read alike collided into one React key, warned about it, and risked reconciling or removing the wrong one — they are now keyed by the full provider+id and project+branch identity the selection is deduplicated by. (#1317) diff --git a/mac/Sources/CodeBurnMenubar/Views/CapacityDockView.swift b/mac/Sources/CodeBurnMenubar/Views/CapacityDockView.swift index 36e5cc3f..ad5398d7 100644 --- a/mac/Sources/CodeBurnMenubar/Views/CapacityDockView.swift +++ b/mac/Sources/CodeBurnMenubar/Views/CapacityDockView.swift @@ -154,27 +154,10 @@ enum CapacityDockGlance { /// The old zero-spacing HStack let intrinsic Text widths bleed across columns. static let windowsColumnGap: CGFloat = 8 static let windowsRowGap: CGFloat = 6 - /// One 9.5pt pace caption under the reset line, with its 2pt gap. Reserved - /// whenever connected data carries a window with validated duration, even - /// while the caption itself is still empty — the slot must not appear and - /// disappear with wall-clock time under an open panel. - static let paceLineHeight: CGFloat = 12 - static let paceLineGap: CGFloat = 2 /// 8 top + one secondary line + 16 bottom. static let windowsEmptyHeight: CGFloat = 37 - /// Whether the windows row carries pace slots: connected data with at - /// least one displayed window holding validated duration metadata. - static func drawsPace(_ quota: QuotaSummary) -> Bool { - guard drawsWindows(quota) else { return false } - let shown = windows(quota) - guard !shown.isEmpty else { return false } - return QuotaPacePresentation.reservesLine(for: shown) - } - - /// The windows row's height for this quota: the plain row, or the row with - /// the pace slot every column reserves. Must stay in step with - /// `windowColumn`, which draws the slot under every column when this fires. + /// The windows row's height for this quota. static func windowsHeight(for quota: QuotaSummary) -> CGFloat { let shown = windows(quota) guard !shown.isEmpty else { return windowsEmptyHeight } @@ -186,8 +169,7 @@ enum CapacityDockGlance { } /// One or two windows stay on one compact row. Three and four windows use - /// two columns and enough row height for every percentage, reset, and pace - /// caption. This is shared by `detailHeight` and the actual SwiftUI grid. + /// two columns and enough row height for every percentage and reset. This is shared by `detailHeight` and the actual SwiftUI grid. static func windowColumnCount(for windowCount: Int) -> Int { guard windowCount > 0 else { return 0 } return min(windowCount, 2) @@ -199,18 +181,13 @@ enum CapacityDockGlance { return (windowCount + columns - 1) / columns } - static func windowRowHeight(hasPaceSlot: Bool) -> CGFloat { - windowContentHeight + (hasPaceSlot ? paceLineGap + paceLineHeight : 0) - } - /// Height of the grid alone, excluding this section's top and bottom pads. static func windowsGridHeight(for quota: QuotaSummary) -> CGFloat { let count = windows(quota).count guard count > 0 else { return 0 } let rows = windowRowCount(for: count) - let rowHeight = windowRowHeight(hasPaceSlot: drawsPace(quota)) return ( - CGFloat(rows) * rowHeight + CGFloat(rows) * windowContentHeight + CGFloat(max(0, rows - 1)) * windowsRowGap ).rounded() } @@ -1154,30 +1131,17 @@ struct CapacityDockDetailView: View { /// One cell per quota window, in the order the provider reported them. /// One or two windows stay on a compact row. Three or four windows use a /// two-column grid whose cell width comes from the actual content geometry, - /// including its inter-column gap. When the panel reserved pace slots - /// (`drawsPace`), every cell draws the slot — empty where its window has no - /// defensible caption — so rows stay aligned with the height the panel - /// reserved. + /// including its inter-column gap. @ViewBuilder private func windowsSection(_ quota: QuotaSummary) -> some View { let s = model.detailScale let windows = CapacityDockGlance.windows(quota) - let hasPaceSlot = CapacityDockGlance.drawsPace(quota) - let paceLines = QuotaPacePresentation.lines( - for: windows, - connection: quota.connection - ) Group { if windows.isEmpty { budgetLine() .frame(height: CapacityDockGlance.captionLine * s) } else { - windowGrid( - windows, - paceLines: paceLines, - hasPaceSlot: hasPaceSlot, - scale: s - ) + windowGrid(windows, scale: s) .frame(height: CapacityDockGlance.windowsGridHeight(for: quota) * s) } } @@ -1190,8 +1154,6 @@ struct CapacityDockDetailView: View { @ViewBuilder private func windowGrid( _ windows: [QuotaSummary.Window], - paceLines: [QuotaPacePresentation.Line?], - hasPaceSlot: Bool, scale: CGFloat ) -> some View { let columnCount = CapacityDockGlance.windowColumnCount(for: windows.count) @@ -1216,8 +1178,6 @@ struct CapacityDockDetailView: View { windows[index], width: columnWidth, alignment: alignment, - paceLine: hasPaceSlot ? paceLines[index] : nil, - hasPaceSlot: hasPaceSlot, scale: scale ) } else { @@ -1241,8 +1201,6 @@ struct CapacityDockDetailView: View { _ window: QuotaSummary.Window, width: CGFloat, alignment: HorizontalAlignment, - paceLine: QuotaPacePresentation.Line?, - hasPaceSlot: Bool, scale: CGFloat ) -> some View { VStack(alignment: alignment, spacing: 0) { @@ -1282,15 +1240,6 @@ struct CapacityDockDetailView: View { ) .padding(.top, 2 * scale) .accessibilityLabel(L("Resets %@", window.resetsInLabel)) - if hasPaceSlot { - paceCaption(paceLine) - .frame( - width: width, - height: CapacityDockGlance.paceLineHeight * scale, - alignment: alignment == .leading ? .leading : .center - ) - .padding(.top, CapacityDockGlance.paceLineGap * scale) - } } .frame( width: width, @@ -1298,34 +1247,6 @@ struct CapacityDockDetailView: View { ) } - /// The whole-window-average pace reading under one quota window. An absent - /// caption leaves its reserved slot empty: no estimate is the honest state - /// for a too-young window, and inventing one is not. - @ViewBuilder - private func paceCaption(_ line: QuotaPacePresentation.Line?) -> some View { - if let line { - let color: Color = switch line.tone { - case .danger: .red.opacity(0.92) - case .warning: .orange.opacity(0.9) - case .neutral: Color.capacityDockText.opacity(0.45) - } - Text(line.text) - .font(.system(size: 9.5, weight: .medium)) - .monospacedDigit() - .foregroundStyle(color) - .lineLimit(1) - .minimumScaleFactor(0.8) - // The full caption remains in the tooltip/accessibility tree; - // middle truncation retains both the estimate kind and its - // useful endpoint when a future caption grows longer. - .truncationMode(.middle) - .help(line.helpText) - .accessibilityElement(children: .ignore) - .accessibilityLabel(line.text) - .accessibilityHint(line.helpText) - } - } - /// No quota window exists for this provider, so money is the capacity. @ViewBuilder private func budgetLine() -> some View { diff --git a/mac/Tests/CodeBurnMenubarTests/CapacityDockGlanceTests.swift b/mac/Tests/CodeBurnMenubarTests/CapacityDockGlanceTests.swift index 438f591a..0cc3430a 100644 --- a/mac/Tests/CodeBurnMenubarTests/CapacityDockGlanceTests.swift +++ b/mac/Tests/CodeBurnMenubarTests/CapacityDockGlanceTests.swift @@ -85,54 +85,6 @@ struct CapacityDockGlanceTests { #expect(CapacityDockGlance.windows(quota([])).isEmpty) } - @Test("Pace slots reserve height for any window with a validated duration") - func paceSlotReservedByDuration() { - let resetsAt = Date().addingTimeInterval(3 * 24 * 3600) - let withoutDuration = [window("5-hour", 0.2, resetsAt: resetsAt), window("Weekly", 0.5, resetsAt: resetsAt)] - let withDuration = [ - window("5-hour", 0.2, resetsAt: resetsAt, windowSeconds: QuotaPacePresentation.claudeFiveHourSeconds), - window("Weekly", 0.5, resetsAt: resetsAt, windowSeconds: QuotaPacePresentation.claudeSevenDaySeconds), - ] - #expect(!CapacityDockGlance.drawsPace(quota(withoutDuration))) - #expect(CapacityDockGlance.drawsPace(quota(withDuration))) - // Missing duration still draws the plain row. - #expect(CapacityDockGlance.windowsHeight(for: quota(withoutDuration)) == CapacityDockGlance.windowsHeight) - let step = CapacityDockGlance.paceLineGap + CapacityDockGlance.paceLineHeight - #expect(CapacityDockGlance.windowsHeight(for: quota(withDuration)) == CapacityDockGlance.windowsHeight + step) - // Stale and loading data carry the durations but no defensible - // estimate. The slot stays reserved anyway: it is the caption that - // goes quiet, and the panel must not resize under the pointer every - // time a refresh starts or a sample ages out. - for connection in [QuotaSummary.Connection.stale, .loading] { - #expect(CapacityDockGlance.drawsPace(quota(withDuration, connection: connection))) - #expect( - CapacityDockGlance.windowsHeight(for: quota(withDuration, connection: connection)) - == CapacityDockGlance.windowsHeight(for: quota(withDuration)) - ) - } - // The computed panel height reflects the reserved slot. - func detailHeight(_ windows: [QuotaSummary.Window], connection: QuotaSummary.Connection) -> CGFloat { - CapacityDockMetrics.detailHeight( - quota: quota(windows, connection: connection), - sessionCount: nil, - hasToday: false, - tailEdge: .right, - scale: 1 - ) - } - #expect(detailHeight(withDuration, connection: .connected) - detailHeight(withoutDuration, connection: .connected) == step) - for scale in [0.9, 1.0, 1.15, 1.25, 1.4] { - let h = CapacityDockMetrics.detailHeight( - quota: quota(withDuration), - sessionCount: 2, - hasToday: true, - tailEdge: .bottom, - scale: CGFloat(scale) - ) - #expect(h == h.rounded()) - } - } - @Test("Three or four windows use two constrained columns and two rows") func multiWindowGridGeometry() { let plainThree = quota([