Skip to content

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.

feat: dual-mode Live Activity — progress bar for task lists

libokai7c898b7d2616
diff --git a/CodyncLiveActivity/CodyncLiveActivityWidget.swift b/CodyncLiveActivity/CodyncLiveActivityWidget.swift
index 047b51c3..3db7a096 100644
--- a/CodyncLiveActivity/CodyncLiveActivityWidget.swift
+++ b/CodyncLiveActivity/CodyncLiveActivityWidget.swift
@@ -28,23 +28,34 @@ struct CodyncLiveActivityWidget: Widget {
}
}
DynamicIslandExpandedRegion(.trailing) {
- if context.state.status != "completed" {
+ if context.state.status != "completed" && context.state.totalCount > 0 {
Text("\(context.state.completedCount)/\(context.state.totalCount)")
.font(.caption)
.foregroundStyle(.secondary)
}
}
DynamicIslandExpandedRegion(.bottom) {
- let completed = context.state.tasks.filter { $0.status == .completed }
- if let prev = completed.last, context.state.status != "completed" {
- HStack(spacing: 6) {
- Image(systemName: "checkmark")
- .font(.caption2.weight(.semibold))
- .foregroundStyle(.green)
- Text(prev.truncatedContent)
- .font(.caption2)
- .foregroundStyle(.secondary)
- .lineLimit(1)
+ if context.state.totalCount > 0 {
+ // Progress bar in Dynamic Island
+ HStack(spacing: 2) {
+ ForEach(Array(context.state.tasks.enumerated()), id: \.offset) { _, task in
+ RoundedRectangle(cornerRadius: 2)
+ .fill(taskColor(task.status))
+ .frame(height: 4)
+ }
+ }
+ } else {
+ let completed = context.state.tasks.filter { $0.status == .completed }
+ if let prev = completed.last, context.state.status != "completed" {
+ HStack(spacing: 6) {
+ Image(systemName: "checkmark")
+ .font(.caption2.weight(.semibold))
+ .foregroundStyle(.green)
+ Text(prev.truncatedContent)
+ .font(.caption2)
+ .foregroundStyle(.secondary)
+ .lineLimit(1)
+ }
}
}
}
@@ -57,6 +68,10 @@ struct CodyncLiveActivityWidget: Widget {
Text("Done")
.font(.caption2)
.foregroundStyle(.green)
+ } else if context.state.totalCount > 0 {
+ Text("\(context.state.completedCount)/\(context.state.totalCount)")
+ .font(.caption2)
+ .foregroundStyle(.secondary)
} else {
Text(context.state.currentTask ?? "Working")
.font(.caption2)
@@ -76,6 +91,107 @@ struct CodyncLiveActivityWidget: Widget {
@ViewBuilder
private func lockScreenBanner(context: ActivityViewContext<CodyncAttributes>) -> some View {
let state = context.state
+
+ if state.totalCount > 0 {
+ progressBanner(context: context)
+ } else {
+ chowderBanner(context: context)
+ }
+ }
+
+ // MARK: - Progress Bar Mode (has task list)
+
+ @ViewBuilder
+ private func progressBanner(context: ActivityViewContext<CodyncAttributes>) -> some View {
+ let state = context.state
+ let isCompleted = state.status == "completed"
+ let primaryFg = Color(red: 47/255, green: 59/255, blue: 84/255)
+ let progress = state.totalCount > 0
+ ? Double(state.completedCount) / Double(state.totalCount)
+ : 0
+
+ VStack(alignment: .leading, spacing: 0) {
+ // Header
+ bannerHeader(context: context, primaryFg: primaryFg)
+
+ // Current task + progress
+ VStack(alignment: .leading, spacing: 10) {
+ if isCompleted {
+ // Completion
+ HStack(spacing: 8) {
+ Image(systemName: "checkmark.circle.fill")
+ .font(.system(size: 20))
+ .foregroundStyle(.green)
+ VStack(alignment: .leading, spacing: 1) {
+ Text("All tasks complete")
+ .font(.subheadline.bold())
+ .foregroundStyle(primaryFg)
+ Text("$\(String(format: "%.2f", state.costUSD))")
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(.horizontal, 6)
+ } else if let task = state.currentTask {
+ // Current task
+ HStack(alignment: .top, spacing: 6) {
+ Image(systemName: "arrow.turn.down.right")
+ .font(.system(size: 11, weight: .semibold))
+ .foregroundStyle(primaryFg.opacity(0.4))
+ .frame(width: 16, height: 16)
+ .padding(.top, 1)
+ Text(task)
+ .font(.callout)
+ .foregroundStyle(primaryFg)
+ .lineLimit(2)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+ .padding(.horizontal, 6)
+ }
+
+ // Progress bar
+ VStack(spacing: 6) {
+ // Segmented progress
+ HStack(spacing: 2) {
+ ForEach(Array(state.tasks.enumerated()), id: \.offset) { _, task in
+ RoundedRectangle(cornerRadius: 3)
+ .fill(taskColor(task.status))
+ .frame(height: 6)
+ }
+ }
+ .padding(.horizontal, 6)
+
+ // Count + percentage
+ HStack {
+ Text("\(state.completedCount)/\(state.totalCount) tasks")
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ Spacer()
+ Text("\(Int(progress * 100))%")
+ .font(.caption.bold())
+ .foregroundStyle(primaryFg.opacity(0.6))
+ }
+ .padding(.horizontal, 6)
+ }
+ }
+ .frame(maxHeight: .infinity)
+
+ // Footer
+ bannerFooter(context: context, primaryFg: primaryFg, isWaiting: false)
+ }
+ .padding(.horizontal, 8)
+ .padding(.vertical, 10)
+ .frame(height: 160)
+ .background(Color.white.opacity(isCompleted ? 1 : 0.75))
+ .activityBackgroundTint(.clear)
+ }
+
+ // MARK: - Chowder Card Mode (no task list)
+
+ @ViewBuilder
+ private func chowderBanner(context: ActivityViewContext<CodyncAttributes>) -> some View {
+ let state = context.state
let isCompleted = state.status == "completed"
let completedTasks = state.tasks.filter { $0.status == .completed }
@@ -95,57 +211,12 @@ struct CodyncLiveActivityWidget: Widget {
let primaryFg = Color(red: 47/255, green: 59/255, blue: 84/255)
VStack(alignment: .leading, spacing: 4) {
- // MARK: Header
- HStack(spacing: 10) {
- HStack(spacing: 6) {
- Image(systemName: "chevron.left.forwardslash.chevron.right")
- .font(.system(size: 10, weight: .bold))
- .foregroundStyle(primaryFg.opacity(0.6))
- .frame(width: 21, height: 21)
- .background(primaryFg.opacity(0.08), in: Circle())
-
- Text(context.attributes.projectName)
- .font(.callout.bold())
- .opacity(0.72)
- .lineLimit(1)
- }
+ // Header
+ bannerHeader(context: context, primaryFg: primaryFg)
- Spacer()
-
- if state.costUSD > 0 {
- let costStr = String(format: "$%.2f", state.costUSD)
- let alert = state.costUSD >= 1.0
- Text(costStr)
- .font(.subheadline)
- .fontWeight(.regular)
- .padding(.vertical, 4)
- .padding(.horizontal, 8)
- .overlay {
- Capsule()
- .stroke(primaryFg.opacity(alert ? 0.06 : 0.12))
- }
- .background(primaryFg.opacity(alert ? 0.12 : 0), in: Capsule())
- .monospacedDigit()
- } else {
- HStack(spacing: 5) {
- Circle()
- .fill(statusColor(state.status))
- .frame(width: 5, height: 5)
- Text(statusLabel(state.status))
- .opacity(0.48)
- }
- .transition(.blurReplace)
- }
- }
- .font(.subheadline.bold())
- .frame(height: 28)
- .padding(.horizontal, 6)
- .foregroundStyle(primaryFg)
-
- // MARK: Cards area
+ // Cards area
ZStack {
if isCompleted {
- // Completion view
VStack(alignment: .center, spacing: 8) {
Image(systemName: "checkmark")
.font(.system(size: 16, weight: .bold))
@@ -157,7 +228,7 @@ struct CodyncLiveActivityWidget: Widget {
Text("Session Complete")
.font(.subheadline.bold())
.foregroundStyle(primaryFg)
- Text("\(state.completedCount)/\(state.totalCount) tasks · $\(String(format: "%.2f", state.costUSD))")
+ Text("$\(String(format: "%.2f", state.costUSD))")
.font(.footnote)
.foregroundStyle(.secondary)
}
@@ -165,7 +236,6 @@ struct CodyncLiveActivityWidget: Widget {
.frame(maxWidth: .infinity)
.padding(.bottom, 12)
} else if isWaiting {
- // Chat bubble — waiting for first task to complete
Text(state.currentTask ?? "Analyzing code…")
.lineLimit(2)
.multilineTextAlignment(.leading)
@@ -182,7 +252,6 @@ struct CodyncLiveActivityWidget: Widget {
.frame(maxWidth: .infinity, alignment: .trailing)
.transition(.blurReplace)
} else {
- // Stacked task cards
ZStack {
ForEach(cards, id: \.self) { card in
let isBehind = card != frontCard
@@ -198,52 +267,113 @@ struct CodyncLiveActivityWidget: Widget {
.frame(maxHeight: .infinity)
.zIndex(10)
- // MARK: Footer
+ // Footer
+ bannerFooter(context: context, primaryFg: primaryFg, isWaiting: isWaiting)
+ }
+ .padding(.horizontal, 8)
+ .padding(.vertical, 10)
+ .frame(height: 160)
+ .background(Color.white.opacity(isWaiting || isCompleted ? 1 : 0.75))
+ .activityBackgroundTint(.clear)
+ }
+
+ // MARK: - Shared Banner Components
+
+ @ViewBuilder
+ private func bannerHeader(context: ActivityViewContext<CodyncAttributes>, primaryFg: Color) -> some View {
+ let state = context.state
+
+ HStack(spacing: 10) {
HStack(spacing: 6) {
- if isCompleted {
- Text("^[\(state.totalCount) task](inflect: true) completed")
- .transition(.blurReplace)
- .padding(.leading, 8)
- } else {
- HStack(spacing: 2) {
- Image(systemName: statusIcon(state.status))
- .frame(width: 24, height: 18)
- Text(isWaiting ? "Starting…" : (state.currentTask ?? statusLabel(state.status)))
- .lineLimit(1)
- .frame(maxWidth: .infinity, alignment: .leading)
- .multilineTextAlignment(.leading)
+ Image(systemName: "chevron.left.forwardslash.chevron.right")
+ .font(.system(size: 10, weight: .bold))
+ .foregroundStyle(primaryFg.opacity(0.6))
+ .frame(width: 21, height: 21)
+ .background(primaryFg.opacity(0.08), in: Circle())
+
+ Text(context.attributes.projectName)
+ .font(.callout.bold())
+ .opacity(0.72)
+ .lineLimit(1)
+ }
+
+ Spacer()
+
+ if state.costUSD > 0 {
+ let costStr = String(format: "$%.2f", state.costUSD)
+ let alert = state.costUSD >= 1.0
+ Text(costStr)
+ .font(.subheadline)
+ .fontWeight(.regular)
+ .padding(.vertical, 4)
+ .padding(.horizontal, 8)
+ .overlay {
+ Capsule()
+ .stroke(primaryFg.opacity(alert ? 0.06 : 0.12))
}
- .id(state.currentTask)
- .transition(.blurReplace)
+ .background(primaryFg.opacity(alert ? 0.12 : 0), in: Capsule())
+ .monospacedDigit()
+ } else {
+ HStack(spacing: 5) {
+ Circle()
+ .fill(statusColor(state.status))
+ .frame(width: 5, height: 5)
+ Text(statusLabel(state.status))
+ .opacity(0.48)
}
+ .transition(.blurReplace)
+ }
+ }
+ .font(.subheadline.bold())
+ .frame(height: 28)
+ .padding(.horizontal, 6)
+ .foregroundStyle(primaryFg)
+ }
- Spacer()
+ @ViewBuilder
+ private func bannerFooter(context: ActivityViewContext<CodyncAttributes>, primaryFg: Color, isWaiting: Bool) -> some View {
+ let state = context.state
+ let isCompleted = state.status == "completed"
- if !isWaiting {
- Text("00:00")
- .opacity(0)
- .overlay(alignment: .trailing) {
- Text(state.sessionStartDate, style: .timer)
- .contentTransition(.numericText(countsDown: false))
- .opacity(0.5)
- }
- .font(.footnote.bold())
- .monospacedDigit()
- .multilineTextAlignment(.trailing)
- .layoutPriority(1)
+ HStack(spacing: 6) {
+ if isCompleted {
+ Text("^[\(state.totalCount) task](inflect: true) completed")
+ .transition(.blurReplace)
+ .padding(.leading, 8)
+ } else {
+ HStack(spacing: 2) {
+ Image(systemName: statusIcon(state.status))
+ .frame(width: 24, height: 18)
+ Text(isWaiting ? "Starting…" : (state.currentTask ?? statusLabel(state.status)))
+ .lineLimit(1)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .multilineTextAlignment(.leading)
}
+ .id(state.currentTask)
+ .transition(.blurReplace)
+ }
+
+ Spacer()
+
+ if !isWaiting {
+ Text("00:00")
+ .opacity(0)
+ .overlay(alignment: .trailing) {
+ Text(state.sessionStartDate, style: .timer)
+ .contentTransition(.numericText(countsDown: false))
+ .opacity(0.5)
+ }
+ .font(.footnote.bold())
+ .monospacedDigit()
+ .multilineTextAlignment(.trailing)
+ .layoutPriority(1)
}
- .foregroundStyle(primaryFg)
- .padding(.leading, 4)
- .padding(.trailing, 12)
- .font(.footnote.bold())
- .opacity(isWaiting || isCompleted ? 0.36 : 1)
}
- .padding(.horizontal, 8)
- .padding(.vertical, 10)
- .frame(height: 160)
- .background(Color.white.opacity(isWaiting || isCompleted ? 1 : 0.75))
- .activityBackgroundTint(.clear)
+ .foregroundStyle(primaryFg)
+ .padding(.leading, 4)
+ .padding(.trailing, 12)
+ .font(.footnote.bold())
+ .opacity(isWaiting || isCompleted ? 0.36 : 1)
}
// MARK: - Helpers
@@ -286,9 +416,17 @@ struct CodyncLiveActivityWidget: Widget {
default: "arrow.turn.down.right"
}
}
+
+ private func taskColor(_ status: TaskStatus) -> Color {
+ switch status {
+ case .completed: .blue
+ case .inProgress: .blue.opacity(0.4)
+ case .pending: Color(.systemGray4)
+ }
+ }
}
-// MARK: - Task Card
+// MARK: - Task Card (chowder mode)
struct TaskCard: View {
let text: String