Priority 11: Small Refactors
From code-review.md refactoring priority table.
L6. receivedChunks Flag Logic in CopilotService
src/main/services/CopilotService.ts:105 — boolean flag set to true on delta receipt (line 118) but the conditional that reads it (line 136) has confusing semantics. The intent (handle case where streaming produced no chunks) is unclear from the code.
Fix: Clarify the flag semantics with better naming or a comment, or restructure the control flow.
M12. SdkLoader Has an Implicit State Machine
src/main/services/SdkLoader.ts:16-20 — four module-level variables (sdkModule, clientInstance, startPromise, cachedPrefix) form an undocumented state machine. Error handling resets clientInstance but the valid state transitions are unclear.
Fix: Document the state machine or encapsulate in a class with explicit states.
M4. Global Mutable State in OrchestratorTools
src/main/services/OrchestratorTools.ts:18-25 — module-level mutable variables (onAgentCreated, managedAgents Map) are mutated from tool handlers with no synchronization or cleanup.
Fix: Encapsulate in a class or pass via dependency injection.
Priority 11: Small Refactors
From code-review.md refactoring priority table.
L6. receivedChunks Flag Logic in CopilotService
src/main/services/CopilotService.ts:105— boolean flag set totrueon delta receipt (line 118) but the conditional that reads it (line 136) has confusing semantics. The intent (handle case where streaming produced no chunks) is unclear from the code.Fix: Clarify the flag semantics with better naming or a comment, or restructure the control flow.
M12. SdkLoader Has an Implicit State Machine
src/main/services/SdkLoader.ts:16-20— four module-level variables (sdkModule,clientInstance,startPromise,cachedPrefix) form an undocumented state machine. Error handling resetsclientInstancebut the valid state transitions are unclear.Fix: Document the state machine or encapsulate in a class with explicit states.
M4. Global Mutable State in OrchestratorTools
src/main/services/OrchestratorTools.ts:18-25— module-level mutable variables (onAgentCreated,managedAgentsMap) are mutated from tool handlers with no synchronization or cleanup.Fix: Encapsulate in a class or pass via dependency injection.