From 37f05ff02c8d1d4e00808dd58e4f521ce5a9a870 Mon Sep 17 00:00:00 2001 From: zzgu Date: Tue, 5 Nov 2024 19:54:00 -0800 Subject: [PATCH] feat(chat-ui): agent steps mock --- ee/tabby-ui/app/search/components/search.tsx | 4 + .../components/agent-steps/agent-steps.tsx | 80 ++++++++++++ ee/tabby-ui/components/agent-steps/styles.css | 117 ++++++++++++++++++ ee/tabby-ui/components/ui/icons.tsx | 25 +++- 4 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 ee/tabby-ui/components/agent-steps/agent-steps.tsx create mode 100644 ee/tabby-ui/components/agent-steps/styles.css diff --git a/ee/tabby-ui/app/search/components/search.tsx b/ee/tabby-ui/app/search/components/search.tsx index adb54475d6f5..a1908516feb2 100644 --- a/ee/tabby-ui/app/search/components/search.tsx +++ b/ee/tabby-ui/app/search/components/search.tsx @@ -84,6 +84,7 @@ import TextAreaSearch from '@/components/textarea-search' import { ThemeToggle } from '@/components/theme-toggle' import { MyAvatar } from '@/components/user-avatar' import UserPanel from '@/components/user-panel' +import { AgentSteps } from '@/components/agent-steps/agent-steps' import { AssistantMessageSection } from './assistant-message-section' import { DevPanel } from './dev-panel' @@ -781,6 +782,9 @@ export function Search() { } else if (message.role === Role.Assistant) { return ( <> +
+ +
( + + + +
+
Tabby Agent
+
3-steps
+
+
+ +
+
+ + + + + Thinking
+
task
+
+
+
+ + Searching web
+
task
+
+
+
+ + Combining results
+
task
+
+
+
+
+); + +const AccordionTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef + >( + ({ children, className, ...props }, forwardedRef) => ( + + + {children} + + + + ), +); + +const AccordionContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>( + ({ children, className, ...props }, forwardedRef) => ( + +
{children}
+
+ ), +); diff --git a/ee/tabby-ui/components/agent-steps/styles.css b/ee/tabby-ui/components/agent-steps/styles.css new file mode 100644 index 000000000000..f6c8af3cbdc4 --- /dev/null +++ b/ee/tabby-ui/components/agent-steps/styles.css @@ -0,0 +1,117 @@ +@import "@radix-ui/colors/black-alpha.css"; +@import "@radix-ui/colors/mauve.css"; +@import "@radix-ui/colors/violet.css"; + +/* reset */ +button, +h3 { + all: unset; +} + +.AccordionRoot { + border-radius: 6px; + width: 100%; + background-color: var(--mauve-6); + box-shadow: 0 2px 10px var(--black-a4); +} + +.AccordionItem { + overflow: hidden; + margin-top: 1px; +} + +.AccordionItem:first-child { + margin-top: 0; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.AccordionItem:last-child { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; +} + +.AccordionItem:focus-within { + position: relative; + z-index: 1; + box-shadow: 0 0 0 2px var(--mauve-12); +} + +.AccordionHeader { + display: flex; +} + +.step-title { + color: black; +} + +.AgentHeader { + width: 100%; + padding-right: 20px; + display: flex; + justify-content: space-between; + align-items: center; +} + +.AccordionTrigger { + font-family: inherit; + background-color: transparent; + padding: 0 20px; + height: 45px; + flex: 1; + display: flex; + align-items: center; + justify-content: space-between; + font-size: 15px; + line-height: 1; + /* color: var(--violet-11); */ + box-shadow: 0 1px 0 var(--mauve-6); + background-color: white; +} + +.AccordionTrigger:hover { + background-color: var(--mauve-2); +} + +.AccordionContent { + overflow: hidden; + font-size: 15px; + color: var(--mauve-11); + background-color: var(--mauve-2); +} +.AccordionContent[data-state="open"] { + animation: slideDown 300ms cubic-bezier(0.87, 0, 0.13, 1); +} +.AccordionContent[data-state="closed"] { + animation: slideUp 300ms cubic-bezier(0.87, 0, 0.13, 1); +} + +.AccordionContentText { + padding: 15px 20px; +} + +.AccordionChevron { + color: var(--violet-10); + transition: transform 300ms cubic-bezier(0.87, 0, 0.13, 1); +} +.AccordionTrigger[data-state="open"] > .AccordionChevron { + transform: rotate(180deg); +} + +@keyframes slideDown { + from { + height: 0; + } + to { + height: var(--radix-accordion-content-height); + } +} + +@keyframes slideUp { + from { + height: var(--radix-accordion-content-height); + } + to { + height: 0; + } +} diff --git a/ee/tabby-ui/components/ui/icons.tsx b/ee/tabby-ui/components/ui/icons.tsx index 31f9e2c2f776..1b811a48305b 100644 --- a/ee/tabby-ui/components/ui/icons.tsx +++ b/ee/tabby-ui/components/ui/icons.tsx @@ -1484,6 +1484,27 @@ function IconJetBrains({ className, ...props }: React.ComponentProps<'svg'>) { ) } + +function IconAgent({ className, ...props }: React.ComponentProps<'svg'>) { + return ( + + + + ) +} + +function IconResult({ className, ...props }: React.ComponentProps<'svg'>) { + return ( + + + + ) +} + function IconLayers({ className, ...props @@ -1788,5 +1809,7 @@ export { IconRegex, IconSquareActivity, IconCircleAlert, - IconCircleHelp + IconCircleHelp, + IconAgent, + IconResult, }