This commit refactors how IdeSettings and ControlPlaneClient are accessed throughout
the configuration system to improve state management and reduce coupling.
Previously, ideSettingsPromise was passed down from the top-level ConfigHandler
through various profile loaders and clients. This created a rigid dependency chain
and required manual promise replacement when settings were updated. Similarly,
downstream components could hold onto stale instances of ControlPlaneClient after a
change in authentication state.
The key changes are:
- Removed ideSettingsPromise prop drilling: Components that require IDE settings
now fetch them directly from the IDE object (ide.getIdeSettings()) when
needed.
- Updated globalLocalProfileManager during every cascadeInit: This ensures it
always holds the most recent ControlPlaneClient, preventing issues with stale
client objects after re-authentication.
- Simplified constructors: The constructors for ConfigHandler, ControlPlaneClient,
and various loaders have been simplified to reflect these changes, primarily by
passing the IDE object directly instead of its derived promises.
28 lines
732 B
TypeScript
28 lines
732 B
TypeScript
import { ConfigHandler } from "../config/ConfigHandler";
|
|
import { ControlPlaneClient } from "../control-plane/client";
|
|
import Mock from "../llm/llms/Mock";
|
|
import { LLMLogger } from "../llm/logger";
|
|
import FileSystemIde from "../util/filesystem";
|
|
|
|
import { TEST_DIR } from "./testDir";
|
|
|
|
export const testIde = new FileSystemIde(TEST_DIR);
|
|
|
|
export const ideSettingsPromise = testIde.getIdeSettings();
|
|
|
|
export const testControlPlaneClient = new ControlPlaneClient(
|
|
Promise.resolve(undefined),
|
|
testIde,
|
|
);
|
|
|
|
export const testConfigHandler = new ConfigHandler(
|
|
testIde,
|
|
new LLMLogger(),
|
|
Promise.resolve(undefined),
|
|
);
|
|
|
|
export const testLLM = new Mock({
|
|
model: "mock-model",
|
|
title: "Mock LLM",
|
|
uniqueId: "not-unique",
|
|
});
|