💄 file icons, preview context items
This commit is contained in:
parent
80b6a7931b
commit
5ccd1dceac
20 changed files with 884 additions and 724 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
22
gui/package-lock.json
generated
22
gui/package-lock.json
generated
|
|
@ -12,6 +12,7 @@
|
|||
"@reduxjs/toolkit": "^1.9.3",
|
||||
"@types/vscode-webview": "^1.57.1",
|
||||
"@uiw/react-markdown-preview": "^4.1.13",
|
||||
"dompurify": "^3.0.6",
|
||||
"downshift": "^7.6.0",
|
||||
"lodash": "^4.17.21",
|
||||
"meilisearch": "^0.33.0",
|
||||
|
|
@ -26,6 +27,7 @@
|
|||
"react-switch": "^7.0.0",
|
||||
"react-syntax-highlighter": "^15.5.0",
|
||||
"react-tooltip": "^5.18.0",
|
||||
"seti-file-icons": "^0.0.8",
|
||||
"styled-components": "^5.3.6",
|
||||
"vscode-webview": "^1.0.1-beta.1"
|
||||
},
|
||||
|
|
@ -1858,6 +1860,11 @@
|
|||
"integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/dompurify": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.0.6.tgz",
|
||||
"integrity": "sha512-ilkD8YEnnGh1zJ240uJsW7AzE+2qpbOUYjacomn3AvJ6J4JhKGSZ2nh4wUIXPZrEPppaCLx5jFe8T89Rk8tQ7w=="
|
||||
},
|
||||
"node_modules/downshift": {
|
||||
"version": "7.6.2",
|
||||
"resolved": "https://registry.npmjs.org/downshift/-/downshift-7.6.2.tgz",
|
||||
|
|
@ -4573,6 +4580,11 @@
|
|||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/seti-file-icons": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/seti-file-icons/-/seti-file-icons-0.0.8.tgz",
|
||||
"integrity": "sha512-HIK9HMkfhmwCZYeyQFuCAGYdwaK5/tmZBVnQmbGXx9orT2bD0xbKqvJR7q6NmsTbgtLNwBwa+PYnTzUvdExuDQ=="
|
||||
},
|
||||
"node_modules/shallowequal": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz",
|
||||
|
|
@ -6342,6 +6354,11 @@
|
|||
"integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==",
|
||||
"dev": true
|
||||
},
|
||||
"dompurify": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.0.6.tgz",
|
||||
"integrity": "sha512-ilkD8YEnnGh1zJ240uJsW7AzE+2qpbOUYjacomn3AvJ6J4JhKGSZ2nh4wUIXPZrEPppaCLx5jFe8T89Rk8tQ7w=="
|
||||
},
|
||||
"downshift": {
|
||||
"version": "7.6.2",
|
||||
"resolved": "https://registry.npmjs.org/downshift/-/downshift-7.6.2.tgz",
|
||||
|
|
@ -8152,6 +8169,11 @@
|
|||
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
||||
"peer": true
|
||||
},
|
||||
"seti-file-icons": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/seti-file-icons/-/seti-file-icons-0.0.8.tgz",
|
||||
"integrity": "sha512-HIK9HMkfhmwCZYeyQFuCAGYdwaK5/tmZBVnQmbGXx9orT2bD0xbKqvJR7q6NmsTbgtLNwBwa+PYnTzUvdExuDQ=="
|
||||
},
|
||||
"shallowequal": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
"@reduxjs/toolkit": "^1.9.3",
|
||||
"@types/vscode-webview": "^1.57.1",
|
||||
"@uiw/react-markdown-preview": "^4.1.13",
|
||||
"dompurify": "^3.0.6",
|
||||
"downshift": "^7.6.0",
|
||||
"lodash": "^4.17.21",
|
||||
"meilisearch": "^0.33.0",
|
||||
|
|
@ -27,6 +28,7 @@
|
|||
"react-switch": "^7.0.0",
|
||||
"react-syntax-highlighter": "^15.5.0",
|
||||
"react-tooltip": "^5.18.0",
|
||||
"seti-file-icons": "^0.0.8",
|
||||
"styled-components": "^5.3.6",
|
||||
"vscode-webview": "^1.0.1-beta.1"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import {
|
|||
handleKeyDownJetBrains,
|
||||
handleKeyDownJetBrainsMac,
|
||||
} from "../util/jetbrains";
|
||||
import FileIcon from "./FileIcon";
|
||||
|
||||
const SEARCH_INDEX_NAME = "continue_context_items";
|
||||
|
||||
|
|
@ -195,7 +196,8 @@ const Ul = styled.ul<{
|
|||
background: ${vscBackground};
|
||||
color: ${vscForeground};
|
||||
max-height: ${UlMaxHeight}px;
|
||||
width: calc(100% - 16px);
|
||||
margin-left: 1px;
|
||||
width: calc(100% - 18px);
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
padding: 0;
|
||||
|
|
@ -220,15 +222,13 @@ const Li = styled.li<{
|
|||
isLastItem: boolean;
|
||||
}>`
|
||||
background-color: ${({ highlighted }) =>
|
||||
highlighted ? lightGray : secondaryDark};
|
||||
${({ highlighted }) => highlighted && `background: ${vscBackground};`}
|
||||
highlighted ? buttonColor + "66" : secondaryDark};
|
||||
${({ selected }) => selected && "font-weight: bold;"}
|
||||
padding: 0.5rem 0.75rem;
|
||||
padding: 0.5rem 0.5rem;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
${({ isLastItem }) => isLastItem && "border-bottom: 1px solid gray;"}
|
||||
/* border-top: 1px solid gray; */
|
||||
cursor: pointer;
|
||||
z-index: 500;
|
||||
`;
|
||||
|
|
@ -351,11 +351,13 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
useEffect(() => {
|
||||
if (!nestedContextProvider) {
|
||||
setItems(
|
||||
contextProviders?.map((provider) => ({
|
||||
name: provider.display_title,
|
||||
description: provider.description,
|
||||
id: provider.title,
|
||||
})) || []
|
||||
contextProviders
|
||||
?.map((provider) => ({
|
||||
name: provider.display_title,
|
||||
description: provider.description,
|
||||
id: provider.title,
|
||||
}))
|
||||
.sort((c, _) => (c.id === "file" ? -1 : 1)) || []
|
||||
);
|
||||
}
|
||||
}, [nestedContextProvider]);
|
||||
|
|
@ -427,7 +429,8 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
name: provider.display_title,
|
||||
description: provider.description,
|
||||
id: provider.title,
|
||||
})) || [];
|
||||
}))
|
||||
.sort((c, _) => (c.id === "file" ? -1 : 1)) || [];
|
||||
setItems(filteredItems);
|
||||
setCurrentlyInContextQuery(true);
|
||||
}
|
||||
|
|
@ -1238,9 +1241,18 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
inputRef.current?.focus();
|
||||
}}
|
||||
>
|
||||
<span className="flex justify-between w-full">
|
||||
{item.name}
|
||||
{" "}
|
||||
<span className="flex justify-between w-full items-center">
|
||||
<div className="flex items-center justify-center">
|
||||
{nestedContextProvider && (
|
||||
<FileIcon
|
||||
height="20px"
|
||||
width="20px"
|
||||
filename={item.name}
|
||||
></FileIcon>
|
||||
)}
|
||||
{item.name}
|
||||
{" "}
|
||||
</div>
|
||||
<span
|
||||
style={{
|
||||
color: lightGray,
|
||||
|
|
|
|||
31
gui/src/components/FileIcon.tsx
Normal file
31
gui/src/components/FileIcon.tsx
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import React from "react";
|
||||
import DOMPurify from "dompurify";
|
||||
import { themeIcons } from "seti-file-icons";
|
||||
|
||||
const FileIcon = ({ filename, height, width }) => {
|
||||
const getIcon = themeIcons({
|
||||
blue: "#268bd2",
|
||||
grey: "#657b83",
|
||||
"grey-light": "#839496",
|
||||
green: "#859900",
|
||||
orange: "#cb4b16",
|
||||
pink: "#d33682",
|
||||
purple: "#6c71c4",
|
||||
red: "#dc322f",
|
||||
white: "#fdf6e3",
|
||||
yellow: "#b58900",
|
||||
ignore: "#586e75",
|
||||
});
|
||||
// Sanitize the SVG string before rendering it
|
||||
const { svg, color } = getIcon(filename);
|
||||
const sanitizedSVG = DOMPurify.sanitize(svg);
|
||||
|
||||
return (
|
||||
<div
|
||||
dangerouslySetInnerHTML={{ __html: sanitizedSVG }}
|
||||
style={{ width: width, height: height, fill: color }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default FileIcon;
|
||||
|
|
@ -11,13 +11,13 @@ import {
|
|||
TrashIcon,
|
||||
PaintBrushIcon,
|
||||
ExclamationTriangleIcon,
|
||||
EyeIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { GUIClientContext } from "../App";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { ContextItem } from "../schema/FullState";
|
||||
import { getFontSize } from "../util";
|
||||
import HeaderButtonWithText from "./HeaderButtonWithText";
|
||||
import FileIcon from "./FileIcon";
|
||||
|
||||
const Button = styled.button<{ fontSize?: number }>`
|
||||
border: none;
|
||||
|
|
@ -188,17 +188,29 @@ const PillButton = (props: PillButtonProps) => {
|
|||
}}
|
||||
onClick={(e) => {
|
||||
props.onClick?.(e);
|
||||
client?.previewContextItem(
|
||||
`${props.item.description.id.provider_title}-${props.item.description.id.item_id}`
|
||||
);
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
if (!pillContainerRef.current?.contains(e.relatedTarget as any)) {
|
||||
props.onBlur?.();
|
||||
// props.onBlur?.();
|
||||
} else {
|
||||
e.preventDefault();
|
||||
buttonRef.current?.focus();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<span className={isHovered ? "underline" : ""}>
|
||||
<span className={(isHovered ? "underline" : "") + " flex"}>
|
||||
{["file", "code"].includes(
|
||||
props.item.description.id.provider_title
|
||||
) && (
|
||||
<FileIcon
|
||||
height="16px"
|
||||
width="16px"
|
||||
filename={props.item.description.name.split(" ").at(0)}
|
||||
></FileIcon>
|
||||
)}
|
||||
{props.item.description.name}
|
||||
</span>
|
||||
</StyledButton>
|
||||
|
|
@ -226,7 +238,7 @@ const PillButton = (props: PillButtonProps) => {
|
|||
</StyledTooltip>
|
||||
</>
|
||||
)}
|
||||
{(props.focusing || props.previewing) && (
|
||||
{/* {(props.focusing || props.previewing) && (
|
||||
<ClickableInsidePillButton
|
||||
text="View (v)"
|
||||
onClick={() => props.toggleViewContent?.()}
|
||||
|
|
@ -236,7 +248,7 @@ const PillButton = (props: PillButtonProps) => {
|
|||
>
|
||||
<EyeIcon width="1.4em" height="1.4em" />
|
||||
</ClickableInsidePillButton>
|
||||
)}
|
||||
)} */}
|
||||
{props.focusing && (
|
||||
<HoverableInsidePillButton
|
||||
text="Delete (⌫)"
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ const StyledMarkdownPreviewComponent = styled(MarkdownPreview)<{
|
|||
}
|
||||
|
||||
background-color: ${(props) => (props.light ? "transparent" : vscBackground)};
|
||||
font-family: "Lexend", sans-serif;
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
||||
font-size: ${(props) => props.fontSize || getFontSize()}px;
|
||||
padding: 8px;
|
||||
color: ${vscForeground};
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ abstract class AbstractContinueGUIClientProtocol {
|
|||
abstract deleteContextGroup(id: string): void;
|
||||
|
||||
abstract setCurrentSessionTitle(title: string): void;
|
||||
|
||||
abstract previewContextItem(id: string): void;
|
||||
}
|
||||
|
||||
export default AbstractContinueGUIClientProtocol;
|
||||
|
|
|
|||
|
|
@ -195,6 +195,10 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
|
|||
setCurrentSessionTitle(title: string): void {
|
||||
this.messenger?.send("set_current_session_title", { title });
|
||||
}
|
||||
|
||||
previewContextItem(id: string): void {
|
||||
this.messenger?.send("preview_context_item", { id });
|
||||
}
|
||||
}
|
||||
|
||||
export default ContinueGUIClientProtocol;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ body,
|
|||
#root {
|
||||
height: 100%;
|
||||
background-color: var(--vscode-editor-background);
|
||||
font-family: "Lexend", sans-serif;
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
|
|
@ -31,7 +32,7 @@ body {
|
|||
}
|
||||
|
||||
.press-start-2p {
|
||||
font-family: "Press Start 2P", "Lexend", sans-serif;
|
||||
font-family: "Press Start 2P", sans-serif;
|
||||
}
|
||||
|
||||
a:focus {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export function getMetaKeyLabel(): string {
|
|||
|
||||
export function getFontSize(): number {
|
||||
const fontSize = localStorage.getItem("fontSize");
|
||||
return fontSize ? parseInt(fontSize) : 13;
|
||||
return fontSize ? parseInt(fontSize) : 14;
|
||||
}
|
||||
|
||||
export function getMarkdownLanguageTagForFile(filepath: string): string {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import asyncio
|
|||
import time
|
||||
from abc import abstractmethod
|
||||
from typing import Awaitable, Callable, Dict, List, Optional
|
||||
from ..server.ide_protocol import AbstractIdeProtocolServer
|
||||
|
||||
from meilisearch_python_async import Client
|
||||
from pydantic import BaseModel, Field
|
||||
|
|
@ -196,6 +197,15 @@ class ContextProvider(BaseModel):
|
|||
|
||||
self.selected_items.append(context_item)
|
||||
|
||||
async def preview_contents(self, id: ContextItemId):
|
||||
"""
|
||||
Open a virtual file or otherwise preview the contents of the context provider in the IDE
|
||||
"""
|
||||
if item := next(
|
||||
filter(lambda x: x.description.id == id, self.selected_items), None
|
||||
):
|
||||
await self.sdk.ide.showVirtualFile(item.description.name, item.content)
|
||||
|
||||
|
||||
class ContextManager:
|
||||
"""
|
||||
|
|
@ -512,6 +522,18 @@ class ContextManager:
|
|||
item.description.id.provider_title
|
||||
].manually_add_context_item(item)
|
||||
|
||||
async def preview_context_item(self, id: str):
|
||||
"""
|
||||
Opens a virtual file or otherwise previews the contents of the context provider in the IDE.
|
||||
"""
|
||||
id: ContextItemId = ContextItemId.from_string(id)
|
||||
if id.provider_title not in self.provider_titles:
|
||||
raise ValueError(
|
||||
f"Context provider with title {id.provider_title} not found"
|
||||
)
|
||||
|
||||
await self.context_providers[id.provider_title].preview_contents(id)
|
||||
|
||||
|
||||
"""
|
||||
Should define "ArgsTransformer" and "PromptTransformer" classes for the different LLMs. A standard way for them to ingest the
|
||||
|
|
|
|||
|
|
@ -235,6 +235,12 @@ class ContextItemId(BaseModel):
|
|||
def to_string(self) -> str:
|
||||
return f"{self.provider_title}-{self.item_id}"
|
||||
|
||||
def __eq__(self, other):
|
||||
return (
|
||||
self.provider_title == other.provider_title
|
||||
and self.item_id == other.item_id
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_string(string: str) -> "ContextItemId":
|
||||
provider_title, *rest = string.split("-")
|
||||
|
|
|
|||
|
|
@ -134,3 +134,14 @@ class FileContextProvider(ContextProvider):
|
|||
items = list(filter(lambda item: item is not None, items))
|
||||
|
||||
return items
|
||||
|
||||
async def preview_contents(self, id: ContextItemId):
|
||||
if item := next(
|
||||
filter(lambda x: x.description.id == id, self.selected_items), None
|
||||
):
|
||||
await self.sdk.ide.setFileOpen(
|
||||
os.path.join(
|
||||
self.sdk.ide.workspace_directory, item.description.description
|
||||
),
|
||||
True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from ...core.context import (
|
|||
ContextProvider,
|
||||
)
|
||||
from ...core.main import ChatMessage
|
||||
from ...models.filesystem import RangeInFileWithContents
|
||||
from ...models.filesystem import RangeInFile, RangeInFileWithContents
|
||||
from ...models.main import Range
|
||||
|
||||
|
||||
|
|
@ -291,3 +291,23 @@ class HighlightedCodeContextProvider(ContextProvider):
|
|||
item=context_item,
|
||||
)
|
||||
)
|
||||
|
||||
async def preview_contents(self, id: ContextItemId):
|
||||
if item := next(
|
||||
filter(lambda x: x.item.description.id == id, self.highlighted_ranges), None
|
||||
):
|
||||
filepath = os.path.join(
|
||||
self.sdk.ide.workspace_directory, item.item.description.description
|
||||
)
|
||||
await self.sdk.ide.setFileOpen(
|
||||
filepath,
|
||||
True,
|
||||
)
|
||||
line_nums_string = item.item.description.name.split(" ")[-1]
|
||||
line_nums = line_nums_string[1:-1].split("-")
|
||||
await self.sdk.ide.highlightCode(
|
||||
RangeInFile(
|
||||
filepath=filepath,
|
||||
range=Range.from_shorthand(line_nums[0] - 1, 0, line_nums[1], 0),
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class SearchContextProvider(ContextProvider):
|
|||
|
||||
title = "search"
|
||||
display_title = "Search"
|
||||
description = "Search the workspace for all matches of an exact string (e.g. '@search console.log')"
|
||||
description = "Search workspace for matches of an exact string"
|
||||
dynamic = True
|
||||
requires_query = True
|
||||
|
||||
|
|
|
|||
|
|
@ -143,6 +143,8 @@ class GUIProtocolServer:
|
|||
self.select_context_group(data["id"])
|
||||
elif message_type == "delete_context_group":
|
||||
self.delete_context_group(data["id"])
|
||||
elif message_type == "preview_context_item":
|
||||
self.preview_context_item(data["id"])
|
||||
|
||||
def on_main_input(self, input: str):
|
||||
# Do something with user input
|
||||
|
|
@ -195,7 +197,7 @@ class GUIProtocolServer:
|
|||
|
||||
def on_show_logs_at_index(self, index: int):
|
||||
name = "Continue Prompt"
|
||||
|
||||
|
||||
logs = None
|
||||
timeline = self.session.autopilot.continue_sdk.history.timeline
|
||||
while logs is None and index < len(timeline):
|
||||
|
|
@ -205,10 +207,13 @@ class GUIProtocolServer:
|
|||
elif timeline[index].step.name == "User Input":
|
||||
break
|
||||
index += 1
|
||||
|
||||
content = "Logs not found" if logs is None else "\n\n############################################\n\n".join(
|
||||
["This is the prompt that was sent to the LLM during this step"]
|
||||
+ logs
|
||||
|
||||
content = (
|
||||
"Logs not found"
|
||||
if logs is None
|
||||
else "\n\n############################################\n\n".join(
|
||||
["This is the prompt that was sent to the LLM during this step"] + logs
|
||||
)
|
||||
)
|
||||
create_async_task(
|
||||
self.session.autopilot.ide.showVirtualFile(name, content), self.on_error
|
||||
|
|
@ -252,6 +257,13 @@ class GUIProtocolServer:
|
|||
self.on_error,
|
||||
)
|
||||
|
||||
def preview_context_item(self, id: str):
|
||||
"""Called when user clicks on an item from the dropdown"""
|
||||
create_async_task(
|
||||
self.session.autopilot.context_manager.preview_context_item(id),
|
||||
self.on_error,
|
||||
)
|
||||
|
||||
def load_session(self, session_id: Optional[str] = None):
|
||||
async def load_and_tell_to_reconnect():
|
||||
new_session_id = await session_manager.load_session(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue