Move update view model to AppDelegate
I'll help you move the update view model data to AppDelegate. Let me first locate the relevant files.
Now I can see the structure. The UpdateViewModel is currently instantiated in TerminalWindow (line 20), but it should be app-global in AppDelegate. Let me check how it's being used in other places:
Now I understand the structure. I need to:
- Move
updateUIModelfromTerminalWindowtoAppDelegate - Update references to access it from AppDelegate instead
- Update the
createUpdateActions()method to work with the app-global model
Let me make these changes:
Now I need to update the checkForUpdates method in AppDelegate to use the app-global model:
Now let me verify the build to ensure everything compiles correctly:
Perfect! The build succeeded. Let me create a summary of the changes:
Summary
I've successfully moved the update view model data from TerminalWindow to AppDelegate to make it app-global. Here's what was changed:
Changes Made:
-
- Added
@Published private(set) var updateUIModel = UpdateViewModel()to make it a global, observable property
- Added
[TerminalWindow.swift](file:///Users/mitchellh/Documents/ghostty/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift#L19)
- Removed the instance-level
updateUIModelproperty - Updated the update accessory view initialization to use
appDelegate.updateUIModelinstead - Refactored
createUpdateActions()to access the model viaAppDelegateinstead ofself
- Removed the instance-level
AppDelegate.swift
checkForUpdatesmethod- Simplified to use the app-global
updateUIModeldirectly instead of getting it from the terminal window
- Simplified to use the app-global
The update information is now app-global and shared across all windows, which makes sense since updates affect the entire application.