merge main and fix assistant select p1

This commit is contained in:
Dallin Romney 2025-03-24 16:01:53 -07:00
commit 42c7dd0dc9
9 changed files with 191 additions and 274 deletions

View file

@ -98,38 +98,38 @@ export function BlockSettingsTopToolbar(props: BlockSettingsTopToolbarProps) {
};
return (
<div className="flex w-full items-center justify-between">
<div className="xs:flex hidden items-center justify-center text-gray-400">
<BlockSettingsToolbarIcon
icon={isExpanded ? ChevronLeftIcon : EllipsisHorizontalIcon}
tooltip={isExpanded ? "Collapse sections" : "Expand sections"}
isSelected={false}
onClick={handleEllipsisClick}
/>
<div
className="flex overflow-hidden transition-all duration-200"
style={{ width: isExpanded ? `160px` : "0px" }}
>
<div className="flex">
{sections.map((section) => (
<BlockSettingsToolbarIcon
key={section.id}
icon={section.icon}
tooltip={section.tooltip}
isSelected={props.selectedSection === section.id}
onClick={() =>
props.setSelectedSection(
props.selectedSection === section.id ? null : section.id,
)
}
/>
))}
<div className="flex items-center justify-between">
<div>
<div className="xs:flex hidden items-center justify-center text-gray-400">
<BlockSettingsToolbarIcon
icon={isExpanded ? ChevronLeftIcon : EllipsisHorizontalIcon}
tooltip={isExpanded ? "Collapse sections" : "Expand sections"}
isSelected={false}
onClick={handleEllipsisClick}
/>
<div
className="flex overflow-hidden transition-all duration-200"
style={{ width: isExpanded ? `160px` : "0px" }}
>
<div className="flex">
{sections.map((section) => (
<BlockSettingsToolbarIcon
key={section.id}
icon={section.icon}
tooltip={section.tooltip}
isSelected={props.selectedSection === section.id}
onClick={() =>
props.setSelectedSection(
props.selectedSection === section.id ? null : section.id,
)
}
/>
))}
</div>
</div>
</div>
</div>
<div className="ml-auto">
<AssistantSelect />
</div>
<AssistantSelect />
</div>
);
}

View file

