iOS Widgets & App Intents
Relevant source files
The following files were used as context for generating this wiki page:
The iOS Widgets and App Intents system provides quick access to Conduit's chat and multimodal features directly from the iOS Home Screen or through system integrations like Shortcuts and Siri. This module implements native Swift components that bridge iOS system capabilities with the Flutter-based core application.
Sources: README.md:144, ios/ConduitWidget/ConduitWidget.swift
Architecture Overview
Conduit utilizes a bridge architecture to handle communication between the native iOS environment and the Flutter application. App Intents define discrete actions that the system can perform, while Widgets provide a visual interface for these actions.
The diagram shows how user interactions with system-level components transition through native Swift definitions before reaching the Flutter application layer.
Sources: ios/Runner/AppIntentBridge.swift, ios/ConduitWidget/ConduitWidget.swift
Home Screen Widgets
Conduit provides Home Screen widgets that act as shortcuts for common chat initiation tasks. These widgets utilize SwiftUI for rendering and App Intents for handling interactions.
Supported Widget Actions
Widgets support several specific entry points into the application:
| Action | Intent Class | Purpose |
|---|---|---|
| New Chat | NewChatIntent | Opens the app to a fresh chat interface. |
| Voice | VoiceIntent | Starts the app directly in voice-call mode. |
| Camera | CameraIntent | Opens the camera to attach a photo to a new prompt. |
| Photos | PhotosIntent | Opens the photo library for image attachments. |
| Clipboard | ClipboardIntent | Ingests the current clipboard content into a new prompt. |
Sources: README.md:144, ios/Runner/ConduitAppIntents.swift:14-50
Widget UI Structure
The widget UI is composed of interactive buttons styled to match the Conduit brand. Each button is bound to a specific AppIntent.
The flow illustrates how widget buttons map directly to specific native intents.
Sources: ios/ConduitWidget/ConduitWidget.swift, ios/Runner/ConduitAppIntents.swift
App Intents Framework
App Intents are the programmatic definitions of actions Conduit exposes to the system. These intents are used by both the Widgets and the iOS Shortcuts app.
Intent Execution Flow
When an intent is triggered, it follows a specific execution path to notify the main application:
- The system calls the
perform()method on the specific intent (e.g.,NewChatIntent). - The intent delegates execution to the
AppIntentBridge.shared.handle()method. - The bridge uses a
FlutterMethodChannelnamedapp.cogwheel.conduit/intentsto send the action name to Flutter. - The intent returns an
.result()to the system, signaling the app should open.
Sources: ios/Runner/AppIntentBridge.swift:16-35, ios/Runner/ConduitAppIntents.swift:15-18
Implementation Detail: AppIntentBridge
The AppIntentBridge class manages the communication link between native code and Flutter.
final class AppIntentBridge {
static let shared = AppIntentBridge()
private var channel: FlutterMethodChannel?
func attach(to messenger: FlutterBinaryMessenger) {
channel = FlutterMethodChannel(
name: "app.cogwheel.conduit/intents",
binaryMessenger: messenger
)
}
func handle(action: String) {
channel?.invokeMethod("onIntentAction", arguments: action)
}
}
Sources: ios/Runner/AppIntentBridge.swift:8-25
System Integrations
By implementing AppIntent, Conduit's actions automatically become available in the system-wide Shortcuts app. This allows users to create automated workflows involving Conduit.
Available Intents
The following intent types are defined in the project:
- Static Intents: Actions that require no parameters, such as
NewChatIntentorVoiceIntent. - Multimodal Intents: Actions that trigger specific system interfaces before app launch, like
CameraIntentandPhotosIntent.
Sources: ios/Runner/ConduitAppIntents.swift:14-50, README.md:144-145
Conclusion
The iOS Widgets and App Intents system extends Conduit beyond the application sandbox, integrating it directly into the iOS user experience. By leveraging the App Intents framework and a custom Flutter bridge, the project ensures that quick actions and shortcuts remain responsive and tightly coupled with the application's core logic.