diff --git a/gui/src/components/ConversationStarters/ConversationStarterCard.tsx b/gui/src/components/ConversationStarters/ConversationStarterCard.tsx
index 35a205481..1542adadf 100644
--- a/gui/src/components/ConversationStarters/ConversationStarterCard.tsx
+++ b/gui/src/components/ConversationStarters/ConversationStarterCard.tsx
@@ -1,33 +1,63 @@
-import { ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
+import { BookmarkIcon, ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
+import { BookmarkIcon as BookmarkIconSolid } from "@heroicons/react/24/solid";
import { SlashCommandDescription } from "core";
-import { defaultBorderRadius, vscInputBackground } from "..";
+import { useState } from "react";
+import { defaultBorderRadius, GhostButton, vscInputBackground } from "..";
interface ConversationStarterCardProps {
command: SlashCommandDescription;
onClick: (command: SlashCommandDescription) => void;
+ onBookmark: (command: SlashCommandDescription) => void;
+ isBookmarked: boolean;
}
export function ConversationStarterCard({
command,
onClick,
+ onBookmark,
+ isBookmarked = false,
}: ConversationStarterCardProps) {
+ const [isHovered, setIsHovered] = useState(false);
+
return (
onClick(command)}
- className="mb-2 w-full shadow-md hover:cursor-pointer hover:brightness-110"
+ className="mb-2 w-full shadow-md hover:brightness-110"
style={{
borderRadius: defaultBorderRadius,
backgroundColor: vscInputBackground,
}}
+ onMouseEnter={() => setIsHovered(true)}
+ onMouseLeave={() => setIsHovered(false)}
>
-
+
-
+
onClick(command)}
+ className="flex flex-1 flex-col hover:cursor-pointer"
+ >
{command.name}
{command.description}
+
+ {
+ e.stopPropagation();
+ onBookmark(command);
+ }}
+ aria-label={
+ isBookmarked ? "Remove bookmarked prompt" : "Bookmark prompt"
+ }
+ className={isHovered || isBookmarked ? "opacity-100" : "opacity-0"}
+ >
+ {isBookmarked ? (
+
+ ) : (
+
+ )}
+
+
);
diff --git a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx
index 69020dae5..8df9cd908 100644
--- a/gui/src/components/ConversationStarters/ConversationStarterCards.tsx
+++ b/gui/src/components/ConversationStarters/ConversationStarterCards.tsx
@@ -10,19 +10,13 @@ const NUM_CARDS_TO_RENDER_COLLAPSED = 3;
export function ConversationStarterCards() {
const dispatch = useAppDispatch();
- const [isExpanded, setIsExpanded] = useState(false);
+ const [bookmarkedCommands, setBookmarkedCommands] = useState
([]);
+
const slashCommands =
useAppSelector((state) => state.config.config.slashCommands) ?? [];
const filteredSlashCommands = slashCommands?.filter(isDeprecatedCommandName);
- const numFilteredSlashCommands = filteredSlashCommands.length;
- const displayedCommands = isExpanded
- ? filteredSlashCommands
- : filteredSlashCommands.slice(0, NUM_CARDS_TO_RENDER_COLLAPSED);
- const hasMoreCommands =
- numFilteredSlashCommands > NUM_CARDS_TO_RENDER_COLLAPSED;
-
function onClick(command: SlashCommandDescription) {
if (command.prompt) {
dispatch(
@@ -31,8 +25,14 @@ export function ConversationStarterCards() {
}
}
- function handleToggleExpand() {
- setIsExpanded(!isExpanded);
+ function handleBookmarkCommand(command: SlashCommandDescription) {
+ setBookmarkedCommands((prev) => {
+ if (prev.includes(command.name)) {
+ return prev.filter((name) => name !== command.name);
+ } else {
+ return [...prev, command.name];
+ }
+ });
}
if (!filteredSlashCommands || filteredSlashCommands.length === 0) {
@@ -40,29 +40,18 @@ export function ConversationStarterCards() {
}
return (
-
-
Prompts
-
-
- {displayedCommands.map((command, i) => (
+
+ {filteredSlashCommands
+ .slice(0, NUM_CARDS_TO_RENDER_COLLAPSED)
+ .map((command, i) => (
))}
-
-
- {hasMoreCommands && (
-
- {isExpanded
- ? "Show less"
- : `Show ${numFilteredSlashCommands - NUM_CARDS_TO_RENDER_COLLAPSED} more...`}
-
- )}
);
}
diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts
index 04460f3b1..eb0632646 100644
--- a/gui/src/components/index.ts
+++ b/gui/src/components/index.ts
@@ -1,5 +1,5 @@
import styled from "styled-components";
-import { getFontSize, isJetBrains } from "../util";
+import { getFontSize } from "../util";
export const VSC_INPUT_BACKGROUND_VAR = "--vscode-input-background";
export const VSC_BACKGROUND_VAR = "--vscode-sideBar-background";
@@ -151,7 +151,7 @@ export const SecondaryButton = styled.button`
`;
export const GhostButton = styled.button`
- padding: 10px 12px;
+ padding: 6px 8px;
margin: 8px 0;
border-radius: ${defaultBorderRadius};