reload config logs, await cascade init, cascade abort controller, client signals
This commit is contained in:
parent
75781e8d8c
commit
2da461e110
11 changed files with 169 additions and 96 deletions
|
|
@ -44,6 +44,17 @@ export class ConfigHandler {
|
|||
private organizations: OrgWithProfiles[] = [];
|
||||
currentProfile: ProfileLifecycleManager | null;
|
||||
currentOrg: OrgWithProfiles;
|
||||
totalConfigLoads: number = 0;
|
||||
public isInitialized: Promise<void>;
|
||||
private setInitialized:
|
||||
| undefined
|
||||
| ((value: void | PromiseLike<void>) => void) = undefined;
|
||||
|
||||
cascadeAbortController: AbortController;
|
||||
private abortCascade() {
|
||||
this.cascadeAbortController.abort();
|
||||
this.cascadeAbortController = new AbortController();
|
||||
}
|
||||
|
||||
constructor(
|
||||
private readonly ide: IDE,
|
||||
|
|
@ -79,8 +90,12 @@ export class ConfigHandler {
|
|||
|
||||
this.currentOrg = personalOrg;
|
||||
this.organizations = [personalOrg];
|
||||
this.isInitialized = new Promise((resolve) => {
|
||||
this.setInitialized = resolve;
|
||||
});
|
||||
|
||||
void this.cascadeInit();
|
||||
this.cascadeAbortController = new AbortController();
|
||||
void this.cascadeInit("Config handler initialization");
|
||||
}
|
||||
|
||||
private workspaceDirs: string[] | null = null;
|
||||
|
|
@ -96,52 +111,67 @@ export class ConfigHandler {
|
|||
return `${workspaceId}:::${orgId}`;
|
||||
}
|
||||
|
||||
private async cascadeInit() {
|
||||
private async cascadeInit(reason: string) {
|
||||
const signal = this.cascadeAbortController.signal;
|
||||
this.workspaceDirs = null; // forces workspace dirs reload
|
||||
|
||||
const orgs = await this.getOrgs();
|
||||
try {
|
||||
const orgs = await this.getOrgs(signal);
|
||||
|
||||
// Figure out selected org
|
||||
const workspaceId = await this.getWorkspaceId();
|
||||
const selectedOrgs =
|
||||
this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {};
|
||||
const currentSelection = selectedOrgs[workspaceId];
|
||||
// Figure out selected org
|
||||
const workspaceId = await this.getWorkspaceId();
|
||||
const selectedOrgs =
|
||||
this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {};
|
||||
const currentSelection = selectedOrgs[workspaceId];
|
||||
|
||||
const firstNonPersonal = orgs.find(
|
||||
(org) => org.id !== this.PERSONAL_ORG_DESC.id,
|
||||
);
|
||||
const fallback = firstNonPersonal ?? orgs[0];
|
||||
// note, ignoring case of zero orgs since should never happen
|
||||
const firstNonPersonal = orgs.find(
|
||||
(org) => org.id !== this.PERSONAL_ORG_DESC.id,
|
||||
);
|
||||
const fallback = firstNonPersonal ?? orgs[0];
|
||||
// note, ignoring case of zero orgs since should never happen
|
||||
|
||||
let selectedOrg: OrgWithProfiles;
|
||||
if (!currentSelection) {
|
||||
selectedOrg = fallback;
|
||||
} else {
|
||||
const match = orgs.find((org) => org.id === currentSelection);
|
||||
if (match) {
|
||||
selectedOrg = match;
|
||||
} else {
|
||||
let selectedOrg: OrgWithProfiles;
|
||||
if (!currentSelection) {
|
||||
selectedOrg = fallback;
|
||||
} else {
|
||||
const match = orgs.find((org) => org.id === currentSelection);
|
||||
if (match) {
|
||||
selectedOrg = match;
|
||||
} else {
|
||||
selectedOrg = fallback;
|
||||
}
|
||||
}
|
||||
|
||||
if (signal.aborted) {
|
||||
return; // local only case, no fetch to throw abort error
|
||||
}
|
||||
this.setInitialized?.();
|
||||
|
||||
this.globalContext.update("lastSelectedOrgIdForWorkspace", {
|
||||
...selectedOrgs,
|
||||
[workspaceId]: selectedOrg.id,
|
||||
});
|
||||
|
||||
this.organizations = orgs;
|
||||
this.currentOrg = selectedOrg;
|
||||
this.currentProfile = selectedOrg.currentProfile;
|
||||
|
||||
await this.reloadConfig(reason);
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.message.includes("AbortError")) {
|
||||
return;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
this.globalContext.update("lastSelectedOrgIdForWorkspace", {
|
||||
...selectedOrgs,
|
||||
[workspaceId]: selectedOrg.id,
|
||||
});
|
||||
|
||||
this.organizations = orgs;
|
||||
this.currentOrg = selectedOrg;
|
||||
this.currentProfile = selectedOrg.currentProfile;
|
||||
await this.reloadConfig();
|
||||
}
|
||||
|
||||
private async getOrgs(): Promise<OrgWithProfiles[]> {
|
||||
private async getOrgs(signal: AbortSignal): Promise<OrgWithProfiles[]> {
|
||||
if (await this.controlPlaneClient.isSignedIn()) {
|
||||
const orgDescs = await this.controlPlaneClient.listOrganizations();
|
||||
const personalHubOrg = await this.getPersonalHubOrg();
|
||||
const orgDescs = await this.controlPlaneClient.listOrganizations(signal);
|
||||
const personalHubOrg = await this.getPersonalHubOrg(signal);
|
||||
const hubOrgs = await Promise.all(
|
||||
orgDescs.map((org) => this.getNonPersonalHubOrg(org)),
|
||||
orgDescs.map((org) => this.getNonPersonalHubOrg(org, signal)),
|
||||
);
|
||||
return [...hubOrgs, personalHubOrg];
|
||||
} else {
|
||||
|
|
@ -160,8 +190,11 @@ export class ConfigHandler {
|
|||
}));
|
||||
}
|
||||
|
||||
private async getHubProfiles(orgScopeId: string | null) {
|
||||
const assistants = await this.controlPlaneClient.listAssistants(orgScopeId);
|
||||
private async getHubProfiles(orgScopeId: string | null, signal: AbortSignal) {
|
||||
const assistants = await this.controlPlaneClient.listAssistants(
|
||||
orgScopeId,
|
||||
signal,
|
||||
);
|
||||
|
||||
return await Promise.all(
|
||||
assistants.map(async (assistant) => {
|
||||
|
|
@ -189,12 +222,16 @@ export class ConfigHandler {
|
|||
|
||||
private async getNonPersonalHubOrg(
|
||||
org: OrganizationDescription,
|
||||
signal: AbortSignal,
|
||||
): Promise<OrgWithProfiles> {
|
||||
const localProfiles = await this.getLocalProfiles({
|
||||
includeGlobal: false,
|
||||
includeWorkspace: true,
|
||||
});
|
||||
const profiles = [...(await this.getHubProfiles(org.id)), ...localProfiles];
|
||||
const profiles = [
|
||||
...(await this.getHubProfiles(org.id, signal)),
|
||||
...localProfiles,
|
||||
];
|
||||
return this.rectifyProfilesForOrg(org, profiles);
|
||||
}
|
||||
|
||||
|
|
@ -204,12 +241,12 @@ export class ConfigHandler {
|
|||
name: "Personal",
|
||||
slug: undefined,
|
||||
};
|
||||
private async getPersonalHubOrg() {
|
||||
private async getPersonalHubOrg(signal: AbortSignal) {
|
||||
const localProfiles = await this.getLocalProfiles({
|
||||
includeGlobal: true,
|
||||
includeWorkspace: true,
|
||||
});
|
||||
const hubProfiles = await this.getHubProfiles(null);
|
||||
const hubProfiles = await this.getHubProfiles(null, signal);
|
||||
const profiles = [...hubProfiles, ...localProfiles];
|
||||
return this.rectifyProfilesForOrg(this.PERSONAL_ORG_DESC, profiles);
|
||||
}
|
||||
|
|
@ -312,13 +349,14 @@ export class ConfigHandler {
|
|||
// Should not be used internally
|
||||
//////////////////
|
||||
async refreshAll() {
|
||||
await this.cascadeInit();
|
||||
await this.cascadeInit("External refresh all");
|
||||
}
|
||||
|
||||
// Ide settings change: refresh session and cascade refresh from the top
|
||||
async updateIdeSettings(ideSettings: IdeSettings) {
|
||||
this.ideSettingsPromise = Promise.resolve(ideSettings);
|
||||
await this.cascadeInit();
|
||||
this.abortCascade();
|
||||
await this.cascadeInit("IDE settings update");
|
||||
}
|
||||
|
||||
// Session change: refresh session and cascade refresh from the top
|
||||
|
|
@ -329,7 +367,8 @@ export class ConfigHandler {
|
|||
Promise.resolve(sessionInfo),
|
||||
this.ideSettingsPromise,
|
||||
);
|
||||
await this.cascadeInit();
|
||||
this.abortCascade();
|
||||
await this.cascadeInit("Control plane session info update");
|
||||
}
|
||||
|
||||
// Org id: check id validity, save selection, switch and reload
|
||||
|
|
@ -356,7 +395,7 @@ export class ConfigHandler {
|
|||
await this.setSelectedProfileId(profileId);
|
||||
} else {
|
||||
this.currentProfile = org.currentProfile;
|
||||
await this.reloadConfig();
|
||||
await this.reloadConfig("Selected org changed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -384,14 +423,16 @@ export class ConfigHandler {
|
|||
});
|
||||
|
||||
this.currentProfile = profile;
|
||||
await this.reloadConfig();
|
||||
await this.reloadConfig("Selected profile changed");
|
||||
}
|
||||
|
||||
// Bottom level of cascade: refresh the current profile
|
||||
// IMPORTANT - must always refresh when switching profiles
|
||||
// Because of e.g. MCP singleton and docs service using things from config
|
||||
// Could improve this
|
||||
async reloadConfig() {
|
||||
async reloadConfig(reason: string) {
|
||||
this.totalConfigLoads += 1;
|
||||
// console.log(`Reloading config (${this.totalConfigLoads}): ${reason}`); // Uncomment to see config loading logs
|
||||
if (!this.currentProfile) {
|
||||
return {
|
||||
config: undefined,
|
||||
|
|
@ -457,6 +498,7 @@ export class ConfigHandler {
|
|||
configLoadInterrupted: true,
|
||||
};
|
||||
}
|
||||
await this.isInitialized;
|
||||
const config = await this.currentProfile.loadConfig(
|
||||
this.additionalContextProviders,
|
||||
);
|
||||
|
|
@ -487,7 +529,7 @@ export class ConfigHandler {
|
|||
private additionalContextProviders: IContextProvider[] = [];
|
||||
registerCustomContextProvider(contextProvider: IContextProvider) {
|
||||
this.additionalContextProviders.push(contextProvider);
|
||||
void this.reloadConfig();
|
||||
void this.reloadConfig("Custom context provider registered");
|
||||
}
|
||||
/**
|
||||
* Retrieves the titles of additional context providers that are of type "submenu".
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => {
|
|||
}`;
|
||||
fs.writeFileSync(getConfigTsPath(), configTs);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
const config = await testConfigHandler.reloadConfig();
|
||||
const config = await testConfigHandler.reloadConfig("test");
|
||||
/**
|
||||
* @ts-ignore is applied because this test is skipped
|
||||
*/
|
||||
|
|
@ -45,7 +45,7 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => {
|
|||
path.join(TEST_DIR, ".continuerc.json"),
|
||||
JSON.stringify({ systemMessage: "SYSTEM2" }),
|
||||
);
|
||||
const config = await testConfigHandler.reloadConfig();
|
||||
const config = await testConfigHandler.reloadConfig("test");
|
||||
/**
|
||||
* @ts-ignore is applied because this test is skipped
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ export class ControlPlaneClient {
|
|||
async resolveFQSNs(
|
||||
fqsns: FQSN[],
|
||||
orgScopeId: string | null,
|
||||
signal?: AbortSignal,
|
||||
): Promise<(SecretResult | undefined)[]> {
|
||||
if (!(await this.isSignedIn())) {
|
||||
return fqsns.map((fqsn) => ({
|
||||
|
|
@ -60,6 +61,7 @@ export class ControlPlaneClient {
|
|||
const resp = await this.request("ide/sync-secrets", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ fqsns, orgScopeId }),
|
||||
signal,
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
}
|
||||
|
|
@ -103,7 +105,10 @@ export class ControlPlaneClient {
|
|||
return resp;
|
||||
}
|
||||
|
||||
public async listAssistants(organizationId: string | null): Promise<
|
||||
public async listAssistants(
|
||||
organizationId: string | null,
|
||||
signal?: AbortSignal,
|
||||
): Promise<
|
||||
{
|
||||
configResult: ConfigResult<AssistantUnrolled>;
|
||||
ownerSlug: string;
|
||||
|
|
@ -123,6 +128,7 @@ export class ControlPlaneClient {
|
|||
|
||||
const resp = await this.request(url, {
|
||||
method: "GET",
|
||||
signal,
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
} catch (e) {
|
||||
|
|
@ -130,7 +136,9 @@ export class ControlPlaneClient {
|
|||
}
|
||||
}
|
||||
|
||||
public async listOrganizations(): Promise<Array<OrganizationDescription>> {
|
||||
public async listOrganizations(
|
||||
signal?: AbortSignal,
|
||||
): Promise<Array<OrganizationDescription>> {
|
||||
if (!(await this.isSignedIn())) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -138,6 +146,7 @@ export class ControlPlaneClient {
|
|||
try {
|
||||
const resp = await this.request("ide/list-organizations", {
|
||||
method: "GET",
|
||||
signal,
|
||||
});
|
||||
const { organizations } = (await resp.json()) as any;
|
||||
return organizations;
|
||||
|
|
@ -148,6 +157,7 @@ export class ControlPlaneClient {
|
|||
|
||||
public async listAssistantFullSlugs(
|
||||
organizationId: string | null,
|
||||
signal?: AbortSignal,
|
||||
): Promise<FullSlug[] | null> {
|
||||
if (!(await this.isSignedIn())) {
|
||||
return null;
|
||||
|
|
@ -160,6 +170,7 @@ export class ControlPlaneClient {
|
|||
try {
|
||||
const resp = await this.request(url, {
|
||||
method: "GET",
|
||||
signal,
|
||||
});
|
||||
const { fullSlugs } = (await resp.json()) as any;
|
||||
return fullSlugs;
|
||||
|
|
@ -168,7 +179,9 @@ export class ControlPlaneClient {
|
|||
}
|
||||
}
|
||||
|
||||
public async getFreeTrialStatus(): Promise<FreeTrialStatus | null> {
|
||||
public async getFreeTrialStatus(
|
||||
signal?: AbortSignal,
|
||||
): Promise<FreeTrialStatus | null> {
|
||||
if (!(await this.isSignedIn())) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -176,6 +189,7 @@ export class ControlPlaneClient {
|
|||
try {
|
||||
const resp = await this.request("ide/free-trial-status", {
|
||||
method: "GET",
|
||||
signal,
|
||||
});
|
||||
return (await resp.json()) as FreeTrialStatus;
|
||||
} catch (e) {
|
||||
|
|
@ -190,6 +204,7 @@ export class ControlPlaneClient {
|
|||
*/
|
||||
public async getModelsAddOnCheckoutUrl(
|
||||
vsCodeUriScheme?: string,
|
||||
signal?: AbortSignal,
|
||||
): Promise<{ url: string } | null> {
|
||||
if (!(await this.isSignedIn())) {
|
||||
return null;
|
||||
|
|
@ -209,6 +224,7 @@ export class ControlPlaneClient {
|
|||
`ide/get-models-add-on-checkout-url?${params.toString()}`,
|
||||
{
|
||||
method: "GET",
|
||||
signal,
|
||||
},
|
||||
);
|
||||
return (await resp.json()) as { url: string };
|
||||
|
|
|
|||
46
core/core.ts
46
core/core.ts
|
|
@ -150,7 +150,7 @@ export class Core {
|
|||
);
|
||||
|
||||
MCPManagerSingleton.getInstance().onConnectionsRefreshed = () => {
|
||||
void this.configHandler.reloadConfig();
|
||||
void this.configHandler.reloadConfig("MCP Connections refreshed");
|
||||
|
||||
// Refresh @mention dropdown submenu items for MCP providers
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
|
|
@ -299,23 +299,31 @@ export class Core {
|
|||
on("config/addModel", (msg) => {
|
||||
const model = msg.data.model;
|
||||
addModel(model, msg.data.role);
|
||||
void this.configHandler.reloadConfig();
|
||||
void this.configHandler.reloadConfig(
|
||||
"Model added (config/addModel message)",
|
||||
);
|
||||
});
|
||||
|
||||
on("config/deleteModel", (msg) => {
|
||||
deleteModel(msg.data.title);
|
||||
void this.configHandler.reloadConfig();
|
||||
void this.configHandler.reloadConfig(
|
||||
"Model removed (config/deleteModel message)",
|
||||
);
|
||||
});
|
||||
|
||||
on("config/newPromptFile", async (msg) => {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
await createNewPromptFileV2(this.ide, config?.experimental?.promptPath);
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig(
|
||||
"Prompt file created (config/newPromptFile message)",
|
||||
);
|
||||
});
|
||||
|
||||
on("config/addLocalWorkspaceBlock", async (msg) => {
|
||||
await createNewWorkspaceBlockFile(this.ide, msg.data.blockType);
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig(
|
||||
"Local block created (config/addLocalWorkspaceBlock message)",
|
||||
);
|
||||
});
|
||||
|
||||
on("config/openProfile", async (msg) => {
|
||||
|
|
@ -323,7 +331,9 @@ export class Core {
|
|||
});
|
||||
|
||||
on("config/reload", async (msg) => {
|
||||
void this.configHandler.reloadConfig();
|
||||
void this.configHandler.reloadConfig(
|
||||
"Force reloaded (config/reload message)",
|
||||
);
|
||||
return await this.configHandler.getSerializedConfig();
|
||||
});
|
||||
|
||||
|
|
@ -343,7 +353,9 @@ export class Core {
|
|||
|
||||
on("config/updateSharedConfig", async (msg) => {
|
||||
const newSharedConfig = this.globalContext.updateSharedConfig(msg.data);
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig(
|
||||
"Shared config update (config/updateSharedConfig message)",
|
||||
);
|
||||
return newSharedConfig;
|
||||
});
|
||||
|
||||
|
|
@ -353,7 +365,9 @@ export class Core {
|
|||
msg.data.role,
|
||||
msg.data.title,
|
||||
);
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig(
|
||||
"Selected model update (config/updateSelectedModel message)",
|
||||
);
|
||||
return newSelectedModels;
|
||||
});
|
||||
|
||||
|
|
@ -630,7 +644,7 @@ export class Core {
|
|||
void refreshIfNotIgnored(data.uris);
|
||||
|
||||
if (hasRulesFiles(data.uris)) {
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig("Rules file created");
|
||||
}
|
||||
|
||||
// If it's a local assistant being created, we want to reload all assistants so it shows up in the list
|
||||
|
|
@ -652,7 +666,7 @@ export class Core {
|
|||
void refreshIfNotIgnored(data.uris);
|
||||
|
||||
if (hasRulesFiles(data.uris)) {
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig("Rules file deleted");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -928,7 +942,7 @@ export class Core {
|
|||
],
|
||||
}),
|
||||
);
|
||||
void this.configHandler.reloadConfig();
|
||||
void this.configHandler.reloadConfig("Autocomplete model added");
|
||||
}
|
||||
|
||||
private async handleFilesChanged({
|
||||
|
|
@ -958,7 +972,9 @@ export class Core {
|
|||
this.globalContext.update("showConfigUpdateToast", false);
|
||||
}
|
||||
}
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig(
|
||||
"Current profile config file updated",
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -974,7 +990,9 @@ export class Core {
|
|||
uri.includes(`.continue\\${blockType}`),
|
||||
)
|
||||
) {
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig(
|
||||
"Config-related file updated: continuerc, prompt, local block, etc",
|
||||
);
|
||||
} else if (
|
||||
uri.endsWith(".continueignore") ||
|
||||
uri.endsWith(".gitignore")
|
||||
|
|
@ -1056,7 +1074,7 @@ export class Core {
|
|||
|
||||
editConfigFile((c) => c, editConfigYamlCallback);
|
||||
|
||||
void this.configHandler.reloadConfig();
|
||||
void this.configHandler.reloadConfig("Onboarding completed");
|
||||
}
|
||||
|
||||
private getContextItems = async (
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ConfigHandler } from "core/config/ConfigHandler";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
import { getTheme } from "./util/getTheme";
|
||||
|
|
@ -58,16 +57,10 @@ export class ContinueGUIWebviewViewProvider
|
|||
}
|
||||
|
||||
constructor(
|
||||
private readonly configHandlerPromise: Promise<ConfigHandler>,
|
||||
private readonly windowId: string,
|
||||
private readonly extensionContext: vscode.ExtensionContext,
|
||||
) {
|
||||
this.webviewProtocol = new VsCodeWebviewProtocol(
|
||||
(async () => {
|
||||
const configHandler = await this.configHandlerPromise;
|
||||
return configHandler.reloadConfig();
|
||||
}).bind(this),
|
||||
);
|
||||
this.webviewProtocol = new VsCodeWebviewProtocol();
|
||||
}
|
||||
|
||||
getSidebarContent(
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ export class VsCodeExtension {
|
|||
resolveConfigHandler = resolve;
|
||||
});
|
||||
this.sidebar = new ContinueGUIWebviewViewProvider(
|
||||
configHandlerPromise,
|
||||
this.windowId,
|
||||
this.extensionContext,
|
||||
);
|
||||
|
|
@ -147,7 +146,7 @@ export class VsCodeExtension {
|
|||
);
|
||||
resolveVerticalDiffManager?.(this.verticalDiffManager);
|
||||
|
||||
void setupRemoteConfigSync(
|
||||
void setupRemoteConfigSync(() =>
|
||||
this.configHandler.reloadConfig.bind(this.configHandler),
|
||||
);
|
||||
|
||||
|
|
@ -284,7 +283,9 @@ export class VsCodeExtension {
|
|||
if (stats.size === 0) {
|
||||
return;
|
||||
}
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig(
|
||||
"Global JSON config updated - fs file watch",
|
||||
);
|
||||
});
|
||||
|
||||
fs.watchFile(
|
||||
|
|
@ -294,7 +295,9 @@ export class VsCodeExtension {
|
|||
if (stats.size === 0) {
|
||||
return;
|
||||
}
|
||||
await this.configHandler.reloadConfig();
|
||||
await this.configHandler.reloadConfig(
|
||||
"Global YAML config updated - fs file watch",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -302,7 +305,7 @@ export class VsCodeExtension {
|
|||
if (stats.size === 0) {
|
||||
return;
|
||||
}
|
||||
void this.configHandler.reloadConfig();
|
||||
void this.configHandler.reloadConfig("config.ts updated - fs file watch");
|
||||
});
|
||||
|
||||
vscode.workspace.onDidChangeTextDocument(async (event) => {
|
||||
|
|
@ -363,7 +366,7 @@ export class VsCodeExtension {
|
|||
);
|
||||
|
||||
if (e.provider.id === "github") {
|
||||
this.configHandler.reloadConfig();
|
||||
this.configHandler.reloadConfig("Github sign-in status changed");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ export class VsCodeWebviewProtocol
|
|||
this._webviewListener = this._webview.onDidReceiveMessage(handleMessage);
|
||||
}
|
||||
|
||||
constructor(private readonly reloadConfig: () => void) {}
|
||||
constructor() {}
|
||||
|
||||
invoke<T extends keyof FromWebviewProtocol>(
|
||||
messageType: T,
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ export function AssistantAndOrgListbox() {
|
|||
className="border-border border-b px-2 py-1.5"
|
||||
>
|
||||
<span
|
||||
className="text-description flex flex-row items-center"
|
||||
className="text-description flex flex-1 flex-row items-center"
|
||||
style={{ fontSize: tinyFont }}
|
||||
onClick={async (e) => {
|
||||
e.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -103,8 +103,9 @@ function ParallelListeners() {
|
|||
[dispatch, hasDoneInitialConfigLoad],
|
||||
);
|
||||
|
||||
const initialLoadAuthAndConfig = useCallback(
|
||||
async (initial: boolean) => {
|
||||
// Load config from the IDE
|
||||
useEffect(() => {
|
||||
async function initialLoadConfig() {
|
||||
dispatch(setIsSessionMetadataLoading(true));
|
||||
dispatch(setConfigLoading(true));
|
||||
const result = await ideMessenger.request(
|
||||
|
|
@ -112,16 +113,11 @@ function ParallelListeners() {
|
|||
undefined,
|
||||
);
|
||||
if (result.status === "success") {
|
||||
await handleConfigUpdate(initial, result.content);
|
||||
await handleConfigUpdate(true, result.content);
|
||||
}
|
||||
dispatch(setConfigLoading(false));
|
||||
},
|
||||
[ideMessenger, handleConfigUpdate],
|
||||
);
|
||||
|
||||
// Load config from the IDE
|
||||
useEffect(() => {
|
||||
void initialLoadAuthAndConfig(true);
|
||||
}
|
||||
void initialLoadConfig();
|
||||
const interval = setInterval(() => {
|
||||
if (hasDoneInitialConfigLoad.current) {
|
||||
// Init to run on initial config load
|
||||
|
|
@ -132,12 +128,12 @@ function ParallelListeners() {
|
|||
// This triggers sending pending status to the GUI for relevant docs indexes
|
||||
clearInterval(interval);
|
||||
} else {
|
||||
void initialLoadAuthAndConfig(true);
|
||||
void initialLoadConfig();
|
||||
}
|
||||
}, 2_000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [hasDoneInitialConfigLoad, initialLoadAuthAndConfig, ideMessenger]);
|
||||
}, [hasDoneInitialConfigLoad, ideMessenger]);
|
||||
|
||||
useWebviewListener(
|
||||
"configUpdate",
|
||||
|
|
@ -145,6 +141,7 @@ function ParallelListeners() {
|
|||
if (!update) {
|
||||
return;
|
||||
}
|
||||
console.log("Received config update");
|
||||
await handleConfigUpdate(false, update);
|
||||
},
|
||||
[handleConfigUpdate],
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@ import { RootState } from "../store";
|
|||
import { streamResponseThunk } from "../thunks/streamResponse";
|
||||
import { findCurrentToolCall, findToolCall, findToolOutput } from "../util";
|
||||
|
||||
const getIdeMessenger = () => (window as any).ideMessenger;
|
||||
|
||||
// We need this to handle reorderings (e.g. a mid-array deletion) of the messages array.
|
||||
// The proper fix is adding a UUID to all chat messages, but this is the temp workaround.
|
||||
export type ChatHistoryItemWithMessageId = ChatHistoryItem & {
|
||||
|
|
|
|||
|
|
@ -57,16 +57,19 @@ export class ContinueHubClient implements IContinueHubClient {
|
|||
async resolveFQSNs(
|
||||
fqsns: FQSN[],
|
||||
orgScopeId: string | null,
|
||||
signal?: AbortSignal,
|
||||
): Promise<(SecretResult | undefined)[]> {
|
||||
const resp = await this.request("ide/sync-secrets", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ fqsns, orgScopeId }),
|
||||
signal,
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
}
|
||||
async listAssistants(options: {
|
||||
organizationId: string | null;
|
||||
alwaysUseProxy?: boolean;
|
||||
signal?: AbortSignal;
|
||||
}): Promise<
|
||||
{
|
||||
configResult: ConfigResult<AssistantUnrolled>;
|
||||
|
|
@ -94,6 +97,7 @@ export class ContinueHubClient implements IContinueHubClient {
|
|||
|
||||
const resp = await this.request(url, {
|
||||
method: "GET",
|
||||
signal: options.signal,
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
} catch (e) {
|
||||
|
|
@ -103,6 +107,7 @@ export class ContinueHubClient implements IContinueHubClient {
|
|||
|
||||
async listAssistantFullSlugs(
|
||||
organizationId: string | null,
|
||||
signal?: AbortSignal,
|
||||
): Promise<FullSlug[] | null> {
|
||||
const url = organizationId
|
||||
? `ide/list-assistant-full-slugs?organizationId=${organizationId}`
|
||||
|
|
@ -111,6 +116,7 @@ export class ContinueHubClient implements IContinueHubClient {
|
|||
try {
|
||||
const resp = await this.request(url, {
|
||||
method: "GET",
|
||||
signal,
|
||||
});
|
||||
const { fullSlugs } = (await resp.json()) as any;
|
||||
return fullSlugs;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue