migrate shared config
This commit is contained in:
parent
593fc2e669
commit
eb8f9b15ba
14 changed files with 513 additions and 52 deletions
|
|
@ -74,8 +74,9 @@ import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
|
|||
// import { isSupportedLanceDbCpuTarget } from "./util";
|
||||
import { validateConfig } from "./validation.js";
|
||||
import { localPathToUri } from "../util/pathToUri";
|
||||
import { modifyContinueConfigWithSharedConfig } from "./sharedConfig";
|
||||
|
||||
function resolveSerializedConfig(filepath: string): SerializedContinueConfig {
|
||||
export function resolveSerializedConfig(filepath: string): SerializedContinueConfig {
|
||||
let content = fs.readFileSync(filepath, "utf8");
|
||||
const config = JSONC.parse(content) as unknown as SerializedContinueConfig;
|
||||
if (config.env && Array.isArray(config.env)) {
|
||||
|
|
@ -582,6 +583,7 @@ function finalToBrowserConfig(
|
|||
docs: final.docs,
|
||||
tools: final.tools,
|
||||
usePlatform: usePlatform(),
|
||||
tabAutocompleteOptions: final.tabAutocompleteOptions,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -797,8 +799,16 @@ async function loadContinueConfigFromJson(
|
|||
serialized.systemMessage = systemPromptDotFile;
|
||||
}
|
||||
|
||||
// Apply shared config
|
||||
// TODO: override several of these values with user/org shared config
|
||||
const sharedConfig = new GlobalContext().getSharedConfig();
|
||||
const withShared = modifyContinueConfigWithSharedConfig(
|
||||
serialized,
|
||||
sharedConfig,
|
||||
);
|
||||
|
||||
// Convert serialized to intermediate config
|
||||
let intermediate = await serializedToIntermediateConfig(serialized, ide);
|
||||
let intermediate = await serializedToIntermediateConfig(withShared, ide);
|
||||
|
||||
// Apply config.ts to modify intermediate config
|
||||
const configJsContents = await buildConfigTsandReadConfigJs(ide, ideType);
|
||||
|
|
|
|||
165
core/config/migrateSharedConfig.ts
Normal file
165
core/config/migrateSharedConfig.ts
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
import * as fs from "fs";
|
||||
|
||||
import * as JSONC from "comment-json";
|
||||
|
||||
import { IDE, SerializedContinueConfig } from "..";
|
||||
import { SharedConfigSchema } from "./sharedConfig";
|
||||
import { GlobalContext } from "../util/GlobalContext";
|
||||
import { editConfigJson } from "../util/paths";
|
||||
import { resolveSerializedConfig } from "./load";
|
||||
|
||||
/*
|
||||
This migration function eliminates deprecated values from the json file
|
||||
And writes them to the shared config
|
||||
*/
|
||||
export function migrateJsonSharedConfig(filepath: string, ide: IDE): void {
|
||||
try {
|
||||
let config = resolveSerializedConfig(filepath);
|
||||
const shareConfigUpdates: SharedConfigSchema = {};
|
||||
|
||||
let effected = false;
|
||||
|
||||
const { allowAnonymousTelemetry, ...withoutAllowTelemetry } = config;
|
||||
if (allowAnonymousTelemetry !== undefined) {
|
||||
shareConfigUpdates.allowAnonymousTelemetry = allowAnonymousTelemetry;
|
||||
config = withoutAllowTelemetry;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { disableIndexing, ...withoutDisableIndexing } = config;
|
||||
if (disableIndexing !== undefined) {
|
||||
shareConfigUpdates.disableIndexing = disableIndexing;
|
||||
config = withoutDisableIndexing;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { disableSessionTitles, ...withoutDisableSessionTitles } = config;
|
||||
if (config.disableSessionTitles !== undefined) {
|
||||
shareConfigUpdates.disableSessionTitles = config.disableSessionTitles;
|
||||
config = withoutDisableSessionTitles;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { tabAutocompleteOptions, ...withoutAutocompleteOptions } = config;
|
||||
if (tabAutocompleteOptions !== undefined) {
|
||||
let migratedAutocomplete = { ...tabAutocompleteOptions };
|
||||
|
||||
const { useCache, ...withoutUseCache } = migratedAutocomplete;
|
||||
if (useCache !== undefined) {
|
||||
shareConfigUpdates.useAutocompleteCache = useCache;
|
||||
migratedAutocomplete = withoutUseCache;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { multilineCompletions, ...withoutMultiline } =
|
||||
migratedAutocomplete;
|
||||
if (multilineCompletions !== undefined) {
|
||||
shareConfigUpdates.useAutocompleteMultilineCompletions =
|
||||
multilineCompletions;
|
||||
migratedAutocomplete = withoutMultiline;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { disableInFiles, ...withoutDisableInFiles } = migratedAutocomplete;
|
||||
if (disableInFiles !== undefined) {
|
||||
shareConfigUpdates.disableAutocompleteInFiles = disableInFiles;
|
||||
migratedAutocomplete = withoutDisableInFiles;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
config = {
|
||||
...withoutAutocompleteOptions,
|
||||
tabAutocompleteOptions: migratedAutocomplete,
|
||||
};
|
||||
}
|
||||
|
||||
const { experimental, ...withoutExperimental } = config;
|
||||
if (experimental !== undefined) {
|
||||
let migratedExperimental = { ...experimental };
|
||||
|
||||
const { useChromiumForDocsCrawling, ...rest10 } = migratedExperimental;
|
||||
if (useChromiumForDocsCrawling !== undefined) {
|
||||
shareConfigUpdates.useChromiumForDocsCrawling =
|
||||
useChromiumForDocsCrawling;
|
||||
migratedExperimental = rest10;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { promptPath, ...withoutPromptPath } = migratedExperimental;
|
||||
if (promptPath !== undefined) {
|
||||
shareConfigUpdates.promptPath = promptPath;
|
||||
migratedExperimental = withoutPromptPath;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { readResponseTTS, ...withoutReadTTS } = migratedExperimental;
|
||||
if (readResponseTTS !== undefined) {
|
||||
shareConfigUpdates.readResponseTTS = readResponseTTS;
|
||||
migratedExperimental = withoutReadTTS;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
config = {
|
||||
...withoutExperimental,
|
||||
experimental: migratedExperimental,
|
||||
};
|
||||
}
|
||||
|
||||
const { ui, ...withoutUI } = config;
|
||||
if (ui !== undefined) {
|
||||
let migratedUI = { ...ui };
|
||||
|
||||
const { codeBlockToolbarPosition, ...withoutToolbarPosition } =
|
||||
migratedUI;
|
||||
if (codeBlockToolbarPosition !== undefined) {
|
||||
shareConfigUpdates.codeBlockToolbarPosition = codeBlockToolbarPosition;
|
||||
migratedUI = withoutToolbarPosition;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { fontSize, ...withoutFontSize } = migratedUI;
|
||||
if (fontSize !== undefined) {
|
||||
shareConfigUpdates.fontSize = fontSize;
|
||||
migratedUI = withoutFontSize;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { codeWrap, ...withoutCodeWrap } = migratedUI;
|
||||
if (codeWrap !== undefined) {
|
||||
shareConfigUpdates.codeWrap = codeWrap;
|
||||
migratedUI = withoutCodeWrap;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { displayRawMarkdown, ...withoutMD } = migratedUI;
|
||||
if (displayRawMarkdown !== undefined) {
|
||||
shareConfigUpdates.displayRawMarkdown = displayRawMarkdown;
|
||||
migratedUI = withoutMD;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
const { showChatScrollbar, ...withoutShowChatScrollbar } = migratedUI;
|
||||
if (showChatScrollbar !== undefined) {
|
||||
shareConfigUpdates.showChatScrollbar = showChatScrollbar;
|
||||
migratedUI = withoutShowChatScrollbar;
|
||||
effected = true;
|
||||
}
|
||||
|
||||
config = {
|
||||
...withoutUI,
|
||||
ui: migratedUI,
|
||||
};
|
||||
}
|
||||
|
||||
if (effected) {
|
||||
new GlobalContext().updateSharedConfig(shareConfigUpdates);
|
||||
void ide.showToast(
|
||||
"warning",
|
||||
"Migrated deprecated Continue JSON settings. Edit in the Config Page",
|
||||
);
|
||||
editConfigJson(() => config);
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(`Migration: Failed to parse config.json: ${e}`);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,12 +17,13 @@ import { ControlPlaneClient } from "../../control-plane/client.js";
|
|||
import { controlPlaneEnv } from "../../control-plane/env.js";
|
||||
import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js";
|
||||
import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
|
||||
import { getConfigYamlPath } from "../../util/paths";
|
||||
import { getConfigJsonPath, getConfigYamlPath } from "../../util/paths";
|
||||
import { Telemetry } from "../../util/posthog";
|
||||
import { TTS } from "../../util/tts";
|
||||
import { loadContinueConfigFromJson } from "../load";
|
||||
import { loadContinueConfigFromYaml } from "../yaml/loadYaml";
|
||||
import { PlatformConfigMetadata } from "./PlatformProfileLoader";
|
||||
import { migrateJsonSharedConfig } from "../migrateSharedConfig";
|
||||
|
||||
export default async function doLoadConfig(
|
||||
ide: IDE,
|
||||
|
|
@ -40,6 +41,13 @@ export default async function doLoadConfig(
|
|||
const ideSettings = await ideSettingsPromise;
|
||||
const workOsAccessToken = await controlPlaneClient.getAccessToken();
|
||||
|
||||
// Migrations for old config files
|
||||
// Removes
|
||||
const configJsonPath = getConfigJsonPath(ideInfo.ideType);
|
||||
if (fs.existsSync(configJsonPath)) {
|
||||
migrateJsonSharedConfig(configJsonPath, ide);
|
||||
}
|
||||
|
||||
const configYamlPath = getConfigYamlPath(ideInfo.ideType);
|
||||
|
||||
let newConfig: ContinueConfig | undefined;
|
||||
|
|
|
|||
|
|
@ -1,30 +1,33 @@
|
|||
import z from "zod";
|
||||
|
||||
const sharedConfigTabAutoCompleteOptionsSchema = z
|
||||
.object({
|
||||
disable: z.boolean(),
|
||||
useCache: z.boolean(),
|
||||
disableInFiles: z.array(z.string()),
|
||||
multilineCompletions: z.enum(["always", "never", "auto"]),
|
||||
})
|
||||
.partial();
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContinueConfig,
|
||||
Config,
|
||||
SerializedContinueConfig,
|
||||
} from "..";
|
||||
|
||||
export const sharedConfigSchema = z
|
||||
.object({
|
||||
allowAnonymousTelemetry: z.boolean(),
|
||||
disableIndexing: z.boolean(),
|
||||
disableSessionTitles: z.boolean(),
|
||||
|
||||
// `experimental` in `ContinueConfig`
|
||||
useChromiumForDocsCrawling: z.boolean(),
|
||||
readResponseTTS: z.boolean(),
|
||||
promptPath: z.string(),
|
||||
tabAutocompleteOptions: sharedConfigTabAutoCompleteOptionsSchema,
|
||||
|
||||
// UI-only, and user-specific:
|
||||
// `ui` in `ContinueConfig`
|
||||
codeBlockToolbarPosition: z.enum(["top", "bottom"]),
|
||||
fontSize: z.number(),
|
||||
codeWrap: z.boolean(),
|
||||
displayRawMarkdown: z.boolean(),
|
||||
showChatScrollbar: z.boolean(),
|
||||
|
||||
// `tabAutocompleteOptions` in `ContinueConfig`
|
||||
useAutocompleteCache: z.boolean(),
|
||||
useAutocompleteMultilineCompletions: z.enum(["always", "never", "auto"]),
|
||||
disableAutocompleteInFiles: z.array(z.string()),
|
||||
})
|
||||
.partial();
|
||||
|
||||
|
|
@ -51,13 +54,109 @@ export function salvageSharedConfig(sharedConfig: object): SharedConfigSchema {
|
|||
salvagedConfig.disableSessionTitles = val.data;
|
||||
}
|
||||
}
|
||||
if ("tabAutocompleteOptions" in sharedConfig) {
|
||||
const val = sharedConfigTabAutoCompleteOptionsSchema.safeParse(
|
||||
sharedConfig.tabAutocompleteOptions,
|
||||
if ("disableAutocompleteInFiles" in sharedConfig) {
|
||||
const val = sharedConfigSchema.shape.disableAutocompleteInFiles.safeParse(
|
||||
sharedConfig.disableAutocompleteInFiles,
|
||||
);
|
||||
if (val.success) {
|
||||
salvagedConfig.tabAutocompleteOptions = val.data;
|
||||
salvagedConfig.disableAutocompleteInFiles = val.data;
|
||||
}
|
||||
}
|
||||
return salvagedConfig;
|
||||
}
|
||||
|
||||
export function modifyContinueConfigWithSharedConfig<
|
||||
T extends
|
||||
| ContinueConfig
|
||||
| BrowserSerializedContinueConfig
|
||||
| Config
|
||||
| SerializedContinueConfig,
|
||||
>(continueConfig: T, sharedConfig: SharedConfigSchema): T {
|
||||
const configCopy = { ...continueConfig };
|
||||
configCopy.tabAutocompleteOptions = {
|
||||
...configCopy.tabAutocompleteOptions,
|
||||
};
|
||||
if (sharedConfig.useAutocompleteCache !== undefined) {
|
||||
configCopy.tabAutocompleteOptions.useCache =
|
||||
sharedConfig.useAutocompleteCache;
|
||||
}
|
||||
if (sharedConfig.useAutocompleteMultilineCompletions !== undefined) {
|
||||
configCopy.tabAutocompleteOptions.multilineCompletions =
|
||||
sharedConfig.useAutocompleteMultilineCompletions;
|
||||
}
|
||||
if (sharedConfig.disableAutocompleteInFiles !== undefined) {
|
||||
configCopy.tabAutocompleteOptions.disableInFiles =
|
||||
sharedConfig.disableAutocompleteInFiles;
|
||||
}
|
||||
|
||||
configCopy.ui = {
|
||||
...configCopy.ui,
|
||||
};
|
||||
if (sharedConfig.codeBlockToolbarPosition !== undefined) {
|
||||
configCopy.ui.codeBlockToolbarPosition =
|
||||
sharedConfig.codeBlockToolbarPosition;
|
||||
}
|
||||
if (sharedConfig.fontSize !== undefined) {
|
||||
configCopy.ui.fontSize = sharedConfig.fontSize;
|
||||
}
|
||||
if (sharedConfig.codeWrap !== undefined) {
|
||||
configCopy.ui.codeWrap = sharedConfig.codeWrap;
|
||||
}
|
||||
if (sharedConfig.displayRawMarkdown !== undefined) {
|
||||
configCopy.ui.displayRawMarkdown = sharedConfig.displayRawMarkdown;
|
||||
}
|
||||
if (sharedConfig.showChatScrollbar !== undefined) {
|
||||
configCopy.ui.showChatScrollbar = sharedConfig.showChatScrollbar;
|
||||
}
|
||||
|
||||
if (sharedConfig.allowAnonymousTelemetry !== undefined) {
|
||||
configCopy.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry;
|
||||
}
|
||||
if (sharedConfig.disableIndexing !== undefined) {
|
||||
configCopy.disableIndexing = sharedConfig.disableIndexing;
|
||||
}
|
||||
if (sharedConfig.disableSessionTitles !== undefined) {
|
||||
configCopy.disableSessionTitles = sharedConfig.disableSessionTitles;
|
||||
}
|
||||
|
||||
configCopy.experimental = {
|
||||
...configCopy.experimental,
|
||||
};
|
||||
if (sharedConfig.promptPath !== undefined) {
|
||||
configCopy.experimental.promptPath = sharedConfig.promptPath;
|
||||
}
|
||||
if (sharedConfig.useChromiumForDocsCrawling !== undefined) {
|
||||
configCopy.experimental.useChromiumForDocsCrawling =
|
||||
sharedConfig.useChromiumForDocsCrawling;
|
||||
}
|
||||
if (sharedConfig.readResponseTTS !== undefined) {
|
||||
configCopy.experimental.readResponseTTS = sharedConfig.readResponseTTS;
|
||||
}
|
||||
|
||||
return configCopy;
|
||||
}
|
||||
|
||||
// continueConfig.tabAutocompleteOptions = {
|
||||
// ...continueConfig.tabAutocompleteOptions,
|
||||
// useCache: sharedConfig.useAutocompleteCache,
|
||||
// disableInFiles: sharedConfig.disableAutocompleteInFiles,
|
||||
// multilineCompletions: sharedConfig.useAutocompleteMultilineCompletions,
|
||||
// };
|
||||
// continueConfig.ui = {
|
||||
// ...continueConfig.ui,
|
||||
// codeBlockToolbarPosition: sharedConfig.codeBlockToolbarPosition,
|
||||
// fontSize: sharedConfig.fontSize,
|
||||
// codeWrap: sharedConfig.codeWrap,
|
||||
// displayRawMarkdown: sharedConfig.displayRawMarkdown,
|
||||
// showChatScrollbar: sharedConfig.showChatScrollbar,
|
||||
// };
|
||||
// continueConfig.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry;
|
||||
// continueConfig.disableIndexing = sharedConfig.disableIndexing;
|
||||
// continueConfig.disableIndexing = sharedConfig.disableIndexing;
|
||||
// continueConfig.disableSessionTitles = sharedConfig.disableSessionTitles;
|
||||
// continueConfig.experimental = {
|
||||
// ...continueConfig.experimental,
|
||||
// useChromiumForDocsCrawling: sharedConfig.useChromiumForDocsCrawling,
|
||||
// readResponseTTS: sharedConfig.readResponseTTS,
|
||||
// promptPath: sharedConfig.promptPath,
|
||||
// };
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import { allTools } from "../../tools";
|
|||
import { clientRenderHelper } from "./clientRender";
|
||||
import { llmsFromModelConfig } from "./models";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
import { modifyContinueConfigWithSharedConfig } from "../sharedConfig";
|
||||
|
||||
async function loadConfigYaml(
|
||||
workspaceConfigs: string[],
|
||||
|
|
@ -281,25 +282,6 @@ async function configYamlToContinueConfig(
|
|||
clearTimeout(mcpConnectionTimeout);
|
||||
});
|
||||
|
||||
// Apply shared config
|
||||
// TODO: override several of these values with user/org shared config
|
||||
const sharedConfig = new GlobalContext().getSharedConfig();
|
||||
continueConfig.tabAutocompleteOptions = sharedConfig.tabAutocompleteOptions;
|
||||
continueConfig.ui = {
|
||||
codeBlockToolbarPosition: sharedConfig.codeBlockToolbarPosition,
|
||||
fontSize: sharedConfig.fontSize,
|
||||
codeWrap: sharedConfig.codeWrap,
|
||||
displayRawMarkdown: sharedConfig.displayRawMarkdown,
|
||||
showChatScrollbar: sharedConfig.showChatScrollbar,
|
||||
};
|
||||
continueConfig.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry;
|
||||
continueConfig.disableIndexing = sharedConfig.disableIndexing;
|
||||
continueConfig.disableSessionTitles = sharedConfig.disableSessionTitles;
|
||||
continueConfig.experimental!.useChromiumForDocsCrawling =
|
||||
sharedConfig.useChromiumForDocsCrawling;
|
||||
continueConfig.experimental!.readResponseTTS = sharedConfig.readResponseTTS;
|
||||
continueConfig.experimental!.promptPath = sharedConfig.promptPath;
|
||||
|
||||
return continueConfig;
|
||||
}
|
||||
|
||||
|
|
@ -355,8 +337,16 @@ export async function loadContinueConfigFromYaml(
|
|||
}
|
||||
}
|
||||
|
||||
// Apply shared config
|
||||
// TODO: override several of these values with user/org shared config
|
||||
const sharedConfig = new GlobalContext().getSharedConfig();
|
||||
const withShared = modifyContinueConfigWithSharedConfig(
|
||||
continueConfig,
|
||||
sharedConfig,
|
||||
);
|
||||
|
||||
return {
|
||||
config: continueConfig,
|
||||
config: withShared,
|
||||
errors: configYamlResult.errors,
|
||||
configLoadInterrupted: false,
|
||||
};
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -1211,6 +1211,7 @@ export interface BrowserSerializedContinueConfig {
|
|||
docs?: SiteIndexingConfig[];
|
||||
tools: Tool[];
|
||||
usePlatform: boolean;
|
||||
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
|
||||
}
|
||||
|
||||
// DOCS SUGGESTIONS AND PACKAGE INFO
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import type {
|
|||
} from "../";
|
||||
import { AutocompleteInput } from "../autocomplete/util/types";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
import { SharedConfigSchema } from "../config/SharedConfig";
|
||||
import { SharedConfigSchema } from "../config/sharedConfig";
|
||||
|
||||
export type OnboardingModes =
|
||||
| "Local"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"config/deleteModel",
|
||||
"config/listProfiles",
|
||||
"config/openProfile",
|
||||
"config/updateSharedConfig",
|
||||
"context/getContextItems",
|
||||
"context/getSymbolsForFiles",
|
||||
"context/loadSubmenuItems",
|
||||
|
|
|
|||
|
|
@ -446,3 +446,11 @@ Example
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Deprecated settings
|
||||
|
||||
Some deprecated `config.json` settings are no longer stored in config and have been moved to be editable through the Config Page (Gear Icon)
|
||||
|
||||
|
||||
If config.json is
|
||||
For security purposes, ifsome settings present in `config.json` will always migrated from the old config if any config.json is detected
|
||||
|
|
@ -80,6 +80,7 @@ class MessageTypes {
|
|||
"config/deleteModel",
|
||||
"config/listProfiles",
|
||||
"config/openProfile",
|
||||
"config/updateSharedConfig",
|
||||
"context/getContextItems",
|
||||
"context/getSymbolsForFiles",
|
||||
"context/loadSubmenuItems",
|
||||
|
|
|
|||
|
|
@ -792,10 +792,8 @@ const getCommandsMap: (
|
|||
vscode.commands.executeCommand("workbench.action.copyEditorToNewWindow");
|
||||
vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar");
|
||||
},
|
||||
"continue.openConfig": () => {
|
||||
core.invoke("config/openProfile", {
|
||||
profileId: undefined,
|
||||
});
|
||||
"continue.openConfigPage": () => {
|
||||
vscode.commands.executeCommand("continue.navigateTo", "/config", true);
|
||||
},
|
||||
"continue.selectFilesAsContext": async (
|
||||
firstUri: vscode.Uri,
|
||||
|
|
|
|||
37
gui/src/components/gui/Switch.tsx
Normal file
37
gui/src/components/gui/Switch.tsx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import React from "react";
|
||||
|
||||
type ToggleSwitchProps = {
|
||||
isToggled: boolean;
|
||||
onToggle: () => void;
|
||||
text: string;
|
||||
};
|
||||
|
||||
const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
|
||||
isToggled,
|
||||
onToggle,
|
||||
text,
|
||||
}) => {
|
||||
return (
|
||||
<label
|
||||
htmlFor="toggle"
|
||||
className="flex cursor-pointer select-none items-center justify-end gap-3"
|
||||
>
|
||||
<span className="lines lines-1 text-right">{text}</span>
|
||||
<div>
|
||||
<div
|
||||
id={`toggle-${text}`}
|
||||
className={`border-vsc-input-border bg-vsc-input-background flex h-5 w-10 items-center rounded-full border border-solid p-0.5`}
|
||||
onClick={onToggle}
|
||||
>
|
||||
<div className="relative h-full w-full">
|
||||
<div
|
||||
className={`absolute left-1/4 top-0 h-full w-1/2 transform rounded-full transition-all ${isToggled ? "translate-x-1/2 bg-green-500" : "-translate-x-1/2 bg-red-500"}`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
);
|
||||
};
|
||||
|
||||
export default ToggleSwitch;
|
||||
|
|
@ -79,6 +79,7 @@ body {
|
|||
word-break: break-word;
|
||||
overflow: hidden;
|
||||
line-height: 1.375;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.lines-3 {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
import { useContext } from "react";
|
||||
import { useContext, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useNavigationListener } from "../../hooks/useNavigationListener";
|
||||
import PageHeader from "../../components/PageHeader";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { SharedConfigSchema } from "core/config/sharedConfig";
|
||||
import {
|
||||
modifyContinueConfigWithSharedConfig,
|
||||
SharedConfigSchema,
|
||||
} from "core/config/sharedConfig";
|
||||
import { Switch } from "@headlessui/react";
|
||||
import { updateConfig } from "../../redux/slices/configSlice";
|
||||
import ToggleSwitch from "../../components/gui/Switch";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { Button } from "../../components";
|
||||
|
||||
function ConfigPage() {
|
||||
useNavigationListener();
|
||||
|
|
@ -14,9 +20,13 @@ function ConfigPage() {
|
|||
const navigate = useNavigate();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const { profiles, selectedProfile, controlServerBetaEnabled } = useAuth();
|
||||
const config = useAppSelector((state) => state.config.config);
|
||||
|
||||
function handleUpdateSharedConfig(sharedConfig: Partial<SharedConfigSchema>) {
|
||||
function handleUpdate(sharedConfig: Partial<SharedConfigSchema>) {
|
||||
dispatch(
|
||||
updateConfig(modifyContinueConfigWithSharedConfig(config, sharedConfig)),
|
||||
);
|
||||
ideMessenger.post("config/updateSharedConfig", sharedConfig);
|
||||
|
||||
// TODO: Optimistic update in redux
|
||||
|
|
@ -26,13 +36,145 @@ function ConfigPage() {
|
|||
// }))
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="overflow-y-scroll">
|
||||
<PageHeader onClick={() => navigate("/")} title="Chat" />
|
||||
// Account for default values
|
||||
const codeWrap = config.ui?.codeWrap ?? false;
|
||||
const showChatScrollbar = config.ui?.showChatScrollbar ?? false;
|
||||
const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false;
|
||||
const disableSessionTitles = config.disableSessionTitles ?? false;
|
||||
const readResponseTTS = config.experimental?.readResponseTTS ?? false;
|
||||
|
||||
<div className="flex flex-col gap-2 overflow-y-scroll px-3">
|
||||
<Switch checked={true}>Hello</Switch>
|
||||
</div>
|
||||
const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true;
|
||||
const disableIndexing = config.disableIndexing ?? false;
|
||||
|
||||
const useAutocompleteCache = config.tabAutocompleteOptions?.useCache ?? false;
|
||||
const useChromiumForDocsCrawling =
|
||||
config.experimental?.useChromiumForDocsCrawling ?? false;
|
||||
|
||||
function handleOpenConfig() {
|
||||
if (!selectedProfile) {
|
||||
return;
|
||||
}
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: selectedProfile.id,
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="overflow-y-scroll px-2">
|
||||
<PageHeader onClick={() => navigate("/")} title="Chat" />
|
||||
<h1 className="text-center">Continue Configuration</h1>
|
||||
|
||||
{!selectedProfile ? (
|
||||
<p>No config profile selected</p>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2 px-3">
|
||||
<Button onClick={handleOpenConfig}>
|
||||
{selectedProfile.id === "local" ? "Open Config File" : "Nooooo"}
|
||||
</Button>
|
||||
<h2 className="text-center">Other Settings</h2>
|
||||
<ToggleSwitch
|
||||
isToggled={codeWrap}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
codeWrap: !codeWrap,
|
||||
})
|
||||
}
|
||||
text="Wrap Codeblocks"
|
||||
></ToggleSwitch>
|
||||
<ToggleSwitch
|
||||
isToggled={displayRawMarkdown}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
displayRawMarkdown: !displayRawMarkdown,
|
||||
})
|
||||
}
|
||||
text="Display Raw Markdown"
|
||||
></ToggleSwitch>
|
||||
<ToggleSwitch
|
||||
isToggled={allowAnonymousTelemetry}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
allowAnonymousTelemetry: !allowAnonymousTelemetry,
|
||||
})
|
||||
}
|
||||
text="Allow Anonymous Telemetry"
|
||||
></ToggleSwitch>
|
||||
<ToggleSwitch
|
||||
isToggled={disableIndexing}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
disableIndexing: !disableIndexing,
|
||||
})
|
||||
}
|
||||
text="Disable Indexing"
|
||||
></ToggleSwitch>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={disableSessionTitles}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
disableSessionTitles: !disableSessionTitles,
|
||||
})
|
||||
}
|
||||
text="Disable Session Titles"
|
||||
></ToggleSwitch>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={readResponseTTS}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
readResponseTTS: !readResponseTTS,
|
||||
})
|
||||
}
|
||||
text="Read Response TTS"
|
||||
></ToggleSwitch>
|
||||
|
||||
<ToggleSwitch
|
||||
isToggled={showChatScrollbar}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
showChatScrollbar: !showChatScrollbar,
|
||||
})
|
||||
}
|
||||
text="Show Chat Scrollbar"
|
||||
></ToggleSwitch>
|
||||
|
||||
{/* <label>
|
||||
fontSize
|
||||
<input></input>
|
||||
</label> */}
|
||||
|
||||
{/* codeBlockToolbarPosition: z.enum(["top", "bottom"]), */}
|
||||
|
||||
{/* disableAutocompleteInFiles: z.array(z.string()), */}
|
||||
|
||||
{/* promptPath: z.string(), */}
|
||||
|
||||
{/* useAutocompleteMultilineCompletions: z.enum(["always", "never", "auto"]), */}
|
||||
|
||||
{/* Other */}
|
||||
<ToggleSwitch
|
||||
isToggled={useAutocompleteCache}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
useAutocompleteCache: !useAutocompleteCache,
|
||||
})
|
||||
}
|
||||
text="Use Chromium for Docs Crawling"
|
||||
></ToggleSwitch>
|
||||
|
||||
{/* Other */}
|
||||
<ToggleSwitch
|
||||
isToggled={useChromiumForDocsCrawling}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
useChromiumForDocsCrawling: !useChromiumForDocsCrawling,
|
||||
})
|
||||
}
|
||||
text="Use Chromium for Docs Crawling"
|
||||
></ToggleSwitch>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue