update context peek

This commit is contained in:
Test 2024-09-20 10:59:06 -07:00
parent d055e2bc92
commit 127a490e28
3 changed files with 20 additions and 19 deletions

View file

@ -23,8 +23,10 @@ class OSContextProvider extends BaseContextProvider {
return [
{
description: "Your operating system and CPU",
content: `I am running ${platform === "win32" ? "Windows" : platform} on ${cpu}.`,
name: "os",
content: `I am running ${
platform === "win32" ? "Windows" : platform
} on ${cpu}.`,
name: "Operating System",
},
];
}

View file

@ -1,8 +1,4 @@
import {
ChevronDownIcon,
ChevronUpIcon,
CircleStackIcon,
} from "@heroicons/react/24/outline";
import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline";
import { ContextItemWithId } from "core";
import { contextItemToRangeInFileWithContents } from "core/commands/util";
import React, { useContext } from "react";
@ -18,7 +14,7 @@ import { getFontSize } from "../../util";
import FileIcon from "../FileIcon";
import SafeImg from "../SafeImg";
import { INSTRUCTIONS_BASE_ITEM } from "core/context/providers/utils";
import { MapIcon } from "@heroicons/react/24/outline";
import { getIconFromDropdownItem } from "./MentionList";
const ContextItemDiv = styled.div`
cursor: pointer;
@ -53,11 +49,6 @@ interface ContextItemsPeekProps {
contextItems?: ContextItemWithId[];
}
const CONTEXT_PROVIDERS_TO_ICONS: Record<string, any> = {
"repo-map": MapIcon,
database: CircleStackIcon,
};
function filterInstructionContextItem(
contextItems: ContextItemsPeekProps["contextItems"],
) {
@ -118,8 +109,10 @@ const ContextItemsPeek = (props: ContextItemsPeekProps) => {
);
}
const ProviderIcon =
CONTEXT_PROVIDERS_TO_ICONS[contextItem.id.providerTitle];
const ProviderIcon = getIconFromDropdownItem(
contextItem.id.providerTitle,
"contextProvider",
);
if (ProviderIcon) {
return (

View file

@ -44,7 +44,7 @@ import ButtonWithTooltip from "../ButtonWithTooltip";
import FileIcon from "../FileIcon";
import SafeImg from "../SafeImg";
import AddDocsDialog from "../dialogs/AddDocsDialog";
import { ComboBoxItem } from "./types";
import { ComboBoxItem, ComboBoxItemType } from "./types";
const ICONS_FOR_DROPDOWN: { [key: string]: any } = {
file: FolderIcon,
@ -68,6 +68,14 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = {
"/cmd": CommandLineIcon,
};
export function getIconFromDropdownItem(id: string, type: ComboBoxItemType) {
debugger;
return (
ICONS_FOR_DROPDOWN[id] ??
(type === "contextProvider" ? AtSymbolIcon : BoltIcon)
);
}
function DropdownIcon(props: { className?: string; item: ComboBoxItem }) {
if (props.item.type === "action") {
return (
@ -85,9 +93,7 @@ function DropdownIcon(props: { className?: string; item: ComboBoxItem }) {
}
})();
const IconComponent =
ICONS_FOR_DROPDOWN[provider] ??
(props.item.type === "contextProvider" ? AtSymbolIcon : BoltIcon);
const IconComponent = getIconFromDropdownItem(provider, props.item.type);
const fallbackIcon = (
<IconComponent