Skip to content

Commit d1d1061

Browse files
joaomorenoCopilot
andcommitted
fix tests
Co-authored-by: Copilot <copilot@github.com>
1 parent 75fea1b commit d1d1061

3 files changed

Lines changed: 22 additions & 27 deletions

File tree

extensions/copilot

src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,16 +1641,28 @@ export class CopilotChatSessionsProvider extends Disposable implements ISessions
16411641
// to the safety timeout to give it a chance to arrive.
16421642
}
16431643

1644-
const result = await raceTimeout(commitPromise, 5_000);
1645-
if (!result) {
1646-
// Timed out — check whether this was a cancellation
1647-
const response = responseCreatedPromise ? await responseCreatedPromise : undefined;
1648-
if (response?.isCanceled) {
1649-
throw new CancellationError();
1650-
}
1651-
throw new Error('Timed out waiting for session commit');
1644+
// Race commit against a safety timeout. If a response-created
1645+
// promise is available, also race it so we can detect
1646+
// cancellation immediately instead of waiting for the timeout.
1647+
const candidates: Promise<{ kind: 'commit'; uri: URI } | { kind: 'timeout' } | { kind: 'cancelled' }>[] = [
1648+
raceTimeout(commitPromise, 5_000).then(uri => uri ? { kind: 'commit' as const, uri } : { kind: 'timeout' as const }),
1649+
];
1650+
if (responseCreatedPromise) {
1651+
candidates.push(responseCreatedPromise.then(r => r?.isCanceled ? { kind: 'cancelled' as const } : new Promise<never>(() => { /* never resolves */ })));
16521652
}
1653-
return result;
1653+
const outcome = await Promise.race(candidates);
1654+
if (outcome.kind === 'commit') {
1655+
return outcome.uri;
1656+
}
1657+
if (outcome.kind === 'cancelled') {
1658+
throw new CancellationError();
1659+
}
1660+
// Timed out — last-resort check for cancellation
1661+
const response = responseCreatedPromise ? await responseCreatedPromise : undefined;
1662+
if (response?.isCanceled) {
1663+
throw new CancellationError();
1664+
}
1665+
throw new Error('Timed out waiting for session commit');
16541666
} finally {
16551667
disposables.dispose();
16561668
}

src/vs/sessions/contrib/welcome/test/browser/welcome.contribution.test.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,6 @@ suite('SessionsWelcomeContribution', () => {
166166
assert.strictEqual(isOverlayVisible(), false, 'should NOT show overlay for Unresolved');
167167
});
168168

169-
test('returning user: extension uninstalled DOES show overlay', () => {
170-
markReturningUser();
171-
mockEntitlementService.entitlementObs.set(ChatEntitlement.Free, undefined);
172-
mockEntitlementService.sentimentObs.set({ completed: true, installed: true } as IChatSentiment, undefined);
173-
174-
const contribution = disposables.add(instantiationService.createInstance(SessionsWelcomeContribution));
175-
assert.ok(contribution);
176-
assert.strictEqual(isOverlayVisible(), false, 'should not show initially');
177-
178-
// Simulate extension being uninstalled
179-
transaction(tx => {
180-
mockEntitlementService.sentimentObs.set({ completed: true, installed: false } as IChatSentiment, tx);
181-
});
182-
183-
assert.strictEqual(isOverlayVisible(), true, 'should show overlay when extension is uninstalled');
184-
});
185-
186169
test('returning user: extension disabled DOES show overlay', () => {
187170
markReturningUser();
188171
mockEntitlementService.entitlementObs.set(ChatEntitlement.Free, undefined);

0 commit comments

Comments
 (0)