mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-08 12:48:48 +02:00
refactor: extract AryxAppService into focused service delegates
Extract seven responsibility clusters from the 3,466-line AryxAppService monolith into focused service classes under src/main/services/: - WorkflowManager: workflow CRUD, templates, validation, resolution - McpProbeManager: MCP server probing, OAuth pre-auth, probe queuing - DiscoveredToolingSyncService: tooling/customization scanning, watchers - GitContextManager: git refresh orchestration, context updates, mutations - CheckpointRecoveryManager: checkpoint retry/recovery state handling - ApprovalCoordinator: approval/user-input/plan-review/OAuth state machine - SessionTurnExecutor: turn execution, streaming deltas, finalization AryxAppService remains the public facade consumed by IPC handlers but now delegates internally via constructor-injected service instances. A new AppServiceDeps type provides a clean dependency injection seam for testing. The facade is reduced from 3,466 to 2,572 lines. All existing tests pass with two test files migrated to constructor DI (appServiceGitRefresh, appServiceMcpProbing). New focused tests added for WorkflowManager and the DI seam itself. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -70,26 +70,27 @@ function createService(workspace: WorkspaceState): {
|
||||
service: InstanceType<typeof AryxAppService>;
|
||||
snapshots: WorkspaceState[];
|
||||
} {
|
||||
const service = new AryxAppService();
|
||||
const internals = service as unknown as Record<string, unknown>;
|
||||
const snapshots: WorkspaceState[] = [];
|
||||
const service = new AryxAppService({
|
||||
probeMcpServers: (async (
|
||||
servers: Array<{ id: string }>,
|
||||
_tokenLookup?: (serverUrl: string) => string | undefined,
|
||||
onResult?: (result: MockProbeResult) => void | Promise<void>,
|
||||
) => {
|
||||
probeCalls.push(servers.map((server) => server.id));
|
||||
for (const result of probeResults) {
|
||||
await onResult?.(result);
|
||||
}
|
||||
return probeResults;
|
||||
}) as never,
|
||||
});
|
||||
const internals = service as unknown as Record<string, unknown>;
|
||||
|
||||
internals.loadWorkspace = async () => workspace;
|
||||
internals.persistAndBroadcast = async (nextWorkspace: WorkspaceState) => {
|
||||
snapshots.push(cloneWorkspaceState(nextWorkspace));
|
||||
return nextWorkspace;
|
||||
};
|
||||
internals.probeMcpServers = async (
|
||||
servers: Array<{ id: string }>,
|
||||
_tokenLookup?: (serverUrl: string) => string | undefined,
|
||||
onResult?: (result: MockProbeResult) => void | Promise<void>,
|
||||
) => {
|
||||
probeCalls.push(servers.map((server) => server.id));
|
||||
for (const result of probeResults) {
|
||||
await onResult?.(result);
|
||||
}
|
||||
return probeResults;
|
||||
};
|
||||
|
||||
return { service, snapshots };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user