diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index f629f9331..ccc9e8a44 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -1,7 +1,7 @@ name: PR checks on: - pull_request: + pull_request_target: branches: - main paths: @@ -22,10 +22,22 @@ on: - ".github/workflows/**" jobs: + validate-pr: + runs-on: ubuntu-latest + environment: tests-requiring-secrets + steps: + - uses: actions/checkout@v4 + install-root: + needs: validate-pr runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + # This is important - it switches from the base repo to the fork + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -45,6 +57,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -70,8 +86,13 @@ jobs: core-checks: needs: install-core runs-on: ubuntu-latest + environment: tests-requiring-secrets steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -97,10 +118,14 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} install-gui: - needs: [ install-root, install-core ] + needs: [install-root, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -132,6 +157,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -158,10 +187,14 @@ jobs: npx tsc --noEmit binary-checks: - needs: [ install-root, install-core ] + needs: [install-root, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -194,10 +227,14 @@ jobs: npx tsc --noEmit install-vscode: - needs: [ install-root, install-core ] + needs: [install-root, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -231,6 +268,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -262,6 +303,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -283,11 +328,14 @@ jobs: vscode-get-test-file-matrix: runs-on: ubuntu-latest - needs: [ install-root, install-vscode ] + needs: [install-root, install-vscode] outputs: test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }} steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - name: Cache node modules uses: actions/cache@v3 @@ -312,9 +360,13 @@ jobs: vscode-package-extension: runs-on: ubuntu-latest - needs: [ install-vscode, install-core ] + needs: [install-vscode, install-core] steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -344,9 +396,13 @@ jobs: vscode-download-e2e-dependencies: runs-on: ubuntu-latest - needs: [ install-vscode, install-core ] + needs: [install-vscode, install-core] steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -386,13 +442,19 @@ jobs: install-core, ] runs-on: ubuntu-latest + # Tests requiring secrets need approval from maintainers + environment: tests-requiring-secrets strategy: fail-fast: false matrix: test_file: ${{ fromJson(needs.vscode-get-test-file-matrix.outputs.test_file_matrix) }} - command: [ "e2e:ci:run", "e2e:ci:run-yaml" ] + command: ["e2e:ci:run", "e2e:ci:run-yaml"] steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -451,10 +513,14 @@ jobs: path: extensions/vscode/e2e/storage/screenshots gui-tests: - needs: [ install-gui, install-core ] + needs: [install-gui, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" @@ -482,10 +548,13 @@ jobs: npm test jetbrains-tests: - needs: [ install-root, core-checks ] + needs: [install-root, core-checks] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/cache@v4 with: @@ -578,4 +647,35 @@ jobs: with: name: jb-failure-report path: | - ${{ github.workspace }}/extensions/intellij/build/reports \ No newline at end of file + ${{ github.workspace }}/extensions/intellij/build/reports + + # GitHub does not have a way of requiring that all checks pass (you must manually select each job) + # This action at least lets us manage the list of required tests via source control + # so that creators of new jobs can add them to this list + require-all-checks-to-pass: + if: always() + runs-on: ubuntu-latest + needs: + - install-root + - install-core + - core-checks + - install-gui + - gui-checks + - binary-checks + - install-vscode + - vscode-checks + - core-tests + - vscode-get-test-file-matrix + - vscode-package-extension + - vscode-download-e2e-dependencies + - vscode-e2e-tests + - gui-tests + - jetbrains-tests + + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + allowed-failures: + allowed-skips: + jobs: ${{ toJSON(needs) }} diff --git a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts index 6bfc6cfe1..1bd90c503 100644 --- a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts +++ b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts @@ -76,7 +76,6 @@ export class StreamTransformPipeline { const timeoutValue = await Telemetry.getValueForFeatureFlag( PosthogFeatureFlag.AutocompleteTimeout, ); - // helper.options.showWhateverWeHaveAtXMs ?? DEFAULT_AUTOCOMPLETE_OPTS.showWhateverWeHaveAtXMs lineGenerator = showWhateverWeHaveAtXMs(lineGenerator, timeoutValue!); diff --git a/core/config/load.ts b/core/config/load.ts index af71ca172..da95ec5a8 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -70,12 +70,14 @@ import { defaultSlashCommandsVscode, } from "./default"; import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; -// import { isSupportedLanceDbCpuTarget } from "./util"; import { useHub } from "../control-plane/env"; import { localPathToUri } from "../util/pathToUri"; +import { modifyContinueConfigWithSharedConfig } from "./sharedConfig"; import { validateConfig } from "./validation.js"; -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)) { @@ -111,11 +113,10 @@ function loadSerializedConfig( overrideConfigJson: SerializedContinueConfig | undefined, ide: IDE, ): ConfigResult { - const configPath = getConfigJsonPath(ideType); let config: SerializedContinueConfig = overrideConfigJson!; if (!config) { try { - config = resolveSerializedConfig(configPath); + config = resolveSerializedConfig(getConfigJsonPath(ideType)); } catch (e) { throw new Error(`Failed to parse config.json: ${e}`); } @@ -135,16 +136,6 @@ function loadSerializedConfig( config.allowAnonymousTelemetry = true; } - // Deprecated getChatTitles property should be accounted for - // This is noted in docs - if ( - config.ui && - "getChatTitles" in config.ui && - config.ui.getChatTitles === false - ) { - config.disableSessionTitles = true; - } - if (ideSettings.remoteConfigServerUrl) { try { const remoteConfigJson = resolveSerializedConfig( @@ -583,6 +574,7 @@ async function finalToBrowserConfig( experimental: final.experimental, docs: final.docs, tools: final.tools, + tabAutocompleteOptions: final.tabAutocompleteOptions, usePlatform: await useHub(ide.getIdeSettings()), }; } @@ -767,7 +759,7 @@ async function buildConfigTsandReadConfigJs(ide: IDE, ideType: IdeType) { return readConfigJs(); } -async function loadFullConfigNode( +async function loadContinueConfigFromJson( ide: IDE, workspaceConfigs: ContinueRcJson[], ideSettings: IdeSettings, @@ -799,8 +791,16 @@ async function loadFullConfigNode( 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); @@ -877,6 +877,6 @@ async function loadFullConfigNode( export { finalToBrowserConfig, intermediateToFinalConfig, - loadFullConfigNode, + loadContinueConfigFromJson, type BrowserSerializedContinueConfig, }; diff --git a/core/config/migrateSharedConfig.ts b/core/config/migrateSharedConfig.ts new file mode 100644 index 000000000..b68e3adec --- /dev/null +++ b/core/config/migrateSharedConfig.ts @@ -0,0 +1,212 @@ +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"; +import { deduplicateArray } from "../util"; + +/* + 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 { + const globalContext = new GlobalContext(); + const currentSharedConfig = globalContext.getSharedConfig(); // for merging security concerns + + try { + let config = resolveSerializedConfig(filepath); + const shareConfigUpdates: SharedConfigSchema = {}; + + let effected = false; + + const { allowAnonymousTelemetry, ...withoutAllowTelemetry } = config; + if (allowAnonymousTelemetry !== undefined) { + if (currentSharedConfig.allowAnonymousTelemetry !== false) { + // safe merge for security + shareConfigUpdates.allowAnonymousTelemetry = allowAnonymousTelemetry; + } + config = withoutAllowTelemetry; + effected = true; + } + + const { disableIndexing, ...withoutDisableIndexing } = config; + if (disableIndexing !== undefined) { + if (currentSharedConfig.disableIndexing !== true) { + // safe merge for security + shareConfigUpdates.disableIndexing = disableIndexing; + } + config = withoutDisableIndexing; + effected = true; + } + + const { disableSessionTitles, ...withoutDisableSessionTitles } = config; + if (config.disableSessionTitles !== undefined) { + if (currentSharedConfig.disableSessionTitles !== true) { + // safe merge for security + 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) { + if (currentSharedConfig.disableAutocompleteInFiles !== undefined) { + // safe merge for security + shareConfigUpdates.disableAutocompleteInFiles = deduplicateArray( + [ + ...currentSharedConfig.disableAutocompleteInFiles, + ...disableInFiles, + ], + (a, b) => a === b, + ); + } else { + shareConfigUpdates.disableAutocompleteInFiles = disableInFiles; + } + shareConfigUpdates.disableAutocompleteInFiles = disableInFiles; + migratedAutocomplete = withoutDisableInFiles; + effected = true; + } + + if (Object.keys(migratedAutocomplete).length > 0) { + config = { + ...withoutAutocompleteOptions, + tabAutocompleteOptions: migratedAutocomplete, + }; + } else { + config = withoutAutocompleteOptions; + } + } + + 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; + } + + if (Object.keys(migratedExperimental).length > 0) { + config = { + ...withoutExperimental, + experimental: migratedExperimental, + }; + } else { + config = withoutExperimental; + } + } + + 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; + } + + // Ancient param to overwrite disableSessionTitles + if ("getChatTitles" in migratedUI) { + const { getChatTitles, ...withoutChatTitles } = migratedUI; + if (getChatTitles === false) { + shareConfigUpdates.disableSessionTitles = true; + migratedUI = withoutChatTitles; + effected = true; + } + } + + if (Object.keys(migratedUI).length > 0) { + config = { + ...withoutUI, + ui: migratedUI, + }; + } else { + config = withoutUI; + } + } + + if (effected) { + new GlobalContext().updateSharedConfig(shareConfigUpdates); + editConfigJson(() => config); + void ide.showToast( + "warning", + "Migrated deprecated Continue JSON settings. Edit in the Settings Page", + ); + } + } catch (e) { + throw new Error(`Migration: Failed to parse config.json: ${e}`); + } +} diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 851015bd2..5ee0620a6 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -17,12 +17,13 @@ import { ControlPlaneClient } from "../../control-plane/client.js"; import { getControlPlaneEnv } 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 { loadFullConfigNode } from "../load"; +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,13 +41,20 @@ 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; let errors: ConfigValidationError[] | undefined; let configLoadInterrupted = false; - if (fs.existsSync(configYamlPath) || overrideConfigYaml) { + if (overrideConfigYaml || fs.existsSync(configYamlPath)) { const result = await loadContinueConfigFromYaml( ide, workspaceConfigs.map((c) => JSON.stringify(c)), @@ -63,7 +71,7 @@ export default async function doLoadConfig( errors = result.errors; configLoadInterrupted = result.configLoadInterrupted; } else { - const result = await loadFullConfigNode( + const result = await loadContinueConfigFromJson( ide, workspaceConfigs, ideSettings, diff --git a/core/config/sharedConfig.ts b/core/config/sharedConfig.ts new file mode 100644 index 000000000..9f2335243 --- /dev/null +++ b/core/config/sharedConfig.ts @@ -0,0 +1,162 @@ +import z from "zod"; +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(), + + // `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(); + +export type SharedConfigSchema = z.infer; + +// For security in case of damaged config file, try to salvage any security-related values +export function salvageSharedConfig(sharedConfig: object): SharedConfigSchema { + const salvagedConfig: SharedConfigSchema = {}; + if ("allowAnonymousTelemetry" in sharedConfig) { + const val = z.boolean().safeParse(sharedConfig.allowAnonymousTelemetry); + if (val.success) { + salvagedConfig.allowAnonymousTelemetry = val.data; + } + } + if ("disableIndexing" in sharedConfig) { + const val = z.boolean().safeParse(sharedConfig.disableIndexing); + if (val.success) { + salvagedConfig.disableIndexing = val.data; + } + } + if ("disableSessionTitles" in sharedConfig) { + const val = z.boolean().safeParse(sharedConfig.disableSessionTitles); + if (val.success) { + salvagedConfig.disableSessionTitles = val.data; + } + } + if ("disableAutocompleteInFiles" in sharedConfig) { + const val = sharedConfigSchema.shape.disableAutocompleteInFiles.safeParse( + sharedConfig.disableAutocompleteInFiles, + ); + if (val.success) { + 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, +// }; diff --git a/core/config/types.ts b/core/config/types.ts index 269ae0e12..384da0c8f 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -572,7 +572,6 @@ declare global { userToken: string; enableControlServerBeta: boolean; pauseCodebaseIndexOnStart: boolean; - enableDebugLogs: boolean; } export interface IDE { @@ -902,7 +901,6 @@ declare global { export interface TabAutocompleteOptions { disable: boolean; - useFileSuffix: boolean; maxPromptTokens: number; debounceDelay: number; maxSuffixPercentage: number; diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 3ce7229a4..9503c0865 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -36,6 +36,8 @@ import { slashFromCustomCommand } from "../../commands"; 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[], @@ -301,10 +303,9 @@ export async function loadContinueConfigFromYaml( platformConfigMetadata: PlatformConfigMetadata | undefined, controlPlaneClient: ControlPlaneClient, ): Promise> { - const configYamlPath = getConfigYamlPath(ideType); const rawYaml = overrideConfigYaml === undefined - ? fs.readFileSync(configYamlPath, "utf-8") + ? fs.readFileSync(getConfigYamlPath(ideType), "utf-8") : ""; const configYamlResult = await loadConfigYaml( @@ -342,8 +343,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, }; diff --git a/core/core.ts b/core/core.ts index 5cedac188..e5bff1f31 100644 --- a/core/core.ts +++ b/core/core.ts @@ -297,6 +297,11 @@ export class Core { addContextProvider(msg.data); }); + on("config/updateSharedConfig", async (msg) => { + this.globalContext.updateSharedConfig(msg.data); + await this.configHandler.reloadConfig(); + }); + on("controlPlane/openUrl", async (msg) => { const env = await getControlPlaneEnv(this.ide.getIdeSettings()); await this.messenger.request("openUrl", `${env.APP_URL}${msg.data.path}`); diff --git a/core/index.d.ts b/core/index.d.ts index c8b96f7d3..f65c10622 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -433,6 +433,13 @@ interface ToolCallState { output?: ContextItem[]; } +interface Reasoning { + active: boolean; + text: string; + startAt: number; + endAt?: number; +} + export interface ChatHistoryItem { message: ChatMessage; contextItems: ContextItemWithId[]; @@ -443,6 +450,7 @@ export interface ChatHistoryItem { isGatheringContext?: boolean; checkpoint?: Checkpoint; isBeforeCheckpoint?: boolean; + reasoning?: Reasoning; } export interface LLMFullCompletionOptions extends BaseCompletionOptions { @@ -593,7 +601,6 @@ export interface IdeSettings { enableControlServerBeta: boolean; continueTestEnvironment: "none" | "production" | "test" | "local"; pauseCodebaseIndexOnStart: boolean; - enableDebugLogs: boolean; } export interface FileStats { @@ -949,7 +956,6 @@ export interface RerankerDescription { export interface TabAutocompleteOptions { disable: boolean; - useFileSuffix: boolean; maxPromptTokens: number; debounceDelay: number; maxSuffixPercentage: number; @@ -1222,6 +1228,7 @@ export interface BrowserSerializedContinueConfig { docs?: SiteIndexingConfig[]; tools: Tool[]; usePlatform: boolean; + tabAutocompleteOptions?: Partial; } // DOCS SUGGESTIONS AND PACKAGE INFO diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 5f88c13eb..dfbd2da5d 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -399,10 +399,10 @@ function compileChatMessages( if ( (systemMessage && systemMessage.trim() !== "") || - msgs?.[0].role === "system" + msgs?.[0]?.role === "system" ) { let content = ""; - if (msgs?.[0].role === "system") { + if (msgs?.[0]?.role === "system") { content = renderChatMessage(msgs?.[0]); } if (systemMessage && systemMessage.trim() !== "") { diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 444a7c743..ce24dfcbb 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -23,6 +23,7 @@ import type { } from "../"; import { AutocompleteInput } from "../autocomplete/util/types"; import { ProfileDescription } from "../config/ConfigHandler"; +import { SharedConfigSchema } from "../config/sharedConfig"; export type OnboardingModes = | "Local" @@ -71,6 +72,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { "config/reload": [undefined, ConfigResult]; "config/listProfiles": [undefined, ProfileDescription[]]; "config/openProfile": [{ profileId: string | undefined }, void]; + "config/updateSharedConfig": [SharedConfigSchema, void]; "context/getContextItems": [ { name: string; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index d734e0af6..0ce81bfe8 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -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", diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 336dc8293..90b403d41 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -1,5 +1,11 @@ import fs from "node:fs"; +import { + salvageSharedConfig, + sharedConfigSchema, + SharedConfigSchema, +} from "../config/sharedConfig"; + import { getGlobalContextFilePath } from "./paths"; export type GlobalContextType = { @@ -16,6 +22,7 @@ export type GlobalContextType = { hasAlreadyCreatedAPromptFile: boolean; showConfigUpdateToast: boolean; isSupportedLanceDbCpuTarget: boolean; + sharedConfig: SharedConfigSchema; }; /** @@ -26,9 +33,10 @@ export class GlobalContext { key: T, value: GlobalContextType[T], ) { - if (!fs.existsSync(getGlobalContextFilePath())) { + const filepath = getGlobalContextFilePath(); + if (!fs.existsSync(filepath)) { fs.writeFileSync( - getGlobalContextFilePath(), + filepath, JSON.stringify( { [key]: value, @@ -38,7 +46,7 @@ export class GlobalContext { ), ); } else { - const data = fs.readFileSync(getGlobalContextFilePath(), "utf-8"); + const data = fs.readFileSync(filepath, "utf-8"); let parsed; try { @@ -49,21 +57,19 @@ export class GlobalContext { } parsed[key] = value; - fs.writeFileSync( - getGlobalContextFilePath(), - JSON.stringify(parsed, null, 2), - ); + fs.writeFileSync(filepath, JSON.stringify(parsed, null, 2)); } } get( key: T, ): GlobalContextType[T] | undefined { - if (!fs.existsSync(getGlobalContextFilePath())) { + const filepath = getGlobalContextFilePath(); + if (!fs.existsSync(filepath)) { return undefined; } - const data = fs.readFileSync(getGlobalContextFilePath(), "utf-8"); + const data = fs.readFileSync(filepath, "utf-8"); try { const parsed = JSON.parse(data); return parsed[key]; @@ -72,4 +78,31 @@ export class GlobalContext { return undefined; } } + + getSharedConfig(): SharedConfigSchema { + const sharedConfig = this.get("sharedConfig") ?? {}; + const result = sharedConfigSchema.safeParse(sharedConfig); + if (result.success) { + return result.data; + } else { + // in case of damaged shared config, repair it + // Attempt to salvage any values that are security concerns + console.error("Failed to load shared config, salvaging...", result.error); + const salvagedConfig = salvageSharedConfig(sharedConfig); + this.update("sharedConfig", salvagedConfig); + return salvagedConfig; + } + } + + updateSharedConfig( + newValues: Partial, + ): SharedConfigSchema { + const currentSharedConfig = this.getSharedConfig(); + const updatedSharedConfig = { + ...currentSharedConfig, + ...newValues, + }; + this.update("sharedConfig", updatedSharedConfig); + return updatedSharedConfig; + } } diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index be33346e7..3c6963071 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -55,7 +55,6 @@ class FileSystemIde implements IDE { enableControlServerBeta: false, continueTestEnvironment: "none", pauseCodebaseIndexOnStart: false, - enableDebugLogs: false, }; } async getGitHubAuthToken(args: GetGhTokenArgs): Promise { diff --git a/core/util/parameters.ts b/core/util/parameters.ts index a7a11b503..648253712 100644 --- a/core/util/parameters.ts +++ b/core/util/parameters.ts @@ -2,7 +2,6 @@ import { TabAutocompleteOptions } from "../index.js"; export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = { disable: false, - useFileSuffix: true, maxPromptTokens: 1024, prefixPercentage: 0.3, maxSuffixPercentage: 0.2, diff --git a/core/util/paths.ts b/core/util/paths.ts index 836bc84b9..1198dec49 100644 --- a/core/util/paths.ts +++ b/core/util/paths.ts @@ -74,6 +74,10 @@ export function getGlobalContextFilePath(): string { return path.join(getIndexFolderPath(), "globalContext.json"); } +export function getSharedConfigFilePath(): string { + return path.join(getContinueGlobalPath(), "sharedConfig.json"); +} + export function getSessionFilePath(sessionId: string): string { return path.join(getSessionsFolderPath(), `${sessionId}.json`); } diff --git a/docs/docs/actions/how-to-customize.md b/docs/docs/actions/how-to-customize.md index 81d33967b..0541bf464 100644 --- a/docs/docs/actions/how-to-customize.md +++ b/docs/docs/actions/how-to-customize.md @@ -50,6 +50,7 @@ export function modifyConfig(config: Config): Config { return config; } ``` + @@ -57,4 +58,4 @@ export function modifyConfig(config: Config): Config { Currently the other action triggers are not open for configuration, but we plan to allow this via .prompt files in the future. - + diff --git a/docs/docs/customize/deep-dives/autocomplete.md b/docs/docs/customize/deep-dives/autocomplete.md index 13b86c51d..8d90f2145 100644 --- a/docs/docs/customize/deep-dives/autocomplete.md +++ b/docs/docs/customize/deep-dives/autocomplete.md @@ -60,7 +60,6 @@ This object allows you to customize the behavior of tab-autocomplete. The availa - `disable`: Disable autocomplete (can also be done from IDE settings) (default: `false`) - `template`: An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables. (String) -- `useFileSuffix`: Determines whether to use the file suffix in the prompt. (Boolean) (default: `true`) - `maxPromptTokens`: The maximum number of prompt tokens to use. A smaller number will yield faster completions, but less context. (Number) (default: `1024`) - `prefixPercentage`: The percentage of the input that should be dedicated to the prefix. (Number) (default: `0.3`) - `maxSuffixPercentage`: The maximum percentage of the prompt that can be dedicated to the suffix. (Number) (default: `0.2`) @@ -68,7 +67,6 @@ This object allows you to customize the behavior of tab-autocomplete. The availa - `multilineCompletions`: Whether to enable multiline completions ("always", "never", or "auto"). Defaults to "auto". (default: `auto`) - `useCache`: Whether to cache and reuse completions when the prompt is the same as a previous one. May be useful to disable for testing purposes. (default: `true`) - `disableInFiles`: A list of glob patterns for files in which you want to disable tab autocomplete. (default: `[]`) -- `onlyMyCode`: If `true`, only includes code within the repository (default: `true`). ### Full example diff --git a/docs/docs/customize/deep-dives/configuration.md b/docs/docs/customize/deep-dives/configuration.md index e2e2b91d1..05fac6842 100644 --- a/docs/docs/customize/deep-dives/configuration.md +++ b/docs/docs/customize/deep-dives/configuration.md @@ -10,7 +10,7 @@ Continue can be deeply customized. User-level configuration is stored and can be - `~/.continue/config.json` (MacOS / Linux) - `%USERPROFILE%\.continue\config.json` (Windows) -To open `config.json`, you can click the "gear" icon in the bottom right corner of the Continue Chat sidebar. When editing this file, you can see the available options suggested as you type, or check the reference below. +To open `config.json`, you can click the "gear" icon in the header of the Continue Chat sidebar to open the settings page, and then click `Open [your config location]` to open the file. When editing this file, you can see the available options suggested as you type, or check the reference below. When you save `config.json`, Continue will automatically refresh to take into account your changes. `config.json` is automatically created the first time you use Continue. `config.json` is automatically generated if it doesn't exist. diff --git a/docs/docs/customize/deep-dives/docs.md b/docs/docs/customize/deep-dives/docs.md index 31cd8b4b8..f06de9fe4 100644 --- a/docs/docs/customize/deep-dives/docs.md +++ b/docs/docs/customize/deep-dives/docs.md @@ -153,13 +153,7 @@ If your documentation is private, you can skip the default crawler and use a loc } ``` -The default local crawler is a lightweight tool that cannot render sites that are dynamically generated using JavaScript. If your sites need to be rendered, you can enable the experimental `useChromiumForDocsCrawling` feature in your `config.json`. This will download and install Chromium to `~/.continue/.utils`, and use it as the local crawler. - -```json title="config.json" -"experimental": { - "useChromiumForDocsCrawling": true -} -``` +The default local crawler is a lightweight tool that cannot render sites that are dynamically generated using JavaScript. If your sites need to be rendered, you can enable the experimental `Use Chromium for Docs Crawling` feature from your [User Settings Page](../settings.md) This will download and install Chromium to `~/.continue/.utils`, and use it as the local crawler. Further notes: @@ -232,7 +226,6 @@ The following configuration example includes: - A custom embeddings provider - A reranker model available, with reranking parameters customized - A Github token to enable Github crawling -- Chromium enabled as a backup for private documentation ```json title="config.json" { @@ -270,9 +263,8 @@ The following configuration example includes: "embeddingsProvider": { "provider": "lmstudio", "model": "nomic-ai/nomic-embed-text-v1.5-GGUF" - }, - "experimental": { - "useChromiumForDocsCrawling": true } } ``` + +This could also involve enabling Chromium as a backup for local documentation the [User Settings Page](../settings.md). diff --git a/docs/docs/customize/overview.md b/docs/docs/customize/overview.md index 83e479132..80c18846a 100644 --- a/docs/docs/customize/overview.md +++ b/docs/docs/customize/overview.md @@ -6,22 +6,22 @@ keywords: [customize, configure, config] Continue can be deeply customized. For example you might: -- **Change your Model Provider**. Continue allows you to choose your favorite or even add multiple model providers. This allows you to use different models for different tasks, or to try another model if you're not happy with the results from your current model. Continue supports all of the popular model providers, including OpenAI, Anthropic, Microsoft/Azure, Mistral, and more. You can even self host your own model provider if you'd like. Learn more about [model providers](/customize/model-providers). -- **Select different model providers for each Compose feature**. Different Continue features can use different model providers. We call these _model types_. For example, you can use a different model provider for chat than you do for autocomplete. Learn more about [model types](/customize/model-types) . -- **Add a Context Provider**. Context providers allow you to add information to your prompts, giving your LLM additional context to work with. Context providers allow you to reference snippets from your codebase, or lookup relevant documentation, or use a search engine to find information and much more. Learn more about [context providers](/customize/context-providers). -- **Create a Slash Command**. Slash commands allow you to easily add custom functionality to Continue. You can use a slash command that allows you to generate a shell command from natural language, or perhaps generate a commit message, or create your own custom command to do whatever you want. Learn more about [slash commands](/customize/slash-commands). -- **Call external tools and functions**. Unchain your LLM with the power of _Tools_. You can call any external tool or function from your prompts. Currently only available with Anthropic. Learn more about [Tools](/customize/tools). +- **Change your Model Provider**. Continue allows you to choose your favorite or even add multiple model providers. This allows you to use different models for different tasks, or to try another model if you're not happy with the results from your current model. Continue supports all of the popular model providers, including OpenAI, Anthropic, Microsoft/Azure, Mistral, and more. You can even self host your own model provider if you'd like. Learn more about [model providers](/customize/model-providers). +- **Select different model providers for each Compose feature**. Different Continue features can use different model providers. We call these _model types_. For example, you can use a different model provider for chat than you do for autocomplete. Learn more about [model types](/customize/model-types) . +- **Add a Context Provider**. Context providers allow you to add information to your prompts, giving your LLM additional context to work with. Context providers allow you to reference snippets from your codebase, or lookup relevant documentation, or use a search engine to find information and much more. Learn more about [context providers](/customize/context-providers). +- **Create a Slash Command**. Slash commands allow you to easily add custom functionality to Continue. You can use a slash command that allows you to generate a shell command from natural language, or perhaps generate a commit message, or create your own custom command to do whatever you want. Learn more about [slash commands](/customize/slash-commands). +- **Call external tools and functions**. Unchain your LLM with the power of _Tools_. You can call any external tool or function from your prompts. Currently only available with Anthropic. Learn more about [Tools](/customize/tools). Whatever you choose, you'll probably start by editing `config.json`. ## Editing config.json -Most custom configuration is done by editing `config.json`. This file is a JSON file that allows you to customize Continue to your liking. It is found at: +Most custom configuration is done by editing `config.json`. This file is a JSON file that allows you to customize Continue to your liking. It is found at: - MacOS and Linux: `~/.continue/config.json` - Windows: `%USERPROFILE%\.continue\config.json` -You can easily access `config.json` from the Continue Chat sidebar. Open the sidebar by pressing cmd/ctrl + L (VS Code) or cmd/ctrl + J (JetBrains) and click the "gear" icon in the bottom right corner. +You can easily access `config.json` from the Continue Chat sidebar. Open the sidebar by pressing cmd/ctrl + L (VS Code) or cmd/ctrl + J (JetBrains) and click the "gear" icon in header to open the Settings page. Then click the button labeled `Open [your config profile]`. ![configure-continue](/img/configure-continue.png) @@ -29,7 +29,7 @@ When editing this file, you can see the available options suggested as you type, :::info -`config.json` is created the first time you use Continue. If you'd like to reset your configuration to the default, you can delete this file and Continue will automatically recreate it with the default settings. +`config.json` is created the first time you use Continue. If you'd like to reset your configuration to the default, you can delete this file and Continue will automatically recreate it with the default settings. ::: diff --git a/docs/docs/customize/settings.md b/docs/docs/customize/settings.md new file mode 100644 index 000000000..0d917df6e --- /dev/null +++ b/docs/docs/customize/settings.md @@ -0,0 +1,34 @@ +--- +title: User Settings Page +description: Reference for Adjusting User-Specific Settings +keywords: [config, settings, configuration, customize, customization, sidebar] +--- + +# The User Settings Page + +The **User Settings page** can be accessed by clicking the gear icon in the header of the Continue sidebar. + +![slash-commands](/img/header-buttons.png) + +Which takes you to this page: + +![User Settings Page](/img/settings-page.png) + +Click the `Open Config File` button to open your configuration file. See the [Configuration Reference](../reference.md) for more information. + +Below that, the following settings which are not part of a configuration file are available: + +- `Wrap Codeblocks`: If on, enables text wrapping in code blocks. Off by default. +- `Display Raw Markdown`: If on, shows raw markdown in responses. Off by default. +- `Allow Anonymous Telemetry`: If on, allows Continue to send anonymous telemetry. **On** by default. +- `Disable Indexing`: Prevents indexing of the codebase, useful primarily for debugging purposes. Off by default. +- `Disable Session Titles`: Prevents generating summary titles for each chat session when turned on. Off by default +- `Response Text to Speech`: If on, reads LLM responses aloud with TTS. Off by default. +- `Show Chat Scrollbar`: If on, enables a scrollbar in the chat window. Off by default. +- `Use autocomplete cache`: If on, caches completions. +- `Use Chromium for Docs Crawling`: Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to ~/.continue/.utils. Off by default +- `Codeblock Actions Position`: Sets the position for the actions that show when hovering over codeblocks. Defaults to `top` +- `Multiline Autocompletions`: Controls multiline completions for autocomplete. Can be set to `always`, `never`, or `auto`. Defaults to `auto` +- `Font Size`: Specifies base font size for UI elements +- `Workspace prompts path`: Where to find Prompt Files in a workspace - replaces the default .continue/prompts +- `Disable autocomplete in files`: List of comma-separated glob pattern to disable autocomplete in matching files. E.g., "\_/.md, \*/.txt" diff --git a/docs/docs/customize/tutorials/running-continue-without-internet.md b/docs/docs/customize/tutorials/running-continue-without-internet.md index c945f8c43..277272767 100644 --- a/docs/docs/customize/tutorials/running-continue-without-internet.md +++ b/docs/docs/customize/tutorials/running-continue-without-internet.md @@ -7,6 +7,6 @@ keywords: [no internet, air-gapped, local model] Continue can be run even on an air-gapped computer if you use a local model. Only a few adjustments are required for this to work. 1. Download the latest .vsix file from the [Open VSX Registry](https://open-vsx.org/extension/Continue/continue) and [install it to VS Code](https://code.visualstudio.com/docs/editor/extension-marketplace#_install-from-a-vsix). -2. Open `~/.continue/config.json` and set `"allowAnonymousTelemetry": false`. This will stop Continue from attempting requests to PostHog for [anonymous telemetry](../../telemetry.md). +2. Open the [User Settings Page](../settings.md) and turn off "Allow Anonymous Telemetry". This will stop Continue from attempting requests to PostHog for [anonymous telemetry](../../telemetry.md). 3. Also in `config.json`, set the default model to a local model. You can available options [here](../model-providers/). 4. Restart VS Code to ensure that the changes to `config.json` take effect. diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 809d4d1c4..b492f47e9 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -83,16 +83,12 @@ Specifies options for tab autocompletion behavior. **Properties:** - `disable`: If `true`, disables tab autocomplete (default: `false`). -- `useFileSuffix`: If `true`, includes file suffix in the prompt (default: `true`). - `maxPromptTokens`: Maximum number of tokens for the prompt (default: `1024`). - `debounceDelay`: Delay (in ms) before triggering autocomplete (default: `350`). - `maxSuffixPercentage`: Maximum percentage of prompt for suffix (default: `0.2`). - `prefixPercentage`: Percentage of input for prefix (default: `0.3`). - `template`: Template string for autocomplete, using Mustache templating. You can use the `{{{ prefix }}}`, `{{{ suffix }}}`, `{{{ filename }}}`, `{{{ reponame }}}`, and `{{{ language }}}` variables. -- `multilineCompletions`: Controls multiline completions (`"always"`, `"never"`, or `"auto"`) (default: `auto`). -- `useCache`: If `true`, caches completions (default: `true`). - `onlyMyCode`: If `true`, only includes code within the repository (default: `true`). -- `disableInFiles`: Array of glob patterns for files where autocomplete is disabled (default: `[]`). Example @@ -341,42 +337,6 @@ Example } ``` -### `disableSessionTitles` - -Prevents generating summary titles for each chat session when set to `true`. - -Note that if the deprecated setting `ui.getChatTitles` is set to `false`, it will override this. - -### `ui` - -Customizable UI settings to control interface appearance and behavior. - -**Properties:** - -- `codeBlockToolbarPosition`: Sets the toolbar position within code blocks, either `top` (default) or `bottom`. -- `fontSize`: Specifies font size for UI elements. -- `displayRawMarkdown`: If `true`, shows raw markdown in responses. -- `showChatScrollbar`: If `true`, enables a scrollbar in the chat window. -- `codeWrap`: If `true`, enables text wrapping in code blocks. - -Example: - -```json title="config.json" -{ - "ui": { - "codeBlockToolbarPosition": "bottom", - "fontSize": 14, - "displayRawMarkdown": false, - "showChatScrollbar": false, - "codeWrap": false - } -} -``` - -### `allowAnonymousTelemetry` - -When `true`, anonymous usage data is collected using Posthog, to improve features. Default is `true`. - ### `userToken` An optional token that identifies the user, primarily for authenticated services. @@ -385,10 +345,6 @@ An optional token that identifies the user, primarily for authenticated services Defines a system message that appears before every response from the language model, providing guidance or context. -### `disableIndexing` - -Prevents indexing of the codebase, useful primarily for debugging purposes. - ### `experimental` Several experimental config parameters are available, as described below: @@ -400,8 +356,6 @@ Several experimental config parameters are available, as described below: - `inlineEdit`: Model title for inline edits. - `applyCodeBlock`: Model title for applying code blocks. - `repoMapFileSelection`: Model title for repo map selections. -- `readResponseTTS`: If `true`, reads LLM responses aloud with TTS. Default is `true`. -- `promptPath`: Change the path to custom prompt files from the default ".prompts" - `quickActions`: Array of custom quick actions - `title` (**required**): Display title for the quick action. - `prompt` (**required**): Prompt for quick action. @@ -411,7 +365,6 @@ Several experimental config parameters are available, as described below: - `docstring`: Prompt for adding docstrings. - `fix`: Prompt for fixing code. - `optimize`: Prompt for optimizing code. -- `useChromiumForDocsCrawling`: Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to `~/.continue/.utils`.. - `modelContextProtocolServers`: See [Model Context Protocol](/customize/context-providers#model-context-protocol) Example @@ -422,7 +375,6 @@ Example "modelRoles": { "inlineEdit": "Edit Model" }, - "promptPath": "custom/.prompts", "quickActions": [ { "title": "Tags", @@ -433,8 +385,6 @@ Example "contextMenuPrompts": { "fixGrammar": "Fix grammar in the above but allow for typos." }, - "readResponseTTS": false, - "useChromiumForDocsCrawling": true, "modelContextProtocolServers": [ { "transport": { @@ -447,3 +397,28 @@ Example } } ``` + +### Fully deprecated settings + +Some deprecated `config.json` settings are no longer stored in config and have been moved to be editable through the [User Settings Page](./customize/settings.md). If found in `config.json`, they will be migrated to the [User Settings Page](./customize/settings.md) and removed from `config.json`. + +- `allowAnonymousTelemetry`: This value will be migrated to the safest merged value (`false` if either are `false`). +- `promptPath`: This value will override during migration. +- `disableIndexing`: This value will be migrated to the safest merged value (`true` if either are `true`). +- `disableSessionTitles`/`ui.getChatTitles`: This value will be migrated to the safest merged value (`true` if either are `true`). `getChatTitles` takes precedence if set to false +- `tabAutocompleteOptions` + - `useCache`: This value will override during migration. + - `disableInFiles`: This value will be migrated to the safest merged value (arrays of file matches merged/deduplicated) + - `multilineCompletions`: This value will override during migration. +- `experimental` + - `useChromiumForDocsCrawling`: This value will override during migration. + - `readResponseTTS`: This value will override during migration. +- `ui` - all will override during migration + + - `codeBlockToolbarPosition` + - `fontSize` + - `codeWrap` + - `displayRawMarkdown` + - `showChatScrollbar` + + See [User Settings Page](./customize/settings.md) for more information about each option. diff --git a/docs/docs/telemetry.md b/docs/docs/telemetry.md index 8e7152d01..3d59ebf74 100644 --- a/docs/docs/telemetry.md +++ b/docs/docs/telemetry.md @@ -26,26 +26,6 @@ The following usage information is collected and reported: ## How to Opt Out -You can disable anonymous telemetry by modifying the `config.json` file located in the `~/.continue` directory. This file typically includes the following entry: +You can disable anonymous telemetry by visiting the [User Settings Page](./customize/settings.md) and toggling "Allow Anonymous Telemetry" off. -```json title="config.json" -{ - "allowAnonymousTelemetry": true -} -``` - -To opt out, change the value of `allowAnonymousTelemetry` to `false`. Alternatively, you can disable telemetry through your VS Code settings by unchecking the "Continue: Telemetry Enabled" box. - -### Steps to Disable Telemetry via Configuration File - -1. Open the `~/.continue/config.json` file in your text editor. -2. Locate the `"allowAnonymousTelemetry"` setting. -3. Change the value from `true` to `false`. -4. Save the file. - -### Steps to Disable Telemetry via VS Code Settings - -1. Open VS Code. -2. Navigate to `File` > `Preferences` > `Settings` (or use the keyboard shortcut ctrl + , on Windows/Linux or cmd + , on macOS). -3. In the search bar, type "Continue: Telemetry Enabled". -4. Uncheck the "Continue: Telemetry Enabled" checkbox. +Alternatively in VS Code, you can disable telemetry through your VS Code settings by unchecking the "Continue: Telemetry Enabled" box (this will override the Settings Page settings). diff --git a/docs/docs/yaml-migration.md b/docs/docs/yaml-migration.md index d0679c5ca..04f1b4e15 100644 --- a/docs/docs/yaml-migration.md +++ b/docs/docs/yaml-migration.md @@ -327,20 +327,27 @@ mcpServers: ## Deprecated configuration options -The following top-level fields from `config.json` have been deprecated. Most UI-related and user-specific options will move into a settings page in the UI +Some deprecated `config.json` settings are no longer stored in config and have been moved to be editable through the [User Settings Page](./customize/settings.md) (Gear Icon). If found in `config.json`, they will be migrated to the [User Settings Page](./customize/settings.md) and removed from `config.json`. + +See the [JSON Config Reference](./reference#fully-deprecated-settings) for more information on fully deprecated options. + +The following top-level fields from `config.json` still work when using `config.json` but have been deprecated and don't have a YAML equivalent: - Slash commands (JSON `slashCommands`) - top-level `requestOptions` - top-level `completionOptions` - `tabAutocompleteOptions` + - `disable` + - `maxPromptTokens` + - `debounceDelay` + - `maxSuffixPercentage` + - `prefixPercentage` + - `template` + - `onlyMyCode` - `analytics` - `customCommands` -- `disableSessionTitles` - `experimental` -- `allowAnonymousTelemetry` (automatically migrated to IDE settings) -- `ui` (moved to user/IDE level) - `userToken` -- `disableIndexing` (moved to user/IDE level) ## New Configuration options diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md index 15cb94c4d..985a66809 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md @@ -60,7 +60,6 @@ ollama run starcoder2:3b - `disable`: 禁用自动补全(也可以在 IDE 配置中完成) - `template`: 一个用来自动补全的可选的模板字符串。它使用 Mustache 模板语言渲染,并且传递 'prefix' 和 'suffix' 变量。(字符串) -- `useFileSuffix`: 决定是否使用文件后缀在提示词中。(布尔型) - `maxPromptTokens`: 提示词使用的 token 的最大数量。一个较小的数字生成较快的补全,但是较少的上下文。(数字) - `prefixPercentage`: 输入专注于前缀的百分比。(数字) - `maxSuffixPercentage`: The maximum percentage of the prompt that can be dedicated to the suffix. (Number) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md index 86a998b5b..98addf212 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md @@ -83,7 +83,6 @@ Specifies options for tab autocompletion behavior. **Properties:** - `disable`: If `true`, disables tab autocomplete (default: `false`). -- `useFileSuffix`: If `true`, includes file suffix in the prompt (default: `true`). - `maxPromptTokens`: Maximum number of tokens for the prompt (default: `1024`). - `debounceDelay`: Delay (in ms) before triggering autocomplete (default: `350`). - `maxSuffixPercentage`: Maximum percentage of prompt for suffix (default: `0.2`). diff --git a/docs/sidebars.js b/docs/sidebars.js index c5026b1ef..380377f8a 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -132,12 +132,13 @@ const sidebars = { }, ], }, - "customize/changelog", + "customize/settings", { type: "link", label: "Reference", href: "/reference", }, + "customize/changelog", // { // type: "link", // label: "YAML Reference", diff --git a/docs/static/img/header-buttons.png b/docs/static/img/header-buttons.png new file mode 100644 index 000000000..f6a644d03 Binary files /dev/null and b/docs/static/img/header-buttons.png differ diff --git a/docs/static/img/settings-page.png b/docs/static/img/settings-page.png new file mode 100644 index 000000000..f4b58cfd5 Binary files /dev/null and b/docs/static/img/settings-page.png differ diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt index 852fb4f02..b93d294e1 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt @@ -120,8 +120,9 @@ class ViewHistoryAction : AnAction() { class OpenConfigAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val continuePluginService = getContinuePluginService(e.project) ?: return - val params = mapOf("profileId" to null) - continuePluginService.coreMessenger?.request("config/openProfile", params, null) { _ -> } + continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus() + val params = mapOf("path" to "/config", "toggle" to true) + continuePluginService.sendToWebview("navigateTo", params) } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index 66910bced..2388ce8ab 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -80,6 +80,7 @@ class MessageTypes { "config/deleteModel", "config/listProfiles", "config/openProfile", + "config/updateSharedConfig", "context/getContextItems", "context/getSymbolsForFiles", "context/loadSubmenuItems", diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index bd6bbd5fb..efffc54ee 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -66,6 +66,10 @@ class IdeProtocolClient( try { when (messageType) { + "toggleDevTools" -> { + continuePluginService.continuePluginWindow?.browser?.browser?.openDevtools() + } + "showTutorial" -> { showTutorial(project) } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index d30a5d5fe..f871fc69e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -94,7 +94,6 @@ class IntelliJIDE( userToken = settings.continueState.userToken ?: "", enableControlServerBeta = settings.continueState.enableContinueTeamsBeta, pauseCodebaseIndexOnStart = false, // TODO: Needs to be implemented - enableDebugLogs = false // TODO: Needs to be implemented ) } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt index 1400e5c54..201b259de 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt @@ -88,7 +88,6 @@ data class IdeSettings( val userToken: String, val enableControlServerBeta: Boolean, val pauseCodebaseIndexOnStart: Boolean, - val enableDebugLogs: Boolean ) data class ContinueRcJson( diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index a5e16ecc5..5a43ff24f 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -132,12 +132,12 @@ - - + text="Continue Config" + description="Continue Config"> + - + diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 1273a7c40..2b12cf21e 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -3080,10 +3080,6 @@ "description": "Disable tab autocomplete. This can also be done from the IDE settings.", "default": false }, - "useFileSuffix": { - "type": "boolean", - "description": "Determines whether to use the file suffix in the prompt." - }, "maxPromptTokens": { "type": "number", "description": "The maximum number of prompt tokens to use. A smaller number will yield faster completions, but less context." diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 4927a0e4a..257b6a4d4 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.256", + "version": "0.9.258", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" @@ -96,16 +96,10 @@ "default": false, "markdownDescription": "Enable Continue for teams beta features. To sign in, click the person icon in the bottom right of the sidebar." }, - "continue.continueTestEnvironment": { - "type": "string", - "enum": [ - "none", - "production", - "test", - "local" - ], - "default": "none", - "description": "Continue test environment" + "continue.enableContinueHub": { + "type": "boolean", + "default": false, + "description": "Enable Continue Hub (internal)" }, "continue.showInlineTip": { "type": "boolean", @@ -224,7 +218,7 @@ "group": "Continue" }, { - "command": "continue.openConfig", + "command": "continue.openConfigPage", "category": "Continue", "title": "Open Continue Config", "icon": "$(gear)", @@ -533,19 +527,19 @@ "when": "view == continue.continueGUIView" }, { - "command": "continue.openConfig", + "command": "continue.openConfigPage", "group": "navigation@4", "when": "view == continue.continueGUIView" }, { "command": "continue.signInToControlPlane", "group": "navigation@5", - "when": "(view == continue.continueGUIView) && (config.continue.enableContinueForTeams || config.continue.continueTestEnvironment !== 'none') && !continue.isSignedInToControlPlane" + "when": "(view == continue.continueGUIView) && (config.continue.enableContinueForTeams || config.continue.enableContinueHub) && !continue.isSignedInToControlPlane" }, { "command": "continue.openAccountDialog", "group": "navigation@5", - "when": "(view == continue.continueGUIView) && (config.continue.enableContinueForTeams || config.continue.continueTestEnvironment !== 'none') && continue.isSignedInToControlPlane" + "when": "(view == continue.continueGUIView) && (config.continue.enableContinueForTeams || config.continue.enableContinueHub) && continue.isSignedInToControlPlane" }, { "command": "continue.openMorePage", diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index fbd2077a1..7f9f561f6 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -636,14 +636,13 @@ class VsCodeIde implements IDE { "enableContinueForTeams", false, ), - continueTestEnvironment: settings.get< - IdeSettings["continueTestEnvironment"] - >("continueTestEnvironment", "none"), + continueTestEnvironment: settings.get("enableContinueHub") + ? "production" + : "none", pauseCodebaseIndexOnStart: settings.get( "pauseCodebaseIndexOnStart", false, ), - enableDebugLogs: false, // settings.get( // "enableControlServerBeta", // false, diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index d8019cfe1..da5e7db94 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -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, diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index b49960919..be58bb375 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -1,6 +1,6 @@ import fs from "fs"; -import { IContextProvider, IdeSettings } from "core"; +import { IContextProvider } from "core"; import { ConfigHandler } from "core/config/ConfigHandler"; import { EXTENSION_NAME, getControlPlaneEnv } from "core/control-plane/env"; import { Core } from "core/core"; @@ -375,9 +375,9 @@ export class VsCodeExtension { void this.core.invoke("didChangeActiveTextEditor", { filepath }); }); - const originalValue = vscode.workspace + const enableContinueHub = vscode.workspace .getConfiguration(EXTENSION_NAME) - .get("continueTestEnvironment"); + .get("enableContinueHub"); vscode.workspace.onDidChangeConfiguration(async (event) => { if (event.affectsConfiguration(EXTENSION_NAME)) { const settings = this.ide.getIdeSettingsSync(); @@ -386,7 +386,11 @@ export class VsCodeExtension { settings, }); - if (settings.continueTestEnvironment !== originalValue) { + if ( + enableContinueHub + ? settings.continueTestEnvironment !== "production" + : settings.continueTestEnvironment === "production" + ) { await vscode.commands.executeCommand("workbench.action.reloadWindow"); } } diff --git a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts index a150d2cd8..de10f9c7d 100644 --- a/extensions/vscode/src/stubs/WorkOsAuthProvider.ts +++ b/extensions/vscode/src/stubs/WorkOsAuthProvider.ts @@ -20,17 +20,15 @@ import { workspace, } from "vscode"; -import { IdeSettings } from "core"; import { PromiseAdapter, promiseFromEvent } from "./promiseUtils"; import { SecretStorage } from "./SecretStorage"; const AUTH_NAME = "Continue"; const controlPlaneEnv = getControlPlaneEnvSync( - workspace - .getConfiguration(EXTENSION_NAME) - .get("continueTestEnvironment") ?? - "none", + workspace.getConfiguration(EXTENSION_NAME).get("enableContinueHub") + ? "production" + : "none", ); const SESSIONS_SECRET_KEY = `${controlPlaneEnv.AUTH_TYPE}.sessions`; diff --git a/gui/src/App.tsx b/gui/src/App.tsx index 18df91b86..73d667292 100644 --- a/gui/src/App.tsx +++ b/gui/src/App.tsx @@ -13,6 +13,7 @@ import MorePage from "./pages/More"; import Stats from "./pages/stats"; import { ROUTES } from "./util/navigation"; import { SubmenuContextProvidersProvider } from "./context/SubmenuContextProviders"; +import ConfigPage from "./pages/config"; const router = createMemoryRouter([ { @@ -52,6 +53,10 @@ const router = createMemoryRouter([ path: ROUTES.CONFIG_ERROR, element: , }, + { + path: ROUTES.CONFIG, + element: , + }, { path: "/migration", element: , diff --git a/gui/src/components/StepContainer/Reasoning.tsx b/gui/src/components/StepContainer/Reasoning.tsx new file mode 100644 index 000000000..d5537c82b --- /dev/null +++ b/gui/src/components/StepContainer/Reasoning.tsx @@ -0,0 +1,138 @@ +import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/solid"; +import { ChatHistoryItem } from "core"; +import { stripImages } from "core/util/messageContent"; +import { useEffect, useState } from "react"; +import styled from "styled-components"; +import { + defaultBorderRadius, + lightGray, + vscBackground, + vscQuickInputBackground, +} from ".."; +import { getFontSize } from "../../util"; +import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview"; + +interface ReasoningProps { + item: ChatHistoryItem; + index: number; + isLast: boolean; +} + +const SpoilerButton = styled.div` + margin: 8px 6px 16px 6px; + background-color: ${vscBackground}; + width: fit-content; + font-size: ${getFontSize() - 2}px; + border: 0.5px solid ${lightGray}; + border-radius: ${defaultBorderRadius}; + padding: 4px 8px; + color: ${lightGray}; + cursor: pointer; + box-shadow: + 0 4px 6px rgba(0, 0, 0, 0.1), + 0 1px 3px rgba(0, 0, 0, 0.08); + transition: box-shadow 0.3s ease; + + &:hover { + box-shadow: + 0 6px 8px rgba(0, 0, 0, 0.15), + 0 3px 6px rgba(0, 0, 0, 0.1); + } +`; + +const ButtonContent = styled.div` + display: flex; + align-items: center; + gap: 6px; +`; + +const ContentDiv = styled.div<{ fontSize?: number }>` + margin: 4px; + padding: 4px; + padding-bottom: 8px; + font-size: ${getFontSize()}px; + overflow: hidden; + border-left: 4px solid ${lightGray}; + border-radius: ${defaultBorderRadius}; + background-color: ${vscQuickInputBackground}; +`; + +const ThinkingText = styled.span` + position: relative; + padding-right: 12px; + + &:after { + content: "..."; + position: absolute; + animation: ellipsis 1s steps(4, end) infinite; + width: 0px; + display: inline-block; + overflow: hidden; + } + + @keyframes ellipsis { + 0%, + 100% { + width: 0px; + } + 33% { + width: 8px; + } + 66% { + width: 16px; + } + 90% { + width: 24px; + } + } +`; + +export default function Reasoning(props: ReasoningProps) { + const [open, setOpen] = useState(false); + const [reasoningTime, setReasoningTime] = useState(""); + const isThinking = !props.item.reasoning?.endAt; + + useEffect(() => { + if (!props.item.reasoning) return; + if (!props.item.reasoning?.endAt) return; + + const startAt = props.item.reasoning?.startAt || Date.now(); + const endAt = props.item.reasoning?.endAt || Date.now(); + const diff = endAt - startAt; + const diffString = `${(diff / 1000).toFixed(1)}s`; + setReasoningTime(diffString); + }, [props.item.reasoning?.startAt, props.item.reasoning?.endAt]); + + if (!props.item.reasoning?.text) { + return null; + } + + return ( + <> + setOpen(!open)}> + + {isThinking ? ( + Thinking + ) : ( + `Thought for ${reasoningTime}` + )} + {open ? ( + + ) : ( + + )} + + + {open && ( + + + + )} + + ); +} diff --git a/gui/src/components/StepContainer/StepContainer.tsx b/gui/src/components/StepContainer/StepContainer.tsx index 5709f7f60..b395db076 100644 --- a/gui/src/components/StepContainer/StepContainer.tsx +++ b/gui/src/components/StepContainer/StepContainer.tsx @@ -11,6 +11,7 @@ import { getFontSize } from "../../util"; import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview"; import ResponseActions from "./ResponseActions"; import ThinkingIndicator from "./ThinkingIndicator"; +import Reasoning from "./Reasoning"; interface StepContainerProps { item: ChatHistoryItem; @@ -90,11 +91,15 @@ export default function StepContainer(props: StepContainerProps) { {renderChatMessage(props.item.message)} ) : ( - + <> + + + + )} {props.isLast && } diff --git a/gui/src/components/gui/NumberInput.tsx b/gui/src/components/gui/NumberInput.tsx new file mode 100644 index 000000000..ce27c1cf8 --- /dev/null +++ b/gui/src/components/gui/NumberInput.tsx @@ -0,0 +1,61 @@ +import React from "react"; + +interface NumberInputProps { + value: number; + onChange: (value: number) => void; + max: number; + min: number; +} + +const NumberInput: React.FC = ({ + value, + onChange, + max, + min, +}) => { + const handleIncrement = () => { + if (value < max) { + onChange(value + 1); + } + }; + + const handleDecrement = () => { + if (value > min) { + onChange(value - 1); + } + }; + + return ( +
+ +
+ + +
+
+ ); +}; + +export default NumberInput; diff --git a/gui/src/components/gui/Select.tsx b/gui/src/components/gui/Select.tsx new file mode 100644 index 000000000..01ec79242 --- /dev/null +++ b/gui/src/components/gui/Select.tsx @@ -0,0 +1,48 @@ +// export const Select = styled.select` +// padding: 8px 12px; +// border-radius: ${defaultBorderRadius}; +// border: 1px solid ${vscInputBorder}; +// background-color: ${vscBackground}; +// color: ${vscForeground}; + +import { vscBackground, vscForeground, vscInputBorder } from ".."; + +// appearance: none; +// -webkit-appearance: none; +// -moz-appearance: none; +// padding-right: 30px; +// background: url('data:image/svg+xml;utf8,') +// no-repeat right 10px center; +// background-size: 10px 10px; +// `; + +// // gui/src/components/gui/Select.tsx +// import React from 'react'; + +export const Select: React.FC> = ( + props, +) => ( +
+ +
+); diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index 071900b51..8f1455c67 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -154,6 +154,13 @@ export const Button = styled.button` } `; +type NumberInputProps = { + value: number; + onChange: (value: number) => void; + max?: number; + min?: number; +}; + export const SecondaryButton = styled.button` padding: 10px 12px; margin: 8px 0; @@ -250,17 +257,6 @@ export const Input = styled.input` } `; -export const Select = styled.select` - padding: 8px 12px; - margin: 8px 0; - box-sizing: border-box; - border-radius: ${defaultBorderRadius}; - outline: 1px solid ${lightGray}; - border: none; - background-color: ${vscBackground}; - color: ${vscForeground}; -`; - export const Label = styled.label<{ fontSize?: number }>` font-size: ${(props) => props.fontSize || getFontSize()}px; `; diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 52d343fe4..931c8c045 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -34,6 +34,7 @@ import { remarkTables } from "./utils/remarkTables"; const StyledMarkdown = styled.div<{ fontSize?: number; whiteSpace: string; + bgColor: string; }>` pre { white-space: ${(props) => props.whiteSpace}; @@ -63,7 +64,7 @@ const StyledMarkdown = styled.div<{ color: #f78383; } - background-color: ${vscBackground}; + background-color: ${(props) => props.bgColor}; font-family: var(--vscode-font-family), system-ui, @@ -104,6 +105,7 @@ interface StyledMarkdownPreviewProps { isRenderingInStepContainer?: boolean; // Currently only used to control the rendering of codeblocks scrollLocked?: boolean; itemIndex?: number; + useParentBackgroundColor?: boolean; } const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-"; @@ -332,7 +334,11 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( const uiConfig = useAppSelector(selectUIConfig); const codeWrapState = uiConfig?.codeWrap ? "pre-wrap" : "pre"; return ( - + {reactContent} ); diff --git a/gui/src/components/modelSelection/ModelSettings.tsx b/gui/src/components/modelSelection/ModelSettings.tsx deleted file mode 100644 index 4198ffba1..000000000 --- a/gui/src/components/modelSelection/ModelSettings.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import { useState } from "react"; -import { useFormContext } from "react-hook-form"; -import styled from "styled-components"; -import { Input, Label, Select, defaultBorderRadius, lightGray } from ".."; -import { getFontSize } from "../../util"; - -const Div = styled.div<{ dashed: boolean }>` - border: 1px ${(props) => (props.dashed ? "dashed" : "solid")} ${lightGray}; - border-radius: ${defaultBorderRadius}; - padding: 8px; - margin-bottom: 16px; -`; - -type ModelOption = "apiKey" | "model" | "contextLength"; - -const DefaultModelOptions: { - [key: string]: { [key in ModelOption]?: string }; -} = { - OpenAI: { - apiKey: "", - model: "gpt-4", - }, - OpenAIFreeTrial: { - apiKey: "", - model: "gpt-4", - }, - Anthropic: { - apiKey: "", - model: "claude-2", - }, - default: { - apiKey: "", - model: "gpt-4", - }, -}; - -function ModelSettings(props: { llm: any | undefined; role: string }) { - const [modelOptions, setModelOptions] = useState<{ - [key in ModelOption]?: string; - }>(DefaultModelOptions[props.llm?.class_name || "default"]); - - const { register, setValue, getValues } = useFormContext(); - - return ( -
- {props.llm ? ( - <> - {props.role}: {props.llm?.class_name || "gpt-4"} -
- {typeof modelOptions.apiKey !== undefined && ( - <> - - - - )} - {modelOptions.model && ( - <> - - - - )} -
- - ) : ( -
- Add Model -
- -
-
- )} -
- ); -} - -export default ModelSettings; diff --git a/gui/src/index.css b/gui/src/index.css index 4a2270c95..d5eac52eb 100644 --- a/gui/src/index.css +++ b/gui/src/index.css @@ -77,6 +77,7 @@ body { word-break: break-word; overflow: hidden; line-height: 1.375; + text-overflow: ellipsis; } .lines-3 { diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 33ba33f59..2ece67b85 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -362,9 +362,26 @@ export const sessionSlice = createSlice({ } else { // Add to the existing message if (message.content) { - // Note this only works because new message above - // was already rendered from parts to string - lastMessage.content += renderChatMessage(message); + const messageContent = renderChatMessage(message); + if (messageContent.includes("")) { + lastItem.reasoning = { + startAt: Date.now(), + active: true, + text: messageContent.replace("", "").trim(), + } + } else if (lastItem.reasoning?.active && messageContent.includes("")) { + const [reasoningEnd, answerStart] = messageContent.split(""); + lastItem.reasoning.text += reasoningEnd.trimEnd(); + lastItem.reasoning.active = false; + lastItem.reasoning.endAt = Date.now(); + lastMessage.content += answerStart.trimStart(); + } else if (lastItem.reasoning?.active) { + lastItem.reasoning.text += messageContent; + } else { + // Note this only works because new message above + // was already rendered from parts to string + lastMessage.content += messageContent; + } } else if ( message.role === "assistant" && message.toolCalls?.[0] && diff --git a/gui/src/util/navigation.ts b/gui/src/util/navigation.ts index 2416226d8..eed39333d 100644 --- a/gui/src/util/navigation.ts +++ b/gui/src/util/navigation.ts @@ -2,6 +2,7 @@ export const ROUTES = { HOME: "/", CONFIG_ERROR: "/config-error", + CONFIG: "/config", MORE: "/more", // EXAMPLE_ROUTE_WITH_PARAMS: (params: ParamsType) => `/route/${params}`, }; diff --git a/packages/config-types/src/index.ts b/packages/config-types/src/index.ts index 5ba03b8cc..8a0806d7b 100644 --- a/packages/config-types/src/index.ts +++ b/packages/config-types/src/index.ts @@ -133,7 +133,6 @@ export type UiOptions = z.infer; export const tabAutocompleteOptionsSchema = z.object({ disable: z.boolean(), - useFileSuffix: z.boolean(), maxPromptTokens: z.number(), debounceDelay: z.number(), maxSuffixPercentage: z.number(),