Commit 3e9c0d4
perf: end-to-end optimization pass across desktop main + renderer (#219)
* perf: end-to-end optimization pass across desktop main + renderer
Profile-driven cleanup of CPU/memory/IPC/render hot paths uncovered while
running the Electron app under stress. No product behavior changes — just
removing waste and tightening contracts.
Main process
- aiIntegrationService: trim redundant work and tighten auth detection paths.
- authDetector: cache + dedupe lookups; expanded test coverage.
- ipc/registerIpc: validation + redaction hardening on the IPC surface.
- ptyService: terminal session lifecycle fixes (stale-id handling, prune).
- rebaseSuggestionService: cache TTL/LRU + rate-bucket prune.
- projectIconResolver: fewer disk hits, deterministic fallbacks.
- syncService, memory/embedding services: drop redundant work, fix worker
shutdown, add coverage.
- cursorModelsDiscovery / droidModelsDiscovery: shared discovery cleanup.
Preload / renderer
- preload: large reorganization of the IPC bridge surface (~+800 lines).
- AppShell, TopBar, TabNav, ChatGitToolbar, AgentChatPane,
AgentChatComposer, LanesPage, WorkspaceGraphPage, TerminalView,
PaneTilingLayout: avoid avoidable re-renders, polling, log spam.
- appStore: state slice cleanup + tests.
- terminalAttention: lifecycle correctness.
Tooling
- Add .claude/commands/optimize.md (the /optimize skill used to drive
this pass).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* ship: iter 1 — fix CI failures + address CodeRabbit review
CI fixes (test-ade-cli, test-desktop shards 1 + 3)
- AgentChatComposer: revert BorderBeam wrapper conditional that was
unmounting/remounting the composer subtree on turnActive flip,
swallowing onChange events. Always render the wrapper, drive with
active prop. (test-desktop (1) submit-recovery, 2 tests)
- memoryService.evaluateWriteGate: re-add `tier IN (1,2)` to dedupe
scan. The optimization had let candidate (tier-3) episodes dedupe
against each other, which broke procedural promotion when 3 distinct
episodes shared signals. Tier-2 promoted writes still fall under the
filter, so the policy change for `resolveAgentMemoryWritePolicy`
remains intact. (test-desktop (3) proceduralLearningService, 3 tests)
- adeRpcServer.test: update one assertion to match the intentional new
promoted/tier-2 contract; load-bearing scopeOwner/runId-from-env
assertions unchanged. (test-ade-cli, 1 test)
Review fixes (13/14 CodeRabbit comments — preserves optimization intent)
- aiIntegrationService: shallowCliAuth keys off !shouldProbeCliModels
so refreshOpenCodeInventory runs a full auth pass.
- registerIpc.timePhase: takes a thunk + Promise.resolve().then.catch
so synchronous throws degrade to []/null fallbacks.
- autoRebaseService: hasAuthoritativeLaneSet guard prevents wiping
persisted statuses for lanes outside a caller-supplied subset.
- rebaseSuggestionService: normalize primary lane refs before
origin/<branch> lookup; scope cache + in-flight promise to default
request shape only (force/lanes/refreshRemoteTracking bypass shared
cache).
- knowledgeCaptureService: low-signal courtesy regex now also requires
!hasDurablePrFeedbackSignals && wordCount<10, preserving "Thanks but
always X..." style actionable guidance.
- projectIconResolver: drop negative-icon caching (no invalidation
signal exists for added icon files).
- ptyService.onData: early return on entry.disposed so late chunks
cannot mutate post-teardown state.
- syncService: force=true bypasses cache only, not in-flight dedupe.
- preload.createKeyedShortIpcCache: bounded LRU-ish cap (256 entries,
touch-on-access) for high-cardinality keys.
- preload IPC fanout: per-callback try/catch so one throwing subscriber
does not starve later subscribers.
- preload agentChatEventFanout: beforeDispatch clears
agentChatSummaryCache so background events invalidate the 1s cache.
- WorkspaceGraphPage.refreshGraphLanes: includeStatus=true (skip
conflict/rebase phases instead) so dirty/behind chips stay current
without reverting to a full snapshot.
Dismissed (1/14)
- authDetector.ts skip-path "skipped probes shouldn't claim
authenticated": false positive. The `authenticated:true,
verified:false` shape is an intentional presence sentinel pinned by
the colocated test (authDetector.test.ts:144-150); combined with the
CLI-probe full-auth fix above, the only consumer treats it as a
fast-path hint, not a verified credential.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* ship: iter 2 — guard createShortIpcCache .finally against force-call races
capy-ai caught a real concurrency bug introduced by the optimization
pass: the generic createShortIpcCache helper unconditionally cleared
its shared `promise` ref in .finally(), so when a `force: true` call
overwrote `promise` mid-flight, the older request's settle would null
out the new request. A subsequent non-force caller then saw `promise
=== null` and started a redundant IPC instead of reusing the in-flight
forced load.
Fix mirrors the pattern already used by the bespoke aiStatusCache 30
lines below: capture the request reference, only null `promise` if it
still equals our request.
Addresses capy-ai comment 3166962638.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent da32d09 commit 3e9c0d4
45 files changed
Lines changed: 2526 additions & 576 deletions
File tree
- .claude/commands
- apps
- ade-cli/src
- desktop/src
- main
- services
- ai
- tools
- chat
- ipc
- lanes
- memory
- projects
- pty
- sync
- preload
- renderer
- components
- app
- chat
- graph
- lanes
- terminals
- ui
- lib
- state
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2657 | 2657 | | |
2658 | 2658 | | |
2659 | 2659 | | |
2660 | | - | |
2661 | | - | |
2662 | | - | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
2663 | 2663 | | |
2664 | 2664 | | |
2665 | 2665 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
235 | 239 | | |
236 | 240 | | |
237 | 241 | | |
| |||
1603 | 1607 | | |
1604 | 1608 | | |
1605 | 1609 | | |
1606 | | - | |
1607 | | - | |
1608 | | - | |
1609 | | - | |
1610 | | - | |
1611 | | - | |
1612 | | - | |
1613 | | - | |
1614 | | - | |
1615 | | - | |
1616 | | - | |
1617 | 1610 | | |
1618 | 1611 | | |
1619 | 1612 | | |
| |||
2061 | 2054 | | |
2062 | 2055 | | |
2063 | 2056 | | |
2064 | | - | |
| 2057 | + | |
2065 | 2058 | | |
2066 | 2059 | | |
2067 | 2060 | | |
| |||
2082 | 2075 | | |
2083 | 2076 | | |
2084 | 2077 | | |
2085 | | - | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
2086 | 2082 | | |
2087 | 2083 | | |
2088 | 2084 | | |
| |||
0 commit comments