Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat: fix context% calculation, redesign UI with native macOS aesthetic
libokai0f8986b22ee5
diff --git a/CodePulse-macOS/Utilities/JSONLTailReader.swift b/CodePulse-macOS/Utilities/JSONLTailReader.swiftindex 4aa11d0a..7851e207 100644--- a/CodePulse-macOS/Utilities/JSONLTailReader.swift+++ b/CodePulse-macOS/Utilities/JSONLTailReader.swift@@ -28,21 +28,18 @@ struct JSONLEntry: Codable {struct JSONLSessionInfo {var model: String = "Unknown"- var totalInputTokens: Int = 0- var totalOutputTokens: Int = 0- var totalCacheReadTokens: Int = 0- var lastUpdateTime: Date?+ var latestInputTokens: Int = 0 // Latest turn's input tokens (for context%)+ var totalOutputTokens: Int = 0 // Sum of all output tokens (for cost)var contextPct: Int {let contextWindowSize = modelContextSize- guard contextWindowSize > 0 else { return 0 }- let used = totalInputTokens + totalCacheReadTokens- return min(100, (used * 100) / contextWindowSize)+ guard contextWindowSize > 0, latestInputTokens > 0 else { return 0 }+ return min(100, (latestInputTokens * 100) / contextWindowSize)}var costUSD: Double {let (inputRate, outputRate) = modelPricing- let inputCost = Double(totalInputTokens) * inputRate / 1_000_000+ let inputCost = Double(latestInputTokens) * inputRate / 1_000_000let outputCost = Double(totalOutputTokens) * outputRate / 1_000_000return inputCost + outputCost}@@ -81,8 +78,9 @@ enum JSONLTailReader {}static func extractInfo(url: URL) -> JSONLSessionInfo {- let lines = readTail(url: url)+ let lines = readTail(url: url, lineCount: 100) // read more lines for better coveragevar info = JSONLSessionInfo()+ var totalOutputTokens = 0let decoder = JSONDecoder()for line in lines {@@ -94,13 +92,19 @@ enum JSONLTailReader {info.model = model}if let usage = message.usage {- info.totalInputTokens += usage.inputTokens ?? 0- info.totalOutputTokens += usage.outputTokens ?? 0- info.totalCacheReadTokens += usage.cacheReadInputTokens ?? 0+ // Context%: use latest input tokens (each turn includes full context)+ let inputTokens = usage.inputTokens ?? 0+ let cacheReadTokens = usage.cacheReadInputTokens ?? 0+ if inputTokens > 0 {+ info.latestInputTokens = inputTokens + cacheReadTokens+ }+ // Cost: accumulate output tokens+ totalOutputTokens += usage.outputTokens ?? 0}}}+ info.totalOutputTokens = totalOutputTokensreturn info}diff --git a/CodePulse-macOS/Views/ProgressBarView.swift b/CodePulse-macOS/Views/ProgressBarView.swiftindex 1195068c..e0eaef3b 100644--- a/CodePulse-macOS/Views/ProgressBarView.swift+++ b/CodePulse-macOS/Views/ProgressBarView.swift@@ -5,11 +5,11 @@ struct ProgressBarView: View {let tasks: [TaskItem]var body: some View {- HStack(spacing: 3) {+ HStack(spacing: 2) {ForEach(tasks) { task in- RoundedRectangle(cornerRadius: 3)+ RoundedRectangle(cornerRadius: 2, style: .continuous).fill(color(for: task.status))- .frame(height: 6)+ .frame(height: 4)}}}@@ -18,7 +18,7 @@ struct ProgressBarView: View {switch status {case .completed: return .greencase .inProgress: return .cyan- case .pending: return Color(.separatorColor)+ case .pending: return .primary.opacity(0.1)}}}diff --git a/CodePulse-macOS/Views/SessionDetailView.swift b/CodePulse-macOS/Views/SessionDetailView.swiftindex ac42b858..b5f94e3c 100644--- a/CodePulse-macOS/Views/SessionDetailView.swift+++ b/CodePulse-macOS/Views/SessionDetailView.swift@@ -7,35 +7,42 @@ struct SessionDetailView: View {var body: some View {VStack(spacing: 0) {- HStack {+ // Navigation header+ HStack(spacing: 6) {Button(action: onBack) {- HStack(spacing: 4) {+ HStack(spacing: 2) {Image(systemName: "chevron.left")- Text("Sessions")+ .font(.system(size: 11, weight: .semibold))+ Text("Back")+ .font(.system(size: 12))}- .font(.system(size: 12))- .foregroundStyle(.cyan)+ .foregroundStyle(.secondary)}.buttonStyle(.plain)+Spacer()+StatusDotView(status: session.status)Text(session.status.label)- .font(.system(size: 11))+ .font(.system(size: 11, weight: .medium)).foregroundStyle(session.status.color)}- .padding(.horizontal, 10)+ .padding(.horizontal, 12).padding(.vertical, 8)- .background(Color.black.opacity(0.1))- Divider()+ Divider().padding(.horizontal, 8)ScrollView {- VStack(alignment: .leading, spacing: 10) {+ VStack(alignment: .leading, spacing: 12) {++ // Title sectionVStack(alignment: .leading, spacing: 4) {Text(session.summary).font(.system(size: 14, weight: .semibold))- HStack(spacing: 4) {- Text(session.projectName)+ .lineLimit(2)++ HStack(spacing: 6) {+ Label(session.projectName, systemImage: "folder")Text("·")Text(session.gitBranch)Text("·")@@ -44,48 +51,51 @@ struct SessionDetailView: View {.font(.system(size: 11)).foregroundStyle(.secondary)}- .padding(.horizontal, 12)- .padding(.top, 8)+ // Stats row+ HStack(spacing: 0) {+ statItem("\(session.contextPct)%", "Context")+ Divider().frame(height: 24)+ statItem(String(format: "$%.2f", session.costUSD), "Cost")+ Divider().frame(height: 24)+ statItem(formatDuration(session.durationSec), "Duration")+ }+ .padding(.vertical, 6)+ .background(+ RoundedRectangle(cornerRadius: 8, style: .continuous)+ .fill(.quaternary.opacity(0.3))+ )++ // Tasks sectionif !session.tasks.isEmpty {- VStack(alignment: .leading, spacing: 6) {+ VStack(alignment: .leading, spacing: 8) {HStack {- Text("TASKS")- .font(.system(size: 10, weight: .medium))- .foregroundStyle(.secondary)+ Text("Tasks")+ .font(.system(size: 12, weight: .medium))Spacer()- Text("\(session.completedTaskCount) of \(session.totalTaskCount)")- .font(.system(size: 10))+ Text("\(session.completedTaskCount)/\(session.totalTaskCount)")+ .font(.system(size: 11, design: .rounded)).foregroundStyle(.secondary)}ProgressBarView(tasks: session.tasks)- ForEach(session.tasks) { task in- HStack(spacing: 6) {- taskIcon(task.status)- Text(task.content)- .font(.system(size: 11))- .foregroundStyle(taskColor(task.status))- if task.status == .inProgress, let form = task.activeForm {- Text("— \(form)")- .font(.system(size: 11))- .foregroundStyle(.quaternary)+ VStack(alignment: .leading, spacing: 4) {+ ForEach(session.tasks) { task in+ HStack(spacing: 6) {+ taskIcon(task.status)+ Text(task.content)+ .font(.system(size: 12))+ .foregroundStyle(task.status == .pending ? .tertiary : .primary)+ .lineLimit(1)}}}}- .padding(.horizontal, 12)- }-- HStack(spacing: 6) {- statCard("CONTEXT", "\(session.contextPct)%", .orange)- statCard("COST", String(format: "$%.2f", session.costUSD), .yellow)- statCard("DURATION", formatDuration(session.durationSec), .pink)}- .padding(.horizontal, 12)- .padding(.bottom, 8)}+ .padding(.horizontal, 12)+ .padding(.vertical, 10)}}}@@ -93,35 +103,36 @@ struct SessionDetailView: View {private func taskIcon(_ status: TaskStatus) -> some View {Group {switch status {- case .completed: Text("✓").foregroundStyle(.green)- case .inProgress: Text("◼").foregroundStyle(.cyan)- case .pending: Text("◻").foregroundStyle(.quaternary)+ case .completed:+ Image(systemName: "checkmark.circle.fill")+ .foregroundStyle(.green)+ case .inProgress:+ Image(systemName: "circlebadge.fill")+ .foregroundStyle(.cyan)+ case .pending:+ Image(systemName: "circle")+ .foregroundStyle(.tertiary)}}.font(.system(size: 11))}- private func taskColor(_ status: TaskStatus) -> Color {- switch status {- case .completed: return .green- case .inProgress: return .cyan- case .pending: return Color(.tertiaryLabelColor)- }- }-- private func statCard(_ label: String, _ value: String, _ color: Color) -> some View {+ private func statItem(_ value: String, _ label: String) -> some View {VStack(spacing: 2) {- Text(label).font(.system(size: 9, weight: .medium)).foregroundStyle(.secondary)- Text(value).font(.system(size: 12, weight: .semibold)).foregroundStyle(color)+ Text(value)+ .font(.system(size: 13, weight: .semibold, design: .rounded))+ Text(label)+ .font(.system(size: 10))+ .foregroundStyle(.secondary)}.frame(maxWidth: .infinity)- .padding(.vertical, 6)- .background(RoundedRectangle(cornerRadius: 6).fill(Color.black.opacity(0.15)))}private func formatDuration(_ seconds: Int) -> String {if seconds < 60 { return "\(seconds)s" }if seconds < 3600 { return "\(seconds / 60)m" }- return "\(seconds / 3600)h \((seconds % 3600) / 60)m"+ let h = seconds / 3600+ let m = (seconds % 3600) / 60+ return "\(h)h \(m)m"}}diff --git a/CodePulse-macOS/Views/SessionListView.swift b/CodePulse-macOS/Views/SessionListView.swiftindex c018645f..003654fa 100644--- a/CodePulse-macOS/Views/SessionListView.swift+++ b/CodePulse-macOS/Views/SessionListView.swift@@ -7,67 +7,68 @@ struct SessionListView: View {var body: some View {VStack(spacing: 0) {- if let session = selectedSession {- SessionDetailView(session: session) {- withAnimation { selectedSession = nil }+ if let selected = selectedSession {+ // Find the live version of this session+ let liveSession = stateManager.sessions.first { $0.sessionId == selected.sessionId } ?? selected+ SessionDetailView(session: liveSession) {+ withAnimation(.easeInOut(duration: 0.2)) { selectedSession = nil }}} else {sessionList}-- Divider().padding(.horizontal, 8)- footer}- .frame(width: 340)+ .frame(width: 320, height: 380)}private var sessionList: some View {- ScrollView {- LazyVStack(spacing: 0) {- if stateManager.sessions.isEmpty {- emptyState- } else {- ForEach(stateManager.sessions) { session in- Button {- withAnimation { selectedSession = session }- } label: {- SessionRowView(session: session)- }- .buttonStyle(.plain)-- if session.id != stateManager.sessions.last?.id {- Divider().padding(.horizontal, 10)+ VStack(spacing: 0) {+ if stateManager.sessions.isEmpty {+ emptyState+ } else {+ ScrollView {+ LazyVStack(spacing: 1) {+ ForEach(stateManager.sessions) { session in+ Button {+ withAnimation(.easeInOut(duration: 0.2)) { selectedSession = session }+ } label: {+ SessionRowView(session: session)+ }+ .buttonStyle(.plain)}}+ .padding(.vertical, 4)+ .padding(.horizontal, 4)}}- .padding(.vertical, 4)++ Spacer(minLength: 0)++ // Footer+ HStack {+ Text("CodePulse")+ .font(.system(size: 10, weight: .medium))+ .foregroundStyle(.quaternary)+ Spacer()+ }+ .padding(.horizontal, 12)+ .padding(.vertical, 6)}}private var emptyState: some View {- VStack(spacing: 8) {+ VStack(spacing: 12) {+ Spacer()Image(systemName: "waveform.path")- .font(.system(size: 32))+ .font(.system(size: 28, weight: .light)).foregroundStyle(.tertiary)- Text("No active Claude Code sessions")+ Text("No active sessions").font(.system(size: 13)).foregroundStyle(.secondary)- }- .frame(maxWidth: .infinity, minHeight: 120)- }-- private var footer: some View {- HStack {- Text("CodePulse")- .font(.system(size: 10))- .foregroundStyle(.quaternary)+ Text("Start a Claude Code session to see it here")+ .font(.system(size: 11))+ .foregroundStyle(.tertiary)Spacer()- Text("⌘.")- .font(.system(size: 10))- .foregroundStyle(.quaternary)}- .padding(.horizontal, 10)- .padding(.vertical, 6)+ .frame(maxWidth: .infinity)}}diff --git a/CodePulse-macOS/Views/SessionRowView.swift b/CodePulse-macOS/Views/SessionRowView.swiftindex 4edddbff..4154b194 100644--- a/CodePulse-macOS/Views/SessionRowView.swift+++ b/CodePulse-macOS/Views/SessionRowView.swift@@ -6,49 +6,43 @@ struct SessionRowView: View {@State private var isHovered = falsevar body: some View {- HStack(spacing: 8) {+ HStack(spacing: 10) {StatusDotView(status: session.status)- VStack(alignment: .leading, spacing: 2) {- HStack(spacing: 4) {- Text(session.summary)- .font(.system(size: 13, weight: isHovered ? .medium : .regular))- .foregroundStyle(.primary)- .lineLimit(1)- .truncationMode(.middle)-- Text("claude")- .font(.system(size: 9))- .padding(.horizontal, 5)- .padding(.vertical, 1)- .background(Color.purple.opacity(0.15))- .foregroundStyle(.purple)- .clipShape(RoundedRectangle(cornerRadius: 3))- }+ VStack(alignment: .leading, spacing: 1) {+ Text(session.summary)+ .font(.system(size: 13, weight: isHovered ? .medium : .regular))+ .foregroundStyle(.primary)+ .lineLimit(1)}Spacer(minLength: 4)- Text(relativeTime(session.updatedAt))- .font(.system(size: 11, design: .rounded))- .foregroundStyle(.tertiary)+ if session.status == .needsInput {+ Text("needs input")+ .font(.system(size: 10))+ .foregroundStyle(.orange)+ } else {+ Text(relativeTime(session.startedAt))+ .font(.system(size: 11, design: .rounded))+ .foregroundStyle(.tertiary)+ }}- .padding(.leading, 6)- .padding(.trailing, 10)- .padding(.vertical, 5)+ .padding(.horizontal, 8)+ .padding(.vertical, 6).background(- RoundedRectangle(cornerRadius: 5, style: .continuous)+ RoundedRectangle(cornerRadius: 6, style: .continuous).fill(isHovered ? Color.primary.opacity(0.06) : Color.clear))- .onHover { isHovered = $0 }+ .onHover { h in withAnimation(.easeOut(duration: 0.12)) { isHovered = h } }.contentShape(Rectangle())}private func relativeTime(_ date: Date) -> String {let seconds = -date.timeIntervalSinceNowif seconds < 60 { return "now" }- if seconds < 3600 { return "\(Int(seconds / 60))m ago" }- if seconds < 86400 { return "\(Int(seconds / 3600))h ago" }- return "\(Int(seconds / 86400))d ago"+ if seconds < 3600 { return "\(Int(seconds / 60))m" }+ if seconds < 86400 { return "\(Int(seconds / 3600))h" }+ return "\(Int(seconds / 86400))d"}}diff --git a/CodePulse-macOS/Views/StatusDotView.swift b/CodePulse-macOS/Views/StatusDotView.swiftindex f6c8a6f4..721fce7c 100644--- a/CodePulse-macOS/Views/StatusDotView.swift+++ b/CodePulse-macOS/Views/StatusDotView.swift@@ -3,34 +3,22 @@ import CodePulseSharedstruct StatusDotView: View {let status: SessionStatus- @State private var isAnimating = false-- private func animates(_ s: SessionStatus) -> Bool {- switch s {- case .working, .needsInput, .error: return true- default: return false- }- }+ @State private var animating = falsevar body: some View {- let dotColor = status.color- let shadowColor = dotColor.opacity(0.5)- let shadowRadius: CGFloat = animates(status) ? 3 : 0- let dotOpacity: Double = isAnimating ? 0.4 : 1.0- let anim: Animation = animates(status)- ? .easeInOut(duration: 1.0).repeatForever(autoreverses: true)- : .default- return Circle()- .fill(dotColor)+ Circle()+ .fill(status.color).frame(width: 8, height: 8)- .shadow(color: shadowColor, radius: shadowRadius)- .opacity(dotOpacity)- .animation(anim, value: isAnimating)- .onAppear {- if animates(status) { isAnimating = true }- }- .onChange(of: status) { _, newStatus in- isAnimating = animates(newStatus)- }+ .shadow(color: status.color.opacity(shouldPulse ? 0.6 : 0), radius: shouldPulse ? 4 : 0)+ .scaleEffect(animating ? 1.15 : 1.0)+ .opacity(animating ? 0.5 : 1.0)+ .onAppear { if shouldPulse { animating = true } }+ .onChange(of: status) { _, s in animating = shouldPulse(s) }+ .animation(shouldPulse ? .easeInOut(duration: 1.2).repeatForever(autoreverses: true) : .default, value: animating)+ }++ private var shouldPulse: Bool { shouldPulse(status) }+ private func shouldPulse(_ s: SessionStatus) -> Bool {+ s == .working || s == .needsInput || s == .error}}