perf(startup): skip deferred cli version probe

This commit is contained in:
777genius 2026-05-25 23:25:21 +03:00
parent 4bf707c720
commit 33463d3479
3 changed files with 24 additions and 14 deletions

View file

@ -1024,6 +1024,7 @@ export class CliInstallerService {
* on timeout, getStatus() returns whatever fields were populated so far. * on timeout, getStatus() returns whatever fields were populated so far.
* *
* Flow: binary resolve --version (sequential) Promise.all([auth, GCS]) (parallel) * Flow: binary resolve --version (sequential) Promise.all([auth, GCS]) (parallel)
* Lightweight multimodel startup status stops after binary resolution; full status hydrates health.
*/ */
private async gatherStatus( private async gatherStatus(
ref: { current: CliInstallationStatus }, ref: { current: CliInstallationStatus },
@ -1050,6 +1051,18 @@ export class CliInstallerService {
diag.binaryResolveMs = Date.now() - binaryResolveStartedAt; diag.binaryResolveMs = Date.now() - binaryResolveStartedAt;
if (binaryPath) { if (binaryPath) {
r.binaryPath = binaryPath; r.binaryPath = binaryPath;
if (r.flavor === 'agent_teams_orchestrator' && providerStatusMode === 'defer') {
const recoveredHealthyStatus = this.getRecoverableHealthyStatus(binaryPath);
diag.versionProbeMs = 0;
r.installed = true;
r.installedVersion = recoveredHealthyStatus?.installedVersion ?? null;
r.launchError = null;
r.authStatusChecking = false;
this.markProvidersDeferred(r);
this.publishStatusSnapshotIfCurrent(r, generation);
return;
}
const versionProbeStartedAt = Date.now(); const versionProbeStartedAt = Date.now();
const versionProbe = await this.probeCliVersion(binaryPath); const versionProbe = await this.probeCliVersion(binaryPath);
diag.versionProbeMs = Date.now() - versionProbeStartedAt; diag.versionProbeMs = Date.now() - versionProbeStartedAt;
@ -1059,13 +1072,6 @@ export class CliInstallerService {
r.launchError = null; r.launchError = null;
r.authStatusChecking = true; r.authStatusChecking = true;
if (r.flavor === 'agent_teams_orchestrator' && providerStatusMode === 'defer') {
r.authStatusChecking = false;
this.markProvidersDeferred(r);
this.publishStatusSnapshotIfCurrent(r, generation);
return;
}
this.rememberHealthyStatus(r); this.rememberHealthyStatus(r);
this.publishStatusSnapshotIfCurrent(r, generation); this.publishStatusSnapshotIfCurrent(r, generation);

View file

@ -302,7 +302,7 @@ export interface CliInstallationStatus {
showVersionDetails: boolean; showVersionDetails: boolean;
/** Whether binary path should be shown in the UI */ /** Whether binary path should be shown in the UI */
showBinaryPath: boolean; showBinaryPath: boolean;
/** Whether the CLI was found and passed the startup health check (`--version`) */ /** Whether the CLI is available. Lightweight startup status may defer the health check. */
installed: boolean; installed: boolean;
/** Installed version string (e.g. "2.1.59"), null if unavailable or not installed */ /** Installed version string (e.g. "2.1.59"), null if unavailable or not installed */
installedVersion: string | null; installedVersion: string | null;

View file

@ -356,7 +356,6 @@ describe('CliInstallerService', () => {
showBinaryPath: false, showBinaryPath: false,
}); });
vi.mocked(ClaudeBinaryResolver.resolve).mockResolvedValue('/mock/agent_teams_orchestrator'); vi.mocked(ClaudeBinaryResolver.resolve).mockResolvedValue('/mock/agent_teams_orchestrator');
vi.mocked(execCli).mockResolvedValueOnce({ stdout: '0.0.46', stderr: '' });
const getProviderStatusesSpy = vi const getProviderStatusesSpy = vi
.spyOn(ClaudeMultimodelBridgeService.prototype, 'getProviderStatuses') .spyOn(ClaudeMultimodelBridgeService.prototype, 'getProviderStatuses')
.mockResolvedValue([ .mockResolvedValue([
@ -377,6 +376,8 @@ describe('CliInstallerService', () => {
.filter((event) => event.type === 'status'); .filter((event) => event.type === 'status');
expect(status.installed).toBe(true); expect(status.installed).toBe(true);
expect(status.binaryPath).toBe('/mock/agent_teams_orchestrator');
expect(status.installedVersion).toBeNull();
expect(resolveInteractiveShellEnvBestEffortMock).not.toHaveBeenCalled(); expect(resolveInteractiveShellEnvBestEffortMock).not.toHaveBeenCalled();
expect(status.authStatusChecking).toBe(false); expect(status.authStatusChecking).toBe(false);
expect(status.authLoggedIn).toBe(false); expect(status.authLoggedIn).toBe(false);
@ -403,11 +404,14 @@ describe('CliInstallerService', () => {
) )
).toBe(true); ).toBe(true);
expect(getProviderStatusesSpy).not.toHaveBeenCalled(); expect(getProviderStatusesSpy).not.toHaveBeenCalled();
expect(execCli).toHaveBeenCalledTimes(1); expect(execCli).not.toHaveBeenCalled();
expect(execCli).toHaveBeenCalledWith( await vi.waitFor(() =>
'/mock/agent_teams_orchestrator', expect(appendCliAuthDiag).toHaveBeenCalledWith(
['--version'], expect.objectContaining({
expect.objectContaining({ timeout: expect.any(Number) }) shellEnvMs: 0,
versionProbeMs: 0,
})
)
); );
}); });