Commit 8cd13e3
committed
🤖 Fix 3s startup freeze: Lazy-load AIService to defer AI SDK import
Root cause: IpcMain constructor eagerly created AIService, which imports
the massive 'ai' package (~3s load time) during loadServices(). This blocked
the main process before window could be shown, causing the macOS spinner.
Solution: Convert AIService to lazy property in IpcMain - only create on
first use. This defers the expensive AI SDK import until actually needed
(when first message is sent), keeping startup instant.
Also removed debug timing instrumentation logs that were added during
investigation (main.tsx, App.tsx, useResumeManager.ts).
Impact:
- Window appears immediately (no spinner)
- AI SDK loads on-demand when first stream starts
- Cleaner console output without timing noise1 parent c8018a4 commit 8cd13e3
File tree
4 files changed
+15
-35
lines changed- src
- hooks
- services
4 files changed
+15
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | 158 | | |
160 | | - | |
161 | 159 | | |
162 | 160 | | |
163 | 161 | | |
| |||
167 | 165 | | |
168 | 166 | | |
169 | 167 | | |
170 | | - | |
171 | 168 | | |
172 | 169 | | |
173 | 170 | | |
174 | 171 | | |
175 | 172 | | |
176 | 173 | | |
177 | | - | |
178 | 174 | | |
179 | 175 | | |
180 | 176 | | |
181 | 177 | | |
182 | 178 | | |
183 | 179 | | |
184 | | - | |
185 | 180 | | |
186 | 181 | | |
187 | | - | |
188 | 182 | | |
189 | | - | |
190 | 183 | | |
191 | 184 | | |
192 | 185 | | |
193 | 186 | | |
194 | | - | |
195 | 187 | | |
196 | 188 | | |
197 | | - | |
198 | 189 | | |
199 | | - | |
200 | 190 | | |
201 | 191 | | |
202 | 192 | | |
| |||
209 | 199 | | |
210 | 200 | | |
211 | 201 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | 202 | | |
218 | 203 | | |
219 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | 120 | | |
124 | 121 | | |
125 | 122 | | |
| |||
130 | 127 | | |
131 | 128 | | |
132 | 129 | | |
133 | | - | |
134 | | - | |
135 | 130 | | |
136 | 131 | | |
137 | 132 | | |
| |||
144 | 139 | | |
145 | 140 | | |
146 | 141 | | |
147 | | - | |
148 | 142 | | |
149 | 143 | | |
150 | | - | |
151 | 144 | | |
152 | 145 | | |
153 | 146 | | |
| |||
178 | 171 | | |
179 | 172 | | |
180 | 173 | | |
181 | | - | |
182 | 174 | | |
183 | 175 | | |
184 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | 1 | | |
6 | 2 | | |
7 | 3 | | |
8 | 4 | | |
9 | | - | |
10 | | - | |
11 | 5 | | |
12 | 6 | | |
13 | 7 | | |
| |||
30 | 24 | | |
31 | 25 | | |
32 | 26 | | |
33 | | - | |
34 | | - | |
35 | 27 | | |
36 | 28 | | |
37 | 29 | | |
38 | 30 | | |
39 | 31 | | |
40 | | - | |
41 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
62 | 75 | | |
63 | 76 | | |
64 | 77 | | |
| |||
0 commit comments