fix(team): keep persisted launch members in spawn statuses
This commit is contained in:
parent
53d45c5e30
commit
72517418d9
2 changed files with 65 additions and 1 deletions
|
|
@ -484,7 +484,13 @@ export function snapshotToMemberSpawnStatuses(
|
||||||
): Record<string, MemberSpawnStatusEntry> {
|
): Record<string, MemberSpawnStatusEntry> {
|
||||||
if (!snapshot) return {};
|
if (!snapshot) return {};
|
||||||
const statuses: Record<string, MemberSpawnStatusEntry> = {};
|
const statuses: Record<string, MemberSpawnStatusEntry> = {};
|
||||||
for (const memberName of snapshot.expectedMembers) {
|
const memberNames = Array.from(
|
||||||
|
new Set([
|
||||||
|
...snapshot.expectedMembers.map(normalizeMemberName).filter(Boolean),
|
||||||
|
...Object.keys(snapshot.members).map(normalizeMemberName).filter(Boolean),
|
||||||
|
])
|
||||||
|
);
|
||||||
|
for (const memberName of memberNames) {
|
||||||
const entry = snapshot.members[memberName];
|
const entry = snapshot.members[memberName];
|
||||||
if (!entry) continue;
|
if (!entry) continue;
|
||||||
let status: MemberSpawnStatusEntry['status'] = 'offline';
|
let status: MemberSpawnStatusEntry['status'] = 'offline';
|
||||||
|
|
|
||||||
58
test/main/services/team/TeamLaunchStateEvaluator.test.ts
Normal file
58
test/main/services/team/TeamLaunchStateEvaluator.test.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
import { snapshotToMemberSpawnStatuses } from '../../../../src/main/services/team/TeamLaunchStateEvaluator';
|
||||||
|
|
||||||
|
describe('TeamLaunchStateEvaluator', () => {
|
||||||
|
it('keeps member spawn statuses for persisted members even when expectedMembers is stale', () => {
|
||||||
|
const statuses = snapshotToMemberSpawnStatuses({
|
||||||
|
version: 1,
|
||||||
|
teamName: 'my-team',
|
||||||
|
runId: 'run-1',
|
||||||
|
leadSessionId: 'lead-session',
|
||||||
|
expectedMembers: ['alice'],
|
||||||
|
bootstrapExpectedMembers: ['alice'],
|
||||||
|
updatedAt: '2026-04-23T00:00:00.000Z',
|
||||||
|
launchPhase: 'active',
|
||||||
|
teamLaunchState: 'partial_pending',
|
||||||
|
summary: {
|
||||||
|
confirmedCount: 0,
|
||||||
|
pendingCount: 2,
|
||||||
|
failedCount: 0,
|
||||||
|
runtimeAlivePendingCount: 0,
|
||||||
|
},
|
||||||
|
members: {
|
||||||
|
alice: {
|
||||||
|
launchState: 'runtime_pending_bootstrap',
|
||||||
|
diagnostics: ['waiting for teammate check-in'],
|
||||||
|
agentToolAccepted: true,
|
||||||
|
runtimeAlive: false,
|
||||||
|
bootstrapConfirmed: false,
|
||||||
|
hardFailure: false,
|
||||||
|
lastEvaluatedAt: '2026-04-23T00:00:00.000Z',
|
||||||
|
sources: {},
|
||||||
|
},
|
||||||
|
bob: {
|
||||||
|
launchState: 'runtime_pending_permission',
|
||||||
|
diagnostics: ['waiting for permission approval'],
|
||||||
|
agentToolAccepted: true,
|
||||||
|
runtimeAlive: true,
|
||||||
|
bootstrapConfirmed: false,
|
||||||
|
hardFailure: false,
|
||||||
|
pendingPermissionRequestIds: ['req-1'],
|
||||||
|
lastEvaluatedAt: '2026-04-23T00:00:01.000Z',
|
||||||
|
sources: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
expect(statuses.alice).toMatchObject({
|
||||||
|
launchState: 'runtime_pending_bootstrap',
|
||||||
|
status: 'waiting',
|
||||||
|
});
|
||||||
|
expect(statuses.bob).toMatchObject({
|
||||||
|
launchState: 'runtime_pending_permission',
|
||||||
|
status: 'online',
|
||||||
|
pendingPermissionRequestIds: ['req-1'],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue