Merge pull request #4939 from continuedev/dallin/assistant-select

Assistant select and Notch UI tweaks
This commit is contained in:
Dallin Romney 2025-04-01 19:32:39 -07:00 • committed by GitHub
commit d6b9dcb4d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 231 additions and 241 deletions

View file

@ -1,6 +1,6 @@
import { Editor, JSONContent } from "@tiptap/react";
import { ContextItemWithId, InputModifiers } from "core";
import { useMemo, useState } from "react";
import { useMemo } from "react";
import styled, { keyframes } from "styled-components";
import { defaultBorderRadius, vscBackground } from "..";
import { useAppSelector } from "../../redux/hooks";
@ -113,12 +113,10 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
}
: {};
const [lumpOpen, setLumpOpen] = useState(true);
return (
<div className={`${props.hidden ? "hidden" : ""}`}>
<div className={`relative flex flex-col px-2`}>
{props.isMainInput && <Lump open={lumpOpen} setOpen={setLumpOpen} />}
{props.isMainInput && <Lump />}
<GradientBorder
loading={isStreaming && props.isLastUserInput ? 1 : 0}
borderColor={
@ -135,8 +133,6 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
availableSlashCommands={filteredSlashCommands}
historyKey={historyKey}
toolbarOptions={toolbarOptions}
lumpOpen={lumpOpen}
setLumpOpen={setLumpOpen}
inputId={props.inputId}
/>
</GradientBorder>

View file

@ -31,7 +31,7 @@ import { ToolTip } from "../gui/Tooltip";
import ModelSelect from "../modelSelection/ModelSelect";
import ModeSelect from "../modelSelection/ModeSelect";
import { useFontSize } from "../ui/font";
import HoverItem from "./InputToolbar/bottom/HoverItem";
import HoverItem from "./InputToolbar/HoverItem";
const StyledDiv = styled.div<{ isHidden?: boolean }>`
padding-top: 4px;
@ -87,8 +87,6 @@ interface InputToolbarProps {
toolbarOptions?: ToolbarOptions;
disabled?: boolean;
isMainInput?: boolean;
lumpOpen: boolean;
setLumpOpen: (open: boolean) => void;
}
function InputToolbar(props: InputToolbarProps) {

View file

@ -2,10 +2,10 @@ import { InformationCircleIcon } from "@heroicons/react/24/outline";
import { Tool } from "core";
import { useEffect } from "react";
import { useDispatch } from "react-redux";
import { useAppSelector } from "../../../../redux/hooks";
import { addTool, toggleToolSetting } from "../../../../redux/slices/uiSlice";
import { fontSize } from "../../../../util";
import { ToolTip } from "../../../gui/Tooltip";
import { useAppSelector } from "../../../redux/hooks";
import { addTool, toggleToolSetting } from "../../../redux/slices/uiSlice";
import { fontSize } from "../../../util";
import { ToolTip } from "../../gui/Tooltip";
interface ToolDropdownItemProps {
tool: Tool;

View file

@ -1,9 +1,9 @@
import { Tool } from "core";
import { useMemo } from "react";
import { useAppDispatch, useAppSelector } from "../../../../redux/hooks";
import { toggleToolGroupSetting } from "../../../../redux/slices/uiSlice";
import { fontSize } from "../../../../util";
import ToggleSwitch from "../../../gui/Switch";
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
import { toggleToolGroupSetting } from "../../../redux/slices/uiSlice";
import { fontSize } from "../../../util";
import ToggleSwitch from "../../gui/Switch";
import ToolDropdownItem from "./ToolDropdownItem";
export const ToolPermissionsDialog = () => {

View file

@ -1,22 +0,0 @@
import { EllipsisHorizontalIcon } from "@heroicons/react/24/outline";
import { ToolbarOptions } from "../../InputToolbar";
import HoverItem from "../bottom/HoverItem";
interface TopInputToolbarProps {
toolbarOptions?: ToolbarOptions;
onAddContextItem?: () => void;
lumpOpen: boolean;
setLumpOpen: (open: boolean) => void;
}
export function TopInputToolbar(props: TopInputToolbarProps) {
return (
<div className="-mb-2 -mt-1 flex items-center">
<HoverItem
onClick={() => props.setLumpOpen(!props.lumpOpen)}
className="ml-auto"
>
<EllipsisHorizontalIcon className="h-3 w-3 text-gray-400 hover:brightness-125" />
</HoverItem>
</div>
);
}

View file

@ -13,7 +13,7 @@ import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
import { toggleBlockSettingsToolbar } from "../../../redux/slices/uiSlice";
import { fontSize } from "../../../util";
import AssistantSelect from "../../modelSelection/platform/AssistantSelect";
import HoverItem from "../InputToolbar/bottom/HoverItem";
import HoverItem from "../InputToolbar/HoverItem";
interface BlockSettingsToolbarIcon {
tooltip: string;
@ -129,7 +129,7 @@ export function BlockSettingsTopToolbar(props: BlockSettingsTopToolbarProps) {
</div>
</div>
</div>
<div className="ml-auto">
<div>
<AssistantSelect />
</div>
</div>

View file

@ -9,12 +9,7 @@ import { useAppSelector } from "../../../redux/hooks";
import { LumpToolbar } from "./LumpToolbar";
import { SelectedSection } from "./sections/SelectedSection";
interface LumpProps {
open: boolean;
setOpen: (open: boolean) => void;
}
const LumpDiv = styled.div<{ open: boolean }>`
const LumpDiv = styled.div`
background-color: ${vscInputBackground};
margin-left: 4px;
margin-right: 4px;
@ -35,33 +30,50 @@ const ContentDiv = styled.div<{ hasSection: boolean; isVisible: boolean }>`
overflow-y: auto;
`;
export function Lump(props: LumpProps) {
const { open, setOpen } = props;
export function Lump() {
const [selectedSection, setSelectedSection] = useState<string | null>(null);
const [displayedSection, setDisplayedSection] = useState<string | null>(null);
const [isVisible, setIsVisible] = useState(false);
const isStreaming = useAppSelector((state) => state.session.isStreaming);
useEffect(() => {
if (!selectedSection) {
return;
}
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === "Escape") {
setSelectedSection(null);
}
};
document.addEventListener("keydown", handleKeyDown);
return () => {
document.removeEventListener("keydown", handleKeyDown);
};
}, [selectedSection]);
useEffect(() => {
if (isStreaming) {
setSelectedSection(null);
}
}, [isStreaming]);
useEffect(() => {
if (selectedSection) {
setDisplayedSection(selectedSection);
setIsVisible(true);
} else {
setIsVisible(false);
// Delay clearing the displayed section until after the fade-out
const timeout = setTimeout(() => {
setDisplayedSection(null);
}, 300); // Match the transition duration
return () => clearTimeout(timeout);
}, 300);
return () => {
clearTimeout(timeout);
};
}
}, [selectedSection]);
if (!open) {
return null;
}
return (
<LumpDiv open={open}>
<LumpDiv>
<div className="mt-0.5 px-2">
<LumpToolbar
selectedSection={selectedSection}
@ -73,9 +85,7 @@ export function Lump(props: LumpProps) {
hasSection={!!selectedSection}
isVisible={isVisible}
>
{!isStreaming && (
<SelectedSection selectedSection={displayedSection} />
)}
<SelectedSection selectedSection={displayedSection} />
</ContentDiv>
</div>
</LumpDiv>

View file

@ -1,4 +1,4 @@
import { ToolPermissionsDialog } from "../../InputToolbar/bottom/ToolPermissionsDialog";
import { ToolPermissionsDialog } from "../../InputToolbar/ToolPermissionsDialog";
interface ToolsSectionProps {}

View file

@ -32,8 +32,6 @@ export interface TipTapEditorProps {
) => void;
editorState?: JSONContent;
toolbarOptions?: ToolbarOptions;
lumpOpen: boolean;
setLumpOpen: (open: boolean) => void;
placeholder?: string;
historyKey: string;
inputId: string;
@ -262,8 +260,6 @@ function TipTapEditor(props: TipTapEditorProps) {
activeKey={activeKey}
hidden={shouldHideToolbar && !props.isMainInput}
onAddContextItem={() => insertCharacterWithWhitespace("@")}
lumpOpen={props.lumpOpen}
setLumpOpen={props.setLumpOpen}
onEnter={onEnterRef.current}
onImageFileSelected={(file) => {
handleImageFile(ideMessenger, file).then((result) => {

View file

@ -1,12 +1,13 @@
import {
ArrowTopRightOnSquareIcon,
BuildingOfficeIcon,
CheckIcon,
ChevronDownIcon,
Cog6ToothIcon,
ExclamationTriangleIcon,
PlusIcon,
} from "@heroicons/react/24/outline";
import { useContext, useEffect, useMemo, useRef, useState } from "react";
import { useContext, useEffect, useMemo, useRef } from "react";
import { useAuth } from "../../../context/Auth";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
import { cycleProfile, selectProfileThunk } from "../../../redux";
@ -35,14 +36,16 @@ import AssistantIcon from "./AssistantIcon";
interface AssistantSelectOptionProps {
profile: ProfileDescription;
selected: boolean;
onClick: () => void;
}
const AssistantSelectOption = ({
profile,
selected,
onClick,
}: AssistantSelectOptionProps) => {
const navigate = useNavigate();
const [hovered, setHovered] = useState(false);
const hasFatalErrors = useMemo(() => {
return !!profile.errors?.find((error) => error.fatal);
@ -72,8 +75,6 @@ const AssistantSelectOption = ({
return (
<ListboxOption
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
value={profile.id}
disabled={hasFatalErrors}
onClick={!hasFatalErrors ? handleOptionClick : undefined}
@ -81,20 +82,22 @@ const AssistantSelectOption = ({
>
<div className="flex w-full flex-col gap-0.5">
<div className="flex w-full items-center justify-between">
<div className="flex w-full items-center">
<div className="flex w-full items-center gap-2">
<div className="mr-2 h-4 w-4 flex-shrink-0">
<AssistantIcon assistant={profile} />
</div>
<span className="line-clamp-1 flex-1">{profile.title}</span>
<span
className={`line-clamp-1 flex-1 ${selected ? "font-bold" : ""}`}
>
{profile.title}
</span>
</div>
<div className="ml-2 flex items-center">
<div className="flex flex-row items-center gap-2">
<div>{selected ? <CheckIcon className="h-3 w-3" /> : null}</div>
{!profile.errors?.length ? (
isLocalProfile(profile) ? (
<Cog6ToothIcon
className="h-3 w-3 flex-shrink-0 cursor-pointer"
style={{
opacity: hovered ? 1 : 0,
}}
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
@ -103,9 +106,6 @@ const AssistantSelectOption = ({
/>
) : (
<ArrowTopRightOnSquareIcon
style={{
opacity: hovered ? 1 : 0,
}}
className="h-3 w-3 flex-shrink-0 cursor-pointer"
onClick={(e) => {
e.stopPropagation();
@ -215,7 +215,7 @@ export default function AssistantSelect() {
return (
<Listbox>
<div className="sm:max-w-4/5 relative flex">
<div className="relative">
<ListboxButton
data-testid="assistant-select-button"
ref={buttonRef}
@ -249,6 +249,7 @@ export default function AssistantSelect() {
key={idx}
profile={profile}
onClick={close}
selected={profile.id === selectedProfile.id}
/>
);
})}

View file

@ -46,7 +46,7 @@ const ListboxOptions = React.forwardRef<HTMLUListElement, ListboxOptionsProps>(
anchor={"bottom start"}
{...props}
className={cn(
"bg-vsc-input-background flex flex-col overflow-auto px-0 shadow-md",
"bg-vsc-input-background flex w-max min-w-[160px] max-w-[400px] flex-col overflow-auto px-0 shadow-md",
props.className,
)}
style={{

View file

@ -101,55 +101,69 @@ export function UserSettingsForm() {
}, [ideMessenger]);
return (
<div className="divide-x-0 divide-y-2 divide-solid divide-zinc-700">
<div className="flex flex-col pt-3">
{/* {selectedProfile && isLocalProfile(selectedProfile) ? (
<div className="flex items-center justify-center">
<SecondaryButton
className="flex flex-row items-center gap-1"
onClick={() => {
ideMessenger.post("config/openProfile", {
profileId: selectedProfile.id,
});
}}
>
<span>Open</span>
<span>Config</span>
<span className="xs:flex hidden">File</span>
</SecondaryButton>
</div>
) : null} */}
{!controlServerBetaEnabled || hubEnabled ? (
<div className="flex flex-col">
<div className="flex flex-col">
<div className="flex flex-col gap-4 py-6">
<div>
<h2 className="mb-2 mt-0">User settings</h2>
</div>
<div className="flex flex-col gap-4 py-4">
<div>
<h2 className="mb-2 mt-0 p-0">User settings</h2>
</div>
<div className="flex flex-col gap-4">
<ToggleSwitch
isToggled={showSessionTabs}
onToggle={() =>
handleUpdate({
showSessionTabs: !showSessionTabs,
})
}
text="Show Session Tabs"
/>
<ToggleSwitch
isToggled={codeWrap}
onToggle={() =>
handleUpdate({
codeWrap: !codeWrap,
})
}
text="Wrap Codeblocks"
/>
<div className="flex flex-col gap-4">
<ToggleSwitch
isToggled={showSessionTabs}
onToggle={() =>
handleUpdate({
showSessionTabs: !showSessionTabs,
})
}
text="Show Session Tabs"
/>
<ToggleSwitch
isToggled={codeWrap}
onToggle={() =>
handleUpdate({
codeWrap: !codeWrap,
})
}
text="Wrap Codeblocks"
/>
<ToggleSwitch
isToggled={showChatScrollbar}
onToggle={() =>
handleUpdate({
showChatScrollbar: !showChatScrollbar,
})
}
text="Show Chat Scrollbar"
/>
<ToggleSwitch
isToggled={readResponseTTS}
onToggle={() =>
handleUpdate({
readResponseTTS: !readResponseTTS,
})
}
text="Text-to-Speech Output"
/>
<ToggleSwitch
isToggled={showChatScrollbar}
onToggle={() =>
handleUpdate({
showChatScrollbar: !showChatScrollbar,
})
}
text="Show Chat Scrollbar"
/>
<ToggleSwitch
isToggled={readResponseTTS}
onToggle={() =>
handleUpdate({
readResponseTTS: !readResponseTTS,
})
}
text="Text-to-Speech Output"
/>
{/* <ToggleSwitch
{/* <ToggleSwitch
isToggled={useChromiumForDocsCrawling}
onToggle={() =>
handleUpdate({
@ -158,46 +172,46 @@ export function UserSettingsForm() {
}
text="Use Chromium for Docs Crawling"
/> */}
<ToggleSwitch
isToggled={!disableSessionTitles}
onToggle={() =>
handleUpdate({
disableSessionTitles: !disableSessionTitles,
})
}
text="Enable Session Titles"
/>
<ToggleSwitch
isToggled={!displayRawMarkdown}
onToggle={() =>
handleUpdate({
displayRawMarkdown: !displayRawMarkdown,
})
}
text="Format Markdown"
/>
<ToggleSwitch
isToggled={!disableSessionTitles}
onToggle={() =>
handleUpdate({
disableSessionTitles: !disableSessionTitles,
})
}
text="Enable Session Titles"
/>
<ToggleSwitch
isToggled={!displayRawMarkdown}
onToggle={() =>
handleUpdate({
displayRawMarkdown: !displayRawMarkdown,
})
}
text="Format Markdown"
/>
<ToggleSwitch
isToggled={allowAnonymousTelemetry}
onToggle={() =>
handleUpdate({
allowAnonymousTelemetry: !allowAnonymousTelemetry,
})
}
text="Allow Anonymous Telemetry"
/>
<ToggleSwitch
isToggled={allowAnonymousTelemetry}
onToggle={() =>
handleUpdate({
allowAnonymousTelemetry: !allowAnonymousTelemetry,
})
}
text="Allow Anonymous Telemetry"
/>
<ToggleSwitch
isToggled={!disableIndexing}
onToggle={() =>
handleUpdate({
disableIndexing: !disableIndexing,
})
}
text="Enable Indexing"
/>
<ToggleSwitch
isToggled={!disableIndexing}
onToggle={() =>
handleUpdate({
disableIndexing: !disableIndexing,
})
}
text="Enable Indexing"
/>
{/* <ToggleSwitch
{/* <ToggleSwitch
isToggled={useAutocompleteCache}
onToggle={() =>
handleUpdate({
@ -207,89 +221,86 @@ export function UserSettingsForm() {
text="Use Autocomplete Cache"
/> */}
<label className="flex items-center justify-between gap-3">
<span className="text-left">Font Size</span>
<NumberInput
value={fontSize}
onChange={(val) =>
handleUpdate({
fontSize: val,
})
}
min={7}
max={50}
<label className="flex items-center justify-between gap-3">
<span className="text-left">Font Size</span>
<NumberInput
value={fontSize}
onChange={(val) =>
handleUpdate({
fontSize: val,
})
}
min={7}
max={50}
/>
</label>
<label className="flex items-center justify-between gap-3">
<span className="line-clamp-1 text-left">
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>
<form
className="flex flex-col gap-1"
onSubmit={(e) => {
e.preventDefault();
handleDisableAutocompleteSubmit();
}}
>
<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);
}}
/>
</label>
<label className="flex items-center justify-between gap-3">
<span className="line-clamp-1 text-left">
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>
<form
className="flex flex-col gap-1"
onSubmit={(e) => {
e.preventDefault();
handleDisableAutocompleteSubmit();
}}
>
<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 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>
)}
</div>
<span className="text-vsc-foreground-muted text-lightgray self-end text-xs">
Comma-separated list of path matchers
</span>
</form>
</div>
</div>
</div>
<span className="text-vsc-foreground-muted text-lightgray self-end text-xs">
Comma-separated list of path matchers
</span>
</form>
</div>
</div>
) : null}