mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-04-28 15:09:43 +00:00
Introduces mac/ with a native SwiftUI menubar app that replaces the previous SwiftBar plugin entirely. Install via `npx codeburn menubar`, which downloads the .app from GitHub Releases, strips Gatekeeper quarantine, and drops it into ~/Applications. Highlights - mac/ SwiftUI app: agent tabs, Today/7/30/Month/All period switcher, Trend/Forecast/Pulse/Stats/Plan insights, activity + model breakdowns, optimize findings, CSV/JSON export, Star-on-GitHub banner, live 60s refresh, instant currency switching with offline FX cache. - Security: CodeburnCLI argv-based spawn (no shell interpretation), SafeFile symlink guards + O_NOFOLLOW writes, FX rate clamping to [0.0001, 1_000_000], keychain filtered to account == "default", removed byte-window credential log, in-flight refresh guard, POSIX flock on config.json writes, TerminalLauncher validates argv before AppleScript interpolation. - Performance: shared static NumberFormatter (thousands of allocations per popover redraw eliminated), concurrent pipe drain with 20 MB cap + 60s timeout in DataClient, Observation-tracked reactive UI, 5-min payload cache keyed on (period, provider). - CLI: new `codeburn menubar` subcommand that downloads + installs + launches the .app (no clone, no build). New `status --format menubar-json` payload builder. `export` rewritten to produce a folder of one-table-per-file CSVs with a `.codeburn-export` marker so arbitrary -o paths cannot be silently deleted. - Removed: src/menubar.ts (SwiftBar plugin generator), install-menubar / uninstall-menubar subcommands, `status --format menubar` directive output, tests/menubar.test.ts, tests/security/menubar-injection.test.ts. - Release: .github/workflows/release-menubar.yml builds universal binary, assembles .app, ad-hoc signs, zips, uploads on mac-v* tag push. Runs on the free macos-latest runner. Tests - 230 TypeScript tests pass - 10 Swift CapacityEstimator tests pass - TypeScript typecheck clean - Swift release build clean
87 lines
2.8 KiB
Swift
87 lines
2.8 KiB
Swift
import SwiftUI
|
|
|
|
struct ActivitySection: View {
|
|
@Environment(AppStore.self) private var store
|
|
@State private var isExpanded: Bool = true
|
|
|
|
var body: some View {
|
|
CollapsibleSection(
|
|
caption: "Activity",
|
|
isExpanded: $isExpanded,
|
|
trailing: {
|
|
HStack(spacing: 8) {
|
|
Text("Cost").frame(minWidth: 54, alignment: .trailing)
|
|
Text("Turns").frame(minWidth: 52, alignment: .trailing)
|
|
Text("1-shot").frame(minWidth: 44, alignment: .trailing)
|
|
}
|
|
.font(.system(size: 10, weight: .medium))
|
|
.foregroundStyle(.tertiary)
|
|
.tracking(-0.05)
|
|
}
|
|
) {
|
|
VStack(alignment: .leading, spacing: 7) {
|
|
let maxCost = store.payload.current.topActivities.map(\.cost).max() ?? 1
|
|
ForEach(store.payload.current.topActivities, id: \.name) { activity in
|
|
ActivityRow(activity: activity, maxCost: maxCost)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct ActivityRow: View {
|
|
let activity: ActivityEntry
|
|
let maxCost: Double
|
|
|
|
var body: some View {
|
|
HStack(spacing: 8) {
|
|
FixedBar(fraction: activity.cost / maxCost)
|
|
.frame(width: 56, height: 6)
|
|
|
|
Text(activity.name)
|
|
.font(.system(size: 12.5, weight: .medium))
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
Text(activity.cost.asCompactCurrency())
|
|
.font(.codeMono(size: 12, weight: .medium))
|
|
.tracking(-0.2)
|
|
.frame(minWidth: 54, alignment: .trailing)
|
|
|
|
Text("\(activity.turns)")
|
|
.font(.system(size: 11))
|
|
.monospacedDigit()
|
|
.foregroundStyle(.secondary)
|
|
.frame(minWidth: 52, alignment: .trailing)
|
|
|
|
Text(oneShotText)
|
|
.font(.system(size: 10.5))
|
|
.monospacedDigit()
|
|
.foregroundStyle(.secondary)
|
|
.frame(minWidth: 44, alignment: .trailing)
|
|
}
|
|
.padding(.horizontal, 2)
|
|
.padding(.vertical, 1)
|
|
}
|
|
|
|
private var oneShotText: String {
|
|
guard let rate = activity.oneShotRate else { return "—" }
|
|
return "\(Int(rate * 100))%"
|
|
}
|
|
}
|
|
|
|
/// Fixed-width horizontal bar that shows a fill fraction.
|
|
struct FixedBar: View {
|
|
let fraction: Double
|
|
|
|
var body: some View {
|
|
GeometryReader { geo in
|
|
ZStack(alignment: .leading) {
|
|
RoundedRectangle(cornerRadius: 2)
|
|
.fill(.secondary.opacity(0.15))
|
|
RoundedRectangle(cornerRadius: 2)
|
|
.fill(Theme.brandAccent)
|
|
.frame(width: max(0, min(geo.size.width, geo.size.width * CGFloat(fraction))))
|
|
}
|
|
}
|
|
}
|
|
}
|