Skip to content

Commit ecc2c3b

Browse files
authored
fix(test): remove tower and watch load flakes (#363)
[skip changeset] Test and restore-ordering fix only; nothing users can see. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Tower handoffs now wait for the exit process to complete when another active session owns the tower, helping ensure ownership changes finish before reconciliation continues. * **Tests** * Improved watcher test timing by waiting for expected file events rather than relying on a fixed delay. * Expanded tower replay and restore test coverage across additional scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent f1fbb9c commit ecc2c3b

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎packages/agent-core-v2/src/features/tower/towerService.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ export class AgentTowerService extends Disposable implements IAgentTowerService
486486
}
487487
return;
488488
}
489-
void this.exit('foreign-reconcile');
489+
await this.exit('foreign-reconcile');
490490
}
491491

492492
private async resolveTowerOwner(): Promise<string | undefined> {

‎packages/agent-core-v2/src/human/test/utils/watch.test.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,9 @@ describe('watch signal mode', () => {
296296

297297
const file = join(root, 'a.txt');
298298
await writeFile(file, 'v1');
299-
await wait(300);
300299

300+
await expect.poll(() => events.some((e) => e.path === file && e.action === 'created')).toBe(true);
301301
expect(events[0]).toEqual({ path: root, action: 'modified', kind: 'directory' });
302-
expect(events.some((e) => e.path === file && e.action === 'created')).toBe(true);
303302
} finally {
304303
await rm(root, { recursive: true, force: true });
305304
}
@@ -366,10 +365,9 @@ describe('watch signal mode', () => {
366365

367366
const file = join(root, 'a.txt');
368367
await writeFile(file, 'v1');
369-
await wait(300);
370368

369+
await expect.poll(() => events.some((e) => e.path === file && e.action === 'created')).toBe(true);
371370
expect(nativeCalls).toBe(0);
372-
expect(events.some((e) => e.path === file && e.action === 'created')).toBe(true);
373371
} finally {
374372
await rm(root, { recursive: true, force: true });
375373
}

‎packages/agent-core-v2/test/features/tower/towerService.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ describe('AgentTowerService', () => {
986986
]);
987987

988988
const ix2 = disposables.add(new TestInstantiationService());
989+
ix2.stub(ILogService, stubLog());
989990
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
990991
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
991992
registerTestAgentWire(ix2, testWireScope('wire', 'tower-replay'), {
@@ -1011,6 +1012,7 @@ describe('AgentTowerService', () => {
10111012
];
10121013

10131014
const ix2 = disposables.add(new TestInstantiationService());
1015+
ix2.stub(ILogService, stubLog());
10141016
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
10151017
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
10161018
registerTestAgentWire(ix2, testWireScope('wire', 'tower-legacy'), {
@@ -1722,6 +1724,7 @@ describe('AgentTowerService', () => {
17221724
]);
17231725

17241726
const ix2 = disposables.add(new TestInstantiationService());
1727+
ix2.stub(ILogService, stubLog());
17251728
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
17261729
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
17271730
ix2.set(IEventBus, new SyncDescriptor(EventBusService));
@@ -1824,6 +1827,7 @@ describe('AgentTowerService', () => {
18241827
}
18251828

18261829
const ix2 = disposables.add(new TestInstantiationService());
1830+
ix2.stub(ILogService, stubLog());
18271831
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
18281832
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
18291833
ix2.set(IEventBus, new SyncDescriptor(EventBusService));
@@ -1891,6 +1895,7 @@ describe('AgentTowerService', () => {
18911895
}
18921896

18931897
const ix2 = disposables.add(new TestInstantiationService());
1898+
ix2.stub(ILogService, stubLog());
18941899
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
18951900
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
18961901
ix2.set(IEventBus, new SyncDescriptor(EventBusService));
@@ -1965,6 +1970,7 @@ describe('AgentTowerService', () => {
19651970
await new TowerStore(repo).init('session-original');
19661971

19671972
const ix2 = disposables.add(new TestInstantiationService());
1973+
ix2.stub(ILogService, stubLog());
19681974
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
19691975
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
19701976
ix2.set(IEventBus, new SyncDescriptor(EventBusService));
@@ -2076,6 +2082,7 @@ describe('AgentTowerService', () => {
20762082
});
20772083

20782084
const ix2 = disposables.add(new TestInstantiationService());
2085+
ix2.stub(ILogService, stubLog());
20792086
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
20802087
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
20812088
ix2.set(IEventBus, new SyncDescriptor(EventBusService));
@@ -2268,6 +2275,7 @@ describe('AgentTowerService', () => {
22682275
ix2.stub(IAgentToolExecutorService, stubToolExecutorEvents().executor);
22692276
ix2.stub(IAgentToolApprovalService, { formatDenyMessage });
22702277
ix2.stub(ITelemetryService, { track2: () => {} });
2278+
ix2.stub(ILogService, stubLog());
22712279
ix2.stub(IFlagService, stubFlag(() => false));
22722280
ix2.stub(ISessionManager, {
22732281
get: (id: string) => (id === 'session-original' ? {} : undefined),
@@ -2343,6 +2351,7 @@ describe('AgentTowerService', () => {
23432351
}
23442352

23452353
const ix2 = disposables.add(new TestInstantiationService());
2354+
ix2.stub(ILogService, stubLog());
23462355
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
23472356
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
23482357
ix2.set(IEventBus, new SyncDescriptor(EventBusService));
@@ -2420,6 +2429,7 @@ describe('AgentTowerService', () => {
24202429
}
24212430

24222431
const ix2 = disposables.add(new TestInstantiationService());
2432+
ix2.stub(ILogService, stubLog());
24232433
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
24242434
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
24252435
ix2.set(IEventBus, new SyncDescriptor(EventBusService));
@@ -2478,6 +2488,7 @@ describe('AgentTowerService', () => {
24782488

24792489
it('restore does not touch the profile tool overlay while tower mode is inactive', async () => {
24802490
const ix2 = disposables.add(new TestInstantiationService());
2491+
ix2.stub(ILogService, stubLog());
24812492
ix2.stub(IFileSystemStorageService, new InMemoryStorageService());
24822493
ix2.set(IAppendLogStore, new SyncDescriptor(AppendLogStore));
24832494
ix2.set(IEventBus, new SyncDescriptor(EventBusService));

0 commit comments

Comments
 (0)