@iloveagents/foundry-web-ui 0.3.1 → 0.5.0

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.
Files changed (227) hide show
  1. package/README.md +13 -4
  2. package/dist/components/ag-ui-runtime-provider.d.ts +64 -0
  3. package/dist/components/ag-ui-runtime-provider.js +71 -0
  4. package/dist/components/app-brand.d.ts +6 -0
  5. package/dist/components/app-brand.js +13 -0
  6. package/dist/components/assistant-chat.d.ts +26 -0
  7. package/dist/components/assistant-chat.js +94 -0
  8. package/dist/components/chat-attachments.d.ts +25 -0
  9. package/dist/components/chat-attachments.js +20 -0
  10. package/dist/components/chat-bubble.d.ts +1 -0
  11. package/dist/components/chat-bubble.js +105 -0
  12. package/dist/components/chat-header.d.ts +2 -0
  13. package/dist/components/chat-header.js +16 -0
  14. package/dist/components/client-tool-executor.d.ts +12 -0
  15. package/dist/components/client-tool-executor.js +108 -0
  16. package/dist/components/collection-empty-state.d.ts +9 -0
  17. package/dist/components/collection-empty-state.js +6 -0
  18. package/dist/components/collection-filter-bar.d.ts +19 -0
  19. package/dist/components/collection-filter-bar.js +28 -0
  20. package/dist/components/collection-search-input.d.ts +6 -0
  21. package/dist/components/collection-search-input.js +8 -0
  22. package/dist/components/collection-skeleton.d.ts +6 -0
  23. package/dist/components/collection-skeleton.js +10 -0
  24. package/dist/components/collection-sort-menu.d.ts +10 -0
  25. package/dist/components/collection-sort-menu.js +9 -0
  26. package/dist/components/collection-surface.d.ts +8 -0
  27. package/dist/components/collection-surface.js +5 -0
  28. package/dist/components/collection-toolbar.d.ts +9 -0
  29. package/dist/components/collection-toolbar.js +5 -0
  30. package/dist/components/collection-view-toggle.d.ts +7 -0
  31. package/dist/components/collection-view-toggle.js +17 -0
  32. package/dist/components/composer-submit-bridge.d.ts +1 -0
  33. package/dist/components/composer-submit-bridge.js +15 -0
  34. package/dist/components/confirm-dialog.d.ts +11 -0
  35. package/dist/components/confirm-dialog.js +6 -0
  36. package/dist/components/confirmation-card.d.ts +14 -0
  37. package/dist/components/confirmation-card.js +12 -0
  38. package/dist/components/context-badges.d.ts +16 -0
  39. package/dist/components/context-badges.js +56 -0
  40. package/dist/components/context-bar.d.ts +41 -0
  41. package/dist/components/context-bar.js +123 -0
  42. package/dist/components/form-dialog.d.ts +12 -0
  43. package/dist/components/form-dialog.js +13 -0
  44. package/dist/components/global-selection-popover.d.ts +7 -0
  45. package/dist/components/global-selection-popover.js +167 -0
  46. package/dist/components/infinite-scroll-sentinel.d.ts +6 -0
  47. package/dist/components/infinite-scroll-sentinel.js +25 -0
  48. package/dist/components/json-viewer.d.ts +10 -0
  49. package/dist/components/json-viewer.js +80 -0
  50. package/dist/components/loading-indicator.d.ts +13 -0
  51. package/dist/components/loading-indicator.js +35 -0
  52. package/dist/components/markdown-text.d.ts +13 -0
  53. package/dist/components/markdown-text.js +221 -0
  54. package/dist/components/message-error.d.ts +10 -0
  55. package/dist/components/message-error.js +10 -0
  56. package/dist/components/message-timestamp.d.ts +10 -0
  57. package/dist/components/message-timestamp.js +18 -0
  58. package/dist/components/name-dialog.d.ts +16 -0
  59. package/dist/components/name-dialog.js +23 -0
  60. package/dist/components/selection-popover.d.ts +12 -0
  61. package/dist/components/selection-popover.js +111 -0
  62. package/dist/components/show-document-tool-ui.d.ts +1 -0
  63. package/dist/components/show-document-tool-ui.js +53 -0
  64. package/dist/components/sidebar.d.ts +4 -0
  65. package/dist/components/sidebar.js +904 -0
  66. package/dist/components/surface-card.d.ts +9 -0
  67. package/dist/components/surface-card.js +33 -0
  68. package/dist/components/theme-runtime-provider.d.ts +15 -0
  69. package/dist/components/theme-runtime-provider.js +48 -0
  70. package/dist/components/theme-toggle.d.ts +2 -0
  71. package/dist/components/theme-toggle.js +19 -0
  72. package/dist/components/tool-call-card.d.ts +27 -0
  73. package/dist/components/tool-call-card.js +13 -0
  74. package/dist/components/tool-fallback.d.ts +26 -0
  75. package/dist/components/tool-fallback.js +129 -0
  76. package/dist/components/tool-panel-layout.d.ts +10 -0
  77. package/dist/components/tool-panel-layout.js +12 -0
  78. package/dist/components/tool-panel.d.ts +1 -0
  79. package/dist/components/tool-panel.js +89 -0
  80. package/dist/components/tooltip-icon-button.d.ts +7 -0
  81. package/dist/components/tooltip-icon-button.js +9 -0
  82. package/dist/components/user-menu.d.ts +2 -0
  83. package/dist/components/user-menu.js +14 -0
  84. package/dist/index.d.ts +68 -0
  85. package/dist/index.js +83 -0
  86. package/dist/lib/ag-ui-adapter.d.ts +29 -0
  87. package/dist/lib/ag-ui-adapter.js +382 -0
  88. package/dist/lib/app-store.d.ts +115 -0
  89. package/dist/lib/app-store.js +199 -0
  90. package/dist/lib/attachment-adapter.d.ts +20 -0
  91. package/dist/lib/attachment-adapter.js +99 -0
  92. package/dist/lib/auth-provider.d.ts +16 -0
  93. package/dist/lib/auth-provider.js +88 -0
  94. package/dist/lib/chat-bubble-store.d.ts +30 -0
  95. package/dist/lib/chat-bubble-store.js +23 -0
  96. package/dist/lib/chat-lifecycle-store.d.ts +10 -0
  97. package/{src/lib/chat-lifecycle-store.ts → dist/lib/chat-lifecycle-store.js} +3 -13
  98. package/dist/lib/client-tools.d.ts +11 -0
  99. package/dist/lib/client-tools.js +274 -0
  100. package/dist/lib/composer-submit-store.d.ts +12 -0
  101. package/dist/lib/composer-submit-store.js +17 -0
  102. package/dist/lib/dev-store.d.ts +38 -0
  103. package/dist/lib/dev-store.js +32 -0
  104. package/dist/lib/nav-config.d.ts +159 -0
  105. package/dist/lib/nav-config.js +162 -0
  106. package/dist/lib/nav-dnd.d.ts +8 -0
  107. package/dist/lib/nav-dnd.js +9 -0
  108. package/dist/lib/nav-store.d.ts +45 -0
  109. package/dist/lib/nav-store.js +49 -0
  110. package/dist/lib/selection-context.d.ts +21 -0
  111. package/dist/lib/selection-context.js +34 -0
  112. package/dist/lib/sidebar-store.d.ts +23 -0
  113. package/dist/lib/sidebar-store.js +98 -0
  114. package/dist/lib/theme-runtime.d.ts +130 -0
  115. package/dist/lib/theme-runtime.js +479 -0
  116. package/dist/lib/theme-store.d.ts +15 -0
  117. package/dist/lib/theme-store.js +53 -0
  118. package/dist/lib/tool-panel-store.d.ts +48 -0
  119. package/dist/lib/tool-panel-store.js +69 -0
  120. package/dist/lib/use-new-conversation.d.ts +8 -0
  121. package/dist/lib/use-new-conversation.js +62 -0
  122. package/dist/lib/use-page-tools.d.ts +27 -0
  123. package/{src/lib/use-page-tools.ts → dist/lib/use-page-tools.js} +11 -13
  124. package/dist/styles.css +142 -0
  125. package/dist/ui/collapsible.d.ts +5 -0
  126. package/{src/ui/collapsible.tsx → dist/ui/collapsible.js} +0 -2
  127. package/dist/ui/dialog.d.ts +15 -0
  128. package/dist/ui/dialog.js +25 -0
  129. package/dist/ui/dropdown-menu.d.ts +7 -0
  130. package/dist/ui/dropdown-menu.js +19 -0
  131. package/dist/ui/popover.d.ts +7 -0
  132. package/dist/ui/popover.js +10 -0
  133. package/dist/ui/select.d.ts +4 -0
  134. package/dist/ui/select.js +9 -0
  135. package/dist/ui/tooltip.d.ts +7 -0
  136. package/dist/ui/tooltip.js +10 -0
  137. package/package.json +31 -12
  138. package/AGENTS.md +0 -59
  139. package/CHANGELOG.md +0 -211
  140. package/CLAUDE.md +0 -1
  141. package/src/__tests__/no-spaces-imports.test.ts +0 -59
  142. package/src/__tests__/open-core-guards.test.ts +0 -307
  143. package/src/__tests__/theme-runtime.test.ts +0 -81
  144. package/src/__tests__/tool-fallback.test.tsx +0 -109
  145. package/src/components/__tests__/context-bar.test.ts +0 -112
  146. package/src/components/ag-ui-runtime-provider.tsx +0 -170
  147. package/src/components/app-brand.tsx +0 -38
  148. package/src/components/assistant-chat.tsx +0 -461
  149. package/src/components/chat-attachments.tsx +0 -68
  150. package/src/components/chat-bubble.tsx +0 -373
  151. package/src/components/chat-header.tsx +0 -44
  152. package/src/components/client-tool-executor.tsx +0 -230
  153. package/src/components/collection-empty-state.tsx +0 -37
  154. package/src/components/collection-filter-bar.tsx +0 -168
  155. package/src/components/collection-search-input.tsx +0 -41
  156. package/src/components/collection-skeleton.tsx +0 -55
  157. package/src/components/collection-sort-menu.tsx +0 -62
  158. package/src/components/collection-surface.tsx +0 -46
  159. package/src/components/collection-toolbar.tsx +0 -33
  160. package/src/components/collection-view-toggle.tsx +0 -61
  161. package/src/components/composer-submit-bridge.tsx +0 -19
  162. package/src/components/confirm-dialog.tsx +0 -49
  163. package/src/components/confirmation-card.tsx +0 -32
  164. package/src/components/context-badges.tsx +0 -136
  165. package/src/components/context-bar.tsx +0 -238
  166. package/src/components/form-dialog.tsx +0 -56
  167. package/src/components/global-selection-popover.tsx +0 -266
  168. package/src/components/infinite-scroll-sentinel.tsx +0 -48
  169. package/src/components/json-viewer.tsx +0 -232
  170. package/src/components/loading-indicator.tsx +0 -40
  171. package/src/components/markdown-text-citations.test.tsx +0 -108
  172. package/src/components/markdown-text.tsx +0 -508
  173. package/src/components/name-dialog.tsx +0 -87
  174. package/src/components/selection-popover.tsx +0 -156
  175. package/src/components/show-document-tool-ui.tsx +0 -90
  176. package/src/components/sidebar.test.tsx +0 -611
  177. package/src/components/sidebar.tsx +0 -1689
  178. package/src/components/surface-card.tsx +0 -45
  179. package/src/components/theme-runtime-provider.tsx +0 -93
  180. package/src/components/theme-toggle.tsx +0 -27
  181. package/src/components/tool-call-card.tsx +0 -126
  182. package/src/components/tool-fallback.tsx +0 -169
  183. package/src/components/tool-panel-layout.tsx +0 -36
  184. package/src/components/tool-panel.tsx +0 -233
  185. package/src/components/tooltip-icon-button.tsx +0 -28
  186. package/src/components/user-menu.tsx +0 -60
  187. package/src/index.ts +0 -185
  188. package/src/lib/__tests__/ag-ui-adapter.test.ts +0 -279
  189. package/src/lib/__tests__/app-store.test.ts +0 -405
  190. package/src/lib/__tests__/attachment-adapter.test.ts +0 -48
  191. package/src/lib/__tests__/chat-bubble-store.test.ts +0 -67
  192. package/src/lib/__tests__/client-tools.test.ts +0 -124
  193. package/src/lib/__tests__/dev-store.test.ts +0 -78
  194. package/src/lib/__tests__/nav-config.test.ts +0 -135
  195. package/src/lib/__tests__/nav-dnd.test.ts +0 -24
  196. package/src/lib/__tests__/nav-store.test.ts +0 -59
  197. package/src/lib/__tests__/selection-context.test.ts +0 -114
  198. package/src/lib/__tests__/sidebar-store.test.ts +0 -144
  199. package/src/lib/__tests__/theme-store.test.ts +0 -83
  200. package/src/lib/__tests__/tool-panel-store.test.ts +0 -61
  201. package/src/lib/__tests__/use-page-context.test.ts +0 -58
  202. package/src/lib/ag-ui-adapter.ts +0 -426
  203. package/src/lib/app-store.ts +0 -361
  204. package/src/lib/attachment-adapter.ts +0 -92
  205. package/src/lib/auth-provider.tsx +0 -144
  206. package/src/lib/chat-bubble-store.ts +0 -46
  207. package/src/lib/client-tools.ts +0 -293
  208. package/src/lib/composer-submit-store.ts +0 -32
  209. package/src/lib/dev-store.ts +0 -69
  210. package/src/lib/nav-config.ts +0 -329
  211. package/src/lib/nav-dnd.ts +0 -14
  212. package/src/lib/nav-store.ts +0 -89
  213. package/src/lib/selection-context.ts +0 -65
  214. package/src/lib/sidebar-store.ts +0 -113
  215. package/src/lib/theme-runtime.ts +0 -660
  216. package/src/lib/theme-store.ts +0 -67
  217. package/src/lib/tool-panel-store.ts +0 -121
  218. package/src/lib/use-new-conversation.test.tsx +0 -168
  219. package/src/lib/use-new-conversation.ts +0 -64
  220. package/src/ui/dialog.tsx +0 -109
  221. package/src/ui/dropdown-menu.tsx +0 -75
  222. package/src/ui/popover.tsx +0 -34
  223. package/src/ui/select.tsx +0 -15
  224. package/src/ui/tooltip.tsx +0 -30
  225. package/src/vite-env.d.ts +0 -1
  226. package/tsconfig.json +0 -16
  227. package/vitest.config.ts +0 -8
