GlassAgentPanel
Tasks and observable steps with status, progress, errors and cancellation.
- Content
- iOS 26 · iPadOS 26 · macOS 26
- Version 1.1.0
glass-agent-panel
Content on an opaque, readable surface. Glass is kept for controls.
CaptureInstallation
spglass add glass-agent-panelCopies the sources and their dependencies into your project. Set up the CLI.
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")
import SPGlassKit| Identifier | glass-agent-panel |
|---|---|
| Module | SPGlassAI |
| Kind | content-component — task cards on opaque themed surfaces; no glass |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/AI/GlassAgentPanelExample.swift |
UI only: the panel displays value types that the host updates. It runs no agent and no task.
Minimal usage
GlassAgentPanel(tasks: agent.tasks)Variants
| Variant | Use |
|---|---|
onCancel: | Shows "Cancel" on pending and running tasks. |
expandedTaskIDs: | The host controls which step lists are open. Without it the panel keeps that state and opens the tasks that are running or failed when it is created. |
| Task without steps | Status tile, title and status only: no progress bar, no step list. |
| Step rail | Steps sit on a vertical rail. Each node tells the state by its shape and symbol (check, ring with a dot, dashed circle, cross, minus) and the status word is written under the step title. |
| Errors | A task or step errorMessage is shown in a tinted block with a warning symbol. |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
tasks | [GlassAgentTask] | — | Tasks in display order. |
expandedTaskIDs | Binding<Set<String>>? | nil | Controlled expansion of the step lists. |
onCancel | (@MainActor (GlassAgentTask) -> Void)? | nil | Called by a task's "Cancel" button. |
GlassAgentTask: id, title, status, steps, errorMessage. GlassAgentStep: id, title, status, detail, errorMessage. GlassAgentStatus: pending, running, succeeded, failed, cancelled.
GlassAgentProgress (task.progress) counts the steps that succeeded out of all steps: completed, total, fraction, summary ("2 of 5 steps completed").
States
| Status | Symbol | Word |
|---|---|---|
| Pending | circle.dotted | "Pending" |
| Running | arrow.triangle.2.circlepath | "Running" |
| Succeeded | checkmark.circle.fill | "Completed" |
| Failed | xmark.octagon.fill | "Failed" |
| Cancelled | minus.circle | "Cancelled" |
Errors (of a task or a step) are shown with a warning symbol and the host's message. An empty tasks array shows "No data".
Advanced example
struct AgentSidebar: View {
@Bindable var agent: AgentModel // host type; exposes [GlassAgentTask]
@State private var expanded: Set<String> = []
var body: some View {
ScrollView {
GlassAgentPanel(tasks: agent.tasks, expandedTaskIDs: $expanded) { task in
agent.cancel(task.id)
}
.padding()
}
.onChange(of: agent.tasks.first { $0.status == .failed }?.id) { _, failedID in
if let failedID { expanded.insert(failedID) } // open the task that just failed
}
}
}Accessibility
- Status is always a symbol and a word; colour only reinforces it.
- Each task header and each step is one combined element ("Group by topic, Running, Topic 3 of 5"); running ones have the "updates frequently" trait.
- The progress bar is labelled with the task title and its value is "2 of 5 steps completed".
- Errors read "Error: <message>". The cancel button reads "Cancel, <task title>".
- The step list is a system
DisclosureGroup: keyboard and VoiceOver expansion are the system's.
Limits
- The panel does not scroll by itself; put it in a
ScrollViewor aListrow. - All tasks are laid out eagerly: it is meant for the tasks of a session, not for an unbounded history.
- No animation runs while a task is running; the running state is a static symbol and a word.
- The default expansion is decided once, when the panel is created; later status changes do not open or close a task unless the host uses
expandedTaskIDs. - The rendering was not inspected in a running application during verification; progress, cancellability and status mapping are unit-tested.
Example
import SwiftUI
import SPGlassKit
public struct GlassAgentPanelExample: GlassExample {
public static let componentID = "glass-agent-panel"
/// Fictitious tasks: nothing is executed, the example only edits these values.
@State private var tasks = [
GlassAgentTask(id: "t1", title: "Prepare the sample weekly digest", status: .running, steps: [
GlassAgentStep(id: "s1", title: "Collect sample notes", status: .succeeded, detail: "12 notes found"),
GlassAgentStep(id: "s2", title: "Group by topic", status: .running, detail: "Topic 3 of 5"),
GlassAgentStep(id: "s3", title: "Write the digest", status: .pending),
]),
GlassAgentTask(id: "t2", title: "Rename sample files with a deliberately long task title that wraps over two lines", status: .failed, steps: [
GlassAgentStep(id: "s1", title: "List files", status: .succeeded),
GlassAgentStep(id: "s2", title: "Apply new names", status: .failed, detail: "4 of 9 renamed", errorMessage: "Sample failure: a file with this name already exists."),
]),
GlassAgentTask(id: "t3", title: "Translate sample page", status: .succeeded, steps: [
GlassAgentStep(id: "s1", title: "Detect language", status: .succeeded),
GlassAgentStep(id: "s2", title: "Translate", status: .succeeded),
]),
GlassAgentTask(id: "t4", title: "Queued sample export", status: .pending),
GlassAgentTask(id: "t5", title: "Sample clean-up", status: .cancelled, steps: [
GlassAgentStep(id: "s1", title: "Scan", status: .cancelled),
], errorMessage: nil),
]
public init() {}
public var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 12) {
Text("Sample data · simulated tasks, no agent is running")
.font(.caption)
.foregroundStyle(.secondary)
GlassAgentPanel(tasks: tasks) { task in
cancel(task.id)
}
GlassButton("Advance the running task", systemImage: "forward.frame") { advance() }
Divider()
Text("No task")
.font(.headline)
GlassAgentPanel(tasks: [])
}
.padding()
}
}
private func cancel(_ id: String) {
guard let index = tasks.firstIndex(where: { $0.id == id }) else { return }
tasks[index].status = .cancelled
for step in tasks[index].steps.indices where !tasks[index].steps[step].status.isTerminal {
tasks[index].steps[step].status = .cancelled
}
}
/// Completes the running step of the first running task and starts the next one.
private func advance() {
guard let index = tasks.firstIndex(where: { $0.status == .running }) else { return }
if let running = tasks[index].steps.firstIndex(where: { $0.status == .running }) {
tasks[index].steps[running].status = .succeeded
}
if let next = tasks[index].steps.firstIndex(where: { $0.status == .pending }) {
tasks[index].steps[next].status = .running
} else {
tasks[index].status = .succeeded
}
}
}
#Preview("GlassAgentPanel") { GlassAgentPanelExample().glassTheme(.obsidian) }
Registry entry
| Identifier | glass-agent-panel |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassAgentStatus, GlassAgentStep, GlassAgentTask, GlassAgentProgress, GlassAgentPanel |
| Licence | MIT |
| Manifest | manifest.json |
Files
AI/AI/GlassAgentPanel.swift18345 bytes · sha256 8217875e84f8…