Skip to content

Commit 5b23724

Browse files
committed
H0X6
Save chat locally. Fixed new chat creation to only trigger on Cmd+N or app open. Removed UserInterfaceState.xcuserstate. (Thanks @mrinmoymsarkar)
1 parent 8289d2f commit 5b23724

File tree

12 files changed

+903
-64
lines changed

12 files changed

+903
-64
lines changed

.gitignore

Lines changed: 174 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,181 @@
44
.LSOverride
55
Icon
66
._*
7+
.Spotlight-V100
8+
.Trashes
79

810
# Xcode
11+
#
12+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
13+
14+
## User settings
15+
xcuserdata/
916
*.xcuserstate
17+
18+
## Obj-C/Swift specific
19+
*.hmap
20+
*.ipa
21+
*.dSYM.zip
22+
*.dSYM
23+
24+
## Playgrounds
25+
timeline.xctimeline
26+
playground.xcworkspace
27+
28+
# Swift Package Manager
29+
#
30+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
31+
# Packages/
32+
# Package.pins
33+
# Package.resolved
34+
# *.xcodeproj
35+
#
36+
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
37+
# hence it is not needed unless you have added a package configuration file to your project
38+
.swiftpm
39+
40+
.build/
41+
42+
# CocoaPods
43+
#
44+
# We recommend against adding the Pods directory to your .gitignore. However
45+
# you should judge for yourself, the pros and cons are mentioned at:
46+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
47+
#
48+
# Pods/
49+
#
50+
# Add this line if you want to avoid checking in source code from the Xcode workspace
51+
# *.xcworkspace
52+
53+
# Carthage
54+
#
55+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
56+
# Carthage/Checkouts
57+
58+
Carthage/Build/
59+
60+
# Accio dependency management
61+
Dependencies/
62+
.accio/
63+
64+
# fastlane
65+
#
66+
# It is recommended to not store the screenshots in the git repo.
67+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
68+
# For more information about the recommended setup visit:
69+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
70+
71+
fastlane/report.xml
72+
fastlane/Preview.html
73+
fastlane/screenshots/**/*.png
74+
fastlane/test_output
75+
76+
# Code Injection
77+
#
78+
# After new code Injection tools there's a generated folder /iOSInjectionProject
79+
# https://github.com/johnno1962/injectionforxcode
80+
81+
iOSInjectionProject/
82+
83+
# macOS
84+
.DS_Store
85+
.AppleDouble
86+
.LSOverride
87+
88+
# Thumbnails
89+
._*
90+
91+
# Files that might appear in the root of a volume
92+
.DocumentRevisions-V100
93+
.fseventsd
94+
.Spotlight-V100
95+
.TemporaryItems
96+
.Trashes
97+
.VolumeIcon.icns
98+
.com.apple.timemachine.donotpresent
99+
100+
# Directories potentially created on remote AFP share
101+
.AppleDB
102+
.AppleDesktop
103+
Network Trash Folder
104+
Temporary Items
105+
.apdisk
106+
107+
# Xcode
108+
#
109+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
110+
111+
## User settings
10112
xcuserdata/
11-
*.xcodeproj/*
12-
!*.xcodeproj/project.pbxproj
13-
!*.xcodeproj/xcshareddata/
14-
!*.xcworkspace/contents.xcworkspacedata
113+
114+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
115+
*.xcscmblueprint
116+
*.xccheckout
117+
118+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
119+
build/
120+
DerivedData/
121+
*.moved-aside
122+
*.pbxuser
123+
!default.pbxuser
124+
*.mode1v3
125+
!default.mode1v3
126+
*.mode2v3
127+
!default.mode2v3
128+
*.perspectivev3
129+
!default.perspectivev3
130+
131+
# Swift Package Manager
132+
#
133+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
134+
# Packages/
135+
# Package.pins
136+
# Package.resolved
137+
# *.xcodeproj
138+
#
139+
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
140+
# hence it is not needed unless you have added a package configuration file to your project
141+
.swiftpm
142+
143+
.build/
144+
145+
# CocoaPods
146+
#
147+
# We recommend against adding the Pods directory to your .gitignore. However
148+
# you should judge for yourself, the pros and cons are mentioned at:
149+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
150+
#
151+
# Pods/
152+
#
153+
# Add this line if you want to avoid checking in source code from the Xcode workspace
154+
# *.xcworkspace
155+
156+
# Carthage
157+
#
158+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
159+
# Carthage/Checkouts
160+
161+
Carthage/Build/
162+
163+
# Accio dependency management
164+
Dependencies/
165+
.accio/
166+
167+
# fastlane
168+
#
169+
# It is recommended to not store the screenshots in the git repo.
170+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
171+
# For more information about the recommended setup visit:
172+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
173+
174+
fastlane/report.xml
175+
fastlane/Preview.html
176+
fastlane/screenshots/**/*.png
177+
fastlane/test_output
178+
179+
# Code Injection
180+
#
181+
# After new code Injection tools there's a generated folder /iOSInjectionProject
182+
# https://github.com/johnno1962/injectionforxcode
183+
184+
iOSInjectionProject/

