Merge branch 'main' into autocomplete_context_fix
This commit is contained in:
commit
8faebaeffb
69 changed files with 1211 additions and 904 deletions
62
.github/workflows/pr_checks.yaml
vendored
62
.github/workflows/pr_checks.yaml
vendored
|
|
@ -1,7 +1,7 @@
|
|||
name: PR checks
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
|
|
@ -22,21 +22,10 @@ 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:
|
||||
|
|
@ -57,9 +46,6 @@ 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:
|
||||
|
|
@ -86,12 +72,8 @@ 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:
|
||||
|
|
@ -122,9 +104,6 @@ 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:
|
||||
|
|
@ -157,9 +136,6 @@ 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:
|
||||
|
|
@ -191,9 +167,6 @@ 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:
|
||||
|
|
@ -231,9 +204,6 @@ 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:
|
||||
|
|
@ -268,9 +238,6 @@ 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:
|
||||
|
|
@ -303,9 +270,6 @@ 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:
|
||||
|
|
@ -321,6 +285,7 @@ jobs:
|
|||
cd core
|
||||
npm test
|
||||
env:
|
||||
IGNORE_API_KEY_TESTS: ${{ github.event.pull_request.head.repo.fork }}
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
|
|
@ -333,9 +298,6 @@ jobs:
|
|||
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
|
||||
|
|
@ -363,9 +325,6 @@ jobs:
|
|||
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:
|
||||
|
|
@ -399,9 +358,6 @@ jobs:
|
|||
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:
|
||||
|
|
@ -443,7 +399,6 @@ jobs:
|
|||
]
|
||||
runs-on: ubuntu-latest
|
||||
# Tests requiring secrets need approval from maintainers
|
||||
environment: tests-requiring-secrets
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
|
@ -451,9 +406,6 @@ jobs:
|
|||
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:
|
||||
|
|
@ -492,6 +444,7 @@ jobs:
|
|||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts
|
||||
echo -e "Host ssh-test-container\n\tHostName $SSH_HOST\n\tUser ec2-user\n\tIdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
|
||||
if: ${{ github.event.pull_request.head.repo.fork == false }}
|
||||
|
||||
- name: Set up Xvfb
|
||||
run: |
|
||||
|
|
@ -501,7 +454,7 @@ jobs:
|
|||
- name: Run e2e tests
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
TEST_FILE="${{ matrix.test_file }}" npm run ${{ matrix.command }}
|
||||
IGNORE_SSH_TESTS="${{ github.event.pull_request.head.repo.fork }}" TEST_FILE="${{ matrix.test_file }}" npm run ${{ matrix.command }}
|
||||
env:
|
||||
DISPLAY: :99
|
||||
|
||||
|
|
@ -517,9 +470,6 @@ 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:
|
||||
|
|
@ -552,10 +502,6 @@ 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/cache@v4
|
||||
with:
|
||||
path: core/node_modules
|
||||
|
|
|
|||
16
SECURITY.md
Normal file
16
SECURITY.md
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Security Policy
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you discover a security vulnerability, please do not open a public issue. Instead, please report it by emailing security@continue.dev. We will be highly responsive to all security concerns and ask that you give us sufficient time to investigate and address the vulnerability before disclosing it publicly.
|
||||
|
||||
Please include the following details in your report:
|
||||
|
||||
- A description of the vulnerability
|
||||
- Steps to reproduce the issue
|
||||
- Your assessment of the potential impact
|
||||
- Any possible mitigations
|
||||
|
||||
## Contact
|
||||
|
||||
For any other questions or concerns related to security, please contact us at security@continue.dev.
|
||||
2
binary/package-lock.json
generated
2
binary/package-lock.json
generated
|
|
@ -48,7 +48,7 @@
|
|||
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
|
||||
"@aws-sdk/credential-providers": "^3.620.1",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "^1.0.16",
|
||||
"@continuedev/config-yaml": "^1.0.23",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ export class CompletionProvider {
|
|||
completionOptions,
|
||||
cacheHit,
|
||||
filepath: helper.filepath,
|
||||
numLines: completion.split("\n").length,
|
||||
completionId: helper.input.completionId,
|
||||
gitRepo: await this.ide.getRepoName(helper.filepath),
|
||||
uniqueId: await this.ide.getUniqueId(),
|
||||
|
|
|
|||
|
|
@ -1,10 +1,4 @@
|
|||
import {
|
||||
Position,
|
||||
Range,
|
||||
RangeInFile,
|
||||
RangeInFileWithContents,
|
||||
TabAutocompleteOptions,
|
||||
} from "../..";
|
||||
import { Position, Range, RangeInFile, TabAutocompleteOptions } from "../..";
|
||||
import { AutocompleteCodeSnippet } from "../snippets/types";
|
||||
|
||||
export type RecentlyEditedRange = RangeInFile & {
|
||||
|
|
@ -42,6 +36,7 @@ export interface AutocompleteOutcome extends TabAutocompleteOptions {
|
|||
modelName: string;
|
||||
completionOptions: any;
|
||||
cacheHit: boolean;
|
||||
numLines: number;
|
||||
filepath: string;
|
||||
gitRepo?: string;
|
||||
completionId: string;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
import * as fs from "node:fs";
|
||||
|
||||
import {
|
||||
AssistantUnrolled,
|
||||
ConfigResult,
|
||||
FullSlug,
|
||||
} from "@continuedev/config-yaml";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import {
|
||||
ControlPlaneClient,
|
||||
ControlPlaneSessionInfo,
|
||||
} from "../control-plane/client.js";
|
||||
import { getControlPlaneEnv, useHub } from "../control-plane/env.js";
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContinueConfig,
|
||||
|
|
@ -15,15 +23,8 @@ import {
|
|||
import Ollama from "../llm/llms/Ollama.js";
|
||||
import { GlobalContext } from "../util/GlobalContext.js";
|
||||
import { getConfigJsonPath, getConfigYamlPath } from "../util/paths.js";
|
||||
|
||||
import {
|
||||
AssistantUnrolled,
|
||||
ConfigResult,
|
||||
FullSlug,
|
||||
} from "@continuedev/config-yaml";
|
||||
import * as YAML from "yaml";
|
||||
import { getControlPlaneEnv, useHub } from "../control-plane/env.js";
|
||||
import { localPathToUri } from "../util/pathToUri.js";
|
||||
|
||||
import {
|
||||
LOCAL_ONBOARDING_CHAT_MODEL,
|
||||
ONBOARDING_LOCAL_MODEL_TITLE,
|
||||
|
|
@ -135,6 +136,7 @@ export class ConfigHandler {
|
|||
{ ...assistant.configResult, config: renderedConfig },
|
||||
assistant.ownerSlug,
|
||||
assistant.packageSlug,
|
||||
assistant.iconUrl,
|
||||
assistant.configResult.config?.version ?? "latest",
|
||||
this.controlPlaneClient,
|
||||
this.ide,
|
||||
|
|
@ -336,11 +338,11 @@ export class ConfigHandler {
|
|||
this.updateListeners.push(listener);
|
||||
}
|
||||
|
||||
async reloadConfig() {
|
||||
async reloadConfig(additionalContextProviders: IContextProvider[] = []) {
|
||||
// TODO: this isn't right, there are two different senses in which you want to "reload"
|
||||
|
||||
const { config, errors, configLoadInterrupted } =
|
||||
await this.currentProfile.reloadConfig();
|
||||
await this.currentProfile.reloadConfig(additionalContextProviders);
|
||||
|
||||
if (config) {
|
||||
this.inactiveProfiles.forEach((profile) => profile.clearConfig());
|
||||
|
|
@ -390,6 +392,6 @@ export class ConfigHandler {
|
|||
|
||||
registerCustomContextProvider(contextProvider: IContextProvider) {
|
||||
this.additionalContextProviders.push(contextProvider);
|
||||
void this.reloadConfig();
|
||||
void this.reloadConfig(this.additionalContextProviders);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {
|
|||
ConfigValidationError,
|
||||
FullSlug,
|
||||
} from "@continuedev/config-yaml";
|
||||
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
ContinueConfig,
|
||||
|
|
@ -18,9 +19,16 @@ export interface ProfileDescription {
|
|||
profileType: "control-plane" | "local" | "platform";
|
||||
title: string;
|
||||
id: string;
|
||||
iconUrl: string;
|
||||
errors: ConfigValidationError[] | undefined;
|
||||
}
|
||||
|
||||
export interface OrganizationDescription {
|
||||
id: string;
|
||||
iconUrl: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export class ProfileLifecycleManager {
|
||||
private savedConfigResult: ConfigResult<ContinueConfig> | undefined;
|
||||
private savedBrowserConfigResult?: ConfigResult<BrowserSerializedContinueConfig>;
|
||||
|
|
@ -42,12 +50,12 @@ export class ProfileLifecycleManager {
|
|||
}
|
||||
|
||||
// Clear saved config and reload
|
||||
async reloadConfig(): Promise<ConfigResult<ContinueConfig>> {
|
||||
async reloadConfig(additionalContextProviders: IContextProvider[] = []): Promise<ConfigResult<ContinueConfig>> {
|
||||
this.savedConfigResult = undefined;
|
||||
this.savedBrowserConfigResult = undefined;
|
||||
this.pendingConfigPromise = undefined;
|
||||
|
||||
return this.loadConfig([], true);
|
||||
return this.loadConfig(additionalContextProviders, true);
|
||||
}
|
||||
|
||||
async loadConfig(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { ConfigJson } from "@continuedev/config-types";
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import {
|
||||
|
|
@ -7,9 +8,8 @@ import {
|
|||
IdeSettings,
|
||||
SerializedContinueConfig,
|
||||
} from "../../index.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
|
|
@ -32,6 +32,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
|
|||
this.description = {
|
||||
id: workspaceId,
|
||||
profileType: "control-plane",
|
||||
iconUrl: "",
|
||||
fullSlug: {
|
||||
ownerSlug: "",
|
||||
packageSlug: "",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
|
||||
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ export default class LocalProfileLoader implements IProfileLoader {
|
|||
packageSlug: "",
|
||||
versionSlug: "",
|
||||
},
|
||||
iconUrl: "",
|
||||
title: "Local Config",
|
||||
errors: undefined,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { AssistantUnrolled } from "@continuedev/config-yaml/dist/schemas/index.js";
|
||||
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
|
|
@ -27,6 +27,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
private configResult: ConfigResult<AssistantUnrolled>,
|
||||
private readonly ownerSlug: string,
|
||||
private readonly packageSlug: string,
|
||||
private readonly iconUrl: string,
|
||||
versionSlug: string,
|
||||
private readonly controlPlaneClient: ControlPlaneClient,
|
||||
private readonly ide: IDE,
|
||||
|
|
@ -44,6 +45,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
},
|
||||
title: `${ownerSlug}/${packageSlug}@${versionSlug}`,
|
||||
errors: configResult.errors,
|
||||
iconUrl: this.iconUrl,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,12 +124,14 @@ export default async function doLoadConfig(
|
|||
|
||||
if (newConfig.analytics) {
|
||||
await TeamAnalytics.setup(
|
||||
newConfig.analytics as any, // TODO: Need to get rid of index.d.ts once and for all
|
||||
newConfig.analytics,
|
||||
uniqueId,
|
||||
ideInfo.extensionVersion,
|
||||
controlPlaneClient,
|
||||
controlPlaneProxyInfo,
|
||||
);
|
||||
} else {
|
||||
await TeamAnalytics.shutdown();
|
||||
}
|
||||
|
||||
newConfig = await injectControlPlaneProxyInfo(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import os from "node:os";
|
||||
|
||||
import { Analytics } from "@continuedev/config-types";
|
||||
|
||||
import ContinueProxyAnalyticsProvider from "./analytics/ContinueProxyAnalyticsProvider.js";
|
||||
import {
|
||||
ControlPlaneProxyInfo,
|
||||
|
|
@ -10,9 +8,10 @@ import {
|
|||
import LogStashAnalyticsProvider from "./analytics/LogStashAnalyticsProvider.js";
|
||||
import PostHogAnalyticsProvider from "./analytics/PostHogAnalyticsProvider.js";
|
||||
import { ControlPlaneClient } from "./client.js";
|
||||
import { AnalyticsConfig } from "../index.js";
|
||||
|
||||
function createAnalyticsProvider(
|
||||
config: Analytics,
|
||||
config: AnalyticsConfig,
|
||||
): IAnalyticsProvider | undefined {
|
||||
// @ts-ignore
|
||||
switch (config.provider) {
|
||||
|
|
@ -42,7 +41,7 @@ export class TeamAnalytics {
|
|||
}
|
||||
|
||||
static async setup(
|
||||
config: Analytics,
|
||||
config: AnalyticsConfig,
|
||||
uniqueId: string,
|
||||
extensionVersion: string,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
|
|
@ -52,22 +51,27 @@ export class TeamAnalytics {
|
|||
TeamAnalytics.os = os.platform();
|
||||
TeamAnalytics.extensionVersion = extensionVersion;
|
||||
|
||||
if (!config) {
|
||||
await TeamAnalytics.provider?.shutdown();
|
||||
TeamAnalytics.provider = undefined;
|
||||
} else {
|
||||
TeamAnalytics.provider = createAnalyticsProvider(config);
|
||||
await TeamAnalytics.provider?.setup(
|
||||
config,
|
||||
uniqueId,
|
||||
controlPlaneProxyInfo,
|
||||
);
|
||||
TeamAnalytics.provider = createAnalyticsProvider(config);
|
||||
await TeamAnalytics.provider?.setup(
|
||||
config,
|
||||
uniqueId,
|
||||
controlPlaneProxyInfo,
|
||||
);
|
||||
|
||||
if (config.provider === "continue-proxy") {
|
||||
(
|
||||
TeamAnalytics.provider as ContinueProxyAnalyticsProvider
|
||||
).controlPlaneClient = controlPlaneClient;
|
||||
}
|
||||
if (config.provider === "continue-proxy") {
|
||||
(
|
||||
TeamAnalytics.provider as ContinueProxyAnalyticsProvider
|
||||
).controlPlaneClient = controlPlaneClient;
|
||||
}
|
||||
}
|
||||
|
||||
static async shutdown() {
|
||||
if (TeamAnalytics.provider) {
|
||||
await TeamAnalytics.provider.shutdown();
|
||||
TeamAnalytics.provider = undefined;
|
||||
TeamAnalytics.os = undefined;
|
||||
TeamAnalytics.extensionVersion = undefined;
|
||||
TeamAnalytics.uniqueId = "NOT_UNIQUE";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Analytics } from "@continuedev/config-types";
|
||||
import { AnalyticsConfig } from "../..";
|
||||
|
||||
export interface AnalyticsMetadata {
|
||||
extensionVersion: string;
|
||||
|
|
@ -13,7 +13,7 @@ export interface ControlPlaneProxyInfo {
|
|||
export interface IAnalyticsProvider {
|
||||
capture(event: string, properties: { [key: string]: any }): Promise<void>;
|
||||
setup(
|
||||
config: Analytics,
|
||||
config: AnalyticsConfig,
|
||||
uniqueId: string,
|
||||
controlPlaneProxyInfo?: ControlPlaneProxyInfo,
|
||||
): Promise<void>;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
import { ConfigJson } from "@continuedev/config-types";
|
||||
import fetch, { RequestInit, Response } from "node-fetch";
|
||||
|
||||
import { IdeSettings, ModelDescription } from "../index.js";
|
||||
|
||||
import {
|
||||
AssistantUnrolled,
|
||||
ConfigResult,
|
||||
|
|
@ -10,6 +6,11 @@ import {
|
|||
FullSlug,
|
||||
SecretResult,
|
||||
} from "@continuedev/config-yaml";
|
||||
import fetch, { RequestInit, Response } from "node-fetch";
|
||||
|
||||
import { OrganizationDescription } from "../config/ProfileLifecycleManager.js";
|
||||
import { IdeSettings, ModelDescription } from "../index.js";
|
||||
|
||||
import { getControlPlaneEnv } from "./env.js";
|
||||
|
||||
export interface ControlPlaneSessionInfo {
|
||||
|
|
@ -32,10 +33,6 @@ export const TRIAL_PROXY_URL =
|
|||
"https://proxy-server-blue-l6vsfbzhba-uw.a.run.app";
|
||||
|
||||
export class ControlPlaneClient {
|
||||
private static ACCESS_TOKEN_VALID_FOR_MS = 1000 * 60 * 5; // 5 minutes
|
||||
|
||||
private lastAccessTokenRefresh = 0;
|
||||
|
||||
constructor(
|
||||
private readonly sessionInfoPromise: Promise<
|
||||
ControlPlaneSessionInfo | undefined
|
||||
|
|
@ -107,7 +104,7 @@ export class ControlPlaneClient {
|
|||
}
|
||||
}
|
||||
|
||||
public async listAssistants(): Promise<
|
||||
public async listAssistants(organizationId?: string): Promise<
|
||||
{
|
||||
configResult: ConfigResult<AssistantUnrolled>;
|
||||
ownerSlug: string;
|
||||
|
|
@ -121,7 +118,11 @@ export class ControlPlaneClient {
|
|||
}
|
||||
|
||||
try {
|
||||
const resp = await this.request("ide/list-assistants", {
|
||||
const url = organizationId
|
||||
? `ide/list-assistants?organizationId=${organizationId}`
|
||||
: "ide/list-assistants";
|
||||
|
||||
const resp = await this.request(url, {
|
||||
method: "GET",
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
|
|
@ -130,6 +131,31 @@ export class ControlPlaneClient {
|
|||
}
|
||||
}
|
||||
|
||||
public async listOrganizations(): Promise<Array<OrganizationDescription>> {
|
||||
return [
|
||||
{
|
||||
id: "1",
|
||||
iconUrl:
|
||||
"https://cdn.prod.website-files.com/663e06c56841363663ffbbcf/663e1b9fb023f0b622ad3608_log-text.svg",
|
||||
name: "Continue",
|
||||
},
|
||||
];
|
||||
// const userId = await this.userId;
|
||||
// if (!userId) {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// try {
|
||||
// const resp = await this.request("ide/list-organizations", {
|
||||
// method: "GET",
|
||||
// });
|
||||
// const { organizations } = (await resp.json()) as any;
|
||||
// return organizations;
|
||||
// } catch (e) {
|
||||
// return [];
|
||||
// }
|
||||
}
|
||||
|
||||
public async listAssistantFullSlugs(): Promise<FullSlug[] | null> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import { recentlyEditedFilesCache } from "./context/retrieval/recentlyEditedFile
|
|||
import { ContinueServerClient } from "./continueServer/stubs/client";
|
||||
import { getAuthUrlForTokenPage } from "./control-plane/auth/index";
|
||||
import { ControlPlaneClient } from "./control-plane/client";
|
||||
import { getControlPlaneEnv } from "./control-plane/env";
|
||||
import { streamDiffLines } from "./edit/streamDiffLines";
|
||||
import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer";
|
||||
import DocsService from "./indexing/docs/DocsService";
|
||||
|
|
@ -52,7 +53,6 @@ import {
|
|||
type IndexingProgressUpdate,
|
||||
} from ".";
|
||||
|
||||
import { getControlPlaneEnv } from "./control-plane/env";
|
||||
import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
|
||||
import type { IMessenger, Message } from "./protocol/messenger";
|
||||
|
||||
|
|
@ -289,6 +289,7 @@ export class Core {
|
|||
on("config/ideSettingsUpdate", (msg) => {
|
||||
this.configHandler.updateIdeSettings(msg.data);
|
||||
});
|
||||
|
||||
on("config/listProfiles", (msg) => {
|
||||
return this.configHandler.listProfiles();
|
||||
});
|
||||
|
|
@ -307,6 +308,10 @@ export class Core {
|
|||
await this.messenger.request("openUrl", `${env.APP_URL}${msg.data.path}`);
|
||||
});
|
||||
|
||||
on("controlPlane/listOrganizations", async (msg) => {
|
||||
return await this.controlPlaneClient.listOrganizations();
|
||||
});
|
||||
|
||||
// Context providers
|
||||
on("context/addDocs", async (msg) => {
|
||||
void this.docsService.indexAndAdd(msg.data);
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -1110,7 +1110,7 @@ export interface ExperimentalConfig {
|
|||
}
|
||||
|
||||
export interface AnalyticsConfig {
|
||||
type: string;
|
||||
provider: string;
|
||||
url?: string;
|
||||
clientKey?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export class DefaultCrawler {
|
|||
});
|
||||
if (!resp.ok) {
|
||||
const text = await resp.text();
|
||||
throw new Error(`Failed to crawl site: ${text}`);
|
||||
throw new Error(`Failed to crawl site (${resp.status}): ${text}`);
|
||||
}
|
||||
const json = (await resp.json()) as PageData[];
|
||||
return json;
|
||||
|
|
|
|||
|
|
@ -152,11 +152,15 @@ describe("DocsCrawler", () => {
|
|||
);
|
||||
|
||||
commonDocsSites.forEach((url) => {
|
||||
test(`Default crawler common site: ${url}`, async () => {
|
||||
const { pages, crawler } = await runCrawl(url);
|
||||
expect(pages.length).toBeGreaterThanOrEqual(1);
|
||||
expect(crawler).toEqual("default");
|
||||
});
|
||||
test(
|
||||
`Default crawler common site: ${url}`,
|
||||
async () => {
|
||||
const { pages, crawler } = await runCrawl(url);
|
||||
expect(pages.length).toBeGreaterThanOrEqual(1);
|
||||
expect(crawler).toEqual("default");
|
||||
},
|
||||
TIMEOUT_MS,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,13 @@ function testLLM(
|
|||
skip,
|
||||
testFim,
|
||||
testToolCall,
|
||||
}: { skip?: boolean; testFim?: boolean; testToolCall?: boolean },
|
||||
timeout,
|
||||
}: {
|
||||
skip?: boolean;
|
||||
testFim?: boolean;
|
||||
testToolCall?: boolean;
|
||||
timeout?: number;
|
||||
},
|
||||
) {
|
||||
if (skip) {
|
||||
return;
|
||||
|
|
@ -37,45 +43,29 @@ function testLLM(
|
|||
});
|
||||
|
||||
describe(llm.providerName + "/" + llm.model, () => {
|
||||
test("Stream Chat works", async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamChat(
|
||||
[{ role: "user", content: "Hi" }],
|
||||
new AbortController().signal,
|
||||
)) {
|
||||
total += chunk.content;
|
||||
}
|
||||
|
||||
expect(total.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
|
||||
test("Stream Complete works", async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamComplete(
|
||||
"Hi",
|
||||
new AbortController().signal,
|
||||
)) {
|
||||
total += chunk;
|
||||
}
|
||||
|
||||
expect(total.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
|
||||
test("Complete works", async () => {
|
||||
const completion = await llm.complete("Hi", new AbortController().signal);
|
||||
|
||||
expect(completion.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
|
||||
if (testFim) {
|
||||
test("FIM works", async () => {
|
||||
test(
|
||||
"Stream Chat works",
|
||||
async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamFim(
|
||||
for await (const chunk of llm.streamChat(
|
||||
[{ role: "user", content: "Hi" }],
|
||||
new AbortController().signal,
|
||||
)) {
|
||||
total += chunk.content;
|
||||
}
|
||||
|
||||
expect(total.length).toBeGreaterThan(0);
|
||||
return;
|
||||
},
|
||||
timeout,
|
||||
);
|
||||
|
||||
test(
|
||||
"Stream Complete works",
|
||||
async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamComplete(
|
||||
"Hi",
|
||||
"name is ChatGPT.",
|
||||
new AbortController().signal,
|
||||
)) {
|
||||
total += chunk;
|
||||
|
|
@ -83,72 +73,120 @@ function testLLM(
|
|||
|
||||
expect(total.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
},
|
||||
timeout,
|
||||
);
|
||||
|
||||
test(
|
||||
"Complete works",
|
||||
async () => {
|
||||
const completion = await llm.complete(
|
||||
"Hi",
|
||||
new AbortController().signal,
|
||||
);
|
||||
|
||||
expect(completion.length).toBeGreaterThan(0);
|
||||
return;
|
||||
},
|
||||
timeout,
|
||||
);
|
||||
|
||||
if (testFim) {
|
||||
test(
|
||||
"FIM works",
|
||||
async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamFim(
|
||||
"Hi",
|
||||
"name is ChatGPT.",
|
||||
new AbortController().signal,
|
||||
)) {
|
||||
total += chunk;
|
||||
}
|
||||
|
||||
expect(total.length).toBeGreaterThan(0);
|
||||
return;
|
||||
},
|
||||
timeout,
|
||||
);
|
||||
}
|
||||
|
||||
if (testToolCall) {
|
||||
test("Tool Call works", async () => {
|
||||
let args = "";
|
||||
let isFirstChunk = true;
|
||||
for await (const chunk of llm.streamChat(
|
||||
[{ role: "user", content: "Hi, my name is Nate." }],
|
||||
new AbortController().signal,
|
||||
{
|
||||
tools: [
|
||||
{
|
||||
displayTitle: "Say Hello",
|
||||
function: {
|
||||
name: "say_hello",
|
||||
description: "Say Hello",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
description: "The name of the person to greet",
|
||||
test(
|
||||
"Tool Call works",
|
||||
async () => {
|
||||
let args = "";
|
||||
let isFirstChunk = true;
|
||||
for await (const chunk of llm.streamChat(
|
||||
[{ role: "user", content: "Hi, my name is Nate." }],
|
||||
new AbortController().signal,
|
||||
{
|
||||
tools: [
|
||||
{
|
||||
displayTitle: "Say Hello",
|
||||
function: {
|
||||
name: "say_hello",
|
||||
description: "Say Hello",
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
description: "The name of the person to greet",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
type: "function",
|
||||
wouldLikeTo: "Say hello",
|
||||
readonly: true,
|
||||
},
|
||||
],
|
||||
toolChoice: {
|
||||
type: "function",
|
||||
wouldLikeTo: "Say hello",
|
||||
readonly: true,
|
||||
},
|
||||
],
|
||||
toolChoice: {
|
||||
type: "function",
|
||||
function: {
|
||||
name: "say_hello",
|
||||
function: {
|
||||
name: "say_hello",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
)) {
|
||||
const typedChunk = chunk as AssistantChatMessage;
|
||||
if (!typedChunk.toolCalls) {
|
||||
continue;
|
||||
)) {
|
||||
const typedChunk = chunk as AssistantChatMessage;
|
||||
if (!typedChunk.toolCalls) {
|
||||
continue;
|
||||
}
|
||||
const toolCall = typedChunk.toolCalls[0];
|
||||
args += toolCall.function?.arguments ?? "";
|
||||
|
||||
expect(chunk.role).toBe("assistant");
|
||||
expect(chunk.content).toBe("");
|
||||
expect(typedChunk.toolCalls).toHaveLength(1);
|
||||
|
||||
if (isFirstChunk) {
|
||||
isFirstChunk = false;
|
||||
expect(toolCall.id).toBeDefined();
|
||||
expect(toolCall.function!.name).toBe("say_hello");
|
||||
}
|
||||
}
|
||||
const toolCall = typedChunk.toolCalls[0];
|
||||
args += toolCall.function?.arguments ?? "";
|
||||
|
||||
expect(chunk.role).toBe("assistant");
|
||||
expect(chunk.content).toBe("");
|
||||
expect(typedChunk.toolCalls).toHaveLength(1);
|
||||
|
||||
if (isFirstChunk) {
|
||||
isFirstChunk = false;
|
||||
expect(toolCall.id).toBeDefined();
|
||||
expect(toolCall.function!.name).toBe("say_hello");
|
||||
}
|
||||
}
|
||||
|
||||
const parsedArgs = JSON.parse(args);
|
||||
expect(parsedArgs.name).toBe("Nate");
|
||||
});
|
||||
const parsedArgs = JSON.parse(args);
|
||||
expect(parsedArgs.name).toBe("Nate");
|
||||
},
|
||||
timeout,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe("LLM", () => {
|
||||
if (process.env.IGNORE_API_KEY_TESTS === "true") {
|
||||
test("Skipping API key tests", () => {
|
||||
console.log(
|
||||
"Skipping API key tests due to IGNORE_API_KEY_TESTS being set",
|
||||
);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
testLLM(
|
||||
new Anthropic({
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
|
|
@ -165,7 +203,7 @@ describe("LLM", () => {
|
|||
});
|
||||
testLLM(
|
||||
new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1-preview" }),
|
||||
{ skip: false },
|
||||
{ skip: false, timeout: 20000 },
|
||||
);
|
||||
testLLM(new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1" }), {
|
||||
skip: false,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class Asksage extends BaseLLM {
|
|||
"gpt4-32k": "gpt4-32k",
|
||||
"gpt-o1": "gpt-o1", // Works
|
||||
"gpt-o1-mini": "gpt-o1-mini", // Works
|
||||
"gpt-o3-mini": "gpt-o3-mini", // Stub
|
||||
"gpt-3.5-turbo": "gpt35-16k", // Works
|
||||
"aws-bedrock-claude-35-sonnet-gov": "aws-bedrock-claude-35-sonnet-gov", // Works
|
||||
"claude-3-5-sonnet-latest": "claude-35-sonnet", // Works
|
||||
|
|
|
|||
|
|
@ -251,9 +251,45 @@ class Gemini extends BaseLLM {
|
|||
return;
|
||||
}
|
||||
}
|
||||
// Helper function to recursively clean JSON Schema objects
|
||||
const cleanJsonSchema = (schema: any): any => {
|
||||
if (!schema || typeof schema !== 'object') return schema;
|
||||
|
||||
if (Array.isArray(schema)) {
|
||||
return schema.map(cleanJsonSchema);
|
||||
}
|
||||
|
||||
const {
|
||||
$schema,
|
||||
additionalProperties,
|
||||
default: defaultValue,
|
||||
...rest
|
||||
} = schema;
|
||||
|
||||
// Recursively clean nested properties
|
||||
if (rest.properties) {
|
||||
rest.properties = Object.entries(rest.properties).reduce(
|
||||
(acc, [key, value]) => ({
|
||||
...acc,
|
||||
[key]: cleanJsonSchema(value),
|
||||
}),
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
// Clean items in arrays
|
||||
if (rest.items) {
|
||||
rest.items = cleanJsonSchema(rest.items);
|
||||
}
|
||||
|
||||
return rest;
|
||||
};
|
||||
|
||||
// Clean the parameters and convert type to uppercase
|
||||
const cleanedParams = cleanJsonSchema(tool.function.parameters);
|
||||
fn.parameters = {
|
||||
...cleanedParams,
|
||||
type: tool.function.parameters.type.toUpperCase(),
|
||||
...tool.function.parameters,
|
||||
};
|
||||
}
|
||||
functions.push(fn);
|
||||
|
|
@ -311,11 +347,16 @@ class Gemini extends BaseLLM {
|
|||
const supportedParts: MessagePart[] = [];
|
||||
const toolCalls: ToolCallDelta[] = [];
|
||||
|
||||
// Process all parts first to maintain order
|
||||
const processedParts: Array<{
|
||||
type: 'content' | 'tool' | 'toolCall',
|
||||
data: any
|
||||
}> = [];
|
||||
|
||||
for (const part of content.parts) {
|
||||
if ("text" in part) {
|
||||
supportedParts.push({ type: "text", text: part.text });
|
||||
} else if ("inlineData" in part) {
|
||||
// TODO does this image url conversion actually work?
|
||||
supportedParts.push({
|
||||
type: "imageUrl",
|
||||
imageUrl: {
|
||||
|
|
@ -323,38 +364,56 @@ class Gemini extends BaseLLM {
|
|||
},
|
||||
});
|
||||
} else if ("functionCall" in part) {
|
||||
// Handle function call
|
||||
toolCalls.push({
|
||||
type: "function",
|
||||
id: "", // Not supported by gemini
|
||||
function: {
|
||||
name: part.functionCall.name,
|
||||
arguments:
|
||||
typeof part.functionCall.args === "string"
|
||||
? part.functionCall.args
|
||||
: JSON.stringify(part.functionCall.args),
|
||||
},
|
||||
// Queue function call
|
||||
processedParts.push({
|
||||
type: 'toolCall',
|
||||
data: {
|
||||
type: "function",
|
||||
id: "", // Not supported by gemini
|
||||
function: {
|
||||
name: part.functionCall.name,
|
||||
arguments:
|
||||
typeof part.functionCall.args === "string"
|
||||
? part.functionCall.args
|
||||
: JSON.stringify(part.functionCall.args),
|
||||
},
|
||||
}
|
||||
});
|
||||
} else if ("functionResponse" in part) {
|
||||
// TODO hypothetically order could be off here
|
||||
// Where function response is in the middle of something
|
||||
yield {
|
||||
role: "tool",
|
||||
content: part.functionResponse.response.output as string,
|
||||
toolCallId: part.functionResponse.name,
|
||||
};
|
||||
// Queue function response
|
||||
processedParts.push({
|
||||
type: 'tool',
|
||||
data: {
|
||||
role: "tool",
|
||||
content: part.functionResponse.response.output as string,
|
||||
toolCallId: part.functionResponse.name,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn("Unsupported gemini part type received", part);
|
||||
}
|
||||
}
|
||||
if (supportedParts.length || toolCalls.length) {
|
||||
// Incrementally stream the content to make it smoother
|
||||
|
||||
// If we have supported content parts, yield them first
|
||||
if (supportedParts.length) {
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: supportedParts.length ? supportedParts : "",
|
||||
...(toolCalls.length ? { toolCalls } : {}),
|
||||
content: supportedParts,
|
||||
};
|
||||
}
|
||||
|
||||
// Then process tool calls and responses in order
|
||||
for (const part of processedParts) {
|
||||
if (part.type === 'toolCall') {
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: "",
|
||||
toolCalls: [part.data],
|
||||
};
|
||||
} else if (part.type === 'tool') {
|
||||
yield part.data;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Handle the case where the expected data structure is not found
|
||||
console.warn("Unexpected response format:", data);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ const CHAT_ONLY_MODELS = [
|
|||
"gpt-4o-mini",
|
||||
"o1-preview",
|
||||
"o1-mini",
|
||||
"o3-mini"
|
||||
];
|
||||
|
||||
const formatMessageForO1 = (messages: ChatCompletionMessageParam[]) => {
|
||||
|
|
@ -92,8 +93,8 @@ class OpenAI extends BaseLLM {
|
|||
return model;
|
||||
}
|
||||
|
||||
private isO1Model(model?: string): boolean {
|
||||
return !!model && model.startsWith("o1");
|
||||
private isO3orO1Model(model?: string): boolean {
|
||||
return !!model && (model.startsWith("o1") || model.startsWith("o3"));
|
||||
}
|
||||
|
||||
protected supportsPrediction(model: string): boolean {
|
||||
|
|
@ -144,8 +145,8 @@ class OpenAI extends BaseLLM {
|
|||
|
||||
finalOptions.stop = options.stop?.slice(0, this.getMaxStopWords());
|
||||
|
||||
// OpenAI o1-preview and o1-mini:
|
||||
if (this.isO1Model(options.model)) {
|
||||
// OpenAI o1-preview and o1-mini or o3-mini:
|
||||
if (this.isO3orO1Model(options.model)) {
|
||||
// a) use max_completion_tokens instead of max_tokens
|
||||
finalOptions.max_completion_tokens = options.maxTokens;
|
||||
finalOptions.max_tokens = undefined;
|
||||
|
|
@ -239,8 +240,8 @@ class OpenAI extends BaseLLM {
|
|||
): ChatCompletionCreateParams {
|
||||
body.stop = body.stop?.slice(0, this.getMaxStopWords());
|
||||
|
||||
// OpenAI o1-preview and o1-mini:
|
||||
if (this.isO1Model(body.model)) {
|
||||
// OpenAI o1-preview and o1-mini or o3-mini:
|
||||
if (this.isO3orO1Model(body.model)) {
|
||||
// a) use max_completion_tokens instead of max_tokens
|
||||
body.max_completion_tokens = body.max_tokens;
|
||||
body.max_tokens = undefined;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
|
||||
import { AutocompleteInput } from "../autocomplete/util/types";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
import { OrganizationDescription } from "../config/ProfileLifecycleManager";
|
||||
import { SharedConfigSchema } from "../config/sharedConfig";
|
||||
|
||||
import type {
|
||||
BrowserSerializedContinueConfig,
|
||||
ChatMessage,
|
||||
|
|
@ -21,9 +27,6 @@ import type {
|
|||
SiteIndexingConfig,
|
||||
ToolCall,
|
||||
} from "../";
|
||||
import { AutocompleteInput } from "../autocomplete/util/types";
|
||||
import { ProfileDescription } from "../config/ConfigHandler";
|
||||
import { SharedConfigSchema } from "../config/sharedConfig";
|
||||
|
||||
export type OnboardingModes =
|
||||
| "Local"
|
||||
|
|
@ -195,4 +198,5 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
];
|
||||
"clipboardCache/add": [{ content: string }, void];
|
||||
"controlPlane/openUrl": [{ path: string }, void];
|
||||
"controlPlane/listOrganizations": [undefined, OrganizationDescription[]];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"didChangeSelectedProfile",
|
||||
"tools/call",
|
||||
"controlPlane/openUrl",
|
||||
"controlPlane/listOrganizations",
|
||||
];
|
||||
|
||||
// Message types to pass through from core to webview
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ export const searchWebTool: Tool = {
|
|||
"Performs a web search, returning top results. This tool should only be called for questions that require external knowledge. Common programming questions do not require web search.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
required: ["repo_url"],
|
||||
required: ["query"],
|
||||
properties: {
|
||||
repo_url: {
|
||||
query: {
|
||||
type: "string",
|
||||
description: "The natural language search query",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -99,6 +99,21 @@ If you prefer to use a model from [OpenAI](../customize/model-providers/top-leve
|
|||
]
|
||||
```
|
||||
|
||||
### Grok-2 from xAI
|
||||
|
||||
If you prefer to use a model from [xAI](../customize/model-providers/top-level/xAI.md), then we recommend Grok-2.
|
||||
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "Grok-2",
|
||||
"provider": "xAI",
|
||||
"model": "grok-2-latest",
|
||||
"apiKey": "[XAI_API_KEY]"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Gemini 1.5 Pro from Google
|
||||
|
||||
If you prefer to use a model from [Google](../customize/model-providers/top-level/gemini.md), then we recommend Gemini 1.5 Pro.
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ The current Models available provided by Ask Sage are:
|
|||
| 8 | GPT-4-32K | Yes | ✅ |
|
||||
| 9 | GPT-o1 | Yes | ✅ |
|
||||
| 10 | GPT-o1-mini | Yes | ✅ |
|
||||
| 10 | GPT-o3-mini | Yes | ✅ |
|
||||
| 11 | GPT-3.5-turbo | Yes | ✅ |
|
||||
| 12 | Calude 3.5 Sonnet Gov | Yes | ✅ |
|
||||
| 13 | Calude 3 Opus | Yes | ✅ |
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ You can get an API key from the [xAI console](https://console.x.ai/)
|
|||
|
||||
## Chat model
|
||||
|
||||
We recommend configuring **grok-beta** as your chat model.
|
||||
We recommend configuring **grok-2-latest** as your chat model. For information on other available models, visit [xAI Documentation](https://docs.x.ai/docs/models).
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Grok Beta",
|
||||
"title": "Grok 2",
|
||||
"provider": "xAI",
|
||||
"model": "grok-beta",
|
||||
"model": "grok-2-latest",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -14,5 +14,6 @@ If you have the ability to use any model, we recommend [Claude 3.5 Sonnet](../mo
|
|||
Otherwise, some of the next best options are:
|
||||
|
||||
- [GPT-4o](../model-providers/top-level/openai.md)
|
||||
- [Grok-2](../model-providers/top-level/xAI.md)
|
||||
- [Gemini 1.5 Pro](../model-providers/top-level/gemini.md)
|
||||
- [Llama3.1 405B](../tutorials/llama3.1.md)
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ Each model has specific configuration options tailored to its provider and funct
|
|||
**Properties:**
|
||||
|
||||
- `title` (**required**): The title to assign to your model, shown in dropdowns, etc.
|
||||
- `provider` (**required**): The provider of the model, which determines the type and interaction method. Options inclued `openai`, `ollama`, etc., see intelliJ suggestions.
|
||||
- `provider` (**required**): The provider of the model, which determines the type and interaction method. Options inclued `openai`, `ollama`, `xAI`, etc., see IntelliJ suggestions.
|
||||
- `model` (**required**): The name of the model, used for prompt template auto-detection. Use `AUTODETECT` special name to get all available models.
|
||||
- `apiKey`: API key required by providers like OpenAI, Anthropic, and Cohere.
|
||||
- `apiKey`: API key required by providers like OpenAI, Anthropic, Cohere, and xAI.
|
||||
- `apiBase`: The base URL of the LLM API.
|
||||
- `contextLength`: Maximum context length of the model, typically in tokens (default: 2048).
|
||||
- `maxStopWords`: Maximum number of stop words allowed, to avoid API errors with extensive lists.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension
|
|||
pluginName=continue-intellij-extension
|
||||
pluginRepositoryUrl=https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion=0.0.86
|
||||
pluginVersion=0.0.87
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild=223
|
||||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
|
|
|
|||
|
|
@ -117,7 +117,9 @@ class MessageTypes {
|
|||
"profiles/switch",
|
||||
"didChangeSelectedProfile",
|
||||
"tools/call",
|
||||
"controlPlane/openUrl"
|
||||
"controlPlane/openUrl",
|
||||
"controlPlane/listOrganizations"
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,24 @@
|
|||
import {
|
||||
EditorView,
|
||||
TextEditor,
|
||||
InputBox,
|
||||
Workbench,
|
||||
Key,
|
||||
VSBrowser,
|
||||
TextEditor,
|
||||
Workbench,
|
||||
} from "vscode-extension-tester";
|
||||
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
import { TestUtils } from "../TestUtils";
|
||||
import { SSHSelectors } from "../selectors/SSH.selectors";
|
||||
import { AutocompleteActions } from "../actions/Autocomplete.actions";
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
import { SSHSelectors } from "../selectors/SSH.selectors";
|
||||
import { TestUtils } from "../TestUtils";
|
||||
|
||||
describe("SSH", function () {
|
||||
if (process.env.IGNORE_SSH_TESTS === "true") {
|
||||
it("Skipping SSH tests", () => {
|
||||
console.log("Skipping SSH tests due to IGNORE_SSH_TESTS being set");
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
it("Should display completions", async () => {
|
||||
await TestUtils.waitForSuccess(async () => {
|
||||
await new Workbench().executeCommand(
|
||||
|
|
|
|||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.9.255",
|
||||
"version": "0.9.259",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.9.255",
|
||||
"version": "0.9.259",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "0.9.258",
|
||||
"version": "0.9.259",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
@ -214,7 +214,7 @@
|
|||
"command": "continue.toggleFullScreen",
|
||||
"category": "Continue",
|
||||
"title": "Toggle Full Screen",
|
||||
"icon": "$(fullscreen)",
|
||||
"icon": "$(link-external)",
|
||||
"group": "Continue"
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,16 +29,6 @@ const LayoutTopDiv = styled(CustomScrollbarDiv)`
|
|||
border-radius: ${defaultBorderRadius};
|
||||
position: relative;
|
||||
overflow-x: hidden;
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
content: "";
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background-color: rgba(136, 136, 136, 0.3);
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
`;
|
||||
|
||||
const GridDiv = styled.div`
|
||||
|
|
|
|||
|
|
@ -1,20 +1,32 @@
|
|||
import { ArrowLeftIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
export interface PageHeaderProps {
|
||||
onClick: () => void;
|
||||
title: string;
|
||||
onTitleClick?: () => void;
|
||||
title?: string;
|
||||
rightContent?: React.ReactNode;
|
||||
}
|
||||
|
||||
export default function PageHeader({ onClick, title }: PageHeaderProps) {
|
||||
export default function PageHeader({
|
||||
onTitleClick,
|
||||
title,
|
||||
rightContent,
|
||||
}: PageHeaderProps) {
|
||||
return (
|
||||
<div className="bg-vsc-background sticky top-0 z-20 m-0 flex items-center border-0 border-b border-solid border-b-zinc-700 bg-inherit p-0">
|
||||
<div
|
||||
className="cursor-pointer transition-colors duration-200 hover:text-zinc-100"
|
||||
onClick={onClick}
|
||||
>
|
||||
<ArrowLeftIcon className="ml-3 inline-block h-3 w-3" />
|
||||
<span className="m-2 inline-block text-base font-bold">{title}</span>
|
||||
<div className="bg-vsc-background sticky top-0 z-20 m-0 flex items-center justify-between border-0 border-b border-solid border-b-zinc-700 bg-inherit pb-1">
|
||||
<div className="flex items-center">
|
||||
{title && (
|
||||
<div
|
||||
className="cursor-pointer transition-colors duration-200 hover:text-zinc-100"
|
||||
onClick={onTitleClick}
|
||||
>
|
||||
<ArrowLeftIcon className="ml-3 inline-block h-3 w-3" />
|
||||
<span className="m-2 inline-block text-base font-bold">
|
||||
{title}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="ml-auto">{rightContent}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ const NumberInput: React.FC<NumberInputProps> = ({
|
|||
/>
|
||||
<div className="flex flex-col">
|
||||
<button
|
||||
style={{ fontSize: "10px" }}
|
||||
onClick={handleIncrement}
|
||||
disabled={value >= max}
|
||||
className="text-vsc-foreground m-0 mb-0.5 cursor-pointer border-none bg-inherit px-1.5 py-0 hover:opacity-80"
|
||||
|
|
@ -47,6 +48,7 @@ const NumberInput: React.FC<NumberInputProps> = ({
|
|||
▲
|
||||
</button>
|
||||
<button
|
||||
style={{ fontSize: "10px" }}
|
||||
className="text-vsc-foreground m-0 mb-0.5 cursor-pointer border-none bg-inherit px-1.5 py-0 hover:opacity-80"
|
||||
onClick={handleDecrement}
|
||||
disabled={value <= min}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
|
|||
text,
|
||||
}) => {
|
||||
return (
|
||||
<div className="flex cursor-pointer select-none items-center justify-end gap-3">
|
||||
<div className="flex cursor-pointer select-none items-center justify-between gap-3">
|
||||
<span className="truncate-right text-right">{text}</span>
|
||||
<div>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import CodeSnippetPreview from "../markdown/CodeSnippetPreview";
|
|||
export const CodeBlockComponent = (props: any) => {
|
||||
const { node, deleteNode, selected, editor, updateAttributes } = props;
|
||||
const item: ContextItemWithId = node.attrs.item;
|
||||
const inputId = node.attrs.inputId;
|
||||
// const contextItems = useSelector(
|
||||
// (store: RootState) =>
|
||||
// store.session.messages[store.session.messages.length - 1].contextItems,
|
||||
|
|
@ -23,6 +24,7 @@ export const CodeBlockComponent = (props: any) => {
|
|||
as={nodeViewWrapperTag}
|
||||
>
|
||||
<CodeSnippetPreview
|
||||
inputId={inputId}
|
||||
borderColor={
|
||||
isFirstContextItem
|
||||
? "#d0d"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ export const CodeBlockExtension = Node.create({
|
|||
item: {
|
||||
default: "",
|
||||
},
|
||||
inputId: {
|
||||
default: "",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ interface ContinueInputBoxProps {
|
|||
editorState?: JSONContent;
|
||||
contextItems?: ContextItemWithId[];
|
||||
hidden?: boolean;
|
||||
inputId: string; // used to keep track of things per input in redux
|
||||
}
|
||||
|
||||
const EDIT_DISALLOWED_CONTEXT_PROVIDERS = [
|
||||
|
|
@ -132,6 +133,7 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
|
|||
availableSlashCommands={filteredSlashCommands}
|
||||
historyKey={historyKey}
|
||||
toolbarOptions={toolbarOptions}
|
||||
inputId={props.inputId}
|
||||
/>
|
||||
</GradientBorder>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
vscInputBackground,
|
||||
} from "..";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { selectUseActiveFile, selectUsePlatform } from "../../redux/selectors";
|
||||
import { selectUseActiveFile } from "../../redux/selectors";
|
||||
import { selectDefaultModel } from "../../redux/slices/configSlice";
|
||||
import {
|
||||
selectHasCodeToEdit,
|
||||
|
|
@ -26,7 +26,6 @@ import {
|
|||
} from "../../util";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import ModelSelect from "../modelSelection/ModelSelect";
|
||||
import AssistantAndModelSelect from "../modelSelection/platform/AssistantAndModelSelect";
|
||||
import HoverItem from "./InputToolbar/HoverItem";
|
||||
import ToggleToolsButton from "./InputToolbar/ToggleToolsButton";
|
||||
|
||||
|
|
@ -97,8 +96,6 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
modelSupportsTools(defaultModel.model, defaultModel.provider) &&
|
||||
!props.toolbarOptions?.hideTools;
|
||||
|
||||
const usePlatform = useAppSelector(selectUsePlatform);
|
||||
|
||||
const supportsImages =
|
||||
defaultModel &&
|
||||
modelSupportsImages(
|
||||
|
|
@ -117,7 +114,7 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
className="find-widget-skip flex"
|
||||
>
|
||||
<div className="flex items-center justify-start gap-2 whitespace-nowrap">
|
||||
{usePlatform ? <AssistantAndModelSelect /> : <ModelSelect />}
|
||||
<ModelSelect />
|
||||
<div className="xs:flex -mb-1 hidden items-center text-gray-400 transition-colors duration-200">
|
||||
{props.toolbarOptions?.hideImageUpload ||
|
||||
(supportsImages && (
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ import {
|
|||
selectHasCodeToEdit,
|
||||
selectIsInEditMode,
|
||||
setMainEditorContentTrigger,
|
||||
setNewestCodeblocksForInput,
|
||||
} from "../../redux/slices/sessionSlice";
|
||||
import { exitEditMode } from "../../redux/thunks";
|
||||
import {
|
||||
|
|
@ -108,11 +109,6 @@ const InputBoxDiv = styled.div<{ border?: string }>`
|
|||
flex-direction: column;
|
||||
`;
|
||||
|
||||
const PaddingDiv = styled.div`
|
||||
padding: 8px 12px;
|
||||
padding-bottom: 4px;
|
||||
`;
|
||||
|
||||
const HoverDiv = styled.div`
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
|
|
@ -180,6 +176,7 @@ interface TipTapEditorProps {
|
|||
border?: string;
|
||||
placeholder?: string;
|
||||
historyKey: string;
|
||||
inputId: string;
|
||||
}
|
||||
|
||||
export const TIPPY_DIV_ID = "tippy-js-div";
|
||||
|
|
@ -782,22 +779,6 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
return;
|
||||
}
|
||||
|
||||
// const rif: RangeInFile & { contents: string } =
|
||||
// data.rangeInFileWithContents;
|
||||
// const basename = getBasename(rif.filepath);
|
||||
// const relativePath = getRelativePath(
|
||||
// rif.filepath,
|
||||
// await ideMessenger.ide.getWorkspaceDirs(),
|
||||
// const rangeStr = `(${rif.range.start.line + 1}-${
|
||||
// rif.range.end.line + 1
|
||||
// })`;
|
||||
|
||||
// const itemName = `${basename} ${rangeStr}`;
|
||||
// const item: ContextItemWithId = {
|
||||
// content: rif.contents,
|
||||
// name: itemName
|
||||
// }
|
||||
|
||||
const contextItem = rifWithContentsToContextItem(
|
||||
data.rangeInFileWithContents,
|
||||
);
|
||||
|
|
@ -819,10 +800,16 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
type: "codeBlock",
|
||||
attrs: {
|
||||
item: contextItem,
|
||||
inputId: props.inputId,
|
||||
},
|
||||
})
|
||||
.run();
|
||||
|
||||
dispatch(
|
||||
setNewestCodeblocksForInput({
|
||||
inputId: props.inputId,
|
||||
contextItemId: contextItem.id.itemId,
|
||||
}),
|
||||
);
|
||||
if (data.prompt) {
|
||||
editor.commands.focus("end");
|
||||
editor.commands.insertContent(data.prompt);
|
||||
|
|
@ -990,8 +977,9 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
event.preventDefault();
|
||||
}}
|
||||
>
|
||||
<PaddingDiv>
|
||||
<div className="px-2.5 pb-1 pt-2">
|
||||
<EditorContent
|
||||
className={`scroll-container overflow-y-scroll ${props.isMainInput ? "max-h-[70vh]" : ""}`}
|
||||
spellCheck={false}
|
||||
editor={editor}
|
||||
onClick={(event) => {
|
||||
|
|
@ -1023,7 +1011,7 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
}}
|
||||
disabled={isStreaming}
|
||||
/>
|
||||
</PaddingDiv>
|
||||
</div>
|
||||
|
||||
{showDragOverMsg &&
|
||||
modelSupportsImages(
|
||||
|
|
|
|||
|
|
@ -69,14 +69,14 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
|
|||
<li className="flex items-start">
|
||||
<PencilSquareIcon className="h-4 w-4 pr-3 align-middle" />
|
||||
<span>
|
||||
Highlight code and press <code>{getMetaKeyLabel() + "I"}</code> to
|
||||
Highlight code and press <kbd>{getMetaKeyLabel()}</kbd> + <kbd>I</kbd> to
|
||||
quickly make natural language edits
|
||||
</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<ClipboardDocumentIcon className="h-4 w-4 pr-3 align-middle" />
|
||||
<span>
|
||||
Highlight code and press <code>{getMetaKeyLabel() + "L"}</code> to
|
||||
Highlight code and press <kbd>{getMetaKeyLabel()}</kbd> + <kbd>L</kbd> to
|
||||
add it to the chat window
|
||||
</span>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronUpIcon,
|
||||
EyeSlashIcon,
|
||||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ContextItemWithId } from "core";
|
||||
import { dedent, getMarkdownLanguageTagForFile } from "core/util";
|
||||
import React, { useContext, useMemo } from "react";
|
||||
import { useContext, useEffect, useMemo, useRef, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray, vscEditorBackground } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
|
|
@ -14,6 +14,8 @@ import FileIcon from "../FileIcon";
|
|||
import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip";
|
||||
import StyledMarkdownPreview from "./StyledMarkdownPreview";
|
||||
import { ctxItemToRifWithContents } from "core/commands/util";
|
||||
import { EyeIcon } from "@heroicons/react/24/solid";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
|
||||
const PreviewMarkdownDiv = styled.div<{
|
||||
borderColor?: string;
|
||||
|
|
@ -31,32 +33,30 @@ const PreviewMarkdownDiv = styled.div<{
|
|||
}
|
||||
`;
|
||||
|
||||
const PreviewMarkdownHeader = styled.div`
|
||||
margin: 0;
|
||||
padding: 2px 6px;
|
||||
border-bottom: 0.5px solid ${lightGray};
|
||||
word-break: break-all;
|
||||
font-size: ${getFontSize() - 3}px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
interface CodeSnippetPreviewProps {
|
||||
item: ContextItemWithId;
|
||||
onDelete?: () => void;
|
||||
borderColor?: string;
|
||||
hideHeader?: boolean;
|
||||
inputId: string;
|
||||
}
|
||||
|
||||
const MAX_PREVIEW_HEIGHT = 300;
|
||||
const MAX_PREVIEW_HEIGHT = 100;
|
||||
|
||||
const backticksRegex = /`{3,}/gm;
|
||||
|
||||
function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const [collapsed, setCollapsed] = React.useState(true);
|
||||
const [hovered, setHovered] = React.useState(false);
|
||||
const [localHidden, setLocalHidden] = useState<boolean | undefined>();
|
||||
const [isSizeLimited, setIsSizeLimited] = useState(true);
|
||||
|
||||
const newestCodeblockForInputId = useAppSelector(
|
||||
(store) => store.session.newestCodeblockForInput[props.inputId],
|
||||
);
|
||||
|
||||
const hidden = useMemo(() => {
|
||||
return localHidden ?? newestCodeblockForInputId !== props.item.id.itemId;
|
||||
}, [localHidden, newestCodeblockForInputId, props.item]);
|
||||
|
||||
const content = useMemo(() => {
|
||||
return dedent`${props.item.content}`;
|
||||
|
|
@ -67,20 +67,45 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
|
|||
return backticks ? backticks.sort().at(-1) + "`" : "```";
|
||||
}, [content]);
|
||||
|
||||
const codeBlockRef = React.useRef<HTMLDivElement>(null);
|
||||
const codeBlockRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const [codeblockDims, setCodeblockDims] = useState({ width: 0, height: 0 });
|
||||
useEffect(() => {
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
setCodeblockDims({
|
||||
width: codeBlockRef.current?.scrollWidth ?? 0,
|
||||
height: codeBlockRef.current?.scrollHeight ?? 0,
|
||||
});
|
||||
});
|
||||
|
||||
if (codeBlockRef.current) {
|
||||
resizeObserver.observe(codeBlockRef.current);
|
||||
}
|
||||
|
||||
return () => {
|
||||
resizeObserver.disconnect();
|
||||
};
|
||||
}, [codeBlockRef]);
|
||||
|
||||
return (
|
||||
<PreviewMarkdownDiv
|
||||
spellCheck={false}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
borderColor={props.borderColor}
|
||||
className="find-widget-skip"
|
||||
>
|
||||
{!props.hideHeader && (
|
||||
<PreviewMarkdownHeader
|
||||
className="flex cursor-pointer justify-between"
|
||||
onClick={() => {
|
||||
<div
|
||||
className="m-0 flex cursor-pointer items-center justify-between break-all border-b px-[5px] py-1.5 hover:opacity-90"
|
||||
style={{
|
||||
fontSize: getFontSize() - 3,
|
||||
}}
|
||||
onClick={() => {
|
||||
setLocalHidden(!hidden);
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="flex items-center gap-1 hover:underline"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (
|
||||
props.item.id.providerTitle === "file" &&
|
||||
props.item.uri?.value
|
||||
|
|
@ -103,29 +128,34 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
|
|||
}
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center gap-1">
|
||||
<FileIcon height="16px" width="16px" filename={props.item.name} />
|
||||
{props.item.name}
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<HeaderButtonWithToolTip
|
||||
text="Delete"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
props.onDelete?.();
|
||||
}}
|
||||
>
|
||||
<XMarkIcon width="1em" height="1em" />
|
||||
</HeaderButtonWithToolTip>
|
||||
</div>
|
||||
</PreviewMarkdownHeader>
|
||||
)}
|
||||
<FileIcon height="16px" width="16px" filename={props.item.name} />
|
||||
{props.item.name}
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<HeaderButtonWithToolTip text={hidden ? "Show" : "Hide"}>
|
||||
{hidden ? (
|
||||
<EyeIcon width="1em" height="1em" />
|
||||
) : (
|
||||
<EyeSlashIcon width="1em" height="1em" />
|
||||
)}
|
||||
</HeaderButtonWithToolTip>
|
||||
<HeaderButtonWithToolTip
|
||||
text="Delete"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
props.onDelete?.();
|
||||
}}
|
||||
>
|
||||
<XMarkIcon width="1em" height="1em" />
|
||||
</HeaderButtonWithToolTip>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
contentEditable={false}
|
||||
className={`m-0 ${collapsed ? "overflow-hidden" : "overflow-auto"}`}
|
||||
className={`m-0 ${isSizeLimited ? "overflow-hidden" : "overflow-auto"} ${hidden ? "hidden" : ""}`}
|
||||
ref={codeBlockRef}
|
||||
style={{
|
||||
maxHeight: collapsed ? MAX_PREVIEW_HEIGHT : undefined, // Could switch to max-h-[33vh] but then chevron icon shows when height can't change
|
||||
maxHeight: isSizeLimited ? MAX_PREVIEW_HEIGHT : undefined, // Could switch to max-h-[33vh] but then chevron icon shows when height can't change
|
||||
}}
|
||||
>
|
||||
<StyledMarkdownPreview
|
||||
|
|
@ -133,22 +163,18 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
|
|||
/>
|
||||
</div>
|
||||
|
||||
{(codeBlockRef.current?.scrollHeight ?? 0) > MAX_PREVIEW_HEIGHT && (
|
||||
{codeblockDims.height > MAX_PREVIEW_HEIGHT && (
|
||||
<HeaderButtonWithToolTip
|
||||
className="absolute bottom-1 right-2"
|
||||
text={collapsed ? "Expand" : "Collapse"}
|
||||
text={isSizeLimited ? "Expand" : "Collapse"}
|
||||
>
|
||||
{collapsed ? (
|
||||
<ChevronDownIcon
|
||||
className="h-5 w-5"
|
||||
onClick={() => setCollapsed(false)}
|
||||
/>
|
||||
) : (
|
||||
<ChevronUpIcon
|
||||
className="h-5 w-5"
|
||||
onClick={() => setCollapsed(true)}
|
||||
/>
|
||||
)}
|
||||
<ChevronDownIcon
|
||||
className="h-5 w-5 transition-all"
|
||||
style={{
|
||||
transform: isSizeLimited ? "" : "rotate(180deg)",
|
||||
}}
|
||||
onClick={() => setIsSizeLimited((v) => !v)}
|
||||
/>
|
||||
</HeaderButtonWithToolTip>
|
||||
)}
|
||||
</PreviewMarkdownDiv>
|
||||
|
|
|
|||
|
|
@ -1,194 +0,0 @@
|
|||
import { Popover } from "@headlessui/react";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
DocumentIcon,
|
||||
SparklesIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray, vscInputBackground } from "../..";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import AddModelForm from "../../../forms/AddModelForm";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
cycleDefaultModel,
|
||||
selectDefaultModel,
|
||||
} from "../../../redux/slices/configSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { cycleProfile } from "../../../redux/thunks/cycleProfile";
|
||||
import { getFontSize, isMetaEquivalentKeyPressed } from "../../../util";
|
||||
import PopoverTransition from "../../mainInput/InputToolbar/PopoverTransition";
|
||||
import { AssistantSelect } from "./AssistantSelect";
|
||||
import { ModelSelect, modelSelectTitle } from "./ModelSelect";
|
||||
import { MAX_HEIGHT_PX } from "./shared";
|
||||
|
||||
const StyledPopoverButton = styled(Popover.Button)`
|
||||
font-family: inherit;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: ${getFontSize() - 2}px;
|
||||
background: transparent;
|
||||
color: ${lightGray};
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledPopoverPanel = styled(Popover.Panel)<{ $showabove: boolean }>`
|
||||
margin-top: 4px;
|
||||
position: absolute;
|
||||
padding: 0px;
|
||||
cursor: default;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
border-radius: ${defaultBorderRadius};
|
||||
border: 0.5px solid ${lightGray};
|
||||
background-color: ${vscInputBackground};
|
||||
|
||||
${(props) => (props.$showabove ? "bottom: 100%;" : "top: 100%;")}
|
||||
`;
|
||||
|
||||
function AssistantAndModelSelect() {
|
||||
const dispatch = useAppDispatch();
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const [showAbove, setShowAbove] = useState(false);
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const selectedProfileId = useAppSelector(
|
||||
(store) => store.session.selectedProfileId,
|
||||
);
|
||||
|
||||
const { profiles, selectedProfile } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => calculatePosition();
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, []);
|
||||
|
||||
function calculatePosition() {
|
||||
if (!buttonRef.current) {
|
||||
return;
|
||||
}
|
||||
const rect = buttonRef.current.getBoundingClientRect();
|
||||
const spaceBelow = window.innerHeight - rect.bottom;
|
||||
const spaceAbove = rect.top;
|
||||
const dropdownHeight = MAX_HEIGHT_PX;
|
||||
|
||||
setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
|
||||
}
|
||||
|
||||
function onClickAddModel(e: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
// Close the dropdown
|
||||
if (buttonRef.current) {
|
||||
buttonRef.current.click();
|
||||
}
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let lastToggleTime = 0;
|
||||
const DEBOUNCE_MS = 500;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "'" && isMetaEquivalentKeyPressed(event as any)) {
|
||||
const now = Date.now();
|
||||
|
||||
if (event.shiftKey) {
|
||||
dispatch(cycleDefaultModel("next"));
|
||||
} else {
|
||||
if (now - lastToggleTime >= DEBOUNCE_MS) {
|
||||
dispatch(cycleProfile());
|
||||
lastToggleTime = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Popover>
|
||||
<div className="relative">
|
||||
<StyledPopoverButton
|
||||
data-testid="model-select-button"
|
||||
ref={buttonRef}
|
||||
className="h-[18px] overflow-hidden"
|
||||
style={{ padding: 0 }}
|
||||
onClick={calculatePosition}
|
||||
>
|
||||
<div className="flex max-w-[33vw] items-center gap-0.5 text-gray-400 transition-colors duration-200">
|
||||
{selectedProfile?.id === "local" ? (
|
||||
<>
|
||||
<DocumentIcon
|
||||
className="mr-1 h-4 w-4 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="truncate">
|
||||
{modelSelectTitle(defaultModel) || "Select model"}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<SparklesIcon
|
||||
className="mr-1 h-4 w-4 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="truncate">
|
||||
{selectedProfile?.fullSlug.packageSlug || "Select assistant"}
|
||||
{" / "}
|
||||
{modelSelectTitle(defaultModel) || "Select model"}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
<ChevronDownIcon
|
||||
className="h-3 w-3 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</StyledPopoverButton>
|
||||
<PopoverTransition>
|
||||
<StyledPopoverPanel
|
||||
$showabove={showAbove}
|
||||
className="flex max-w-[90vw] overflow-hidden"
|
||||
style={{ zIndex: 1000 }}
|
||||
>
|
||||
<AssistantSelect
|
||||
onClose={() => {
|
||||
if (buttonRef.current) {
|
||||
buttonRef.current.click();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ModelSelect
|
||||
selectedProfileId={selectedProfileId}
|
||||
onClickAddModel={onClickAddModel}
|
||||
/>
|
||||
</StyledPopoverPanel>
|
||||
</PopoverTransition>
|
||||
</div>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
export default AssistantAndModelSelect;
|
||||
17
gui/src/components/modelSelection/platform/AssistantIcon.tsx
Normal file
17
gui/src/components/modelSelection/platform/AssistantIcon.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import { isLocalProfile } from "../../../util";
|
||||
import { ComputerDesktopIcon, SparklesIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
export interface AssistantIconProps {
|
||||
assistant: ProfileDescription;
|
||||
}
|
||||
|
||||
export default function AssistantIcon({ assistant }: AssistantIconProps) {
|
||||
if (isLocalProfile(assistant)) {
|
||||
return <ComputerDesktopIcon />;
|
||||
} else if (assistant.iconUrl) {
|
||||
return <img src={assistant.iconUrl} className="rounded-full" />;
|
||||
} else {
|
||||
return <SparklesIcon />;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,113 +1,91 @@
|
|||
import {
|
||||
DocumentIcon,
|
||||
PlusIcon,
|
||||
SparklesIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useContext } from "react";
|
||||
import { lightGray } from "../..";
|
||||
import { Popover } from "@headlessui/react";
|
||||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { setProfileId } from "../../../redux/thunks/setProfileId";
|
||||
import { getFontSize, getMetaKeyLabel } from "../../../util";
|
||||
import AboutAssistantDialog from "../../dialogs/AboutAssistantDialog";
|
||||
import { Divider, Option, OptionDiv } from "./shared";
|
||||
|
||||
interface AssistantSelectProps {
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function AssistantSelect(props: AssistantSelectProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { profiles, selectedProfile } = useAuth();
|
||||
import { cycleProfile } from "../../../redux/thunks/cycleProfile";
|
||||
import {
|
||||
getFontSize,
|
||||
isLocalProfile,
|
||||
isMetaEquivalentKeyPressed,
|
||||
} from "../../../util";
|
||||
import PopoverTransition from "../../mainInput/InputToolbar/PopoverTransition";
|
||||
import { AssistantSelectOptions } from "./AssistantSelectOptions";
|
||||
import AssistantIcon from "./AssistantIcon";
|
||||
import { getProfileDisplayText } from "./utils";
|
||||
|
||||
export default function AssistantSelect() {
|
||||
const dispatch = useAppDispatch();
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const { selectedProfile } = useAuth();
|
||||
|
||||
function onNewAssistant() {
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "new",
|
||||
});
|
||||
const isLocalProfileSelected =
|
||||
selectedProfile && isLocalProfile(selectedProfile);
|
||||
|
||||
useEffect(() => {
|
||||
let lastToggleTime = 0;
|
||||
const DEBOUNCE_MS = 500;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.key === "'" &&
|
||||
isMetaEquivalentKeyPressed(event as any) &&
|
||||
event.shiftKey
|
||||
) {
|
||||
const now = Date.now();
|
||||
|
||||
if (now - lastToggleTime >= DEBOUNCE_MS) {
|
||||
dispatch(cycleProfile());
|
||||
lastToggleTime = now;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!selectedProfile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="border-lightgray flex min-w-0 flex-col overflow-x-hidden border-0 border-r-[0.5px] border-solid pt-0">
|
||||
<div className={`max-h-[300px]`}>
|
||||
{profiles.map((option, idx) => (
|
||||
<Option
|
||||
key={idx}
|
||||
idx={idx}
|
||||
disabled={!!option.errors?.length}
|
||||
showConfigure={true}
|
||||
selected={option.id === selectedProfile?.id}
|
||||
onLink={
|
||||
option.id !== "local"
|
||||
? (e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: option.id,
|
||||
});
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
onConfigure={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
if (option.id === "local") {
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: option.id,
|
||||
});
|
||||
} else {
|
||||
props.onClose();
|
||||
dispatch(setDialogMessage(<AboutAssistantDialog />));
|
||||
dispatch(setShowDialog(true));
|
||||
}
|
||||
}}
|
||||
errors={option.errors}
|
||||
onClickError={() => {
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: option.id,
|
||||
});
|
||||
}}
|
||||
onClick={() => dispatch(setProfileId(option.id))}
|
||||
>
|
||||
<div className="flex min-w-0 items-center">
|
||||
{option.id === "local" ? (
|
||||
<DocumentIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
) : (
|
||||
<SparklesIcon
|
||||
className="mr-2 h-4 w-4 flex-shrink-0"
|
||||
color={
|
||||
option.id === selectedProfile?.id ? "yellow" : undefined
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<span className="flex-1 truncate text-xs">{option.title}</span>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-auto w-full">
|
||||
<OptionDiv key={profiles.length} onClick={onNewAssistant}>
|
||||
<div className="flex items-center py-0.5">
|
||||
<PlusIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
New Assistant
|
||||
</div>
|
||||
</OptionDiv>
|
||||
|
||||
<Divider className="!my-0" />
|
||||
|
||||
<span
|
||||
className="block px-3 py-2"
|
||||
style={{ color: lightGray, fontSize: getFontSize() - 4 }}
|
||||
<Popover>
|
||||
<div className="relative">
|
||||
<Popover.Button
|
||||
data-testid="assistant-select-button"
|
||||
ref={buttonRef}
|
||||
className="text-vsc-foreground-muted cursor-pointer border-none bg-transparent text-gray-500 hover:brightness-125"
|
||||
style={{ fontSize: `${getFontSize() - 2}px` }}
|
||||
>
|
||||
<code>{getMetaKeyLabel()}'</code> toggle assistant
|
||||
</span>
|
||||
<div className="flex max-w-[50vw] items-center gap-0.5">
|
||||
<div className="mr-1 h-4 w-4 flex-shrink-0">
|
||||
<AssistantIcon assistant={selectedProfile} />
|
||||
</div>
|
||||
<span className="truncate">
|
||||
{getProfileDisplayText(selectedProfile)}
|
||||
</span>
|
||||
<ChevronDownIcon
|
||||
className="h-3 w-3 flex-shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
</Popover.Button>
|
||||
|
||||
<PopoverTransition>
|
||||
<Popover.Panel className="bg-vsc-input-background absolute right-0 top-full z-[1000] mr-1 mt-1 flex max-w-[90vw] cursor-default flex-row overflow-hidden rounded-md border border-gray-400 p-0">
|
||||
<AssistantSelectOptions
|
||||
onClose={() => {
|
||||
if (buttonRef.current) {
|
||||
buttonRef.current.click();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Popover.Panel>
|
||||
</PopoverTransition>
|
||||
</div>
|
||||
</div>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,130 @@
|
|||
import { PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext } from "react";
|
||||
import { lightGray } from "../..";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { setProfileId } from "../../../redux/thunks/setProfileId";
|
||||
import { getFontSize, getMetaKeyLabel, isLocalProfile } from "../../../util";
|
||||
import AboutAssistantDialog from "../../dialogs/AboutAssistantDialog";
|
||||
import { Divider, Option, OptionDiv } from "./shared";
|
||||
import { getProfileDisplayText } from "./utils";
|
||||
import AssistantIcon from "./AssistantIcon";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { ROUTES } from "../../../util/navigation";
|
||||
|
||||
interface AssistantSelectOptionsProps {
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function AssistantSelectOptions(props: AssistantSelectOptionsProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { profiles, selectedProfile, selectedOrganization } = useAuth();
|
||||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
|
||||
function onNewAssistant() {
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "platform/new",
|
||||
});
|
||||
}
|
||||
|
||||
function handleOptionLink(e: React.MouseEvent, profileId: string) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
ideMessenger.post("config/openProfile", { profileId });
|
||||
}
|
||||
|
||||
function handleConfigure(e: React.MouseEvent, option: any) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
if (option.id === "local") {
|
||||
ideMessenger.post("config/openProfile", { profileId: option.id });
|
||||
} else {
|
||||
props.onClose();
|
||||
dispatch(setDialogMessage(<AboutAssistantDialog />));
|
||||
dispatch(setShowDialog(true));
|
||||
}
|
||||
}
|
||||
|
||||
function handleClickError(profileId: string) {
|
||||
ideMessenger.post("config/openProfile", { profileId });
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="border-lightgray flex min-w-0 flex-col overflow-x-hidden pt-0">
|
||||
<div
|
||||
className="pb-1 pl-3.5 pt-3 font-semibold hover:cursor-pointer hover:underline"
|
||||
onClick={() => navigate(ROUTES.CONFIG)}
|
||||
>
|
||||
{selectedOrganization?.name || "Personal"} Assistants
|
||||
</div>
|
||||
|
||||
<div className={`max-h-[300px]`}>
|
||||
{profiles.map((profile, idx) => (
|
||||
<Option
|
||||
key={idx}
|
||||
idx={idx}
|
||||
disabled={!!profile.errors?.length}
|
||||
showConfigure={true}
|
||||
selected={profile.id === selectedProfile?.id}
|
||||
onLink={
|
||||
!isLocalProfile(profile)
|
||||
? (e) => handleOptionLink(e, profile.id)
|
||||
: undefined
|
||||
}
|
||||
onConfigure={(e) => handleConfigure(e, profile)}
|
||||
errors={profile.errors}
|
||||
onClickError={() => handleClickError(profile.id)}
|
||||
onClick={() => dispatch(setProfileId(profile.id))}
|
||||
>
|
||||
<div className="flex min-w-0 items-center">
|
||||
<div className="mr-2 h-4 w-4 flex-shrink-0">
|
||||
<AssistantIcon assistant={profile} />
|
||||
</div>
|
||||
<div className="flex min-w-0 flex-col gap-0.5">
|
||||
<span
|
||||
className="text-lightgray truncate"
|
||||
style={{ fontSize: getFontSize() - 4 }}
|
||||
>
|
||||
{profile.fullSlug.ownerSlug}
|
||||
</span>
|
||||
<span
|
||||
className="flex-1 truncate"
|
||||
style={{ fontSize: getFontSize() - 2 }}
|
||||
>
|
||||
{getProfileDisplayText(profile)}
|
||||
{profile.fullSlug.versionSlug &&
|
||||
` (${profile.fullSlug.versionSlug})`}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-auto w-full">
|
||||
<OptionDiv key={profiles.length} onClick={onNewAssistant}>
|
||||
<div
|
||||
className="flex items-center py-0.5"
|
||||
style={{ fontSize: getFontSize() - 2 }}
|
||||
>
|
||||
<PlusIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
New Assistant
|
||||
</div>
|
||||
</OptionDiv>
|
||||
|
||||
<Divider className="!my-0" />
|
||||
|
||||
<span
|
||||
className="block px-3 py-3"
|
||||
style={{ color: lightGray, fontSize: getFontSize() - 4 }}
|
||||
>
|
||||
<code>{getMetaKeyLabel()} ⇧ '</code> to toggle
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
import { CubeIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { lightGray } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
selectDefaultModel,
|
||||
setDefaultModel,
|
||||
} from "../../../redux/slices/configSlice";
|
||||
import { getFontSize, getMetaKeyLabel } from "../../../util";
|
||||
import { Divider, Option, OptionDiv } from "./shared";
|
||||
|
||||
export interface ModelOption {
|
||||
value: string;
|
||||
title: string;
|
||||
apiKey?: string;
|
||||
}
|
||||
|
||||
export function modelSelectTitle(model: any): string {
|
||||
if (model?.title) return model?.title;
|
||||
if (model?.model !== undefined && model?.model.trim() !== "") {
|
||||
if (model?.class_name) {
|
||||
return `${model?.class_name} - ${model?.model}`;
|
||||
}
|
||||
return model?.model;
|
||||
}
|
||||
return model?.class_name;
|
||||
}
|
||||
|
||||
interface ModelSelectProps {
|
||||
selectedProfileId: string;
|
||||
onClickAddModel: (e: any) => void;
|
||||
}
|
||||
|
||||
export function ModelSelect(props: ModelSelectProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const defaultModel = useAppSelector(selectDefaultModel);
|
||||
const allModels = useAppSelector((state) => state.config.config.models);
|
||||
const [options, setOptions] = useState<ModelOption[]>([]);
|
||||
const [sortedOptions, setSortedOptions] = useState<ModelOption[]>([]);
|
||||
|
||||
// Sort so that options without an API key are at the end
|
||||
useEffect(() => {
|
||||
const enabledOptions = options.filter((option) => option.apiKey !== "");
|
||||
const disabledOptions = options.filter((option) => option.apiKey === "");
|
||||
|
||||
const sorted = [...enabledOptions, ...disabledOptions];
|
||||
|
||||
setSortedOptions(sorted);
|
||||
}, [options]);
|
||||
|
||||
useEffect(() => {
|
||||
setOptions(
|
||||
allModels.map((model) => {
|
||||
return {
|
||||
value: model.title,
|
||||
title: modelSelectTitle(model),
|
||||
apiKey: model.apiKey,
|
||||
};
|
||||
}),
|
||||
);
|
||||
}, [allModels]);
|
||||
|
||||
function onModelChange(modelTitle: string) {
|
||||
if (modelTitle === defaultModel?.title) return;
|
||||
dispatch(setDefaultModel({ title: modelTitle }));
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="xs:flex hidden min-w-0 flex-col">
|
||||
<div className={`max-h-[300px] overflow-y-scroll`}>
|
||||
{sortedOptions.map((option, idx) => (
|
||||
<Option
|
||||
idx={idx}
|
||||
key={idx}
|
||||
onClick={() => onModelChange(option.title)}
|
||||
disabled={option.apiKey === ""}
|
||||
selected={option.title === defaultModel?.title}
|
||||
showConfigure={false}
|
||||
onConfigure={() => {}}
|
||||
>
|
||||
<div className="flex flex-grow items-center">
|
||||
<CubeIcon className="mr-2 h-4 w-4 flex-shrink-0" />
|
||||
<span className="flex-grow">
|
||||
{option.title}
|
||||
{option.apiKey === "" && (
|
||||
<span className="ml-2 text-[10px] italic">
|
||||
(Missing API key)
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</Option>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="mt-auto">
|
||||
{props.selectedProfileId === "local" && (
|
||||
<>
|
||||
<OptionDiv key={options.length} onClick={props.onClickAddModel}>
|
||||
<div className="flex items-center py-0.5">
|
||||
<PlusIcon className="mr-2 h-4 w-4" />
|
||||
Add Chat model
|
||||
</div>
|
||||
</OptionDiv>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Divider className="!my-0" />
|
||||
|
||||
<span
|
||||
className="block px-3 py-2"
|
||||
style={{ color: lightGray, fontSize: getFontSize() - 4 }}
|
||||
>
|
||||
<code>{getMetaKeyLabel()}⇧'</code> toggle model
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -13,7 +13,6 @@ export const OptionDiv = styled.div<{
|
|||
isDisabled?: boolean;
|
||||
isSelected?: boolean;
|
||||
}>`
|
||||
border-radius: ${defaultBorderRadius};
|
||||
padding: 6px 12px;
|
||||
|
||||
min-width: 0px;
|
||||
|
|
|
|||
6
gui/src/components/modelSelection/platform/utils.ts
Normal file
6
gui/src/components/modelSelection/platform/utils.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import { isLocalProfile } from "../../../util";
|
||||
|
||||
export function getProfileDisplayText(profile: ProfileDescription): string {
|
||||
return isLocalProfile(profile) ? profile.title : profile.fullSlug.packageSlug;
|
||||
}
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import {
|
||||
OrganizationDescription,
|
||||
ProfileDescription,
|
||||
} from "core/config/ProfileLifecycleManager";
|
||||
import { ControlPlaneSessionInfo } from "core/control-plane/client";
|
||||
import React, {
|
||||
createContext,
|
||||
|
|
@ -28,6 +31,8 @@ interface AuthContextType {
|
|||
selectedProfile: ProfileDescription | undefined;
|
||||
profiles: ProfileDescription[];
|
||||
controlServerBetaEnabled: boolean;
|
||||
organizations: OrganizationDescription[];
|
||||
selectedOrganization: OrganizationDescription | undefined;
|
||||
}
|
||||
|
||||
const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
||||
|
|
@ -39,6 +44,20 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
undefined,
|
||||
);
|
||||
|
||||
const [organizations, setOrganizations] = useState<OrganizationDescription[]>(
|
||||
[],
|
||||
);
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const selectedOrganizationId = useAppSelector(
|
||||
(store) => store.session.selectedOrganizationId,
|
||||
);
|
||||
|
||||
const selectedOrganization = useMemo(() => {
|
||||
return organizations.find((p) => p.id === selectedOrganizationId);
|
||||
}, [organizations, selectedOrganizationId]);
|
||||
|
||||
const profiles = useAppSelector(selectAvailableProfiles);
|
||||
|
||||
const selectedProfileId = useAppSelector(
|
||||
|
|
@ -48,13 +67,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
return profiles.find((p) => p.id === selectedProfileId);
|
||||
}, [profiles, selectedProfileId]);
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const lastControlServerBetaEnabledStatus = useAppSelector(
|
||||
(state) => state.misc.lastControlServerBetaEnabledStatus,
|
||||
);
|
||||
|
||||
const login: AuthContextType["login"] = (useOnboarding: boolean) => {
|
||||
return new Promise((resolve) => {
|
||||
ideMessenger
|
||||
|
|
@ -142,11 +156,23 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
enableControlServerBeta || continueTestEnvironment !== "none";
|
||||
setControlServerBetaEnabled(enabled);
|
||||
dispatch(setLastControlServerBetaEnabledStatus(enabled));
|
||||
|
||||
const shouldShowPopup = !lastControlServerBetaEnabledStatus && enabled;
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (session) {
|
||||
ideMessenger
|
||||
.request("controlPlane/listOrganizations", undefined)
|
||||
.then((result) => {
|
||||
if (result.status === "success") {
|
||||
setOrganizations(result.content);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setOrganizations([]);
|
||||
}
|
||||
}, [session]);
|
||||
|
||||
useWebviewListener(
|
||||
"didChangeIdeSettings",
|
||||
async (msg) => {
|
||||
|
|
@ -185,6 +211,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
login,
|
||||
selectedProfile,
|
||||
profiles,
|
||||
selectedOrganization,
|
||||
organizations,
|
||||
controlServerBetaEnabled,
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ function EditorInset() {
|
|||
console.log("Enter: ", e, modifiers);
|
||||
}}
|
||||
historyKey="chat"
|
||||
inputId="editor-inset"
|
||||
/>
|
||||
</EditorInsetDiv>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
--button-color: rgb(113, 28, 59);
|
||||
--button-color-hover: rgba(113, 28, 59, 0.667);
|
||||
--def-border-radius: 5px;
|
||||
|
||||
--vscode-editor-background: rgb(30, 30, 30);
|
||||
--vscode-editor-foreground: rgb(197, 200, 198);
|
||||
--vscode-textBlockQuote-background: rgba(255, 255, 255, 1);
|
||||
|
|
@ -103,3 +102,32 @@ body {
|
|||
direction: rtl;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.scroll-container {
|
||||
overflow-y: auto; /* Enable vertical scrolling only if needed */
|
||||
scrollbar-width: thin; /* Firefox */
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.scroll-container::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.scroll-container::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.scroll-container::-webkit-scrollbar-thumb {
|
||||
background-color: #888;
|
||||
border-radius: 4px;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.scroll-container::-webkit-scrollbar-thumb:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
.scroll-container:is(:hover, :focus)::-webkit-scrollbar {
|
||||
display: block; /* Show scrollbar only on hover or focus */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ const modelsByProvider: Record<string, ModelPackage[]> = {
|
|||
models.mistralLarge,
|
||||
],
|
||||
Cohere: [models.commandR, models.commandRPlus],
|
||||
DeepSeek: [models.deepseekCoderApi, models.deepseekChatApi],
|
||||
DeepSeek: [models.deepseekCoderApi, models.deepseekChatApi, models.deepseekReasonerApi],
|
||||
Gemini: [models.geminiPro, models.gemini15Pro, models.gemini15Flash],
|
||||
"Open Source": [models.llama3Chat, models.mistralOs, models.deepseek],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -230,6 +230,19 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
providerOptions: ["deepseek"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
deepseekReasonerApi: {
|
||||
title: "DeepSeek Reasoner",
|
||||
description:
|
||||
"An open-source reasoning model which generates a chain of thought to enhance the accuracy of its responses.",
|
||||
params: {
|
||||
title: "DeepSeek Reasoner",
|
||||
model: "deepseek-reasoner",
|
||||
contextLength: 64_000,
|
||||
},
|
||||
icon: "deepseek.png",
|
||||
providerOptions: ["deepseek"],
|
||||
isOpenSource: true,
|
||||
},
|
||||
deepseekCoder2Lite: {
|
||||
title: "DeepSeek Coder 2 Lite",
|
||||
description:
|
||||
|
|
@ -1228,6 +1241,21 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksagegpto3mini: {
|
||||
title: "GPT-o3-mini",
|
||||
description:
|
||||
"o3-mini can outperform o1 in coding and other reasoning tasks, and is 93% cheaper and has lower latency. It supports function calling, Structured Outputs, streaming, and developer messages. o3-mini comes with a larger context window of 200,000 tokens and a max output of 100,000 tokens",
|
||||
params: {
|
||||
model: "gpt-o3-mini",
|
||||
contextLength: 200_000,
|
||||
title: "GPT-o3-mini",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
asksageclaude35gov: {
|
||||
title: "Claude 3.5 Sonnet gov",
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
|
|||
required: true,
|
||||
},
|
||||
],
|
||||
packages: [models.deepseekCoderApi, models.deepseekChatApi],
|
||||
packages: [models.deepseekCoderApi, models.deepseekChatApi, models.deepseekReasonerApi],
|
||||
apiKeyUrl: "https://platform.deepseek.com/api_keys",
|
||||
},
|
||||
together: {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ function MorePage() {
|
|||
|
||||
return (
|
||||
<div className="overflow-y-scroll">
|
||||
<PageHeader onClick={() => navigate("/")} title="Chat" />
|
||||
<PageHeader onTitleClick={() => navigate("/")} title="Chat" />
|
||||
|
||||
<div className="gap-2 divide-x-0 divide-y-2 divide-solid divide-zinc-700 px-4">
|
||||
<div className="py-5">
|
||||
|
|
|
|||
87
gui/src/pages/config/ScopeSelect.tsx
Normal file
87
gui/src/pages/config/ScopeSelect.tsx
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
// gui/src/pages/config/ScopeSelect.tsx
|
||||
|
||||
import { Listbox } from "@headlessui/react";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
UserCircleIcon,
|
||||
CubeIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState } from "react";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setSelectedOrganizationId } from "../../redux/slices/sessionSlice";
|
||||
|
||||
export function ScopeSelect() {
|
||||
const { organizations, selectedOrganization } = useAuth();
|
||||
const [value, setValue] = useState<string>(
|
||||
selectedOrganization?.id || "personal",
|
||||
);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const handleChange = (newValue: string) => {
|
||||
setValue(newValue);
|
||||
dispatch(
|
||||
setSelectedOrganizationId(newValue === "personal" ? null : newValue),
|
||||
);
|
||||
};
|
||||
const selectedDisplay =
|
||||
value === "personal"
|
||||
? { name: "Personal", iconUrl: null }
|
||||
: organizations.find((org) => org.id === value);
|
||||
|
||||
return (
|
||||
<Listbox value={value} onChange={handleChange}>
|
||||
<div className="relative">
|
||||
<Listbox.Button className="border-vsc-foreground text-vsc-foreground hover:bg-vsc-background flex w-full cursor-pointer items-center gap-0.5 rounded border bg-transparent p-2 hover:opacity-90">
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
{selectedDisplay?.iconUrl ? (
|
||||
<img src={selectedDisplay.iconUrl} alt="" className="h-5 w-5" />
|
||||
) : (
|
||||
<UserCircleIcon className="h-5 w-5" />
|
||||
)}
|
||||
<span className="truncate">
|
||||
{selectedDisplay?.name || "Select Organization"}
|
||||
</span>
|
||||
</div>
|
||||
<ChevronDownIcon className="h-4 w-4" aria-hidden="true" />
|
||||
</div>
|
||||
</Listbox.Button>
|
||||
|
||||
<Listbox.Options className="bg-vsc-input-background absolute z-50 mt-1 w-full min-w-[200px] list-none overflow-auto rounded p-0 shadow-lg">
|
||||
<div className="text-vsc-foreground p-2 font-semibold">
|
||||
Organizations
|
||||
</div>
|
||||
{organizations.map((org) => (
|
||||
<Listbox.Option
|
||||
key={org.id}
|
||||
value={org.id}
|
||||
className="text-vsc-foreground hover:bg-lightgray/20 cursor-pointer rounded p-2 hover:opacity-90"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
{org.iconUrl ? (
|
||||
<img src={org.iconUrl} alt="" className="h-5 w-5" />
|
||||
) : (
|
||||
<CubeIcon className="h-5 w-5" />
|
||||
)}
|
||||
<span>{org.name}</span>
|
||||
</div>
|
||||
</Listbox.Option>
|
||||
))}
|
||||
|
||||
<div className="bg-lightgray mx-1 my-1 h-px" />
|
||||
|
||||
<Listbox.Option
|
||||
value="personal"
|
||||
className="text-vsc-foreground hover:bg-lightgray/20 cursor-pointer rounded p-2 hover:opacity-90"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<UserCircleIcon className="h-5 w-5" />
|
||||
<span>Personal</span>
|
||||
</div>
|
||||
</Listbox.Option>
|
||||
</Listbox.Options>
|
||||
</div>
|
||||
</Listbox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,21 +1,23 @@
|
|||
import { useContext, useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import PageHeader from "../../components/PageHeader";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useNavigationListener } from "../../hooks/useNavigationListener";
|
||||
import PageHeader from "../../components/PageHeader";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
|
||||
import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
modifyContinueConfigWithSharedConfig,
|
||||
SharedConfigSchema,
|
||||
modifyContinueConfigWithSharedConfig,
|
||||
} from "core/config/sharedConfig";
|
||||
import { updateConfig } from "../../redux/slices/configSlice";
|
||||
import ToggleSwitch from "../../components/gui/Switch";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { Button, Input } from "../../components";
|
||||
import { getFontSize } from "../../util";
|
||||
import { Input, SecondaryButton } from "../../components";
|
||||
import NumberInput from "../../components/gui/NumberInput";
|
||||
import { Select } from "../../components/gui/Select";
|
||||
import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import ToggleSwitch from "../../components/gui/Switch";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { updateConfig } from "../../redux/slices/configSlice";
|
||||
import { getFontSize } from "../../util";
|
||||
import { ScopeSelect } from "./ScopeSelect";
|
||||
|
||||
function ConfigPage() {
|
||||
useNavigationListener();
|
||||
|
|
@ -23,7 +25,7 @@ function ConfigPage() {
|
|||
const navigate = useNavigate();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const { selectedProfile } = useAuth();
|
||||
const { selectedProfile, selectedOrganization, session } = useAuth();
|
||||
const config = useAppSelector((state) => state.config.config);
|
||||
|
||||
function handleUpdate(sharedConfig: Partial<SharedConfigSchema>) {
|
||||
|
|
@ -50,6 +52,14 @@ function ConfigPage() {
|
|||
config.tabAutocompleteOptions?.multilineCompletions ?? "auto";
|
||||
const fontSize = getFontSize();
|
||||
|
||||
const [hubEnabled, setHubEnabled] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
ideMessenger.ide.getIdeSettings().then(({ continueTestEnvironment }) => {
|
||||
setHubEnabled(continueTestEnvironment === "production");
|
||||
});
|
||||
}, [ideMessenger]);
|
||||
|
||||
// Disable autocomplete
|
||||
const disableAutocompleteInFiles = (
|
||||
config.tabAutocompleteOptions?.disableInFiles ?? []
|
||||
|
|
@ -100,22 +110,57 @@ function ConfigPage() {
|
|||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="overflow-y-scroll px-2">
|
||||
<PageHeader onClick={() => navigate("/")} title="Chat" />
|
||||
<h1 className="text-center">Continue Config</h1>
|
||||
|
||||
{!selectedProfile ? (
|
||||
<p className="text-center">No config profile selected</p>
|
||||
) : (
|
||||
<div className="flex flex-col items-center justify-center gap-2 px-3">
|
||||
if (!selectedProfile) {
|
||||
return (
|
||||
<div className="overflow-y-scroll">
|
||||
<PageHeader onTitleClick={() => navigate("/")} title="Chat" />
|
||||
<div className="px-4">
|
||||
<div>
|
||||
<Button onClick={handleOpenConfig}>
|
||||
{selectedProfile.id === "local" ? "Open Config File" : "Nooooo"}
|
||||
</Button>
|
||||
<h2>Continue Config</h2>
|
||||
</div>
|
||||
<h2 className="text-center">Other Settings</h2>
|
||||
<div className="flex flex-col items-end gap-2">
|
||||
<p className="italic">No config profile selected</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="overflow-y-scroll">
|
||||
<PageHeader onTitleClick={() => navigate("/")} title="Chat" />
|
||||
|
||||
<div className="divide-x-0 divide-y-2 divide-solid divide-zinc-700 px-4">
|
||||
{hubEnabled && !!session && (
|
||||
<div className="flex flex-col gap-4 py-6">
|
||||
<div>
|
||||
<h2 className="mb-1 mt-0">Account</h2>
|
||||
{selectedOrganization?.name && (
|
||||
<span className="text-lightgray">
|
||||
You are currently signed in to{" "}
|
||||
<span className="font-semibold">
|
||||
{selectedOrganization?.name}
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ScopeSelect />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex flex-col gap-4 py-6">
|
||||
<h2 className="mb-1 mt-0">Configuration</h2>
|
||||
|
||||
<SecondaryButton onClick={handleOpenConfig} className="!my-0">
|
||||
Open configuration file
|
||||
</SecondaryButton>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-4 py-6">
|
||||
<div>
|
||||
<h2 className="mb-4 mt-0">User settings</h2>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-4">
|
||||
<ToggleSwitch
|
||||
isToggled={codeWrap}
|
||||
onToggle={() =>
|
||||
|
|
@ -202,7 +247,7 @@ function ConfigPage() {
|
|||
text="Use Chromium for Docs Crawling"
|
||||
/>
|
||||
|
||||
<label className="flex items-center justify-end gap-3">
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">Codeblock Actions Position</span>
|
||||
<Select
|
||||
value={codeBlockToolbarPosition}
|
||||
|
|
@ -219,7 +264,7 @@ function ConfigPage() {
|
|||
</Select>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center justify-end gap-3">
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">Multiline Autocompletions</span>
|
||||
<Select
|
||||
value={useAutocompleteMultilineCompletions}
|
||||
|
|
@ -238,7 +283,7 @@ function ConfigPage() {
|
|||
</Select>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center justify-end gap-3">
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">Font Size</span>
|
||||
<NumberInput
|
||||
value={fontSize}
|
||||
|
|
@ -252,95 +297,109 @@ function ConfigPage() {
|
|||
/>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center justify-between gap-3">
|
||||
<span className="text-right">Font Size</span>
|
||||
<NumberInput
|
||||
value={fontSize}
|
||||
onChange={(val) =>
|
||||
handleUpdate({
|
||||
fontSize: val,
|
||||
})
|
||||
}
|
||||
min={7}
|
||||
max={50}
|
||||
/>
|
||||
</label>
|
||||
<form
|
||||
className="flex flex-col items-end gap-1"
|
||||
className="flex flex-col gap-1"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
handleSubmitPromptPath();
|
||||
}}
|
||||
>
|
||||
<label className="flex flex-row items-center justify-end gap-3">
|
||||
<span className="text-right">Workspace prompts path</span>
|
||||
<Input
|
||||
value={formPromptPath}
|
||||
className="max-w-[100px]"
|
||||
onChange={(e) => {
|
||||
setFormPromptPath(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<div className="flex h-full flex-col">
|
||||
{formPromptPath !== promptPath ? (
|
||||
<>
|
||||
<div
|
||||
onClick={handleSubmitPromptPath}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Workspace prompts path</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
value={formPromptPath}
|
||||
className="max-w-[100px]"
|
||||
onChange={(e) => {
|
||||
setFormPromptPath(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<div className="flex h-full flex-col">
|
||||
{formPromptPath !== promptPath ? (
|
||||
<>
|
||||
<div
|
||||
onClick={handleSubmitPromptPath}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
|
||||
</div>
|
||||
<div
|
||||
onClick={cancelChangePromptPath}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
|
||||
</div>
|
||||
<div
|
||||
onClick={cancelChangePromptPath}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form
|
||||
className="flex flex-col items-end gap-1"
|
||||
className="flex flex-col gap-1"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
handleDisableAutocompleteSubmit();
|
||||
}}
|
||||
>
|
||||
<label className="flex flex-row items-center justify-end gap-3">
|
||||
<span className="text-right">
|
||||
Disable autocomplete in files
|
||||
</span>
|
||||
<Input
|
||||
value={formDisableAutocomplete}
|
||||
className="max-w-[100px]"
|
||||
onChange={(e) => {
|
||||
setFormDisableAutocomplete(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<div className="flex h-full flex-col">
|
||||
{formDisableAutocomplete !== disableAutocompleteInFiles ? (
|
||||
<>
|
||||
<div
|
||||
onClick={handleDisableAutocompleteSubmit}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
|
||||
<div className="flex items-center justify-between">
|
||||
<span>Disable autocomplete in files</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
value={formDisableAutocomplete}
|
||||
className="max-w-[100px]"
|
||||
onChange={(e) => {
|
||||
setFormDisableAutocomplete(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<div className="flex h-full flex-col">
|
||||
{formDisableAutocomplete !== disableAutocompleteInFiles ? (
|
||||
<>
|
||||
<div
|
||||
onClick={handleDisableAutocompleteSubmit}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
|
||||
</div>
|
||||
<div
|
||||
onClick={cancelChangeDisableAutocomplete}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
|
||||
</div>
|
||||
<div
|
||||
onClick={cancelChangeDisableAutocomplete}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<CheckIcon className="text-vsc-foreground-muted h-4 w-4" />
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<span className="text-vsc-foreground-muted text-xs">
|
||||
</div>
|
||||
<span className="text-vsc-foreground-muted self-end text-xs">
|
||||
Comma-separated list of path matchers
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ import { ToolCallDiv } from "./ToolCallDiv";
|
|||
import { ToolCallButtons } from "./ToolCallDiv/ToolCallButtonsDiv";
|
||||
import ToolOutput from "./ToolCallDiv/ToolOutput";
|
||||
import FreeTrialOverDialog from "../../components/dialogs/FreeTrialOverDialog";
|
||||
import AssistantSelect from "../../components/modelSelection/platform/AssistantSelect";
|
||||
|
||||
const StopButton = styled.div`
|
||||
background-color: ${vscBackground};
|
||||
|
|
@ -366,17 +367,25 @@ export function Chat() {
|
|||
|
||||
return (
|
||||
<>
|
||||
{isInEditMode && (
|
||||
{(isInEditMode || usePlatform) && (
|
||||
<PageHeader
|
||||
title="Back to Chat"
|
||||
onClick={async () => {
|
||||
await dispatch(loadLastSession({ saveCurrentSession: false }));
|
||||
dispatch(exitEditMode());
|
||||
}}
|
||||
title={isInEditMode ? "Edit Mode" : ""}
|
||||
onTitleClick={
|
||||
isInEditMode
|
||||
? async () => {
|
||||
await dispatch(
|
||||
loadLastSession({ saveCurrentSession: false }),
|
||||
);
|
||||
dispatch(exitEditMode());
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
rightContent={usePlatform && <AssistantSelect />}
|
||||
/>
|
||||
)}
|
||||
|
||||
{widget}
|
||||
|
||||
<StepsDiv
|
||||
ref={stepsDivRef}
|
||||
className={`overflow-y-scroll pt-[8px] ${showScrollbar ? "thin-scrollbar" : "no-scrollbar"} ${history.length > 0 ? "flex-1" : ""}`}
|
||||
|
|
@ -407,6 +416,7 @@ export function Chat() {
|
|||
isMainInput={false}
|
||||
editorState={item.editorState}
|
||||
contextItems={item.contextItems}
|
||||
inputId={item.message.id}
|
||||
/>
|
||||
</>
|
||||
) : item.message.role === "tool" ? (
|
||||
|
|
@ -503,6 +513,7 @@ export function Chat() {
|
|||
onEnter={(editorState, modifiers, editor) =>
|
||||
sendInput(editorState, modifiers, undefined, editor)
|
||||
}
|
||||
inputId={"main-editor"}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export default function HistoryPage() {
|
|||
|
||||
return (
|
||||
<div className="overflow-y-scroll" style={{ fontSize: getFontSize() }}>
|
||||
<PageHeader onClick={() => navigate("/")} title="Chat" />
|
||||
<PageHeader onTitleClick={() => navigate("/")} title="Chat" />
|
||||
<History />
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import { v4 as uuidv4 } from "uuid";
|
|||
import { RootState } from "../store";
|
||||
import { streamResponseThunk } from "../thunks/streamResponse";
|
||||
import { findCurrentToolCall } from "../util";
|
||||
import { OrganizationDescription } from "core/config/ProfileLifecycleManager";
|
||||
|
||||
// We need this to handle reorderings (e.g. a mid-array deletion) of the messages array.
|
||||
// The proper fix is adding a UUID to all chat messages, but this is the temp workaround.
|
||||
|
|
@ -46,6 +47,8 @@ type SessionState = {
|
|||
id: string;
|
||||
selectedProfileId: string;
|
||||
availableProfiles: ProfileDescription[];
|
||||
selectedOrganizationId: string | null;
|
||||
availableOrganizations: OrganizationDescription[];
|
||||
streamAborter: AbortController;
|
||||
codeToEdit: CodeToEdit[];
|
||||
curCheckpointIndex: number;
|
||||
|
|
@ -57,6 +60,7 @@ type SessionState = {
|
|||
states: ApplyState[];
|
||||
curIndex: number;
|
||||
};
|
||||
newestCodeblockForInput: Record<string, string>;
|
||||
};
|
||||
|
||||
function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) {
|
||||
|
|
@ -96,8 +100,11 @@ const initialState: SessionState = {
|
|||
packageSlug: "",
|
||||
versionSlug: "",
|
||||
},
|
||||
iconUrl: "",
|
||||
},
|
||||
],
|
||||
selectedOrganizationId: "",
|
||||
availableOrganizations: [],
|
||||
curCheckpointIndex: 0,
|
||||
streamAborter: new AbortController(),
|
||||
codeToEdit: [],
|
||||
|
|
@ -108,6 +115,7 @@ const initialState: SessionState = {
|
|||
curIndex: 0,
|
||||
},
|
||||
lastSessionId: undefined,
|
||||
newestCodeblockForInput: {},
|
||||
};
|
||||
|
||||
export const sessionSlice = createSlice({
|
||||
|
|
@ -368,9 +376,13 @@ export const sessionSlice = createSlice({
|
|||
startAt: Date.now(),
|
||||
active: true,
|
||||
text: messageContent.replace("<think>", "").trim(),
|
||||
}
|
||||
} else if (lastItem.reasoning?.active && messageContent.includes("</think>")) {
|
||||
const [reasoningEnd, answerStart] = messageContent.split("</think>");
|
||||
};
|
||||
} else if (
|
||||
lastItem.reasoning?.active &&
|
||||
messageContent.includes("</think>")
|
||||
) {
|
||||
const [reasoningEnd, answerStart] =
|
||||
messageContent.split("</think>");
|
||||
lastItem.reasoning.text += reasoningEnd.trimEnd();
|
||||
lastItem.reasoning.active = false;
|
||||
lastItem.reasoning.endAt = Date.now();
|
||||
|
|
@ -552,6 +564,29 @@ export const sessionSlice = createSlice({
|
|||
: payload[0]?.id,
|
||||
};
|
||||
},
|
||||
setSelectedOrganizationId: (
|
||||
state,
|
||||
{ payload }: PayloadAction<string | null>,
|
||||
) => {
|
||||
return {
|
||||
...state,
|
||||
selectedOrganizationId: payload,
|
||||
};
|
||||
},
|
||||
setAvailableOrganizations: (
|
||||
state,
|
||||
{ payload }: PayloadAction<OrganizationDescription[]>,
|
||||
) => {
|
||||
return {
|
||||
...state,
|
||||
availableOrganizations: payload,
|
||||
selectedOrganizationId: payload.find(
|
||||
(org) => org.id === state.selectedOrganizationId,
|
||||
)
|
||||
? state.selectedOrganizationId
|
||||
: payload[0]?.id,
|
||||
};
|
||||
},
|
||||
updateCurCheckpoint: (
|
||||
state,
|
||||
{ payload }: PayloadAction<{ filepath: string; content: string }>,
|
||||
|
|
@ -643,6 +678,17 @@ export const sessionSlice = createSlice({
|
|||
setMode: (state, action: PayloadAction<MessageModes>) => {
|
||||
state.mode = action.payload;
|
||||
},
|
||||
setNewestCodeblocksForInput: (
|
||||
state,
|
||||
{
|
||||
payload,
|
||||
}: PayloadAction<{
|
||||
inputId: string;
|
||||
contextItemId: string;
|
||||
}>,
|
||||
) => {
|
||||
state.newestCodeblockForInput[payload.inputId] = payload.contextItemId;
|
||||
},
|
||||
},
|
||||
selectors: {
|
||||
selectIsGatheringContext: (state) => {
|
||||
|
|
@ -669,6 +715,9 @@ export const sessionSlice = createSlice({
|
|||
selectAvailableProfiles: (state) => {
|
||||
return state.availableProfiles;
|
||||
},
|
||||
selectAvailableOrganizations: (state) => {
|
||||
return state.availableOrganizations;
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
addPassthroughCases(builder, [streamResponseThunk]);
|
||||
|
|
@ -720,6 +769,7 @@ export const {
|
|||
clearLastEmptyResponse,
|
||||
setMainEditorContentTrigger,
|
||||
setSelectedProfileId,
|
||||
setSelectedOrganizationId,
|
||||
deleteMessage,
|
||||
setIsGatheringContext,
|
||||
updateCurCheckpoint,
|
||||
|
|
@ -733,6 +783,7 @@ export const {
|
|||
setCalling,
|
||||
cancelToolCall,
|
||||
setAvailableProfiles,
|
||||
setAvailableOrganizations,
|
||||
acceptToolCall,
|
||||
setToolGenerated,
|
||||
setToolCallOutput,
|
||||
|
|
@ -741,6 +792,7 @@ export const {
|
|||
addSessionMetadata,
|
||||
updateSessionMetadata,
|
||||
deleteSessionMetadata,
|
||||
setNewestCodeblocksForInput,
|
||||
} = sessionSlice.actions;
|
||||
|
||||
export const {
|
||||
|
|
@ -749,6 +801,7 @@ export const {
|
|||
selectIsSingleRangeEditOrInsertion,
|
||||
selectHasCodeToEdit,
|
||||
selectAvailableProfiles,
|
||||
selectAvailableOrganizations,
|
||||
} = sessionSlice.selectors;
|
||||
|
||||
export default sessionSlice.reducer;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,12 @@ const rootReducer = combineReducers({
|
|||
});
|
||||
|
||||
const saveSubsetFilters = [
|
||||
createFilter("session", ["history", "sessionId"]),
|
||||
createFilter("session", [
|
||||
"history",
|
||||
"sessionId",
|
||||
"selectedOrganizationId",
|
||||
"selectedProfileId",
|
||||
]),
|
||||
// Don't persist any of the edit state for now
|
||||
createFilter("editModeState", []),
|
||||
createFilter("config", ["defaultModelTitle"]),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import _ from "lodash";
|
||||
import { getLocalStorage } from "./localStorage";
|
||||
import { KeyboardEvent } from "react";
|
||||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
|
||||
type Platform = "mac" | "linux" | "windows" | "unknown";
|
||||
|
||||
|
|
@ -105,3 +106,7 @@ export function updatedObj(old: any, pathToValue: { [key: string]: any }) {
|
|||
|
||||
return newObject;
|
||||
}
|
||||
|
||||
export function isLocalProfile(profile: ProfileDescription): boolean {
|
||||
return profile.id === "local";
|
||||
}
|
||||
|
|
|
|||
15
keycaps-todo.md
Normal file
15
keycaps-todo.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
gui\src\components\mainInput\TutorialCard.tsx
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
gui\src\components\modelSelection\ModelSelect.tsx
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
gui\src\components\modelSelection\platform\AssistantSelect.tsx
|
||||
|
||||
???
|
||||
|
|
@ -97,6 +97,13 @@ export const OpenAi: ModelProvider = {
|
|||
maxCompletionTokens: 65536,
|
||||
recommendedFor: ["chat"],
|
||||
},
|
||||
{
|
||||
model: "o3-mini",
|
||||
displayName: "o3 Mini",
|
||||
contextLength: 128000,
|
||||
maxCompletionTokens: 65536,
|
||||
recommendedFor: ["chat"],
|
||||
},
|
||||
// embed
|
||||
{
|
||||
model: "text-embedding-3-large",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue