new macOS version
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// FloatingHUDView.swift — Content for the always-on-top focus HUD panel
|
||||
// All notifications (friction, nudges, resume) render here — not in system notifications.
|
||||
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
struct FloatingHUDView: View {
|
||||
@@ -19,23 +21,24 @@ struct FloatingHUDView: View {
|
||||
.animation(.spring(duration: 0.3), value: session.isExecuting)
|
||||
.animation(.spring(duration: 0.3), value: session.executorOutput?.title)
|
||||
.animation(.spring(duration: 0.3), value: session.monitoringError)
|
||||
.animation(.spring(duration: 0.3), value: session.nudgeMessage)
|
||||
.animation(.spring(duration: 0.3), value: session.showingResumeCard)
|
||||
}
|
||||
|
||||
// MARK: - Header
|
||||
|
||||
private var header: some View {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "eye.fill")
|
||||
.foregroundStyle(.blue)
|
||||
Image(systemName: session.isSessionActive ? "eye.fill" : "eye")
|
||||
.foregroundStyle(session.isSessionActive ? .blue : .secondary)
|
||||
.font(.caption)
|
||||
|
||||
Text(session.activeTask?.title ?? "Focus Session")
|
||||
Text(session.activeTask?.title ?? (session.isSessionActive ? "Focus Session" : "Argus Monitoring"))
|
||||
.font(.caption.bold())
|
||||
.lineLimit(1)
|
||||
|
||||
Spacer()
|
||||
|
||||
// Pulse dot — green when capturing, orange when executing
|
||||
if session.isExecuting {
|
||||
Image(systemName: "bolt.fill")
|
||||
.font(.caption2)
|
||||
@@ -55,24 +58,24 @@ struct FloatingHUDView: View {
|
||||
.padding(.vertical, 10)
|
||||
}
|
||||
|
||||
// MARK: - Content
|
||||
// MARK: - Content (priority order)
|
||||
|
||||
@ViewBuilder
|
||||
private var content: some View {
|
||||
// Error / warning banner — shown above all other content when monitoring has a problem
|
||||
// 1. Error / warning banner
|
||||
if let error = session.monitoringError {
|
||||
MonitoringErrorBanner(message: error)
|
||||
.transition(.move(edge: .top).combined(with: .opacity))
|
||||
}
|
||||
|
||||
// Executor output sticky card (highest priority — persists until dismissed)
|
||||
// 2. Executor output sticky card (highest priority — persists until dismissed)
|
||||
if let output = session.executorOutput {
|
||||
ExecutorOutputCard(title: output.title, content: output.content) {
|
||||
session.executorOutput = nil
|
||||
}
|
||||
.transition(.move(edge: .top).combined(with: .opacity))
|
||||
}
|
||||
// Executing spinner
|
||||
// 3. Executing spinner
|
||||
else if session.isExecuting {
|
||||
HStack(spacing: 10) {
|
||||
ProgressView()
|
||||
@@ -84,34 +87,196 @@ struct FloatingHUDView: View {
|
||||
.padding(14)
|
||||
.transition(.opacity)
|
||||
}
|
||||
// Proactive friction card
|
||||
// 4. Resume card (shown in HUD, not as system overlay)
|
||||
else if session.showingResumeCard, let card = session.resumeCard {
|
||||
ResumeCardView(card: card)
|
||||
.transition(.move(edge: .top).combined(with: .opacity))
|
||||
}
|
||||
// 5. Proactive friction / session action card
|
||||
else if let card = session.proactiveCard {
|
||||
HUDCardView(card: card)
|
||||
.transition(.move(edge: .top).combined(with: .opacity))
|
||||
}
|
||||
// Latest VLM summary (idle state)
|
||||
// 6. Nudge card (amber, shown in HUD instead of system notification)
|
||||
else if let nudge = session.nudgeMessage {
|
||||
NudgeCardView(message: nudge)
|
||||
.transition(.move(edge: .top).combined(with: .opacity))
|
||||
}
|
||||
// 7. Idle state — latest VLM summary
|
||||
else if session.monitoringError == nil {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
if let task = session.latestInferredTask, !task.isEmpty {
|
||||
IdleSummaryView()
|
||||
.transition(.opacity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Nudge Card (amber — replaces UNUserNotificationCenter)
|
||||
|
||||
private struct NudgeCardView: View {
|
||||
let message: String
|
||||
@Environment(SessionManager.self) private var session
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
Image(systemName: "lightbulb.fill")
|
||||
.foregroundStyle(.orange)
|
||||
.font(.caption)
|
||||
|
||||
Text(message)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.primary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.lineLimit(4)
|
||||
|
||||
Spacer(minLength: 0)
|
||||
|
||||
Button { session.dismissNudge() } label: {
|
||||
Image(systemName: "xmark")
|
||||
.font(.caption2.bold())
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.padding(12)
|
||||
.background(Color.orange.opacity(0.08))
|
||||
.overlay(
|
||||
Rectangle()
|
||||
.frame(width: 3)
|
||||
.foregroundStyle(Color.orange),
|
||||
alignment: .leading
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Resume Card (warm welcome-back in HUD)
|
||||
|
||||
private struct ResumeCardView: View {
|
||||
let card: ResumeCard
|
||||
@Environment(SessionManager.self) private var session
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "arrow.counterclockwise.circle.fill")
|
||||
.foregroundStyle(.blue)
|
||||
.font(.caption)
|
||||
Text(card.welcomeBack)
|
||||
.font(.caption.bold())
|
||||
.foregroundStyle(.blue)
|
||||
Spacer()
|
||||
Button { session.showingResumeCard = false } label: {
|
||||
Image(systemName: "xmark")
|
||||
.font(.caption2.bold())
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
Text(card.youWereDoing)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.primary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
|
||||
Text(card.nextStep)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
|
||||
Text(card.motivation)
|
||||
.font(.caption.italic())
|
||||
.foregroundStyle(.blue.opacity(0.8))
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
|
||||
Button("Got it — let's go") {
|
||||
session.showingResumeCard = false
|
||||
}
|
||||
.font(.caption.bold())
|
||||
.foregroundStyle(.white)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 5)
|
||||
.background(Color.blue)
|
||||
.clipShape(.rect(cornerRadius: 6))
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
.padding(14)
|
||||
.background(Color.blue.opacity(0.07))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Idle Summary View
|
||||
|
||||
private struct IdleSummaryView: View {
|
||||
@Environment(SessionManager.self) private var session
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
// Step progress — only when session is active with steps
|
||||
if session.isSessionActive && session.totalSteps > 0 {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "checklist")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.blue)
|
||||
Text("Step \(min(session.completedCount + 1, session.totalSteps))/\(session.totalSteps): \(session.currentStep?.title ?? "In progress")")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.blue)
|
||||
.lineLimit(1)
|
||||
}
|
||||
Divider()
|
||||
}
|
||||
|
||||
// Inferred task
|
||||
if let task = session.latestInferredTask, !task.isEmpty {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("DOING NOW")
|
||||
.font(.system(size: 9, weight: .semibold))
|
||||
.foregroundStyle(.secondary)
|
||||
.tracking(0.5)
|
||||
Text(task)
|
||||
.font(.caption.bold())
|
||||
.foregroundStyle(.primary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.lineLimit(2)
|
||||
}
|
||||
}
|
||||
|
||||
// App badge + VLM summary
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
if let app = session.latestAppName, !app.isEmpty {
|
||||
Text(app)
|
||||
.font(.system(size: 9, weight: .medium))
|
||||
.foregroundStyle(.purple)
|
||||
.padding(.horizontal, 5)
|
||||
.padding(.vertical, 2)
|
||||
.background(Color.purple.opacity(0.1))
|
||||
.clipShape(.capsule)
|
||||
.lineLimit(1)
|
||||
}
|
||||
Text(session.latestVlmSummary ?? "Monitoring your screen…")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.lineLimit(3)
|
||||
}
|
||||
.padding(14)
|
||||
.transition(.opacity)
|
||||
|
||||
// Distraction count badge
|
||||
if session.isSessionActive && session.distractionCount > 0 {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "exclamationmark.triangle")
|
||||
.font(.system(size: 9))
|
||||
.foregroundStyle(.orange)
|
||||
Text("\(session.distractionCount) distraction\(session.distractionCount == 1 ? "" : "s") this session")
|
||||
.font(.system(size: 9))
|
||||
.foregroundStyle(.orange)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(14)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - HUD Card (friction + proposed actions)
|
||||
// MARK: - HUD Card (friction + proposed actions / session actions)
|
||||
|
||||
private struct HUDCardView: View {
|
||||
let card: ProactiveCard
|
||||
@@ -145,7 +310,6 @@ private struct HUDCardView: View {
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
// Action buttons
|
||||
actionButtons
|
||||
}
|
||||
.padding(14)
|
||||
@@ -161,24 +325,15 @@ private struct HUDCardView: View {
|
||||
Button {
|
||||
session.approveProactiveCard(actionIndex: index)
|
||||
} label: {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(action.label)
|
||||
.font(.caption.bold())
|
||||
.lineLimit(2)
|
||||
.multilineTextAlignment(.leading)
|
||||
if let details = action.details, !details.isEmpty {
|
||||
Text(details)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.purple.opacity(0.7))
|
||||
.lineLimit(2)
|
||||
.multilineTextAlignment(.leading)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 6)
|
||||
.background(Color.purple.opacity(0.12))
|
||||
.clipShape(.rect(cornerRadius: 8))
|
||||
Text(action.label)
|
||||
.font(.caption.bold())
|
||||
.lineLimit(2)
|
||||
.multilineTextAlignment(.leading)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 6)
|
||||
.background(Color.purple.opacity(0.12))
|
||||
.clipShape(.rect(cornerRadius: 8))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(.purple)
|
||||
@@ -186,7 +341,7 @@ private struct HUDCardView: View {
|
||||
notNowButton
|
||||
}
|
||||
|
||||
case .sessionAction(let type, _, _, _, _):
|
||||
case .sessionAction(let type, _, _, _, _, _):
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Button {
|
||||
session.approveProactiveCard(actionIndex: 0)
|
||||
@@ -201,6 +356,26 @@ private struct HUDCardView: View {
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(.purple)
|
||||
|
||||
notNowButton
|
||||
}
|
||||
|
||||
case .appSwitchLoop:
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Button {
|
||||
session.approveProactiveCard(actionIndex: 0)
|
||||
} label: {
|
||||
Text("Help me with this")
|
||||
.font(.caption.bold())
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 6)
|
||||
.background(Color.purple.opacity(0.12))
|
||||
.clipShape(.rect(cornerRadius: 8))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(.purple)
|
||||
|
||||
notNowButton
|
||||
}
|
||||
|
||||
@@ -222,7 +397,7 @@ private struct HUDCardView: View {
|
||||
case "resume": return "Resume session"
|
||||
case "switch": return "Switch to this task"
|
||||
case "complete": return "Mark complete"
|
||||
case "start_new": return "Start focus session"
|
||||
case "start_new": return "Create task + start focus session"
|
||||
default: return "OK"
|
||||
}
|
||||
}
|
||||
@@ -233,7 +408,7 @@ private struct HUDCardView: View {
|
||||
return description ?? "I noticed something that might be slowing you down."
|
||||
case .appSwitchLoop(let apps, let count):
|
||||
return "You've switched between \(apps.joined(separator: " ↔ ")) \(count)× — are you stuck?"
|
||||
case .sessionAction(_, _, let checkpoint, let reason, _):
|
||||
case .sessionAction(_, _, let checkpoint, let reason, _, _):
|
||||
if !checkpoint.isEmpty { return "Left off: \(checkpoint)" }
|
||||
return reason.isEmpty ? "Argus noticed a session change." : reason
|
||||
}
|
||||
@@ -293,6 +468,13 @@ private struct ExecutorOutputCard: View {
|
||||
let content: String
|
||||
let onDismiss: () -> Void
|
||||
|
||||
@State private var copied = false
|
||||
|
||||
private var maxScrollHeight: CGFloat {
|
||||
let screenHeight = NSScreen.main?.visibleFrame.height ?? 800
|
||||
return max(120, screenHeight - 157)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack(spacing: 6) {
|
||||
@@ -316,16 +498,34 @@ private struct ExecutorOutputCard: View {
|
||||
Text(content)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.primary)
|
||||
.textSelection(.enabled)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.frame(maxHeight: 120)
|
||||
.frame(maxHeight: maxScrollHeight)
|
||||
|
||||
Button("Dismiss") { onDismiss() }
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
HStack {
|
||||
Button("Dismiss") { onDismiss() }
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.buttonStyle(.plain)
|
||||
Spacer()
|
||||
Button {
|
||||
NSPasteboard.general.clearContents()
|
||||
NSPasteboard.general.setString(content, forType: .string)
|
||||
copied = true
|
||||
Task {
|
||||
try? await Task.sleep(for: .seconds(2))
|
||||
copied = false
|
||||
}
|
||||
} label: {
|
||||
Label(copied ? "Copied!" : "Copy", systemImage: copied ? "checkmark" : "doc.on.doc")
|
||||
.font(.caption.bold())
|
||||
.foregroundStyle(copied ? AnyShapeStyle(.secondary) : AnyShapeStyle(Color.green))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
.animation(.easeInOut(duration: 0.15), value: copied)
|
||||
}
|
||||
}
|
||||
.padding(14)
|
||||
.background(Color.green.opacity(0.07))
|
||||
|
||||
Reference in New Issue
Block a user