Commit 79d52c1
committed
perf(git): cache status updates and optimize editor refresh
Rework backend git status handling around cached repository metadata and faster per-file updates.
Backend git changes:
- include head_hash in full and patch git status payloads so clients can distinguish HEAD changes from regular file patches
- cache the discovered git repository, metadata snapshots, parsed index entries, HEAD blob SHA values, HEAD blob content, and numstat results
- make check_status_changed inspect .git/index, HEAD, current refs, packed refs, and merge/rebase marker files before recomputing a full status
- replace the per-file git2 diff path with custom index parsing plus in-memory diffing, while keeping git status --porcelain as a fallback
- compute numstat with similar::utils::diff_slices instead of git2 diff iteration
- track HEAD changes in the status cache and force full updates when branch or HEAD hash changes
- stop creating merge commits with a synthetic Anycode User identity and surface a clear error when git user.name/user.email are not configured
Editor and frontend changes:
- make Code.init tolerate unsupported languages and tree-sitter WASM load failures by clearing syntax state and resetting the language
- centralize tree-sitter language loading through a shared loadLanguage helper with pending-load caching
- return an empty language for unknown file extensions instead of defaulting to javascript
- remove ruby and php from supported language extension mappings and add toml support
- invalidate syntax highlighting cache only from the edited line downward instead of clearing the whole cache
- update renderer change refresh to compare visual rows directly and reuse precomputed syntax nodes
- avoid requesting git:file-original on patch updates so open editors only refresh original content after full git status updates
Tests:
- add backend git tests for numstat correctness, subdirectory workdirs, deleted files, and staged-then-deleted states
- add editor cache invalidation coverage for preserving cached lines above edits1 parent f301257 commit 79d52c1
13 files changed
Lines changed: 1128 additions & 200 deletions
File tree
- anycode-backend/src
- handlers
- tests
- anycode-base
- src
- renderer
- tests
- anycode
- hooks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | | - | |
| 165 | + | |
| 166 | + | |
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| |||
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
222 | | - | |
| 224 | + | |
| 225 | + | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
| |||
274 | 277 | | |
275 | 278 | | |
276 | 279 | | |
277 | | - | |
| 280 | + | |
| 281 | + | |
278 | 282 | | |
279 | 283 | | |
280 | 284 | | |
| |||
284 | 288 | | |
285 | 289 | | |
286 | 290 | | |
287 | | - | |
| 291 | + | |
| 292 | + | |
288 | 293 | | |
289 | 294 | | |
290 | 295 | | |
| |||
294 | 299 | | |
295 | 300 | | |
296 | 301 | | |
297 | | - | |
| 302 | + | |
| 303 | + | |
298 | 304 | | |
299 | 305 | | |
300 | 306 | | |
| |||
304 | 310 | | |
305 | 311 | | |
306 | 312 | | |
307 | | - | |
| 313 | + | |
| 314 | + | |
308 | 315 | | |
309 | 316 | | |
310 | 317 | | |
| |||
314 | 321 | | |
315 | 322 | | |
316 | 323 | | |
317 | | - | |
| 324 | + | |
| 325 | + | |
318 | 326 | | |
319 | 327 | | |
320 | 328 | | |
| |||
323 | 331 | | |
324 | 332 | | |
325 | 333 | | |
326 | | - | |
327 | | - | |
328 | | - | |
| 334 | + | |
329 | 335 | | |
330 | 336 | | |
331 | 337 | | |
| |||
347 | 353 | | |
348 | 354 | | |
349 | 355 | | |
350 | | - | |
| 356 | + | |
| 357 | + | |
351 | 358 | | |
352 | 359 | | |
353 | 360 | | |
| |||
384 | 391 | | |
385 | 392 | | |
386 | 393 | | |
387 | | - | |
388 | | - | |
389 | | - | |
| 394 | + | |
390 | 395 | | |
391 | 396 | | |
392 | 397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 60 | + | |
63 | 61 | | |
64 | 62 | | |
65 | 63 | | |
| |||
74 | 72 | | |
75 | 73 | | |
76 | 74 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 75 | + | |
81 | 76 | | |
82 | 77 | | |
83 | 78 | | |
| |||
89 | 84 | | |
90 | 85 | | |
91 | 86 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 87 | + | |
96 | 88 | | |
97 | 89 | | |
98 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
| 235 | + | |
| 236 | + | |
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
| |||
0 commit comments