feat: org select

This commit is contained in:
Patrick Erichsen 2025-01-31 11:28:31 -08:00
parent fe5925e7e8
commit dc751a3274
4 changed files with 463 additions and 1 deletions

View file

@ -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";

View file

@ -0,0 +1,33 @@
import React from "react";
type ToggleSwitchProps = {
isToggled: boolean;
onToggle: () => void;
text: string;
};
const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
isToggled,
onToggle,
text,
}) => {
return (
<div className="flex cursor-pointer select-none items-center justify-between gap-3">
<span className="truncate-right text-right">{text}</span>
<div>
<div
className={`border-vsc-input-border bg-vsc-input-background flex h-5 w-10 items-center rounded-full border border-solid p-0.5`}
onClick={onToggle}
>
<div className="relative h-full w-full">
<div
className={`absolute left-1/4 top-0 h-full w-1/2 transform rounded-full transition-all ${isToggled ? "translate-x-1/2 bg-green-500" : "-translate-x-1/2 bg-red-500"}`}
/>
</div>
</div>
</div>
</div>
);
};
export default ToggleSwitch;

View file

@ -0,0 +1,58 @@
import { Listbox } from "@headlessui/react";
import {
ChevronDownIcon,
UserCircleIcon,
CubeIcon,
} from "@heroicons/react/24/outline";
import { useState } from "react";
export function ScopeSelect() {
const [value, setValue] = useState("");
const [showAbove, setShowAbove] = useState(false);
return (
<Listbox value={value} onChange={setValue}>
<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">
<CubeIcon className="h-5 w-5" />
<span className="truncate">Continue</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-1 shadow-lg ${showAbove ? "bottom-full mb-1" : ""}`}
>
<div className="text-vsc-foreground p-2 text-[13px] font-medium">
Organizations
</div>
<Listbox.Option
value="continue"
className="text-vsc-foreground hover:bg-lightgray/20 cursor-pointer rounded p-1.5 hover:opacity-90"
>
<div className="flex items-center gap-2">
<CubeIcon className="h-5 w-5" />
<span>Continue</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-1.5 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>
);
}

View file

@ -0,0 +1,371 @@
import { useContext, useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { useNavigationListener } from "../../hooks/useNavigationListener";
import PageHeader from "../../components/PageHeader";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { updateConfig } from "../../redux/slices/configSlice";
import ToggleSwitch from "../../components/gui/Switch";
import { useAuth } from "../../context/Auth";
import { Input, SecondaryButton, Select } from "../../components";
import { getFontSize } from "../../util";
import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { ScopeSelect } from "./ScopeSelect";
function ConfigPage() {
useNavigationListener();
const dispatch = useAppDispatch();
const navigate = useNavigate();
const ideMessenger = useContext(IdeMessengerContext);
const { selectedProfile } = useAuth();
const config = useAppSelector((state) => state.config.config);
function handleUpdate(sharedConfig: Partial<SharedConfigSchema>) {
dispatch(
updateConfig(modifyContinueConfigWithSharedConfig(config, sharedConfig)),
);
ideMessenger.post("config/updateSharedConfig", sharedConfig);
}
const codeWrap = config.ui?.codeWrap ?? false;
const showChatScrollbar = config.ui?.showChatScrollbar ?? false;
const displayRawMarkdown = config.ui?.displayRawMarkdown ?? false;
const disableSessionTitles = config.disableSessionTitles ?? false;
const readResponseTTS = config.experimental?.readResponseTTS ?? false;
const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true;
const disableIndexing = config.disableIndexing ?? false;
const useAutocompleteCache = config.tabAutocompleteOptions?.useCache ?? false;
const useChromiumForDocsCrawling =
config.experimental?.useChromiumForDocsCrawling ?? false;
const codeBlockToolbarPosition = config.ui?.codeBlockToolbarPosition ?? "top";
const useAutocompleteMultilineCompletions =
config.tabAutocompleteOptions?.multilineCompletions ?? "auto";
const fontSize = getFontSize();
// Disable autocomplete
const disableAutocompleteInFiles = (
config.tabAutocompleteOptions?.disableInFiles ?? []
).join(", ");
const [formDisableAutocomplete, setFormDisableAutocomplete] = useState(
disableAutocompleteInFiles,
);
const cancelChangeDisableAutocomplete = () => {
setFormDisableAutocomplete(disableAutocompleteInFiles);
};
const handleDisableAutocompleteSubmit = () => {
handleUpdate({
disableAutocompleteInFiles: formDisableAutocomplete
.split(",")
.map((val) => val.trim())
.filter((val) => !!val),
});
};
useEffect(() => {
// Necessary so that reformatted/trimmed values don't cause dirty state
setFormDisableAutocomplete(disableAutocompleteInFiles);
}, [disableAutocompleteInFiles]);
// Workspace prompts
const promptPath = config.experimental?.promptPath || "";
const [formPromptPath, setFormPromptPath] = useState(promptPath);
const cancelChangePromptPath = () => {
setFormPromptPath(promptPath);
};
const handleSubmitPromptPath = () => {
handleUpdate({
promptPath: formPromptPath || "",
});
};
useEffect(() => {
// Necessary so that reformatted/trimmed values don't cause dirty state
setFormPromptPath(promptPath);
}, [promptPath]);
function handleOpenConfig() {
if (!selectedProfile) {
return;
}
ideMessenger.post("config/openProfile", {
profileId: selectedProfile.id,
});
}
if (!selectedProfile) {
return (
<div className="overflow-y-scroll">
<PageHeader onClick={() => navigate("/")} title="Chat" />
<div className="px-4">
<div>
<h2>Continue Config</h2>
</div>
<p className="italic">No config profile selected</p>
</div>
</div>
);
}
return (
<div className="overflow-y-scroll">
<PageHeader onClick={() => navigate("/")} title="Chat" />
<div className="divide-x-0 divide-y-2 divide-solid divide-zinc-700 px-4">
<div className="flex flex-col gap-4 py-6">
<div>
<h2 className="mb-1 mt-0">Account</h2>
<span className="text-lightgray">
You are currently signed in to{" "}
<span className="font-semibold">ORG_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={() =>
handleUpdate({
codeWrap: !codeWrap,
})
}
text="Wrap Codeblocks"
/>
<ToggleSwitch
isToggled={displayRawMarkdown}
onToggle={() =>
handleUpdate({
displayRawMarkdown: !displayRawMarkdown,
})
}
text="Display Raw Markdown"
/>
<ToggleSwitch
isToggled={allowAnonymousTelemetry}
onToggle={() =>
handleUpdate({
allowAnonymousTelemetry: !allowAnonymousTelemetry,
})
}
text="Allow Anonymous Telemetry"
/>
<ToggleSwitch
isToggled={disableIndexing}
onToggle={() =>
handleUpdate({
disableIndexing: !disableIndexing,
})
}
text="Disable Indexing"
/>
<ToggleSwitch
isToggled={disableSessionTitles}
onToggle={() =>
handleUpdate({
disableSessionTitles: !disableSessionTitles,
})
}
text="Disable Session Titles"
/>
<ToggleSwitch
isToggled={readResponseTTS}
onToggle={() =>
handleUpdate({
readResponseTTS: !readResponseTTS,
})
}
text="Response Text to Speech"
/>
<ToggleSwitch
isToggled={showChatScrollbar}
onToggle={() =>
handleUpdate({
showChatScrollbar: !showChatScrollbar,
})
}
text="Show Chat Scrollbar"
/>
<ToggleSwitch
isToggled={useAutocompleteCache}
onToggle={() =>
handleUpdate({
useAutocompleteCache: !useAutocompleteCache,
})
}
text="Use Autocomplete Cache"
/>
<ToggleSwitch
isToggled={useChromiumForDocsCrawling}
onToggle={() =>
handleUpdate({
useChromiumForDocsCrawling: !useChromiumForDocsCrawling,
})
}
text="Use Chromium for Docs Crawling"
/>
<label className="flex items-center justify-between gap-3">
<span className="text-right">Codeblock Actions Position</span>
<Select
value={codeBlockToolbarPosition}
onChange={(e) =>
handleUpdate({
codeBlockToolbarPosition: e.target.value as
| "top"
| "bottom",
})
}
>
<option value="top">Top</option>
<option value="bottom">Bottom</option>
</Select>
</label>
<label className="flex items-center justify-between gap-3">
<span className="text-right">Multiline Autocompletions</span>
<Select
value={useAutocompleteMultilineCompletions}
onChange={(e) =>
handleUpdate({
useAutocompleteMultilineCompletions: e.target.value as
| "auto"
| "always"
| "never",
})
}
>
<option value="auto">Auto</option>
<option value="always">Always</option>
<option value="never">Never</option>
</Select>
</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"
onSubmit={(e) => {
e.preventDefault();
handleSubmitPromptPath();
}}
>
<label className="flex flex-row items-center justify-between gap-3">
<span>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>
<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>
</label>
</form>
<form
className="flex flex-col items-end gap-1"
onSubmit={(e) => {
e.preventDefault();
handleDisableAutocompleteSubmit();
}}
>
<label className="flex flex-row items-center justify-between gap-3">
<span>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>
<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>
</label>
<span className="text-vsc-foreground-muted text-xs">
Comma-separated list of path matchers
</span>
</form>
</div>
</div>
</div>
</div>
);
}
export default ConfigPage;