SP GlassKit1.1.0

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.

GlassAgentPanel running in SP Glass Studio.Capture
Capture of the component running in SP Glass Studio on the iOS 26.5 simulator. Liquid Glass is rendered by the system; this is an image, not a live preview.

Installation

spglass add glass-agent-panel

Copies the sources and their dependencies into your project. Set up the CLI.

Swift
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")

import SPGlassKit
Identifierglass-agent-panel
ModuleSPGlassAI
Kindcontent-component — task cards on opaque themed surfaces; no glass
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/AI/GlassAgentPanelExample.swift

UI only: the panel displays value types that the host updates. It runs no agent and no task.

Minimal usage

Swift
GlassAgentPanel(tasks: agent.tasks)

Variants

VariantUse
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 stepsStatus tile, title and status only: no progress bar, no step list.
Step railSteps 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.
ErrorsA task or step errorMessage is shown in a tinted block with a warning symbol.

Parameters

ParameterTypeDefaultMeaning
tasks[GlassAgentTask]—Tasks in display order.
expandedTaskIDsBinding<Set<String>>?nilControlled expansion of the step lists.
onCancel(@MainActor (GlassAgentTask) -> Void)?nilCalled 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

StatusSymbolWord
Pendingcircle.dotted"Pending"
Runningarrow.triangle.2.circlepath"Running"
Succeededcheckmark.circle.fill"Completed"
Failedxmark.octagon.fill"Failed"
Cancelledminus.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

Swift
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 ScrollView or a List row.
  • 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

Complete example (compiled with the package)
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

Identifierglass-agent-panel
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassAgentStatus, GlassAgentStep, GlassAgentTask, GlassAgentProgress, GlassAgentPanel
LicenceMIT
Manifestmanifest.json

Files