@gram-ai/elements 1.27.4 → 1.27.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -60
- package/README.typedoc.md +6 -6
- package/bin/cli.js +74 -74
- package/dist/compat-shims-CO9JXXV4.cjs.map +1 -1
- package/dist/{compat-shims-BPJ7Q68c.js → compat-shims-DxtUrORi.js} +4 -2
- package/dist/compat-shims-DxtUrORi.js.map +1 -0
- package/dist/components/ShareButton/index.d.ts +2 -2
- package/dist/components/assistant-ui/message-feedback.d.ts +1 -1
- package/dist/components/assistant-ui/tooltip-icon-button.d.ts +2 -2
- package/dist/components/ui/avatar.d.ts +2 -2
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/calendar.d.ts +1 -1
- package/dist/components/ui/collapsible.d.ts +1 -1
- package/dist/components/ui/dialog.d.ts +4 -4
- package/dist/components/ui/popover.d.ts +2 -2
- package/dist/components/ui/skeleton.d.ts +1 -1
- package/dist/components/ui/time-range-picker.d.ts +1 -1
- package/dist/components/ui/tool-ui.d.ts +7 -7
- package/dist/components/ui/tooltip.d.ts +2 -2
- package/dist/contexts/ConnectionStatusContext.d.ts +1 -1
- package/dist/elements.cjs +1 -1
- package/dist/elements.js +2 -2
- package/dist/hooks/useDensity.d.ts +73 -73
- package/dist/hooks/useMCPTools.d.ts +1 -1
- package/dist/hooks/useRadius.d.ts +1 -1
- package/dist/{index-BpJstUh1.cjs → index-C4bFBGfl.cjs} +4 -4
- package/dist/{index-BpJstUh1.cjs.map → index-C4bFBGfl.cjs.map} +1 -1
- package/dist/{index-CUitXazZ.js → index-D93pV0_o.js} +55 -55
- package/dist/{index-CUitXazZ.js.map → index-D93pV0_o.js.map} +1 -1
- package/dist/{index-D0bAYNQy.js → index-DuCQRbcQ.js} +279 -265
- package/dist/index-DuCQRbcQ.js.map +1 -0
- package/dist/{index-KSX4Qjip.cjs → index-y_PNN5vK.cjs} +10 -10
- package/dist/index-y_PNN5vK.cjs.map +1 -0
- package/dist/lib/cassette.d.ts +4 -4
- package/dist/lib/errorTracking.d.ts +1 -1
- package/dist/lib/messageConverter.d.ts +1 -1
- package/dist/lib/models.d.ts +1 -1
- package/dist/plugins/chart/ui/bar-chart.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/accordion-wrapper.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/accordion.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/action-button.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/alert-wrapper.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/alert.d.ts +4 -4
- package/dist/plugins/generative-ui/ui/avatar.d.ts +5 -5
- package/dist/plugins/generative-ui/ui/badge.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/button-wrapper.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/button.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/card-wrapper.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/card.d.ts +8 -8
- package/dist/plugins/generative-ui/ui/checkbox.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/data-table.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/dialog.d.ts +3 -3
- package/dist/plugins/generative-ui/ui/dropdown-menu.d.ts +3 -3
- package/dist/plugins/generative-ui/ui/grid.d.ts +3 -3
- package/dist/plugins/generative-ui/ui/input-wrapper.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/input.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/label.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/metric.d.ts +3 -3
- package/dist/plugins/generative-ui/ui/pagination.d.ts +6 -6
- package/dist/plugins/generative-ui/ui/popover.d.ts +4 -4
- package/dist/plugins/generative-ui/ui/progress.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/radio-group.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/select.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/separator.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/skeleton.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/stack.d.ts +6 -6
- package/dist/plugins/generative-ui/ui/switch.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/table.d.ts +9 -9
- package/dist/plugins/generative-ui/ui/tabs-wrapper.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/tabs.d.ts +1 -1
- package/dist/plugins/generative-ui/ui/text.d.ts +3 -3
- package/dist/plugins/generative-ui/ui/textarea.d.ts +2 -2
- package/dist/plugins/generative-ui/ui/tooltip.d.ts +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/dist/{profiler-BFkhZRxj.js → profiler-FpBY9eRv.js} +2 -2
- package/dist/{profiler-BFkhZRxj.js.map → profiler-FpBY9eRv.js.map} +1 -1
- package/dist/{profiler-CyzxBxVz.cjs → profiler-_mthyjvo.cjs} +2 -2
- package/dist/{profiler-CyzxBxVz.cjs.map → profiler-_mthyjvo.cjs.map} +1 -1
- package/dist/react-shim.js +1 -1
- package/dist/server/express.cjs.map +1 -1
- package/dist/server/express.js.map +1 -1
- package/dist/{startRecording-Dq92sEHf.cjs → startRecording-NJcpiHw-.cjs} +2 -2
- package/dist/{startRecording-Dq92sEHf.cjs.map → startRecording-NJcpiHw-.cjs.map} +1 -1
- package/dist/{startRecording-C-PPAs_Z.js → startRecording-r5MXQ2Dm.js} +2 -2
- package/dist/{startRecording-C-PPAs_Z.js.map → startRecording-r5MXQ2Dm.js.map} +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -5
- package/src/compat-plugin.ts +14 -14
- package/src/compat-shims.ts +33 -31
- package/src/compat.test.ts +48 -48
- package/src/compat.ts +6 -6
- package/src/components/Chat/index.tsx +17 -17
- package/src/components/Chat/stories/Charts.stories.tsx +98 -98
- package/src/components/Chat/stories/Composer.stories.tsx +15 -15
- package/src/components/Chat/stories/ConnectionConfiguration.stories.tsx +44 -44
- package/src/components/Chat/stories/CustomComponents.stories.tsx +17 -17
- package/src/components/Chat/stories/Density.stories.tsx +20 -20
- package/src/components/Chat/stories/ErrorBoundary.stories.tsx +47 -47
- package/src/components/Chat/stories/FrontendTools.stories.tsx +39 -39
- package/src/components/Chat/stories/GenerativeUI.stories.tsx +48 -48
- package/src/components/Chat/stories/MessageFeedback.stories.tsx +52 -52
- package/src/components/Chat/stories/Modal.stories.tsx +28 -28
- package/src/components/Chat/stories/Model.stories.tsx +11 -11
- package/src/components/Chat/stories/Radius.stories.tsx +20 -20
- package/src/components/Chat/stories/Sidecar.stories.tsx +13 -13
- package/src/components/Chat/stories/StyleIsolation.stories.tsx +11 -11
- package/src/components/Chat/stories/Theme.stories.tsx +25 -25
- package/src/components/Chat/stories/Thread.stories.tsx +25 -25
- package/src/components/Chat/stories/ToolApproval.stories.tsx +55 -55
- package/src/components/Chat/stories/ToolMentions.stories.tsx +17 -17
- package/src/components/Chat/stories/Tools.stories.tsx +88 -88
- package/src/components/Chat/stories/Variants.stories.tsx +32 -32
- package/src/components/Chat/stories/Welcome.stories.tsx +14 -14
- package/src/components/ChatHistory.tsx +7 -7
- package/src/components/FrontendTools/index.tsx +5 -5
- package/src/components/Replay.stories.tsx +157 -157
- package/src/components/Replay.tsx +76 -73
- package/src/components/ShadowRoot.tsx +40 -40
- package/src/components/ShareButton/index.tsx +32 -32
- package/src/components/assistant-ui/assistant-modal.tsx +92 -87
- package/src/components/assistant-ui/assistant-sidecar.tsx +35 -35
- package/src/components/assistant-ui/attachment.tsx +80 -80
- package/src/components/assistant-ui/connection-status-indicator.tsx +33 -33
- package/src/components/assistant-ui/error-boundary.tsx +34 -34
- package/src/components/assistant-ui/follow-on-suggestions.tsx +26 -26
- package/src/components/assistant-ui/markdown-text.tsx +69 -69
- package/src/components/assistant-ui/mentioned-tools-badges.tsx +38 -38
- package/src/components/assistant-ui/message-feedback.tsx +57 -50
- package/src/components/assistant-ui/reasoning.tsx +83 -83
- package/src/components/assistant-ui/thread-list.tsx +45 -45
- package/src/components/assistant-ui/thread.tsx +278 -278
- package/src/components/assistant-ui/tool-fallback.tsx +37 -37
- package/src/components/assistant-ui/tool-group.tsx +26 -26
- package/src/components/assistant-ui/tool-mention-autocomplete.tsx +122 -122
- package/src/components/assistant-ui/tooltip-icon-button.tsx +18 -18
- package/src/components/ui/avatar.tsx +12 -12
- package/src/components/ui/button.tsx +12 -12
- package/src/components/ui/buttonVariants.ts +17 -17
- package/src/components/ui/calendar.tsx +106 -106
- package/src/components/ui/charts.stories.tsx +56 -56
- package/src/components/ui/collapsible.tsx +5 -5
- package/src/components/ui/dialog.tsx +30 -30
- package/src/components/ui/generative-ui.stories.tsx +200 -200
- package/src/components/ui/generative-ui.tsx +26 -26
- package/src/components/ui/popover.tsx +14 -14
- package/src/components/ui/skeleton.tsx +5 -5
- package/src/components/ui/time-range-picker.stories.tsx +80 -80
- package/src/components/ui/time-range-picker.tsx +245 -244
- package/src/components/ui/tool-ui.stories.tsx +37 -37
- package/src/components/ui/tool-ui.tsx +221 -215
- package/src/components/ui/tooltip.tsx +15 -15
- package/src/constants/tailwind.ts +1 -1
- package/src/contexts/ChatIdContext.tsx +7 -7
- package/src/contexts/ConnectionStatusContext.tsx +64 -64
- package/src/contexts/ElementsProvider.tsx +214 -213
- package/src/contexts/ReplayContext.ts +3 -3
- package/src/contexts/ToolApprovalContext.tsx +54 -54
- package/src/contexts/ToolExecutionContext.tsx +34 -34
- package/src/contexts/contexts.ts +7 -7
- package/src/contexts/portal-container-context.ts +2 -2
- package/src/contexts/portal-container.tsx +7 -7
- package/src/embedded.ts +1 -1
- package/src/global.css +25 -25
- package/src/hooks/useAuth.ts +72 -72
- package/src/hooks/useDensity.ts +79 -79
- package/src/hooks/useElements.ts +6 -6
- package/src/hooks/useExpanded.ts +12 -12
- package/src/hooks/useFollowOnSuggestions.ts +83 -83
- package/src/hooks/useGramThreadListAdapter.tsx +99 -99
- package/src/hooks/useMCPTools.ts +47 -47
- package/src/hooks/useModel.ts +14 -14
- package/src/hooks/usePluginComponents.ts +11 -11
- package/src/hooks/usePortalContainer.ts +5 -5
- package/src/hooks/useRadius.ts +23 -23
- package/src/hooks/useRecordCassette.ts +34 -34
- package/src/hooks/useSession.ts +11 -11
- package/src/hooks/useThemeProps.ts +13 -13
- package/src/hooks/useThreadId.ts +4 -4
- package/src/hooks/useToolApproval.ts +7 -7
- package/src/hooks/useToolMentions.ts +40 -40
- package/src/index.ts +26 -26
- package/src/lib/api.test.ts +61 -61
- package/src/lib/api.ts +4 -3
- package/src/lib/auth.ts +13 -13
- package/src/lib/cassette.ts +84 -84
- package/src/lib/easing.ts +1 -1
- package/src/lib/errorTracking.config.ts +5 -5
- package/src/lib/errorTracking.ts +29 -29
- package/src/lib/generative-ui.ts +7 -7
- package/src/lib/humanize.ts +3 -3
- package/src/lib/messageConverter.test.ts +130 -127
- package/src/lib/messageConverter.ts +196 -196
- package/src/lib/models.ts +21 -20
- package/src/lib/token.test.ts +56 -56
- package/src/lib/token.ts +14 -14
- package/src/lib/tool-mentions.ts +45 -45
- package/src/lib/tools.ts +66 -62
- package/src/lib/utils.ts +5 -5
- package/src/lib.d.ts +1 -1
- package/src/plugins/README.md +5 -5
- package/src/plugins/chart/catalog.ts +18 -18
- package/src/plugins/chart/chart.test.ts +31 -31
- package/src/plugins/chart/component.tsx +34 -34
- package/src/plugins/chart/index.ts +4 -4
- package/src/plugins/chart/ui/area-chart.tsx +42 -42
- package/src/plugins/chart/ui/bar-chart.tsx +46 -46
- package/src/plugins/chart/ui/donut-chart.tsx +48 -48
- package/src/plugins/chart/ui/index.ts +7 -7
- package/src/plugins/chart/ui/line-chart.tsx +43 -43
- package/src/plugins/chart/ui/pie-chart.tsx +44 -44
- package/src/plugins/chart/ui/radar-chart.tsx +33 -33
- package/src/plugins/chart/ui/scatter-chart.tsx +43 -43
- package/src/plugins/components/MacOSWindowFrame.tsx +15 -15
- package/src/plugins/components/PluginLoadingState.tsx +10 -10
- package/src/plugins/components/index.ts +1 -1
- package/src/plugins/generative-ui/catalog.ts +54 -54
- package/src/plugins/generative-ui/component.tsx +85 -85
- package/src/plugins/generative-ui/index.ts +4 -4
- package/src/plugins/generative-ui/ui/accordion-wrapper.tsx +16 -16
- package/src/plugins/generative-ui/ui/accordion.tsx +16 -16
- package/src/plugins/generative-ui/ui/action-button.tsx +28 -28
- package/src/plugins/generative-ui/ui/alert-wrapper.tsx +8 -8
- package/src/plugins/generative-ui/ui/alert.tsx +20 -20
- package/src/plugins/generative-ui/ui/avatar-wrapper.tsx +7 -7
- package/src/plugins/generative-ui/ui/avatar.tsx +30 -30
- package/src/plugins/generative-ui/ui/badge.tsx +22 -22
- package/src/plugins/generative-ui/ui/button-wrapper.tsx +12 -12
- package/src/plugins/generative-ui/ui/button.tsx +28 -28
- package/src/plugins/generative-ui/ui/card-wrapper.tsx +8 -8
- package/src/plugins/generative-ui/ui/card.tsx +27 -27
- package/src/plugins/generative-ui/ui/checkbox-wrapper.tsx +9 -9
- package/src/plugins/generative-ui/ui/checkbox.tsx +9 -9
- package/src/plugins/generative-ui/ui/data-table.tsx +8 -8
- package/src/plugins/generative-ui/ui/dialog.tsx +31 -31
- package/src/plugins/generative-ui/ui/dropdown-menu.tsx +44 -44
- package/src/plugins/generative-ui/ui/grid.tsx +12 -12
- package/src/plugins/generative-ui/ui/index.ts +40 -40
- package/src/plugins/generative-ui/ui/input-wrapper.tsx +11 -11
- package/src/plugins/generative-ui/ui/input.tsx +9 -9
- package/src/plugins/generative-ui/ui/label.tsx +8 -8
- package/src/plugins/generative-ui/ui/list.tsx +11 -11
- package/src/plugins/generative-ui/ui/metric.tsx +23 -23
- package/src/plugins/generative-ui/ui/pagination.tsx +28 -28
- package/src/plugins/generative-ui/ui/popover.tsx +21 -21
- package/src/plugins/generative-ui/ui/progress.tsx +13 -13
- package/src/plugins/generative-ui/ui/radio-group.tsx +12 -12
- package/src/plugins/generative-ui/ui/select-wrapper.tsx +7 -7
- package/src/plugins/generative-ui/ui/select.tsx +37 -37
- package/src/plugins/generative-ui/ui/separator.tsx +9 -9
- package/src/plugins/generative-ui/ui/skeleton-wrapper.tsx +10 -10
- package/src/plugins/generative-ui/ui/skeleton.tsx +5 -5
- package/src/plugins/generative-ui/ui/stack.tsx +28 -28
- package/src/plugins/generative-ui/ui/switch.tsx +11 -11
- package/src/plugins/generative-ui/ui/table.tsx +32 -32
- package/src/plugins/generative-ui/ui/tabs-wrapper.tsx +11 -11
- package/src/plugins/generative-ui/ui/tabs.tsx +26 -26
- package/src/plugins/generative-ui/ui/text.tsx +12 -12
- package/src/plugins/generative-ui/ui/textarea.tsx +7 -7
- package/src/plugins/generative-ui/ui/tooltip.tsx +12 -12
- package/src/plugins/index.ts +7 -7
- package/src/react-shim.ts +6 -6
- package/src/server/bun.ts +12 -12
- package/src/server/core.ts +25 -25
- package/src/server/express.ts +17 -15
- package/src/server/fastify.ts +14 -14
- package/src/server/hono.ts +9 -9
- package/src/server/nextjs.ts +12 -12
- package/src/server/tanstack-start.ts +12 -12
- package/src/server.ts +27 -27
- package/src/storybook.d.ts +4 -4
- package/src/types/index.ts +122 -122
- package/src/types/plugins.ts +7 -7
- package/src/vite-env.d.ts +12 -12
- package/dist/compat-shims-BPJ7Q68c.js.map +0 -1
- package/dist/index-D0bAYNQy.js.map +0 -1
- package/dist/index-KSX4Qjip.cjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { cn } from
|
|
1
|
+
import { cn } from "@/lib/utils";
|
|
2
2
|
import {
|
|
3
3
|
useAssistantState,
|
|
4
4
|
type ToolCallMessagePartComponent,
|
|
5
|
-
} from
|
|
6
|
-
import { useToolApproval } from
|
|
5
|
+
} from "@assistant-ui/react";
|
|
6
|
+
import { useToolApproval } from "@/hooks/useToolApproval";
|
|
7
7
|
import {
|
|
8
8
|
ToolUI,
|
|
9
9
|
type ToolStatus,
|
|
10
10
|
type ContentItem,
|
|
11
|
-
} from
|
|
11
|
+
} from "@/components/ui/tool-ui";
|
|
12
12
|
|
|
13
13
|
export const ToolFallback: ToolCallMessagePartComponent = ({
|
|
14
14
|
toolName,
|
|
@@ -22,47 +22,47 @@ export const ToolFallback: ToolCallMessagePartComponent = ({
|
|
|
22
22
|
whitelistTool,
|
|
23
23
|
confirmPendingApproval,
|
|
24
24
|
rejectPendingApproval,
|
|
25
|
-
} = useToolApproval()
|
|
25
|
+
} = useToolApproval();
|
|
26
26
|
|
|
27
27
|
// Check if this specific tool call has a pending approval
|
|
28
|
-
const pendingApproval = pendingApprovals.get(toolCallId)
|
|
29
|
-
const message = useAssistantState(({ message }) => message)
|
|
30
|
-
const toolParts = message.parts.filter((part) => part.type ===
|
|
28
|
+
const pendingApproval = pendingApprovals.get(toolCallId);
|
|
29
|
+
const message = useAssistantState(({ message }) => message);
|
|
30
|
+
const toolParts = message.parts.filter((part) => part.type === "tool-call");
|
|
31
31
|
const matchingMessagePartIndex = toolParts.findIndex(
|
|
32
|
-
(part) => part.toolCallId === toolCallId
|
|
33
|
-
)
|
|
32
|
+
(part) => part.toolCallId === toolCallId,
|
|
33
|
+
);
|
|
34
34
|
|
|
35
35
|
const handleApproveOnce = () => {
|
|
36
|
-
confirmPendingApproval(toolCallId)
|
|
37
|
-
}
|
|
36
|
+
confirmPendingApproval(toolCallId);
|
|
37
|
+
};
|
|
38
38
|
|
|
39
39
|
const handleApproveForSession = () => {
|
|
40
|
-
whitelistTool(toolName)
|
|
41
|
-
confirmPendingApproval(toolCallId)
|
|
42
|
-
}
|
|
40
|
+
whitelistTool(toolName);
|
|
41
|
+
confirmPendingApproval(toolCallId);
|
|
42
|
+
};
|
|
43
43
|
|
|
44
44
|
const handleDeny = () => {
|
|
45
|
-
rejectPendingApproval(toolCallId)
|
|
46
|
-
}
|
|
45
|
+
rejectPendingApproval(toolCallId);
|
|
46
|
+
};
|
|
47
47
|
|
|
48
48
|
// Map assistant-ui status to ToolUI status
|
|
49
49
|
const getToolStatus = (): ToolStatus => {
|
|
50
|
-
if (pendingApproval) return
|
|
51
|
-
if (status.type ===
|
|
52
|
-
if (status.type ===
|
|
50
|
+
if (pendingApproval) return "approval";
|
|
51
|
+
if (status.type === "incomplete") return "error";
|
|
52
|
+
if (status.type === "complete") {
|
|
53
53
|
// Check if the result indicates an error (e.g., tool was denied)
|
|
54
54
|
if (
|
|
55
55
|
result &&
|
|
56
|
-
typeof result ===
|
|
57
|
-
|
|
56
|
+
typeof result === "object" &&
|
|
57
|
+
"isError" in result &&
|
|
58
58
|
result.isError
|
|
59
59
|
) {
|
|
60
|
-
return
|
|
60
|
+
return "error";
|
|
61
61
|
}
|
|
62
|
-
return
|
|
62
|
+
return "complete";
|
|
63
63
|
}
|
|
64
|
-
return
|
|
65
|
-
}
|
|
64
|
+
return "running";
|
|
65
|
+
};
|
|
66
66
|
|
|
67
67
|
// Parse result to structured content if possible
|
|
68
68
|
const getResult = ():
|
|
@@ -70,28 +70,28 @@ export const ToolFallback: ToolCallMessagePartComponent = ({
|
|
|
70
70
|
| Record<string, unknown>
|
|
71
71
|
| { content: ContentItem[] }
|
|
72
72
|
| undefined => {
|
|
73
|
-
if (result === undefined) return undefined
|
|
73
|
+
if (result === undefined) return undefined;
|
|
74
74
|
// Check if it's structured content with a content array
|
|
75
75
|
if (
|
|
76
|
-
typeof result ===
|
|
76
|
+
typeof result === "object" &&
|
|
77
77
|
result !== null &&
|
|
78
|
-
|
|
78
|
+
"content" in result &&
|
|
79
79
|
Array.isArray((result as { content: unknown }).content)
|
|
80
80
|
) {
|
|
81
|
-
return result as { content: ContentItem[] }
|
|
81
|
+
return result as { content: ContentItem[] };
|
|
82
82
|
}
|
|
83
83
|
// Otherwise return as-is (string or object)
|
|
84
|
-
if (typeof result ===
|
|
85
|
-
return result as Record<string, unknown
|
|
86
|
-
}
|
|
84
|
+
if (typeof result === "string") return result;
|
|
85
|
+
return result as Record<string, unknown>;
|
|
86
|
+
};
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
89
|
<div
|
|
90
90
|
className={cn(
|
|
91
|
-
|
|
91
|
+
"aui-tool-fallback-root flex w-full flex-col",
|
|
92
92
|
matchingMessagePartIndex !== -1 &&
|
|
93
93
|
matchingMessagePartIndex !== toolParts.length - 1 &&
|
|
94
|
-
|
|
94
|
+
"border-b",
|
|
95
95
|
)}
|
|
96
96
|
>
|
|
97
97
|
<ToolUI
|
|
@@ -107,5 +107,5 @@ export const ToolFallback: ToolCallMessagePartComponent = ({
|
|
|
107
107
|
className="rounded-none border-0"
|
|
108
108
|
/>
|
|
109
109
|
</div>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
110
|
+
);
|
|
111
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { cn } from
|
|
2
|
-
import { useAssistantState } from
|
|
3
|
-
import { useMemo, type FC, type PropsWithChildren } from
|
|
4
|
-
import { useElements } from
|
|
5
|
-
import { humanizeToolName } from
|
|
6
|
-
import { ToolUIGroup } from
|
|
1
|
+
import { cn } from "@/lib/utils";
|
|
2
|
+
import { useAssistantState } from "@assistant-ui/react";
|
|
3
|
+
import { useMemo, type FC, type PropsWithChildren } from "react";
|
|
4
|
+
import { useElements } from "@/hooks/useElements";
|
|
5
|
+
import { humanizeToolName } from "@/lib/humanize";
|
|
6
|
+
import { ToolUIGroup } from "@/components/ui/tool-ui";
|
|
7
7
|
|
|
8
8
|
export const ToolGroup: FC<
|
|
9
9
|
PropsWithChildren<{ startIndex: number; endIndex: number }>
|
|
@@ -11,48 +11,48 @@ export const ToolGroup: FC<
|
|
|
11
11
|
// startIndex/endIndex are inclusive indices into message.parts.
|
|
12
12
|
// assistant-ui only groups consecutive tool-call parts, so every part
|
|
13
13
|
// in the range is a tool-call — the count is simply the range size.
|
|
14
|
-
const toolCount = endIndex - startIndex + 1
|
|
14
|
+
const toolCount = endIndex - startIndex + 1;
|
|
15
15
|
|
|
16
16
|
const firstToolName = useAssistantState(({ message }) => {
|
|
17
|
-
const part = message.parts[startIndex]
|
|
18
|
-
return part?.type ===
|
|
19
|
-
})
|
|
17
|
+
const part = message.parts[startIndex];
|
|
18
|
+
return part?.type === "tool-call" ? part.toolName : undefined;
|
|
19
|
+
});
|
|
20
20
|
const anyMessagePartsAreRunning = useAssistantState(({ message }) => {
|
|
21
21
|
for (let i = startIndex; i <= endIndex; i++) {
|
|
22
|
-
if (message.parts[i]?.status?.type ===
|
|
22
|
+
if (message.parts[i]?.status?.type === "running") return true;
|
|
23
23
|
}
|
|
24
|
-
return false
|
|
25
|
-
})
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
26
|
|
|
27
|
-
const { config } = useElements()
|
|
28
|
-
const defaultExpanded = config.tools?.expandToolGroupsByDefault ?? false
|
|
27
|
+
const { config } = useElements();
|
|
28
|
+
const defaultExpanded = config.tools?.expandToolGroupsByDefault ?? false;
|
|
29
29
|
|
|
30
30
|
const groupTitle = useMemo(() => {
|
|
31
|
-
if (toolCount === 0) return
|
|
31
|
+
if (toolCount === 0) return "No tools called";
|
|
32
32
|
if (toolCount === 1) {
|
|
33
33
|
return firstToolName
|
|
34
34
|
? `Calling ${humanizeToolName(firstToolName)}...`
|
|
35
|
-
:
|
|
35
|
+
: "Calling tool...";
|
|
36
36
|
}
|
|
37
37
|
return anyMessagePartsAreRunning
|
|
38
38
|
? `Calling ${toolCount} tools...`
|
|
39
|
-
: `Executed ${toolCount} tools
|
|
40
|
-
}, [toolCount, firstToolName, anyMessagePartsAreRunning])
|
|
39
|
+
: `Executed ${toolCount} tools`;
|
|
40
|
+
}, [toolCount, firstToolName, anyMessagePartsAreRunning]);
|
|
41
41
|
|
|
42
42
|
// If there's a custom component for the single tool, render children directly
|
|
43
43
|
if (firstToolName && config.tools?.components?.[firstToolName]) {
|
|
44
|
-
return children
|
|
44
|
+
return children;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// For single tool calls, render without the group wrapper
|
|
48
48
|
if (toolCount === 1) {
|
|
49
49
|
return (
|
|
50
|
-
<div className={cn(
|
|
51
|
-
<div className="
|
|
50
|
+
<div className={cn("my-4 w-full max-w-xl")}>
|
|
51
|
+
<div className="overflow-hidden rounded-lg border border-border bg-card">
|
|
52
52
|
{children}
|
|
53
53
|
</div>
|
|
54
54
|
</div>
|
|
55
|
-
)
|
|
55
|
+
);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// For multiple tool calls, use the group component
|
|
@@ -60,11 +60,11 @@ export const ToolGroup: FC<
|
|
|
60
60
|
<div className="my-4 w-full max-w-xl">
|
|
61
61
|
<ToolUIGroup
|
|
62
62
|
title={groupTitle}
|
|
63
|
-
status={anyMessagePartsAreRunning ?
|
|
63
|
+
status={anyMessagePartsAreRunning ? "running" : "complete"}
|
|
64
64
|
defaultExpanded={defaultExpanded}
|
|
65
65
|
>
|
|
66
66
|
{children}
|
|
67
67
|
</ToolUIGroup>
|
|
68
68
|
</div>
|
|
69
|
-
)
|
|
70
|
-
}
|
|
69
|
+
);
|
|
70
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { FC, useCallback, useEffect, useRef, useState } from
|
|
2
|
-
import { Wrench } from
|
|
3
|
-
import * as m from
|
|
4
|
-
|
|
5
|
-
import { cn } from
|
|
6
|
-
import { useDensity } from
|
|
7
|
-
import { useRadius } from
|
|
8
|
-
import { EASE_OUT_QUINT } from
|
|
1
|
+
import { FC, useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Wrench } from "lucide-react";
|
|
3
|
+
import * as m from "motion/react-m";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
import { useDensity } from "@/hooks/useDensity";
|
|
7
|
+
import { useRadius } from "@/hooks/useRadius";
|
|
8
|
+
import { EASE_OUT_QUINT } from "@/lib/easing";
|
|
9
9
|
import {
|
|
10
10
|
MentionableTool,
|
|
11
11
|
detectMentionContext,
|
|
12
12
|
filterToolsByQuery,
|
|
13
13
|
insertToolMention,
|
|
14
|
-
} from
|
|
14
|
+
} from "@/lib/tool-mentions";
|
|
15
15
|
|
|
16
16
|
export interface ToolMentionAutocompleteProps {
|
|
17
|
-
tools: MentionableTool[]
|
|
18
|
-
value: string
|
|
19
|
-
cursorPosition: number
|
|
20
|
-
onValueChange: (value: string, cursorPosition: number) => void
|
|
21
|
-
textareaRef: React.RefObject<HTMLTextAreaElement | null
|
|
22
|
-
className?: string
|
|
17
|
+
tools: MentionableTool[];
|
|
18
|
+
value: string;
|
|
19
|
+
cursorPosition: number;
|
|
20
|
+
onValueChange: (value: string, cursorPosition: number) => void;
|
|
21
|
+
textareaRef: React.RefObject<HTMLTextAreaElement | null>;
|
|
22
|
+
className?: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export const ToolMentionAutocomplete: FC<ToolMentionAutocompleteProps> = ({
|
|
@@ -30,112 +30,112 @@ export const ToolMentionAutocomplete: FC<ToolMentionAutocompleteProps> = ({
|
|
|
30
30
|
textareaRef,
|
|
31
31
|
className,
|
|
32
32
|
}) => {
|
|
33
|
-
const [selectedIndex, setSelectedIndex] = useState(0)
|
|
34
|
-
const [isVisible, setIsVisible] = useState(false)
|
|
35
|
-
const [filteredTools, setFilteredTools] = useState<MentionableTool[]>([])
|
|
33
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
34
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
35
|
+
const [filteredTools, setFilteredTools] = useState<MentionableTool[]>([]);
|
|
36
36
|
const [mentionContext, setMentionContext] = useState<{
|
|
37
|
-
atPosition: number
|
|
38
|
-
query: string
|
|
39
|
-
} | null>(null)
|
|
37
|
+
atPosition: number;
|
|
38
|
+
query: string;
|
|
39
|
+
} | null>(null);
|
|
40
40
|
|
|
41
|
-
const containerRef = useRef<HTMLDivElement>(null)
|
|
42
|
-
const d = useDensity()
|
|
43
|
-
const r = useRadius()
|
|
41
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
42
|
+
const d = useDensity();
|
|
43
|
+
const r = useRadius();
|
|
44
44
|
|
|
45
45
|
useEffect(() => {
|
|
46
|
-
const context = detectMentionContext(value, cursorPosition)
|
|
46
|
+
const context = detectMentionContext(value, cursorPosition);
|
|
47
47
|
|
|
48
48
|
if (context.isInMention && tools.length > 0) {
|
|
49
|
-
const filtered = filterToolsByQuery(tools, context.query)
|
|
50
|
-
setFilteredTools(filtered)
|
|
51
|
-
setIsVisible(filtered.length > 0)
|
|
49
|
+
const filtered = filterToolsByQuery(tools, context.query);
|
|
50
|
+
setFilteredTools(filtered);
|
|
51
|
+
setIsVisible(filtered.length > 0);
|
|
52
52
|
setMentionContext({
|
|
53
53
|
atPosition: context.atPosition,
|
|
54
54
|
query: context.query,
|
|
55
|
-
})
|
|
56
|
-
setSelectedIndex(0)
|
|
55
|
+
});
|
|
56
|
+
setSelectedIndex(0);
|
|
57
57
|
} else {
|
|
58
|
-
setIsVisible(false)
|
|
59
|
-
setMentionContext(null)
|
|
58
|
+
setIsVisible(false);
|
|
59
|
+
setMentionContext(null);
|
|
60
60
|
}
|
|
61
|
-
}, [value, cursorPosition, tools])
|
|
61
|
+
}, [value, cursorPosition, tools]);
|
|
62
62
|
|
|
63
63
|
const selectTool = useCallback(
|
|
64
64
|
(tool: MentionableTool) => {
|
|
65
|
-
if (!mentionContext) return
|
|
65
|
+
if (!mentionContext) return;
|
|
66
66
|
|
|
67
67
|
const result = insertToolMention(
|
|
68
68
|
value,
|
|
69
69
|
tool.name,
|
|
70
70
|
mentionContext.atPosition,
|
|
71
|
-
cursorPosition
|
|
72
|
-
)
|
|
71
|
+
cursorPosition,
|
|
72
|
+
);
|
|
73
73
|
|
|
74
|
-
onValueChange(result.text, result.cursorPosition)
|
|
75
|
-
setIsVisible(false)
|
|
74
|
+
onValueChange(result.text, result.cursorPosition);
|
|
75
|
+
setIsVisible(false);
|
|
76
76
|
},
|
|
77
|
-
[mentionContext, value, cursorPosition, onValueChange, textareaRef]
|
|
78
|
-
)
|
|
77
|
+
[mentionContext, value, cursorPosition, onValueChange, textareaRef],
|
|
78
|
+
);
|
|
79
79
|
|
|
80
80
|
useEffect(() => {
|
|
81
|
-
if (!isVisible) return
|
|
81
|
+
if (!isVisible) return;
|
|
82
82
|
|
|
83
83
|
const handleKeyDown = (e: KeyboardEvent) => {
|
|
84
84
|
switch (e.key) {
|
|
85
|
-
case
|
|
86
|
-
e.preventDefault()
|
|
87
|
-
e.stopPropagation()
|
|
88
|
-
setSelectedIndex((prev) => (prev + 1) % filteredTools.length)
|
|
89
|
-
break
|
|
90
|
-
case
|
|
91
|
-
e.preventDefault()
|
|
92
|
-
e.stopPropagation()
|
|
85
|
+
case "ArrowDown":
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
setSelectedIndex((prev) => (prev + 1) % filteredTools.length);
|
|
89
|
+
break;
|
|
90
|
+
case "ArrowUp":
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
e.stopPropagation();
|
|
93
93
|
setSelectedIndex(
|
|
94
|
-
(prev) => (prev - 1 + filteredTools.length) % filteredTools.length
|
|
95
|
-
)
|
|
96
|
-
break
|
|
97
|
-
case
|
|
98
|
-
case
|
|
99
|
-
e.preventDefault()
|
|
100
|
-
e.stopPropagation()
|
|
94
|
+
(prev) => (prev - 1 + filteredTools.length) % filteredTools.length,
|
|
95
|
+
);
|
|
96
|
+
break;
|
|
97
|
+
case "Enter":
|
|
98
|
+
case "Tab":
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
e.stopPropagation();
|
|
101
101
|
if (filteredTools[selectedIndex]) {
|
|
102
|
-
selectTool(filteredTools[selectedIndex])
|
|
102
|
+
selectTool(filteredTools[selectedIndex]);
|
|
103
103
|
}
|
|
104
|
-
break
|
|
105
|
-
case
|
|
106
|
-
e.preventDefault()
|
|
107
|
-
e.stopPropagation()
|
|
108
|
-
setIsVisible(false)
|
|
109
|
-
break
|
|
104
|
+
break;
|
|
105
|
+
case "Escape":
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
setIsVisible(false);
|
|
109
|
+
break;
|
|
110
110
|
}
|
|
111
|
-
}
|
|
111
|
+
};
|
|
112
112
|
|
|
113
|
-
const textarea = textareaRef.current
|
|
113
|
+
const textarea = textareaRef.current;
|
|
114
114
|
if (textarea) {
|
|
115
|
-
textarea.addEventListener(
|
|
115
|
+
textarea.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
116
116
|
return () =>
|
|
117
|
-
textarea.removeEventListener(
|
|
117
|
+
textarea.removeEventListener("keydown", handleKeyDown, {
|
|
118
118
|
capture: true,
|
|
119
|
-
})
|
|
119
|
+
});
|
|
120
120
|
}
|
|
121
|
-
}, [isVisible, filteredTools, selectedIndex, selectTool, textareaRef])
|
|
121
|
+
}, [isVisible, filteredTools, selectedIndex, selectTool, textareaRef]);
|
|
122
122
|
|
|
123
123
|
// Scroll selected item into view
|
|
124
124
|
useEffect(() => {
|
|
125
|
-
if (!isVisible) return
|
|
126
|
-
const container = containerRef.current
|
|
127
|
-
if (!container) return
|
|
125
|
+
if (!isVisible) return;
|
|
126
|
+
const container = containerRef.current;
|
|
127
|
+
if (!container) return;
|
|
128
128
|
|
|
129
129
|
const selectedItem = container.querySelector(
|
|
130
|
-
`[data-index="${selectedIndex}"]
|
|
131
|
-
) as HTMLElement
|
|
130
|
+
`[data-index="${selectedIndex}"]`,
|
|
131
|
+
) as HTMLElement;
|
|
132
132
|
if (selectedItem) {
|
|
133
|
-
selectedItem.scrollIntoView({ block:
|
|
133
|
+
selectedItem.scrollIntoView({ block: "nearest" });
|
|
134
134
|
}
|
|
135
|
-
}, [selectedIndex, isVisible])
|
|
135
|
+
}, [selectedIndex, isVisible]);
|
|
136
136
|
|
|
137
137
|
useEffect(() => {
|
|
138
|
-
if (!isVisible) return
|
|
138
|
+
if (!isVisible) return;
|
|
139
139
|
|
|
140
140
|
const handleClickOutside = (e: MouseEvent) => {
|
|
141
141
|
if (
|
|
@@ -144,62 +144,62 @@ export const ToolMentionAutocomplete: FC<ToolMentionAutocompleteProps> = ({
|
|
|
144
144
|
textareaRef.current &&
|
|
145
145
|
!textareaRef.current.contains(e.target as Node)
|
|
146
146
|
) {
|
|
147
|
-
setIsVisible(false)
|
|
147
|
+
setIsVisible(false);
|
|
148
148
|
}
|
|
149
|
-
}
|
|
149
|
+
};
|
|
150
150
|
|
|
151
|
-
document.addEventListener(
|
|
152
|
-
return () => document.removeEventListener(
|
|
153
|
-
}, [isVisible, textareaRef])
|
|
151
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
152
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
153
|
+
}, [isVisible, textareaRef]);
|
|
154
154
|
|
|
155
155
|
// When autocomplete is visible, modify composer styles and position autocomplete to match composer width
|
|
156
156
|
useEffect(() => {
|
|
157
|
-
const textarea = textareaRef.current
|
|
158
|
-
if (!textarea) return
|
|
157
|
+
const textarea = textareaRef.current;
|
|
158
|
+
if (!textarea) return;
|
|
159
159
|
|
|
160
|
-
const composer = textarea.closest(
|
|
161
|
-
if (!composer) return
|
|
160
|
+
const composer = textarea.closest(".aui-composer-root") as HTMLElement;
|
|
161
|
+
if (!composer) return;
|
|
162
162
|
|
|
163
163
|
const updateStyles = () => {
|
|
164
|
-
const autocomplete = containerRef.current
|
|
165
|
-
if (!autocomplete) return
|
|
164
|
+
const autocomplete = containerRef.current;
|
|
165
|
+
if (!autocomplete) return;
|
|
166
166
|
|
|
167
167
|
if (isVisible) {
|
|
168
168
|
// Modify composer to connect with autocomplete
|
|
169
|
-
composer.style.borderTopColor =
|
|
170
|
-
composer.style.borderTopLeftRadius =
|
|
171
|
-
composer.style.borderTopRightRadius =
|
|
169
|
+
composer.style.borderTopColor = "var(--ring)";
|
|
170
|
+
composer.style.borderTopLeftRadius = "0";
|
|
171
|
+
composer.style.borderTopRightRadius = "0";
|
|
172
172
|
|
|
173
173
|
// Position autocomplete to match composer width
|
|
174
|
-
const composerRect = composer.getBoundingClientRect()
|
|
175
|
-
const autocompleteParent = autocomplete.offsetParent as HTMLElement
|
|
174
|
+
const composerRect = composer.getBoundingClientRect();
|
|
175
|
+
const autocompleteParent = autocomplete.offsetParent as HTMLElement;
|
|
176
176
|
if (autocompleteParent) {
|
|
177
|
-
const parentRect = autocompleteParent.getBoundingClientRect()
|
|
178
|
-
autocomplete.style.left = `${composerRect.left - parentRect.left}px
|
|
179
|
-
autocomplete.style.right =
|
|
180
|
-
autocomplete.style.width = `${composerRect.width}px
|
|
177
|
+
const parentRect = autocompleteParent.getBoundingClientRect();
|
|
178
|
+
autocomplete.style.left = `${composerRect.left - parentRect.left}px`;
|
|
179
|
+
autocomplete.style.right = "auto";
|
|
180
|
+
autocomplete.style.width = `${composerRect.width}px`;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
}
|
|
183
|
+
};
|
|
184
184
|
|
|
185
185
|
if (isVisible) {
|
|
186
186
|
// Use requestAnimationFrame to ensure DOM is updated
|
|
187
|
-
requestAnimationFrame(updateStyles)
|
|
187
|
+
requestAnimationFrame(updateStyles);
|
|
188
188
|
} else {
|
|
189
|
-
composer.style.borderTopColor =
|
|
190
|
-
composer.style.borderTopLeftRadius =
|
|
191
|
-
composer.style.borderTopRightRadius =
|
|
189
|
+
composer.style.borderTopColor = "";
|
|
190
|
+
composer.style.borderTopLeftRadius = "";
|
|
191
|
+
composer.style.borderTopRightRadius = "";
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
return () => {
|
|
195
|
-
composer.style.borderTopColor =
|
|
196
|
-
composer.style.borderTopLeftRadius =
|
|
197
|
-
composer.style.borderTopRightRadius =
|
|
198
|
-
}
|
|
199
|
-
}, [isVisible, textareaRef])
|
|
195
|
+
composer.style.borderTopColor = "";
|
|
196
|
+
composer.style.borderTopLeftRadius = "";
|
|
197
|
+
composer.style.borderTopRightRadius = "";
|
|
198
|
+
};
|
|
199
|
+
}, [isVisible, textareaRef]);
|
|
200
200
|
|
|
201
201
|
if (!isVisible || filteredTools.length === 0) {
|
|
202
|
-
return null
|
|
202
|
+
return null;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
return (
|
|
@@ -210,9 +210,9 @@ export const ToolMentionAutocomplete: FC<ToolMentionAutocompleteProps> = ({
|
|
|
210
210
|
exit={{ opacity: 0, y: 8 }}
|
|
211
211
|
transition={{ duration: 0.15, ease: EASE_OUT_QUINT }}
|
|
212
212
|
className={cn(
|
|
213
|
-
|
|
214
|
-
r(
|
|
215
|
-
className
|
|
213
|
+
"aui-tool-mention-autocomplete absolute bottom-full z-50 max-h-[220px] overflow-clip overflow-y-auto overscroll-contain rounded-br-none! rounded-bl-none! border border-b-0 border-ring bg-background shadow-xs",
|
|
214
|
+
r("xl"),
|
|
215
|
+
className,
|
|
216
216
|
)}
|
|
217
217
|
>
|
|
218
218
|
<div className="flex flex-col gap-1">
|
|
@@ -222,15 +222,15 @@ export const ToolMentionAutocomplete: FC<ToolMentionAutocompleteProps> = ({
|
|
|
222
222
|
type="button"
|
|
223
223
|
data-index={index}
|
|
224
224
|
className={cn(
|
|
225
|
-
|
|
226
|
-
d(
|
|
227
|
-
|
|
228
|
-
index === selectedIndex &&
|
|
225
|
+
"aui-tool-mention-item flex w-full items-center gap-2 text-left transition-colors",
|
|
226
|
+
d("p-sm"),
|
|
227
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
228
|
+
index === selectedIndex && "bg-accent text-accent-foreground",
|
|
229
229
|
)}
|
|
230
230
|
onClick={(e) => {
|
|
231
|
-
e.preventDefault()
|
|
232
|
-
e.stopPropagation()
|
|
233
|
-
selectTool(tool)
|
|
231
|
+
e.preventDefault();
|
|
232
|
+
e.stopPropagation();
|
|
233
|
+
selectTool(tool);
|
|
234
234
|
}}
|
|
235
235
|
onMouseEnter={() => setSelectedIndex(index)}
|
|
236
236
|
>
|
|
@@ -238,7 +238,7 @@ export const ToolMentionAutocomplete: FC<ToolMentionAutocompleteProps> = ({
|
|
|
238
238
|
<div className="min-w-0 flex-1">
|
|
239
239
|
<div className="text-sm font-medium">{tool.name}</div>
|
|
240
240
|
{tool.description && (
|
|
241
|
-
<div className="
|
|
241
|
+
<div className="line-clamp-2 text-xs text-muted-foreground">
|
|
242
242
|
{tool.description}
|
|
243
243
|
</div>
|
|
244
244
|
)}
|
|
@@ -247,7 +247,7 @@ export const ToolMentionAutocomplete: FC<ToolMentionAutocompleteProps> = ({
|
|
|
247
247
|
))}
|
|
248
248
|
</div>
|
|
249
249
|
</m.div>
|
|
250
|
-
)
|
|
251
|
-
}
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
252
|
|
|
253
|
-
export default ToolMentionAutocomplete
|
|
253
|
+
export default ToolMentionAutocomplete;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import { ComponentPropsWithRef, forwardRef } from
|
|
4
|
-
import { Slottable } from
|
|
3
|
+
import { ComponentPropsWithRef, forwardRef } from "react";
|
|
4
|
+
import { Slottable } from "@radix-ui/react-slot";
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
Tooltip,
|
|
8
8
|
TooltipContent,
|
|
9
9
|
TooltipTrigger,
|
|
10
|
-
} from
|
|
11
|
-
import { Button } from
|
|
12
|
-
import { cn } from
|
|
10
|
+
} from "@/components/ui/tooltip";
|
|
11
|
+
import { Button } from "@/components/ui/button";
|
|
12
|
+
import { cn } from "@/lib/utils";
|
|
13
13
|
|
|
14
14
|
type TooltipIconButtonProps = ComponentPropsWithRef<typeof Button> & {
|
|
15
|
-
tooltip: string
|
|
16
|
-
side?:
|
|
17
|
-
align?:
|
|
18
|
-
}
|
|
15
|
+
tooltip: string;
|
|
16
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
17
|
+
align?: "start" | "center" | "end";
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
export const TooltipIconButton = forwardRef<
|
|
21
21
|
HTMLButtonElement,
|
|
@@ -25,12 +25,12 @@ export const TooltipIconButton = forwardRef<
|
|
|
25
25
|
{
|
|
26
26
|
children,
|
|
27
27
|
tooltip,
|
|
28
|
-
side =
|
|
29
|
-
align =
|
|
28
|
+
side = "bottom",
|
|
29
|
+
align = "center",
|
|
30
30
|
className,
|
|
31
31
|
...rest
|
|
32
32
|
},
|
|
33
|
-
ref
|
|
33
|
+
ref,
|
|
34
34
|
) => {
|
|
35
35
|
return (
|
|
36
36
|
<Tooltip>
|
|
@@ -39,7 +39,7 @@ export const TooltipIconButton = forwardRef<
|
|
|
39
39
|
variant="ghost"
|
|
40
40
|
size="icon"
|
|
41
41
|
{...rest}
|
|
42
|
-
className={cn(
|
|
42
|
+
className={cn("aui-button-icon size-6 p-1", className)}
|
|
43
43
|
ref={ref}
|
|
44
44
|
>
|
|
45
45
|
<Slottable>{children}</Slottable>
|
|
@@ -50,8 +50,8 @@ export const TooltipIconButton = forwardRef<
|
|
|
50
50
|
{tooltip}
|
|
51
51
|
</TooltipContent>
|
|
52
52
|
</Tooltip>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
)
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
56
|
|
|
57
|
-
TooltipIconButton.displayName =
|
|
57
|
+
TooltipIconButton.displayName = "TooltipIconButton";
|