INNER CODE UNIT · Swift
applicationShouldTerminate
AgentiLoop/Agent · Agent/AgentApp.swift:102
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
// Tell the view model to stop all running tasks, MCP servers, etc.
NotificationCenter.default.post(name: .appWillQuit, object: nil)
// Drain compilation queue before exit to prevent stdout deadlock with C++ static destructors.
ScriptService.drainCompilationQueue()
return .terminateNow
}
}
@main
struct AgentApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@AppStorage(UpdateChecker.includePrereleasesKey) private var includePrereleases = false
var body: some Scene {
WindowGroup {
ContentView()
.task {
// Initialize SwiftData chat history store