Skip to content

Commit 734f812

Browse files
fix: move featured tool catalog to tooltip + make scrollable for smaller viewports
1 parent 0ace3b8 commit 734f812

File tree

5 files changed

+37
-20
lines changed

5 files changed

+37
-20
lines changed

components/chat.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const Chat: React.FC<ScriptProps> = ({
159159
) : (
160160
<>
161161
{showAssistantName && scriptDisplayName && (
162-
<div className="sticky top-0 p-4 z-50 bg-background">
162+
<div className="sticky top-0 p-4 z-10 bg-background">
163163
<h1 className="text-3xl font-medium truncate">
164164
{scriptDisplayName ?? ''}
165165
</h1>

components/chat/chatBar/CatalogListBox.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ export const CatalogListBox = forwardRef<ToolCatalogRef, CatalogListboxProps>(
122122

123123
return (
124124
<Listbox
125-
className="relative overflow-y-auto"
126125
aria-label={'catalog'}
127126
variant={'flat'}
128127
disallowEmptySelection

components/chat/chatBar/commands.tsx

+29-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import { ToolActionChatMessage } from '@/components/shared/tools/ToolActionChatM
88
import { UrlToolModal } from '@/components/shared/tools/UrlToolModal';
99
import { ChatContext } from '@/contexts/chat';
1010
import { useAsync } from '@/hooks/useFetch';
11-
import { Card, Listbox, ListboxItem, useDisclosure } from '@nextui-org/react';
11+
import {
12+
Card,
13+
Listbox,
14+
ListboxItem,
15+
Tooltip,
16+
useDisclosure,
17+
} from '@nextui-org/react';
1218
import React, {
1319
forwardRef,
1420
useContext,
@@ -311,18 +317,28 @@ export default forwardRef<ChatCommandsRef, CommandsProps>(
311317
return (
312318
<div className="relative w-full h-3/4 command-options">
313319
<Upload isOpen={uploadOpen} setIsOpen={setUploadOpen} />
314-
{isCatalogOpen && (
315-
<Card className="absolute bottom-14 p-4" ref={catalogClickOutsideRef}>
316-
<CatalogListBox
317-
ref={toolcatalogRef}
318-
query={text}
319-
loading={loadingTool}
320-
equippedTools={tools}
321-
onAddTool={addTool.execute}
322-
onUncapturedKeyDown={() => inputElement?.focus()}
323-
/>
324-
</Card>
325-
)}
320+
321+
<Tooltip
322+
isOpen={isCatalogOpen}
323+
placement="top-start"
324+
content={
325+
<div
326+
className="max-h-[80vh] overflow-auto"
327+
ref={catalogClickOutsideRef}
328+
>
329+
<CatalogListBox
330+
ref={toolcatalogRef}
331+
query={text}
332+
loading={loadingTool}
333+
equippedTools={tools}
334+
onAddTool={addTool.execute}
335+
onUncapturedKeyDown={() => inputElement?.focus()}
336+
/>
337+
</div>
338+
}
339+
>
340+
<div />
341+
</Tooltip>
326342

327343
<UrlToolModal
328344
isOpen={urlToolModal.isOpen}

components/chat/messages.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { CallFrame } from '@gptscript-ai/gptscript';
88
import Calls from './messages/calls';
99
import { GoIssueReopened } from 'react-icons/go';
1010
import { defaultUrlTransform } from 'react-markdown';
11+
import clsx from 'clsx';
1112

1213
export enum MessageType {
1314
Alert,
@@ -73,13 +74,13 @@ const Message = React.memo(
7374
closeDelay={0.5}
7475
>
7576
<Avatar
76-
showFallback
7777
name={abbreviate(message.name || 'System')}
7878
className="w-[40px] cursor-default"
7979
classNames={{
80-
base: `bg-white p-6 text-sm border dark:border-none dark:bg-zinc-900 ${
81-
message.error && 'border-danger dark:border-danger'
82-
}`,
80+
base: clsx(
81+
`bg-white p-6 text-sm border dark:border-none dark:bg-zinc-900`,
82+
{ 'border-danger dark:border-danger': !!message.error }
83+
),
8384
name: `text-lg text-default-600`,
8485
}}
8586
/>

components/edit/configure/imports.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ const Imports: React.FC<ImportsProps> = ({
164164
)}
165165
<div className={`flex flex-col gap-2`}>
166166
<Tooltip
167+
placement="right"
167168
content={
168-
<div ref={clickOutsideRef}>
169+
<div ref={clickOutsideRef} className="max-h-[80vh] overflow-auto">
169170
<CatalogListBox
170171
equippedTools={tools || []}
171172
onAddTool={(tool) => {

0 commit comments

Comments
 (0)