Merge branch 'main' into fix-syntaxhighlighting
This commit is contained in:
commit
fb035dee5e
53 changed files with 811 additions and 699 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";
|
||||
|
||||
|
|
@ -308,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
|
|
@ -1105,7 +1105,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,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -178,6 +178,15 @@ function testLLM(
|
|||
}
|
||||
|
||||
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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 && (
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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" : ""}`}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -97,8 +100,11 @@ const initialState: SessionState = {
|
|||
packageSlug: "",
|
||||
versionSlug: "",
|
||||
},
|
||||
iconUrl: "",
|
||||
},
|
||||
],
|
||||
selectedOrganizationId: "",
|
||||
availableOrganizations: [],
|
||||
curCheckpointIndex: 0,
|
||||
streamAborter: new AbortController(),
|
||||
codeToEdit: [],
|
||||
|
|
@ -370,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();
|
||||
|
|
@ -554,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 }>,
|
||||
|
|
@ -682,6 +715,9 @@ export const sessionSlice = createSlice({
|
|||
selectAvailableProfiles: (state) => {
|
||||
return state.availableProfiles;
|
||||
},
|
||||
selectAvailableOrganizations: (state) => {
|
||||
return state.availableOrganizations;
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
addPassthroughCases(builder, [streamResponseThunk]);
|
||||
|
|
@ -733,6 +769,7 @@ export const {
|
|||
clearLastEmptyResponse,
|
||||
setMainEditorContentTrigger,
|
||||
setSelectedProfileId,
|
||||
setSelectedOrganizationId,
|
||||
deleteMessage,
|
||||
setIsGatheringContext,
|
||||
updateCurCheckpoint,
|
||||
|
|
@ -746,6 +783,7 @@ export const {
|
|||
setCalling,
|
||||
cancelToolCall,
|
||||
setAvailableProfiles,
|
||||
setAvailableOrganizations,
|
||||
acceptToolCall,
|
||||
setToolGenerated,
|
||||
setToolCallOutput,
|
||||
|
|
@ -763,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";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue