Skip to content

Commit 447fcd5

Browse files
committed
ensure we mark discovery complete from cache
1 parent f7d00b0 commit 447fcd5

6 files changed

Lines changed: 42 additions & 1 deletion

File tree

src/vs/workbench/api/browser/positron/mainThreadLanguageRuntime.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,17 @@ export class MainThreadLanguageRuntime
16401640
this._proxy.$discoverLanguageRuntimes(disabledLanguageIds);
16411641
}
16421642

1643+
/**
1644+
* Tell the extension host that initial discovery is over without asking
1645+
* it to enumerate. Used by the warm-start fast path in
1646+
* `RuntimeStartupService.discoverAllRuntimes`.
1647+
*
1648+
* (part of implementation of IRuntimeManager)
1649+
*/
1650+
markDiscoveryComplete(): void {
1651+
this._proxy.$markRuntimeDiscoveryComplete();
1652+
}
1653+
16431654
/**
16441655
* Return a list of runtimes that are recommended for the current workspace.
16451656
*

src/vs/workbench/api/common/positron/extHost.positron.protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export interface ExtHostLanguageRuntimeShape {
118118
$showProfileLanguageRuntime(handle: number): void;
119119
$getLaunchInfo(handle: number): Promise<ILanguageRuntimeLaunchInfo | undefined>;
120120
$discoverLanguageRuntimes(disabledLanguageIds: string[]): void;
121+
$markRuntimeDiscoveryComplete(): void;
121122
$recommendWorkspaceRuntimes(disabledLanguageIds: string[]): Promise<ILanguageRuntimeMetadata[]>;
122123
$getDiscoveryRootSignature(languageId: string): Promise<IRuntimeRootSignature | undefined>;
123124
$onDidRegisterLanguageRuntime(metadata: ILanguageRuntimeMetadata): void;

src/vs/workbench/api/common/positron/extHostLanguageRuntime.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,18 @@ export class ExtHostLanguageRuntime implements extHostProtocol.ExtHostLanguageRu
10361036
this._proxy.$completeLanguageRuntimeDiscovery();
10371037
}
10381038

1039+
/**
1040+
* Set the discovery-complete flag without running an enumeration. Called
1041+
* by the main thread on the warm-start fast path, where the discovery
1042+
* cache has satisfied every manager and no real enumeration is needed.
1043+
* Without this, late-registered runtime managers (those registered via
1044+
* `registerLanguageRuntimeManager` after initial discovery) would never
1045+
* see the flag flip and so would never self-discover.
1046+
*/
1047+
public $markRuntimeDiscoveryComplete(): void {
1048+
this._runtimeDiscoveryComplete = true;
1049+
}
1050+
10391051
/**
10401052
* Notifies the extension host that the foreground session has changed.
10411053
* This is forwarding the event from the main thread to the extension host.

src/vs/workbench/services/languageRuntime/common/languageRuntimeService.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,16 @@ export interface IRuntimeManager {
969969
*/
970970
discoverAllRuntimes(disabledLanguageIds: string[]): Promise<void>;
971971

972+
/**
973+
* Mark the manager's discovery-complete flag without running a real
974+
* enumeration. Used by the warm-start fast path: the discovery cache
975+
* already satisfied every bucket, so no manager needs to enumerate, but
976+
* the ext host still needs to know that initial discovery is over so
977+
* runtime managers registered later (via `registerLanguageRuntimeManager`)
978+
* self-trigger their own discovery.
979+
*/
980+
markDiscoveryComplete(): void;
981+
972982
/**
973983
* Recommend runtimes for this specific workspace.
974984
*

src/vs/workbench/services/runtimeStartup/common/runtimeStartup.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,15 @@ export class RuntimeStartupService extends Disposable implements IRuntimeStartup
981981
if (managersNeedingFullDiscovery.length === 0) {
982982
// Warm-start fast path. No manager has any work to do; transition
983983
// straight to Complete. Mark every ext host's discovery flag true
984-
// so the next rediscover invocation isn't fighting stale state.
984+
// so the next rediscover invocation isn't fighting stale state, and
985+
// signal each ext host that initial discovery is over so any
986+
// runtime manager registered later (via the public
987+
// `registerLanguageRuntimeManager` API) self-triggers its own
988+
// discovery -- the IIFE inside the ext host is gated on a flag
989+
// that, without this signal, would never flip on a warm start.
985990
for (const manager of this._runtimeManagers) {
986991
this._discoveryCompleteByExtHostId.set(manager.id, true);
992+
manager.markDiscoveryComplete();
987993
}
988994
this.setStartupPhase(RuntimeStartupPhase.Complete);
989995
} else {

src/vs/workbench/services/runtimeStartup/test/common/runtimeStartup.vitest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function makeManager(opts: IManagerOptions): IRuntimeManager {
8383
return {
8484
id: opts.id,
8585
discoverAllRuntimes: async () => { /* no-op for unit test */ },
86+
markDiscoveryComplete: () => { /* no-op for unit test */ },
8687
recommendWorkspaceRuntimes: async () => [],
8788
managesRuntime: async (metadata) => ownsByPath.has(metadata.runtimePath),
8889
validateMetadata: async (m) => m,

0 commit comments

Comments
 (0)