Hush.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
279279
CODE_SIGN_STYLE = Automatic;
280280
COMBINE_HIDPI_IMAGES = YES;
281-
CURRENT_PROJECT_VERSION = 1;
281+
CURRENT_PROJECT_VERSION = H0X6;
282282
DEAD_CODE_STRIPPING = YES;
283283
DEVELOPMENT_TEAM = GH69QQ984P;
284284
ENABLE_HARDENED_RUNTIME = YES;
@@ -296,7 +296,7 @@
296296
"@executable_path/../Frameworks",
297297
);
298298
MACOSX_DEPLOYMENT_TARGET = 14.4;
299-
MARKETING_VERSION = 1.0;
299+
MARKETING_VERSION = 1.0.0;
300300
PRODUCT_BUNDLE_IDENTIFIER = com.kaizokonpaku.Hush;
301301
PRODUCT_NAME = "$(TARGET_NAME)";
302302
REGISTER_APP_GROUPS = YES;
@@ -314,7 +314,7 @@
314314
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
315315
CODE_SIGN_STYLE = Automatic;
316316
COMBINE_HIDPI_IMAGES = YES;
317-
CURRENT_PROJECT_VERSION = 1;
317+
CURRENT_PROJECT_VERSION = H0X6;
318318
DEAD_CODE_STRIPPING = YES;
319319
DEVELOPMENT_TEAM = GH69QQ984P;
320320
ENABLE_HARDENED_RUNTIME = YES;
@@ -332,7 +332,7 @@
332332
"@executable_path/../Frameworks",
333333
);
334334
MACOSX_DEPLOYMENT_TARGET = 14.4;
335-
MARKETING_VERSION = 1.0;
335+
MARKETING_VERSION = 1.0.0;
336336
PRODUCT_BUNDLE_IDENTIFIER = com.kaizokonpaku.Hush;
337337
PRODUCT_NAME = "$(TARGET_NAME)";
338338
REGISTER_APP_GROUPS = YES;
Binary file not shown.

Hush/App/HushApp.swift

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,82 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
3131
/// Shared app state
3232
private var appState = AppState.shared
3333

34+
/// Chat session service
35+
private let chatSessionService = ChatSessionService.shared
36+
3437
/// Called when the application finishes launching
3538
func applicationDidFinishLaunching(_ notification: Notification) {
3639
// Start with prohibited policy - will switch to accessory when chat is active
3740
NSApp.setActivationPolicy(.prohibited)
3841

3942
createCustomWindow()
4043
AppInitializer.initializeApp(window: window)
44+
45+
// Initialize chat session if chat is active
46+
if appState.isChatActive {
47+
print("🚀 App launching with active chat - starting session")
48+
chatSessionService.startNewSession()
49+
}
50+
51+
// Set up additional observers for app lifecycle
52+
setupAppLifecycleObservers()
53+
}
54+
55+
/// Called when the application is about to terminate
56+
func applicationWillTerminate(_ notification: Notification) {
57+
// Save any active chat session
58+
print("👋 App terminating - saving chat session")
59+
chatSessionService.closeCurrentSession()
60+
}
61+
62+
/// Called when the application becomes active (foreground)
63+
func applicationDidBecomeActive(_ notification: Notification) {
64+
print("👁️ App became active")
65+
66+
// Check if we need a new chat session when returning to foreground
67+
if appState.isChatActive && chatSessionService.currentSession == nil {
68+
print("🔄 Resuming chat session")
69+
chatSessionService.startNewSession()
70+
}
71+
}
72+
73+
/// Called when the application resigns active state (background)
74+
func applicationWillResignActive(_ notification: Notification) {
75+
print("🔽 App resigning active - saving chat session")
76+
chatSessionService.saveCurrentSession()
77+
}
78+
79+
/// Set up observers for app lifecycle events
80+
private func setupAppLifecycleObservers() {
81+
// Register for sleep/wake notifications
82+
NSWorkspace.shared.notificationCenter.addObserver(
83+
self,
84+
selector: #selector(systemWillSleep),
85+
name: NSWorkspace.willSleepNotification,
86+
object: nil
87+
)
88+
89+
NSWorkspace.shared.notificationCenter.addObserver(
90+
self,
91+
selector: #selector(systemDidWake),
92+
name: NSWorkspace.didWakeNotification,
93+
object: nil
94+
)
95+
}
96+
97+
/// Called when system is about to sleep
98+
@objc private func systemWillSleep() {
99+
print("💤 System going to sleep - saving chat session")
100+
chatSessionService.saveCurrentSession()
101+
}
102+
103+
/// Called when system wakes from sleep
104+
@objc private func systemDidWake() {
105+
print("⏰ System woke from sleep")
106+
// Check if we need to restore chat session
107+
if appState.isChatActive && chatSessionService.currentSession == nil {
108+
chatSessionService.startNewSession()
109+
}
41110
}
42111

43112
/// Creates the custom floating window

0 commit comments

Comments
 (0)