@@ -0,0 +1,10 @@
1
+ import type { FC } from "react";
2
+ /**
3
+ * Message send/receive time — revealed on hover in the same row as the
4
+ * message actions (edit / copy). The short time is shown; the full date
5
+ * lives in the native tooltip. Shared by the full-page thread and the
6
+ * compact chat bubble.
7
+ */
8
+ export declare const MessageTimestamp: FC<{
9
+ className?: string;
10
+ }>;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useAuiState } from "@assistant-ui/react";
3
+ import { cn } from "@iloveagents/foundry-web-primitives";
4
+ /**
5
+ * Message send/receive time — revealed on hover in the same row as the
6
+ * message actions (edit / copy). The short time is shown; the full date
7
+ * lives in the native tooltip. Shared by the full-page thread and the
8
+ * compact chat bubble.
9
+ */
10
+ export const MessageTimestamp = ({ className }) => {
11
+ const createdAt = useAuiState((s) => s.message.createdAt);
12
+ if (!createdAt)
13
+ return null;
14
+ const d = createdAt instanceof Date ? createdAt : new Date(createdAt);
15
+ if (Number.isNaN(d.getTime()))
16
+ return null;
17
+ return (_jsx("span", { title: d.toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" }), className: cn("text-xs text-muted-foreground/70 tabular-nums select-none", "opacity-0 transition-opacity group-hover:opacity-100", className), children: d.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" }) }));
18
+ };
@@ -0,0 +1,16 @@
1
+ import { type ReactNode } from "react";
2
+ export declare function NameDialog({ open, onOpenChange, title, description, placeholder, label, submitLabel, pendingLabel, initialValue, error, pending, extra, onSubmit, }: {
3
+ open: boolean;
4
+ onOpenChange: (open: boolean) => void;
5
+ title: ReactNode;
6
+ description?: ReactNode;
7
+ placeholder: string;
8
+ label?: ReactNode;
9
+ submitLabel?: string;
10
+ pendingLabel?: string;
11
+ initialValue?: string;
12
+ error?: ReactNode;
13
+ pending?: boolean;
14
+ extra?: ReactNode;
15
+ onSubmit: (value: string) => void | Promise<void>;
16
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useId, useState } from "react";
3
+ import { Button } from "@iloveagents/foundry-web-primitives";
4
+ import { Input } from "@iloveagents/foundry-web-primitives";
5
+ import { FormDialog } from "./form-dialog.js";
6
+ import { Field } from "@iloveagents/foundry-web-primitives";
7
+ export function NameDialog({ open, onOpenChange, title, description, placeholder, label = "Name", submitLabel = "Create", pendingLabel, initialValue = "", error, pending = false, extra, onSubmit, }) {
8
+ const inputId = useId();
9
+ const [value, setValue] = useState(initialValue);
10
+ useEffect(() => {
11
+ if (open)
12
+ setValue(initialValue);
13
+ }, [open, initialValue]);
14
+ return (_jsx(FormDialog, { open: open, onOpenChange: onOpenChange, title: title, description: description, size: "sm", footer: _jsxs(_Fragment, { children: [_jsx(Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), disabled: pending, children: "Cancel" }), _jsx(Button, { type: "submit", form: `${inputId}-form`, disabled: !value.trim() || pending, children: pending ? (pendingLabel ?? `${submitLabel}...`) : submitLabel })] }), children: _jsxs("form", { id: `${inputId}-form`, className: "space-y-4", onSubmit: (event) => {
15
+ event.preventDefault();
16
+ if (pending)
17
+ return;
18
+ const trimmed = value.trim();
19
+ if (!trimmed)
20
+ return;
21
+ void onSubmit(trimmed);
22
+ }, children: [_jsx(Field, { label: label, htmlFor: inputId, error: error, children: _jsx(Input, { id: inputId, value: value, onChange: (event) => setValue(event.target.value), placeholder: placeholder, disabled: pending, autoFocus: true }) }), extra] }) }));
23
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Floating "Add to chat" button for text selection in the tool panel.
3
+ *
4
+ * Appears near the selected text when the user makes a selection within
5
+ * the panel content area. Clicking adds the selection to the context store.
6
+ */
7
+ import { type RefObject } from "react";
8
+ interface SelectionPopoverProps {
9
+ containerRef: RefObject<HTMLDivElement | null>;
10
+ }
11
+ export declare function SelectionPopover({ containerRef }: SelectionPopoverProps): import("react/jsx-runtime").JSX.Element | null;
12
+ export {};
@@ -0,0 +1,111 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Floating "Add to chat" button for text selection in the tool panel.
4
+ *
5
+ * Appears near the selected text when the user makes a selection within
6
+ * the panel content area. Clicking adds the selection to the context store.
7
+ */
8
+ import { useState, useEffect, useCallback, useRef } from "react";
9
+ import { TextSelect } from "lucide-react";
10
+ import { cn } from "@iloveagents/foundry-web-primitives";
11
+ import { useAppStore } from "../lib/app-store.js";
12
+ import { useToolPanelStore } from "../lib/tool-panel-store.js";
13
+ const POPOVER_HEIGHT = 36;
14
+ const POPOVER_WIDTH = 126;
15
+ const OFFSET = 8;
16
+ export function SelectionPopover({ containerRef }) {
17
+ const [position, setPosition] = useState(null);
18
+ const [selectedText, setSelectedText] = useState("");
19
+ const addContextItem = useAppStore((s) => s.addContextItem);
20
+ const buttonRef = useRef(null);
21
+ const hidePopover = useCallback(() => {
22
+ setPosition(null);
23
+ setSelectedText("");
24
+ }, []);
25
+ const handleMouseUp = useCallback(() => {
26
+ // Small delay to let the selection finalize
27
+ requestAnimationFrame(() => {
28
+ const selection = window.getSelection();
29
+ if (!selection || selection.isCollapsed || !selection.toString().trim()) {
30
+ return;
31
+ }
32
+ // Ensure selection is within the container
33
+ const container = containerRef.current;
34
+ if (!container)
35
+ return;
36
+ const anchorNode = selection.anchorNode;
37
+ if (!anchorNode || !container.contains(anchorNode)) {
38
+ return;
39
+ }
40
+ const text = selection.toString().trim();
41
+ if (!text)
42
+ return;
43
+ const range = selection.getRangeAt(0);
44
+ const rect = range.getBoundingClientRect();
45
+ // The tool panel uses CSS transforms (translate-x), which creates
46
+ // a new containing block -- `position: fixed` becomes relative to
47
+ // the nearest transformed ancestor, not the viewport. Convert
48
+ // viewport coords to container-relative coords.
49
+ const containerRect = container.getBoundingClientRect();
50
+ // Position above selection
51
+ let top = rect.top - containerRect.top + container.scrollTop - POPOVER_HEIGHT - OFFSET;
52
+ let left = rect.left - containerRect.left + rect.width / 2 - POPOVER_WIDTH / 2;
53
+ // If would go above visible area, place below instead
54
+ if (rect.top - containerRect.top - POPOVER_HEIGHT - OFFSET < 0) {
55
+ top = rect.bottom - containerRect.top + container.scrollTop + OFFSET;
56
+ }
57
+ // Clamp horizontal within container
58
+ const maxLeft = containerRect.width - POPOVER_WIDTH - OFFSET;
59
+ left = Math.max(OFFSET, Math.min(left, maxLeft));
60
+ setSelectedText(text);
61
+ setPosition({ top, left });
62
+ });
63
+ }, [containerRef]);
64
+ const handleAddToContext = useCallback(() => {
65
+ if (!selectedText)
66
+ return;
67
+ const source = useToolPanelStore.getState().content?.title ?? "Document";
68
+ addContextItem({
69
+ type: "selection",
70
+ label: selectedText,
71
+ payload: { kind: "text", text: selectedText },
72
+ sourcePage: source,
73
+ persistence: "ephemeral",
74
+ });
75
+ // Clear selection and hide popover
76
+ window.getSelection()?.removeAllRanges();
77
+ hidePopover();
78
+ }, [selectedText, addContextItem, hidePopover]);
79
+ useEffect(() => {
80
+ const container = containerRef.current;
81
+ if (!container)
82
+ return;
83
+ container.addEventListener("mouseup", handleMouseUp);
84
+ // Hide on mousedown (new selection starting), scroll, or Escape.
85
+ // Skip if the mousedown is on the popover button itself -- React's
86
+ // synthetic onMouseDown fires after native listeners, so we can't
87
+ // rely on stopPropagation there.
88
+ const handleMouseDown = (e) => {
89
+ if (buttonRef.current?.contains(e.target))
90
+ return;
91
+ hidePopover();
92
+ };
93
+ const handleScroll = () => hidePopover();
94
+ const handleKeyDown = (e) => {
95
+ if (e.key === "Escape")
96
+ hidePopover();
97
+ };
98
+ container.addEventListener("mousedown", handleMouseDown);
99
+ container.addEventListener("scroll", handleScroll, true);
100
+ window.addEventListener("keydown", handleKeyDown);
101
+ return () => {
102
+ container.removeEventListener("mouseup", handleMouseUp);
103
+ container.removeEventListener("mousedown", handleMouseDown);
104
+ container.removeEventListener("scroll", handleScroll, true);
105
+ window.removeEventListener("keydown", handleKeyDown);
106
+ };
107
+ }, [containerRef, handleMouseUp, hidePopover]);
108
+ if (!position)
109
+ return null;
110
+ return (_jsxs("button", { ref: buttonRef, type: "button", className: cn("absolute z-50", "flex items-center gap-1.5", "rounded-lg border border-border bg-background shadow-lg", "px-3 py-1.5 text-xs font-medium text-foreground", "hover:bg-muted transition-colors", "animate-in fade-in-0 zoom-in-95 duration-150"), style: { top: position.top, left: position.left }, onMouseDown: (e) => e.preventDefault(), onClick: handleAddToContext, children: [_jsx(TextSelect, { className: "size-3.5 text-primary" }), "Add to chat"] }));
111
+ }
@@ -0,0 +1 @@
1
+ export declare const ShowDocumentToolUI: import("@assistant-ui/react").AssistantToolUI;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { makeAssistantToolUI } from "@assistant-ui/react";
3
+ import { useRef } from "react";
4
+ import { FileText } from "lucide-react";
5
+ import { useToolPanelStore } from "../lib/tool-panel-store.js";
6
+ import { ToolCallCard } from "./tool-call-card.js";
7
+ export const ShowDocumentToolUI = makeAssistantToolUI({
8
+ toolName: "show_document",
9
+ render: ({ args, result, status, toolCallId }) => {
10
+ const openPanel = useToolPanelStore((state) => state.openPanel);
11
+ const openedToolCallsRef = useRef(new Set());
12
+ if (status.type === "complete" &&
13
+ result?.status === "success" &&
14
+ args &&
15
+ !openedToolCallsRef.current.has(toolCallId)) {
16
+ openedToolCallsRef.current.add(toolCallId);
17
+ queueMicrotask(() => {
18
+ openPanel({
19
+ title: args.title,
20
+ content: args.content,
21
+ type: args.type || "markdown",
22
+ });
23
+ });
24
+ }
25
+ let description = "";
26
+ if (status.type === "running") {
27
+ description = "Opening document...";
28
+ }
29
+ else if (status.type === "complete" && result) {
30
+ description =
31
+ result.message ||
32
+ (result.status === "success" ? "Document ready" : "Failed to open document");
33
+ }
34
+ else if (status.type === "requires-action") {
35
+ description = "Action required to display document";
36
+ }
37
+ const handleViewDocument = () => {
38
+ if (args) {
39
+ openPanel({
40
+ title: args.title,
41
+ content: args.content,
42
+ type: args.type || "markdown",
43
+ });
44
+ }
45
+ };
46
+ return (_jsx(ToolCallCard, { icon: _jsx(FileText, { className: "size-3.5" }), title: "Document Display", description: description, status: status, className: "w-full", action: status.type === "complete" && result?.status === "success" && args
47
+ ? {
48
+ label: "View Document",
49
+ onClick: handleViewDocument,
50
+ }
51
+ : undefined, children: args && (_jsxs("div", { className: "text-muted-foreground text-xs", children: [_jsx("span", { className: "font-medium", children: "Title:" }), " ", args.title, args.type && (_jsxs("span", { className: "ml-2", children: [_jsx("span", { className: "font-medium", children: "Type:" }), " ", args.type] }))] })) }));
52
+ },
53
+ });
@@ -0,0 +1,4 @@
1
+ declare function scrollNavRowIntoView(nav: HTMLElement, row: HTMLElement): void;
2
+ export declare const _scrollNavRowIntoViewForTest: typeof scrollNavRowIntoView;
3
+ export declare function Sidebar(): import("react/jsx-runtime").JSX.Element;
4
+ export {};