Merge remote-tracking branch 'origin/perf/team-page-lag-optimization' into HEAD

# Conflicts:
#	src/main/services/team/TeamProvisioningService.ts
#	src/renderer/components/sidebar/GlobalTaskList.tsx
#	src/renderer/components/sidebar/SidebarTaskItem.tsx
This commit is contained in:
777genius 2026-05-31 09:15:26 +03:00
commit 8df2a8797b
4 changed files with 20 additions and 11 deletions

View file

@ -256,7 +256,7 @@ async function mapLimitLocal<T, R>(
if (index >= items.length) { if (index >= items.length) {
return; return;
} }
results[index] = await mapper(items[index]!); results[index] = await mapper(items[index]);
} }
}) })
); );

View file

@ -26006,7 +26006,12 @@ export class TeamProvisioningService {
): { rows: RuntimeTelemetryProcessTableRow[] | null } | null { ): { rows: RuntimeTelemetryProcessTableRow[] | null } | null {
const cached = this.runtimeProcessRowsForUsageSnapshotByTeam.get(teamName); const cached = this.runtimeProcessRowsForUsageSnapshotByTeam.get(teamName);
const nowMs = Date.now(); const nowMs = Date.now();
if (!cached || cached.expiresAtMs <= nowMs || cached.runId !== runId) { if (
!cached ||
cached.expiresAtMs <= nowMs ||
cached.runId !== runId ||
cached.generation !== this.getRuntimeSnapshotCacheGeneration(teamName)
) {
return null; return null;
} }
@ -26026,7 +26031,10 @@ export class TeamProvisioningService {
return { rows: null }; return { rows: null };
} }
const rows = cached.rows.filter((row) => row.runtimeTelemetrySource !== 'windows-host'); const rows =
this.normalizeRuntimeProcessRowsForTelemetry(cached.rows)?.filter(
(row) => row.runtimeTelemetrySource !== 'windows-host'
) ?? [];
return { rows }; return { rows };
} }
@ -26427,14 +26435,10 @@ export class TeamProvisioningService {
} }
private shouldSampleMissingRuntimeUsageStatsWithPidusage(): boolean { private shouldSampleMissingRuntimeUsageStatsWithPidusage(): boolean {
if (!this.isRuntimePidusageTelemetryEnabled()) {
return false;
}
// CPU/RSS telemetry already comes from the enriched process table in the // CPU/RSS telemetry already comes from the enriched process table in the
// default path. If this opt-in is enabled, preserve the older fallback for // default path. If this opt-in is enabled, preserve the older fallback for
// missing rows across platforms. // missing rows across platforms.
return true; return this.isRuntimePidusageTelemetryEnabled();
} }
private isRuntimePidusageTelemetryEnabled(): boolean { private isRuntimePidusageTelemetryEnabled(): boolean {

View file

@ -72,12 +72,12 @@ interface TeamTranscriptProjectContextOptions {
includeTeamSubagentSessionDiscovery?: boolean; includeTeamSubagentSessionDiscovery?: boolean;
} }
type TeamTranscriptFileStat = { interface TeamTranscriptFileStat {
mtimeMs: number; mtimeMs: number;
size: number; size: number;
ctimeMs?: number; ctimeMs?: number;
isFile: () => boolean; isFile: () => boolean;
}; }
type ScannedSessionProjectMatch = Omit<SessionProjectMatch, 'projectPath'> & { type ScannedSessionProjectMatch = Omit<SessionProjectMatch, 'projectPath'> & {
projectPath?: string; projectPath?: string;

View file

@ -3514,7 +3514,7 @@ describe('TeamProvisioningService', () => {
expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(2); expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(2);
}); });
it('keeps the short live runtime metadata cache for tracked runs', async () => { it('reuses process rows through the short liveness cache for tracked runs', async () => {
vi.useFakeTimers(); vi.useFakeTimers();
vi.setSystemTime(new Date('2026-05-03T12:00:00.000Z')); vi.setSystemTime(new Date('2026-05-03T12:00:00.000Z'));
const svc = new TeamProvisioningService(); const svc = new TeamProvisioningService();
@ -3533,6 +3533,11 @@ describe('TeamProvisioningService', () => {
vi.setSystemTime(new Date('2026-05-03T12:00:03.000Z')); vi.setSystemTime(new Date('2026-05-03T12:00:03.000Z'));
await (svc as any).getLiveTeamAgentRuntimeMetadata('runtime-team'); await (svc as any).getLiveTeamAgentRuntimeMetadata('runtime-team');
expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(1);
vi.setSystemTime(new Date('2026-05-03T12:00:06.000Z'));
await (svc as any).getLiveTeamAgentRuntimeMetadata('runtime-team');
expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(2); expect(listRuntimeProcessTableForCurrentPlatform).toHaveBeenCalledTimes(2);
}); });