@ -8,7 +8,7 @@ import {
} from "@heroicons/react/24/outline";
import { MessageModes } from "core";
import { modelSupportsTools } from "core/llm/autodetect";
import { useEffect } from "react";
import { useEffect, useMemo } from "react";
import styled from "styled-components";
import { defaultBorderRadius, lightGray, vscInputBackground } from "..";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
@ -19,6 +19,7 @@ import {
setMode,
} from "../../redux/slices/sessionSlice";
import { getFontSize, getMetaKeyLabel, isJetBrains } from "../../util";
import Shortcut from "../gui/Shortcut";
import {
Listbox,
ListboxButton,
@ -66,7 +67,13 @@ function ModeSelect() {
const mode = useAppSelector(selectCurrentMode);
const selectedModel = useAppSelector(selectDefaultModel);
const agentModeSupported = selectedModel && modelSupportsTools(selectedModel);
const jetbrains = isJetBrains();
const jetbrains = useMemo(() => {
return isJetBrains();
}, []);
const metaKeyLabel = useMemo(() => {
return getMetaKeyLabel();
}, []);
const getModeIcon = (mode: MessageModes) => {
switch (mode) {
@ -151,8 +158,8 @@ function ModeSelect() {
)}
<div className="text-lightgray px-2 py-1">
{getMetaKeyLabel()}
<span>.</span> for next mode
<Shortcut>{metaKeyLabel}</Shortcut>
<Shortcut>.</Shortcut> for next mode
</div>
</ListboxOptions>
</div>

View file

@ -21,7 +21,6 @@ import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
import { fontSize, isMetaEquivalentKeyPressed } from "../../util";
import Shortcut from "../gui/Shortcut";
import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../ui";
import { Divider } from "./platform/shared";
interface ModelOptionProps {
option: Option;
@ -283,8 +282,7 @@ function ModelSelect() {
</div>
<div className="mt-auto">
<Divider className="!my-0" />
<div className="bg-lightgray my-0 h-[0.5px]" />
{selectedProfile?.profileType === "local" && (
<>
<ListboxOption
@ -300,8 +298,7 @@ function ModelSelect() {
</>
)}
<Divider className="!my-0" />
<div className="bg-lightgray my-0 h-[0.5px]" />
<span className="block px-3 py-2" style={{ color: lightGray }}>
<Shortcut>meta '</Shortcut> to toggle model
</span>

View file

@ -4,20 +4,25 @@ import { useContext, useEffect, useRef } from "react";
import { useAuth } from "../../../context/Auth";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
import { cycleProfile } from "../../../redux";
import { useAppDispatch } from "../../../redux/hooks";
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
import { fontSize, isMetaEquivalentKeyPressed } from "../../../util";
import { Popover, PopoverButton, PopoverPanel, Transition } from "../../ui";
import { Listbox, ListboxButton, ListboxOptions, Transition } from "../../ui";
import AssistantIcon from "./AssistantIcon";
import { AssistantSelectOptions } from "./AssistantSelectOptions";
function AssistantSelectButton(props: { selectedProfile: ProfileDescription }) {
const isLumpToolbarExpanded = useAppSelector(
(state) => state.ui.isBlockSettingsToolbarExpanded,
);
return (
<div className="flex max-w-[50vw] items-center gap-0.5">
<div className="mr-1 h-3 w-3 flex-shrink-0 select-none">
<AssistantIcon size={3} assistant={props.selectedProfile} />
<AssistantIcon assistant={props.selectedProfile} />
</div>
<span className="select-none truncate">
<span
className={`select-none truncate ${isLumpToolbarExpanded ? "xs:hidden sm:block" : ""}`}
>
{props.selectedProfile.title}
</span>
<ChevronDownIcon
@ -68,7 +73,7 @@ export default function AssistantSelect() {
orgSlug: selectedOrganization?.slug,
});
}}
className="hover:bg flex cursor-pointer select-none items-center gap-1 whitespace-nowrap text-gray-400"
className="flex cursor-pointer select-none items-center gap-1 whitespace-nowrap text-gray-400"
style={{ fontSize: fontSize(-3) }}
>
<PlusIcon className="h-3 w-3 select-none" /> Create your first assistant
@ -77,19 +82,19 @@ export default function AssistantSelect() {
}
return (
<Popover>
<Listbox>
<div className="relative">
<PopoverButton
<ListboxButton
data-testid="assistant-select-button"
ref={buttonRef}
className="mt-0.5 cursor-pointer border-none bg-transparent text-gray-400 hover:brightness-125"
style={{ fontSize: fontSize(-3) }}
>
<AssistantSelectButton selectedProfile={selectedProfile} />
</PopoverButton>
</ListboxButton>
<Transition>
<PopoverPanel className="bg-vsc-input-background absolute right-0 top-full z-[1000] mr-1 mt-1 flex min-w-[200px] max-w-[90vw] cursor-default flex-row overflow-hidden rounded-md border-2 border-zinc-600 p-0">
<ListboxOptions className="bg-vsc-input-background absolute right-0 top-full z-[1000] mr-1 mt-1 flex min-w-[200px] max-w-[90vw] cursor-default flex-row overflow-hidden rounded-md border-2 border-zinc-600 p-0">
<AssistantSelectOptions
onClose={() => {
if (buttonRef.current) {
@ -97,9 +102,9 @@ export default function AssistantSelect() {
}
}}
/>
</PopoverPanel>
</ListboxOptions>
</Transition>
</div>
</Popover>
</Listbox>
);
}

View file

@ -9,8 +9,40 @@ import { selectProfileThunk } from "../../../redux";
import { useAppDispatch } from "../../../redux/hooks";
import { getFontSize, getMetaKeyLabel, isLocalProfile } from "../../../util";
import { ROUTES } from "../../../util/navigation";
import { ToolTip } from "../../gui/Tooltip";
import { ListboxOption } from "../../ui";
import AssistantIcon from "./AssistantIcon";
import { Divider, Option, OptionDiv } from "./shared";
import {
ArrowTopRightOnSquareIcon,
Cog6ToothIcon,
ExclamationTriangleIcon,
} from "@heroicons/react/24/outline";
// const IconBase = styled.div<{ $hovered: boolean }>`
// `;
// const StyledCog6ToothIcon = styled(IconBase).attrs({ as: Cog6ToothIcon })``;
// const StyledArrowTopRightOnSquareIcon = styled(IconBase).attrs({
// as: ArrowTopRightOnSquareIcon,
// })``;
// const StyledExclamationTriangleIcon = styled(IconBase).attrs({
// as: ExclamationTriangleIcon,
// })``;
// width: 1.2em;
// height: 1.2em;
// cursor: pointer;
// padding: 4px;
// border-radius: ${defaultBorderRadius};
// opacity: ${(props) => (props.$hovered ? 0.75 : 0)};
// visibility: ${(props) => (props.$hovered ? "visible" : "hidden")};
// &:hover {
// opacity: 1;
// background-color: ${lightGray}33;
// }
interface AssistantSelectOptionsProps {
onClose: () => void;
@ -51,42 +83,82 @@ export function AssistantSelectOptions({
<div className="border-lightgray flex w-full flex-col overflow-x-hidden pt-0">
<div className={`max-h-[300px] w-full`}>
{profiles.map((profile, idx) => {
const disabled = !!profile.errors?.length;
const showConfigure = isLocalProfile(profile);
// const [hovered, setHovered] = useState(false);
function handleOptionClick(e: any) {
if (disabled) {
e.preventDefault();
e.stopPropagation();
}
dispatch(selectProfileThunk(profile.id));
onClose();
}
return (
<Option
<ListboxOption
value={profile.id}
key={idx}
idx={idx}
disabled={!!profile.errors?.length}
showConfigure={isLocalProfile(profile)}
selected={profile.id === selectedProfile?.id}
onOpenConfig={() => {
handleConfigure(profile);
}}
errors={profile.errors}
onClickError={() => handleClickError(profile.id)}
onClick={() => {
dispatch(selectProfileThunk(profile.id));
onClose();
}}
disabled={disabled}
onClick={!disabled ? handleOptionClick : undefined}
>
<div className="flex w-full items-center">
<div className="mr-2 h-4 w-4 flex-shrink-0">
<AssistantIcon assistant={profile} />
<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="mr-2 h-4 w-4 flex-shrink-0">
<AssistantIcon assistant={profile} />
</div>
<span
className="flex-1 truncate"
style={{ fontSize: getFontSize() - 2 }}
>
{profile.title}
</span>
</div>
<div className="ml-2 flex items-center">
{!profile.errors?.length ? (
showConfigure ? (
<Cog6ToothIcon
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
handleConfigure(profile);
}}
/>
) : (
<ArrowTopRightOnSquareIcon
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
handleConfigure(profile);
}}
/>
)
) : (
<>
<ExclamationTriangleIcon
data-tooltip-id={`${idx}-errors-tooltip`}
className="cursor-pointer text-red-500"
onClick={() => handleClickError(profile.id)}
/>
<ToolTip id={`${idx}-errors-tooltip`}>
<div className="font-semibold">Errors</div>
{JSON.stringify(profile.errors, null, 2)}
</ToolTip>
</>
)}
</div>
</div>
<span
className="flex-1 truncate"
style={{ fontSize: getFontSize() - 2 }}
>
{profile.title}
</span>
</div>
</Option>
</ListboxOption>
);
})}
</div>
<div className="mt-auto w-full">
<OptionDiv
key={"new-assistant"}
<ListboxOption
value={"new-assistant"}
onClick={session ? onNewAssistant : () => login(false)}
>
<div
@ -96,9 +168,9 @@ export function AssistantSelectOptions({
<PlusIcon className="mr-2 h-4 w-4 flex-shrink-0" />
New Assistant
</div>
</OptionDiv>
</ListboxOption>
<Divider className="!my-0" />
<div className="bg-lightgray my-0 h-[0.5px]" />
<div
className="flex items-center justify-between p-2"

View file

@ -1,159 +0,0 @@
import { ConfigValidationError } from "@continuedev/config-yaml";
import {
ArrowTopRightOnSquareIcon,
Cog6ToothIcon,
ExclamationTriangleIcon,
} from "@heroicons/react/24/outline";
import { useState } from "react";
import styled from "styled-components";
import { defaultBorderRadius, lightGray } from "../..";
import { ToolTip } from "../../gui/Tooltip";
export const OptionDiv = styled.div<{
isDisabled?: boolean;
isSelected?: boolean;
}>`
padding: 6px 12px;
min-width: 0px;
${({ isDisabled, isSelected }) =>
!isDisabled &&
`
cursor: pointer;
&:hover {
background: ${lightGray}33;
}
${
isSelected &&
`
background: ${lightGray}22;
`
}
`}
${({ isDisabled }) =>
isDisabled &&
`
opacity: 0.5;
`}
`;
export const MAX_HEIGHT_PX = 300;
export const Divider = styled.div`
height: 0.5px;
background-color: ${lightGray};
`;
interface ModelOptionProps {
children: React.ReactNode;
idx: number;
disabled: boolean;
selected: boolean;
showConfigure: boolean;
onOpenConfig: () => void;
onClick: () => void;
errors?: ConfigValidationError[];
onClickError?: (e: any) => void;
}
const IconBase = styled.div<{ $hovered: boolean }>`
width: 1.2em;
height: 1.2em;
cursor: pointer;
padding: 4px;
border-radius: ${defaultBorderRadius};
opacity: ${(props) => (props.$hovered ? 0.75 : 0)};
visibility: ${(props) => (props.$hovered ? "visible" : "hidden")};
&:hover {
opacity: 1;
background-color: ${lightGray}33;
}
`;
const StyledCog6ToothIcon = styled(IconBase).attrs({ as: Cog6ToothIcon })``;
const StyledArrowTopRightOnSquareIcon = styled(IconBase).attrs({
as: ArrowTopRightOnSquareIcon,
})``;
const StyledExclamationTriangleIcon = styled(IconBase).attrs({
as: ExclamationTriangleIcon,
})``;
export function Option({
children,
idx,
disabled,
onClick,
showConfigure,
selected,
errors,
onClickError,
onOpenConfig,
}: ModelOptionProps) {
const [hovered, setHovered] = useState(false);
function handleOptionClick(e: any) {
if (disabled) {
e.preventDefault();
e.stopPropagation();
}
onClick();
}
return (
<OptionDiv
key={idx}
isDisabled={disabled}
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
isSelected={selected}
onClick={!disabled ? handleOptionClick : undefined}
>
<div className="flex w-full flex-col gap-0.5">
<div className="flex w-full items-center justify-between">
{children}
<div className="ml-2 flex items-center">
{!errors?.length ? (
showConfigure ? (
<StyledCog6ToothIcon
$hovered={hovered}
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
onOpenConfig();
}}
/>
) : (
<StyledArrowTopRightOnSquareIcon
$hovered={hovered}
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
onOpenConfig();
}}
/>
)
) : (
<>
<StyledExclamationTriangleIcon
data-tooltip-id={`${idx}-errors-tooltip`}
$hovered={hovered}
className="cursor-pointer text-red-500"
onClick={onClickError}
/>
<ToolTip id={`${idx}-errors-tooltip`}>
<div className="font-semibold">Errors</div>
{JSON.stringify(errors, null, 2)}
</ToolTip>
</>
)}
</div>
</div>
</div>
</OptionDiv>
);
}

View file

@ -1,3 +1,4 @@
import { useMemo } from "react";
import styled from "styled-components";
import {
defaultBorderRadius,
@ -7,16 +8,6 @@ import {
import { ToolTip } from "../../components/gui/Tooltip";
import { getPlatform, isJetBrains } from "../../util";
const GridDiv = styled.div`
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
grid-gap: 1rem;
padding: 1rem 0;
justify-items: center;
align-items: center;
overflow-x: hidden;
`;
const StyledKeyDiv = styled.div`
border: 0.5px solid ${lightGray};
border-radius: ${defaultBorderRadius};
@ -64,9 +55,9 @@ interface KeyboardShortcutProps {
function KeyboardShortcut(props: KeyboardShortcutProps) {
const shortcut = getPlatform() === "mac" ? props.mac : props.windows;
return (
<div className="flex w-full items-center justify-between gap-x-4">
<span className="text-xs">{props.description}</span>
<div className="float-right flex gap-2">
<div className="flex w-full flex-wrap items-center justify-between gap-x-4 gap-y-1">
<span className="max-w-60 text-xs">{props.description}:</span>
<div className="flex flex-1 flex-row items-center justify-end gap-1.5">
{shortcut.split(" ").map((key, i) => {
return <KeyDiv key={i} text={key}></KeyDiv>;
})}
@ -201,23 +192,25 @@ const jetbrainsShortcuts: KeyboardShortcutProps[] = [
];
function KeyboardShortcuts() {
const shortcuts = useMemo(() => {
return isJetBrains() ? jetbrainsShortcuts : vscodeShortcuts;
}, []);
return (
<div>
<div className="flex max-w-[400px] flex-col">
<h3 className="mx-auto mb-1 text-xl">Keyboard shortcuts</h3>
<GridDiv>
{(isJetBrains() ? jetbrainsShortcuts : vscodeShortcuts).map(
(shortcut, i) => {
return (
<KeyboardShortcut
key={i}
mac={shortcut.mac}
windows={shortcut.windows}
description={shortcut.description}
/>
);
},
)}
</GridDiv>
<div className="flex flex-col items-center justify-center gap-x-3 gap-y-3 p-1">
{shortcuts.map((shortcut, i) => {
return (
<KeyboardShortcut
key={i}
mac={shortcut.mac}
windows={shortcut.windows}
description={shortcut.description}
/>
);
})}
</div>
</div>
);
}

View file

@ -32,30 +32,32 @@ function ConfigPage() {
id: "settings",
label: "Settings",
component: <UserSettingsForm />,
icon: <Cog6ToothIcon className="h-4 w-4 flex-shrink-0" />,
icon: <Cog6ToothIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
},
{
id: "indexing",
label: "Indexing",
component: <IndexingSettingsSection />,
icon: <CircleStackIcon className="h-4 w-4 flex-shrink-0" />,
icon: <CircleStackIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
},
{
id: "help",
label: "Help",
component: <HelpCenterSection />,
icon: <QuestionMarkCircleIcon className="h-4 w-4 flex-shrink-0" />,
icon: (
<QuestionMarkCircleIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
),
},
{
id: "shortcuts",
label: "Shortcuts",
component: <KeyboardShortcuts />,
icon: <AcademicCapIcon className="h-4 w-4 flex-shrink-0" />,
icon: <AcademicCapIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
},
];
return (
<div className="flex h-full flex-col">
<div className="flex h-full flex-col overflow-y-auto">
<div className="bg-vsc-background sticky top-0 z-10">
<PageHeader
showBorder
@ -65,14 +67,14 @@ function ConfigPage() {
/>
{/* Tab Headers */}
<div className="grid w-full grid-cols-2 border-0 border-b-[1px] border-solid border-b-zinc-700 sm:flex sm:justify-center">
<div className="grid grid-cols-2 border-0 border-b-[1px] border-solid border-b-zinc-700 p-0.5 sm:flex sm:justify-center md:gap-x-2">
{tabs.map((tab) => (
<div
style={{
fontSize: fontSize(-2),
}}
key={tab.id}
className={`hover:bg-vsc-input-background flex cursor-pointer items-center justify-center gap-2 rounded-md px-4 py-2 ${
className={`hover:bg-vsc-input-background flex cursor-pointer items-center justify-center gap-1.5 rounded-md px-2 py-2 ${
activeTab === tab.id ? "" : "text-gray-400"
}`}
onClick={() => setActiveTab(tab.id)}
@ -85,7 +87,7 @@ function ConfigPage() {
</div>
{/* Tab Content */}
<div className="flex-1 overflow-y-auto overflow-x-hidden px-4">
<div className="flex-1 overflow-y-auto px-4">
{tabs.find((tab) => tab.id === activeTab)?.component}
</div>
</div>

View file

@ -292,7 +292,7 @@ export function Chat() {
<StepsDiv
ref={stepsDivRef}
className={`overflow-y-scroll ${showPageHeader ? "" : "pt-[8px]"} ${showScrollbar ? "thin-scrollbar" : "no-scrollbar"} ${history.length > 0 ? "flex-1" : ""}`}
className={`mt-[2px] overflow-y-scroll ${showPageHeader ? "" : "pt-[8px]"} ${showScrollbar ? "thin-scrollbar" : "no-scrollbar"} ${history.length > 0 ? "flex-1" : ""}`}
>
{highlights}
{history.map((item, index: number) => (