@townco/ui 0.1.68 → 0.1.70

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 (51) hide show
  1. package/dist/core/hooks/use-chat-messages.d.ts +6 -1
  2. package/dist/core/hooks/use-chat-session.d.ts +1 -1
  3. package/dist/core/hooks/use-tool-calls.d.ts +6 -1
  4. package/dist/core/schemas/chat.d.ts +10 -0
  5. package/dist/core/schemas/tool-call.d.ts +13 -8
  6. package/dist/core/schemas/tool-call.js +8 -0
  7. package/dist/core/utils/tool-call-state.d.ts +30 -0
  8. package/dist/core/utils/tool-call-state.js +73 -0
  9. package/dist/core/utils/tool-summary.d.ts +13 -0
  10. package/dist/core/utils/tool-summary.js +172 -0
  11. package/dist/core/utils/tool-verbiage.d.ts +28 -0
  12. package/dist/core/utils/tool-verbiage.js +185 -0
  13. package/dist/gui/components/AppSidebar.d.ts +22 -0
  14. package/dist/gui/components/AppSidebar.js +22 -0
  15. package/dist/gui/components/ChatLayout.d.ts +5 -0
  16. package/dist/gui/components/ChatLayout.js +130 -138
  17. package/dist/gui/components/ChatView.js +42 -118
  18. package/dist/gui/components/HookNotification.d.ts +9 -0
  19. package/dist/gui/components/HookNotification.js +50 -0
  20. package/dist/gui/components/MessageContent.js +151 -39
  21. package/dist/gui/components/SessionHistory.d.ts +10 -0
  22. package/dist/gui/components/SessionHistory.js +101 -0
  23. package/dist/gui/components/SessionHistoryItem.d.ts +11 -0
  24. package/dist/gui/components/SessionHistoryItem.js +24 -0
  25. package/dist/gui/components/Sheet.d.ts +25 -0
  26. package/dist/gui/components/Sheet.js +36 -0
  27. package/dist/gui/components/Sidebar.d.ts +65 -0
  28. package/dist/gui/components/Sidebar.js +231 -0
  29. package/dist/gui/components/SidebarToggle.d.ts +3 -0
  30. package/dist/gui/components/SidebarToggle.js +9 -0
  31. package/dist/gui/components/SubAgentDetails.js +13 -2
  32. package/dist/gui/components/ToolCallList.js +3 -3
  33. package/dist/gui/components/ToolOperation.d.ts +11 -0
  34. package/dist/gui/components/ToolOperation.js +329 -0
  35. package/dist/gui/components/WorkProgress.d.ts +20 -0
  36. package/dist/gui/components/WorkProgress.js +79 -0
  37. package/dist/gui/components/index.d.ts +8 -1
  38. package/dist/gui/components/index.js +9 -1
  39. package/dist/gui/hooks/index.d.ts +1 -0
  40. package/dist/gui/hooks/index.js +1 -0
  41. package/dist/gui/hooks/use-mobile.d.ts +1 -0
  42. package/dist/gui/hooks/use-mobile.js +15 -0
  43. package/dist/gui/index.d.ts +1 -0
  44. package/dist/gui/index.js +2 -0
  45. package/dist/gui/lib/motion.d.ts +55 -0
  46. package/dist/gui/lib/motion.js +217 -0
  47. package/dist/sdk/schemas/message.d.ts +2 -2
  48. package/dist/sdk/schemas/session.d.ts +5 -0
  49. package/dist/sdk/transports/types.d.ts +5 -0
  50. package/package.json +8 -7
  51. package/src/styles/global.css +128 -1
@@ -0,0 +1,65 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import * as React from "react";
3
+ import { TooltipContent } from "./Tooltip.js";
4
+ type SidebarContextProps = {
5
+ state: "expanded" | "collapsed";
6
+ open: boolean;
7
+ setOpen: (open: boolean) => void;
8
+ openMobile: boolean;
9
+ setOpenMobile: (open: boolean) => void;
10
+ isMobile: boolean;
11
+ toggleSidebar: () => void;
12
+ };
13
+ declare function useSidebar(): SidebarContextProps;
14
+ declare const SidebarProvider: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
15
+ defaultOpen?: boolean;
16
+ open?: boolean;
17
+ onOpenChange?: (open: boolean) => void;
18
+ }, "ref"> & React.RefAttributes<HTMLDivElement>>;
19
+ declare const Sidebar: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
20
+ side?: "left" | "right";
21
+ variant?: "sidebar" | "floating" | "inset";
22
+ collapsible?: "offcanvas" | "icon" | "none";
23
+ }, "ref"> & React.RefAttributes<HTMLDivElement>>;
24
+ declare const SidebarTrigger: React.ForwardRefExoticComponent<Omit<import("./Button.js").ButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
25
+ declare const SidebarRail: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
26
+ declare const SidebarInset: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
27
+ declare const SidebarInput: React.ForwardRefExoticComponent<Omit<import("./Input.js").InputProps & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
28
+ declare const SidebarHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
29
+ declare const SidebarFooter: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
30
+ declare const SidebarSeparator: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
31
+ declare const SidebarContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
32
+ declare const SidebarGroup: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
33
+ declare const SidebarGroupLabel: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
34
+ asChild?: boolean;
35
+ }, "ref"> & React.RefAttributes<HTMLDivElement>>;
36
+ declare const SidebarGroupAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
37
+ asChild?: boolean;
38
+ }, "ref"> & React.RefAttributes<HTMLButtonElement>>;
39
+ declare const SidebarGroupContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
40
+ declare const SidebarMenu: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
41
+ declare const SidebarMenuItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
42
+ declare const SidebarMenuButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
43
+ asChild?: boolean;
44
+ isActive?: boolean;
45
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>;
46
+ } & VariantProps<(props?: ({
47
+ variant?: "default" | "outline" | null | undefined;
48
+ size?: "default" | "sm" | "lg" | null | undefined;
49
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
50
+ declare const SidebarMenuAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
51
+ asChild?: boolean;
52
+ showOnHover?: boolean;
53
+ }, "ref"> & React.RefAttributes<HTMLButtonElement>>;
54
+ declare const SidebarMenuBadge: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
55
+ declare const SidebarMenuSkeleton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
56
+ showIcon?: boolean;
57
+ }, "ref"> & React.RefAttributes<HTMLDivElement>>;
58
+ declare const SidebarMenuSub: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
59
+ declare const SidebarMenuSubItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
60
+ declare const SidebarMenuSubButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
61
+ asChild?: boolean;
62
+ size?: "sm" | "md";
63
+ isActive?: boolean;
64
+ }, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
65
+ export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
@@ -0,0 +1,231 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Slot as SlotPrimitive } from "@radix-ui/react-slot";
3
+ import { cva } from "class-variance-authority";
4
+ import { PanelLeft } from "lucide-react";
5
+ import * as React from "react";
6
+ import { useIsMobile } from "../hooks/use-mobile.js";
7
+ import { cn } from "../lib/utils.js";
8
+ import { Button } from "./Button.js";
9
+ import { Input } from "./Input.js";
10
+ import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "./Sheet.js";
11
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "./Tooltip.js";
12
+ const SIDEBAR_COOKIE_NAME = "sidebar_state";
13
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
14
+ const SIDEBAR_WIDTH = "16rem";
15
+ const SIDEBAR_WIDTH_MOBILE = "18rem";
16
+ const SIDEBAR_WIDTH_ICON = "3rem";
17
+ const SIDEBAR_KEYBOARD_SHORTCUT = "s";
18
+ const SidebarContext = React.createContext(null);
19
+ function useSidebar() {
20
+ const context = React.useContext(SidebarContext);
21
+ if (!context) {
22
+ throw new Error("useSidebar must be used within a SidebarProvider.");
23
+ }
24
+ return context;
25
+ }
26
+ const SidebarProvider = React.forwardRef(({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }, ref) => {
27
+ const isMobile = useIsMobile();
28
+ const [openMobile, setOpenMobile] = React.useState(false);
29
+ // This is the internal state of the sidebar.
30
+ // We use openProp and setOpenProp for control from outside the component.
31
+ const [_open, _setOpen] = React.useState(defaultOpen);
32
+ const open = openProp ?? _open;
33
+ const setOpen = React.useCallback((value) => {
34
+ const openState = typeof value === "function" ? value(open) : value;
35
+ if (setOpenProp) {
36
+ setOpenProp(openState);
37
+ }
38
+ else {
39
+ _setOpen(openState);
40
+ }
41
+ // This sets the cookie to keep the sidebar state.
42
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
43
+ }, [setOpenProp, open]);
44
+ // Helper to toggle the sidebar.
45
+ const toggleSidebar = React.useCallback(() => {
46
+ return isMobile
47
+ ? setOpenMobile((open) => !open)
48
+ : setOpen((open) => !open);
49
+ }, [isMobile, setOpen, setOpenMobile]);
50
+ // Adds a keyboard shortcut to toggle the sidebar (Cmd/Ctrl+Shift+S).
51
+ React.useEffect(() => {
52
+ const handleKeyDown = (event) => {
53
+ if (event.key.toLowerCase() === SIDEBAR_KEYBOARD_SHORTCUT &&
54
+ event.shiftKey &&
55
+ (event.metaKey || event.ctrlKey)) {
56
+ event.preventDefault();
57
+ toggleSidebar();
58
+ }
59
+ };
60
+ window.addEventListener("keydown", handleKeyDown);
61
+ return () => window.removeEventListener("keydown", handleKeyDown);
62
+ }, [toggleSidebar]);
63
+ // We add a state so that we can do data-state="expanded" or "collapsed".
64
+ // This makes it easier to style the sidebar with Tailwind classes.
65
+ const state = open ? "expanded" : "collapsed";
66
+ const contextValue = React.useMemo(() => ({
67
+ state,
68
+ open,
69
+ setOpen,
70
+ isMobile,
71
+ openMobile,
72
+ setOpenMobile,
73
+ toggleSidebar,
74
+ }), [
75
+ state,
76
+ open,
77
+ setOpen,
78
+ isMobile,
79
+ openMobile,
80
+ setOpenMobile,
81
+ toggleSidebar,
82
+ ]);
83
+ return (_jsx(SidebarContext.Provider, { value: contextValue, children: _jsx(TooltipProvider, { delayDuration: 0, children: _jsx("div", { className: cn("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar", className), ref: ref, style: {
84
+ "--sidebar-width": SIDEBAR_WIDTH,
85
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
86
+ ...style,
87
+ }, ...props, children: children }) }) }));
88
+ });
89
+ SidebarProvider.displayName = "SidebarProvider";
90
+ const Sidebar = React.forwardRef(({ side = "left", variant = "sidebar", collapsible = "offcanvas", className, children, ...props }, ref) => {
91
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
92
+ if (collapsible === "none") {
93
+ return (_jsx("div", { className: cn("flex h-full w-[var(--sidebar-width)] flex-col bg-sidebar text-sidebar-foreground", className), ref: ref, ...props, children: children }));
94
+ }
95
+ if (isMobile) {
96
+ return (_jsx(Sheet, { onOpenChange: setOpenMobile, open: openMobile, ...props, children: _jsxs(SheetContent, { className: "w-[var(--sidebar-width)] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", "data-mobile": "true", "data-sidebar": "sidebar", side: side, style: {
97
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
98
+ }, children: [_jsxs(SheetHeader, { className: "sr-only", children: [_jsx(SheetTitle, { children: "Sidebar" }), _jsx(SheetDescription, { children: "Displays the mobile sidebar." })] }), _jsx("div", { className: "flex h-full w-full flex-col", children: children })] }) }));
99
+ }
100
+ return (_jsxs("div", { className: "group peer hidden text-sidebar-foreground md:block", "data-collapsible": state === "collapsed" ? collapsible : "", "data-side": side, "data-state": state, "data-variant": variant, ref: ref, children: [_jsx("div", { className: cn("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-150 ease-linear", "group-data-[collapsible=offcanvas]:w-0", "group-data-[side=right]:rotate-180", variant === "floating" || variant === "inset"
101
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
102
+ : "group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]") }), _jsx("div", { className: cn("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-150 ease-linear md:flex", side === "left"
103
+ ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
104
+ : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
105
+ // Adjust the padding for floating and inset variants.
106
+ variant === "floating" || variant === "inset"
107
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"
108
+ : "group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l", className), ...props, children: _jsx("div", { className: "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow", "data-sidebar": "sidebar", children: children }) })] }));
109
+ });
110
+ Sidebar.displayName = "Sidebar";
111
+ const SidebarTrigger = React.forwardRef(({ className, onClick, ...props }, ref) => {
112
+ const { toggleSidebar } = useSidebar();
113
+ return (_jsxs(Button, { className: cn("h-7 w-7", className), "data-sidebar": "trigger", onClick: (event) => {
114
+ onClick?.(event);
115
+ toggleSidebar();
116
+ }, ref: ref, size: "icon", variant: "ghost", ...props, children: [_jsx(PanelLeft, {}), _jsx("span", { className: "sr-only", children: "Toggle Sidebar" })] }));
117
+ });
118
+ SidebarTrigger.displayName = "SidebarTrigger";
119
+ const SidebarRail = React.forwardRef(({ className, ...props }, ref) => {
120
+ const { toggleSidebar } = useSidebar();
121
+ return (_jsx("button", { type: "button", "aria-label": "Toggle Sidebar", className: cn("-translate-x-1/2 group-data-[side=left]:-right-4 absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=right]:left-0 sm:flex", "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize", "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize", "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:after:left-full", "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2", "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2", className), "data-sidebar": "rail", onClick: toggleSidebar, ref: ref, tabIndex: -1, title: "Toggle Sidebar", ...props }));
122
+ });
123
+ SidebarRail.displayName = "SidebarRail";
124
+ const SidebarInset = React.forwardRef(({ className, ...props }, ref) => {
125
+ return (_jsx("main", { className: cn("relative flex w-full flex-1 flex-col bg-background", "md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow", className), ref: ref, ...props }));
126
+ });
127
+ SidebarInset.displayName = "SidebarInset";
128
+ const SidebarInput = React.forwardRef(({ className, ...props }, ref) => {
129
+ return (_jsx(Input, { className: cn("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring", className), "data-sidebar": "input", ref: ref, ...props }));
130
+ });
131
+ SidebarInput.displayName = "SidebarInput";
132
+ const SidebarHeader = React.forwardRef(({ className, ...props }, ref) => {
133
+ return (_jsx("div", { className: cn("flex flex-col gap-2 p-2", className), "data-sidebar": "header", ref: ref, ...props }));
134
+ });
135
+ SidebarHeader.displayName = "SidebarHeader";
136
+ const SidebarFooter = React.forwardRef(({ className, ...props }, ref) => {
137
+ return (_jsx("div", { className: cn("flex flex-col gap-2 p-2", className), "data-sidebar": "footer", ref: ref, ...props }));
138
+ });
139
+ SidebarFooter.displayName = "SidebarFooter";
140
+ const SidebarSeparator = React.forwardRef(({ className, ...props }, ref) => {
141
+ return (_jsx("div", { className: cn("mx-2 h-px w-auto bg-sidebar-border", className), "data-sidebar": "separator", ref: ref, ...props }));
142
+ });
143
+ SidebarSeparator.displayName = "SidebarSeparator";
144
+ const SidebarContent = React.forwardRef(({ className, ...props }, ref) => {
145
+ return (_jsx("div", { className: cn("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden", className), "data-sidebar": "content", ref: ref, ...props }));
146
+ });
147
+ SidebarContent.displayName = "SidebarContent";
148
+ const SidebarGroup = React.forwardRef(({ className, ...props }, ref) => {
149
+ return (_jsx("div", { className: cn("relative flex w-full min-w-0 flex-col p-2", className), "data-sidebar": "group", ref: ref, ...props }));
150
+ });
151
+ SidebarGroup.displayName = "SidebarGroup";
152
+ const SidebarGroupLabel = React.forwardRef(({ className, asChild = false, ...props }, ref) => {
153
+ const Comp = asChild ? SlotPrimitive : "div";
154
+ return (_jsx(Comp, { className: cn("flex h-8 shrink-0 items-center rounded-md px-2 font-medium text-sidebar-foreground/70 text-xs outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0", "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0", className), "data-sidebar": "group-label", ref: ref, ...props }));
155
+ });
156
+ SidebarGroupLabel.displayName = "SidebarGroupLabel";
157
+ const SidebarGroupAction = React.forwardRef(({ className, asChild = false, ...props }, ref) => {
158
+ const Comp = asChild ? SlotPrimitive : "button";
159
+ return (_jsx(Comp, { className: cn("absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
160
+ // Increases the hit area of the button on mobile.
161
+ "after:-inset-2 after:absolute after:md:hidden", "group-data-[collapsible=icon]:hidden", className), "data-sidebar": "group-action", ref: ref, type: "button", ...props }));
162
+ });
163
+ SidebarGroupAction.displayName = "SidebarGroupAction";
164
+ const SidebarGroupContent = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { className: cn("w-full text-sm", className), "data-sidebar": "group-content", ref: ref, ...props })));
165
+ SidebarGroupContent.displayName = "SidebarGroupContent";
166
+ const SidebarMenu = React.forwardRef(({ className, ...props }, ref) => (_jsx("ul", { className: cn("flex w-full min-w-0 flex-col gap-1", className), "data-sidebar": "menu", ref: ref, ...props })));
167
+ SidebarMenu.displayName = "SidebarMenu";
168
+ const SidebarMenuItem = React.forwardRef(({ className, ...props }, ref) => (_jsx("li", { className: cn("group/menu-item relative", className), "data-sidebar": "menu-item", ref: ref, ...props })));
169
+ SidebarMenuItem.displayName = "SidebarMenuItem";
170
+ const sidebarMenuButtonVariants = cva("peer/menu-button group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0", {
171
+ variants: {
172
+ variant: {
173
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
174
+ outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
175
+ },
176
+ size: {
177
+ default: "h-8 text-sm",
178
+ sm: "h-7 text-xs",
179
+ lg: "group-data-[collapsible=icon]:!p-0 h-12 text-sm",
180
+ },
181
+ },
182
+ defaultVariants: {
183
+ variant: "default",
184
+ size: "default",
185
+ },
186
+ });
187
+ const SidebarMenuButton = React.forwardRef(({ asChild = false, isActive = false, variant = "default", size = "default", tooltip, className, ...props }, ref) => {
188
+ const Comp = asChild ? SlotPrimitive : "button";
189
+ const { isMobile, state } = useSidebar();
190
+ const button = (_jsx(Comp, { className: cn(sidebarMenuButtonVariants({ variant, size }), className), "data-active": isActive, "data-sidebar": "menu-button", "data-size": size, ref: ref, type: asChild ? undefined : "button", ...props }));
191
+ if (!tooltip) {
192
+ return button;
193
+ }
194
+ if (typeof tooltip === "string") {
195
+ tooltip = {
196
+ children: tooltip,
197
+ };
198
+ }
199
+ return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: button }), _jsx(TooltipContent, { align: "center", hidden: state !== "collapsed" || isMobile, side: "right", ...tooltip })] }));
200
+ });
201
+ SidebarMenuButton.displayName = "SidebarMenuButton";
202
+ const SidebarMenuAction = React.forwardRef(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
203
+ const Comp = asChild ? SlotPrimitive : "button";
204
+ return (_jsx(Comp, { className: cn("absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",
205
+ // Increases the hit area of the button on mobile.
206
+ "after:-inset-2 after:absolute after:md:hidden", "peer-data-[size=sm]/menu-button:top-1", "peer-data-[size=default]/menu-button:top-1.5", "peer-data-[size=lg]/menu-button:top-2.5", "group-data-[collapsible=icon]:hidden", showOnHover &&
207
+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0", className), "data-sidebar": "menu-action", ref: ref, type: asChild ? undefined : "button", ...props }));
208
+ });
209
+ SidebarMenuAction.displayName = "SidebarMenuAction";
210
+ const SidebarMenuBadge = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { className: cn("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 font-medium text-sidebar-foreground text-xs tabular-nums", "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground", "peer-data-[size=sm]/menu-button:top-1", "peer-data-[size=default]/menu-button:top-1.5", "peer-data-[size=lg]/menu-button:top-2.5", "group-data-[collapsible=icon]:hidden", className), "data-sidebar": "menu-badge", ref: ref, ...props })));
211
+ SidebarMenuBadge.displayName = "SidebarMenuBadge";
212
+ const SidebarMenuSkeleton = React.forwardRef(({ className, showIcon = false, ...props }, ref) => {
213
+ // Random width between 50 to 90%.
214
+ const width = React.useMemo(() => {
215
+ return `${Math.floor(Math.random() * 40) + 50}%`;
216
+ }, []);
217
+ return (_jsxs("div", { className: cn("flex h-8 items-center gap-2 rounded-md px-2", className), "data-sidebar": "menu-skeleton", ref: ref, ...props, children: [showIcon && (_jsx("div", { className: "size-4 rounded-md bg-sidebar-accent-foreground/10 animate-pulse", "data-sidebar": "menu-skeleton-icon" })), _jsx("div", { className: "h-4 flex-1 rounded-md bg-sidebar-accent-foreground/10 animate-pulse", "data-sidebar": "menu-skeleton-text", style: {
218
+ maxWidth: width,
219
+ } })] }));
220
+ });
221
+ SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
222
+ const SidebarMenuSub = React.forwardRef(({ className, ...props }, ref) => (_jsx("ul", { className: cn("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-sidebar-border border-l px-2.5 py-0.5", "group-data-[collapsible=icon]:hidden", className), "data-sidebar": "menu-sub", ref: ref, ...props })));
223
+ SidebarMenuSub.displayName = "SidebarMenuSub";
224
+ const SidebarMenuSubItem = React.forwardRef(({ ...props }, ref) => _jsx("li", { ref: ref, ...props }));
225
+ SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
226
+ const SidebarMenuSubButton = React.forwardRef(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
227
+ const Comp = asChild ? SlotPrimitive : "a";
228
+ return (_jsx(Comp, { className: cn("-translate-x-px flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground", size === "sm" && "text-xs", size === "md" && "text-sm", "group-data-[collapsible=icon]:hidden", className), "data-active": isActive, "data-sidebar": "menu-sub-button", "data-size": size, ref: ref, ...props }));
229
+ });
230
+ SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
231
+ export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
@@ -0,0 +1,3 @@
1
+ import type { ComponentProps } from "react";
2
+ import { type SidebarTrigger } from "./Sidebar.js";
3
+ export declare function SidebarToggle({ className, }: ComponentProps<typeof SidebarTrigger>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Menu } from "lucide-react";
3
+ import { cn } from "../lib/utils.js";
4
+ import { IconButton } from "./IconButton.js";
5
+ import { useSidebar } from "./Sidebar.js";
6
+ export function SidebarToggle({ className, }) {
7
+ const { toggleSidebar, open } = useSidebar();
8
+ return (_jsx(IconButton, { className: cn(className), "data-testid": "sidebar-toggle-button", "data-state": open ? "open" : "closed", onClick: toggleSidebar, "aria-label": "Toggle sidebar", children: _jsx(Menu, { className: "size-4 text-muted-foreground" }) }));
9
+ }
@@ -19,7 +19,8 @@ export function SubAgentDetails({ port, sessionId, host, parentStatus, agentName
19
19
  // Use controlled state if provided, otherwise use internal state
20
20
  const isExpanded = controlledIsExpanded ?? internalIsExpanded;
21
21
  const setIsExpanded = onExpandChange ?? setInternalIsExpanded;
22
- const [isThinkingExpanded, setIsThinkingExpanded] = useState(false);
22
+ // Start with Thinking expanded while running to show the live stream
23
+ const [isThinkingExpanded, setIsThinkingExpanded] = useState(true);
23
24
  const [isNearBottom, setIsNearBottom] = useState(true);
24
25
  const thinkingContainerRef = useRef(null);
25
26
  // Only use SSE streaming if not in replay mode and port/sessionId provided
@@ -99,6 +100,16 @@ export function SubAgentDetails({ port, sessionId, host, parentStatus, agentName
99
100
  checkScrollPosition(); // Check initial position
100
101
  return () => container.removeEventListener("scroll", handleScroll);
101
102
  }, [checkScrollPosition, isThinkingExpanded, isExpanded]);
103
+ // When thinking section expands, scroll to bottom and reset follow state
104
+ useEffect(() => {
105
+ if (isThinkingExpanded) {
106
+ setIsNearBottom(true);
107
+ // Use requestAnimationFrame to ensure DOM has rendered
108
+ requestAnimationFrame(() => {
109
+ scrollToBottom();
110
+ });
111
+ }
112
+ }, [isThinkingExpanded, scrollToBottom]);
102
113
  // Get last line of streaming content for preview
103
114
  const lastLine = currentMessage?.content
104
115
  ? currentMessage.content.split("\n").filter(Boolean).pop() || ""
@@ -109,7 +120,7 @@ export function SubAgentDetails({ port, sessionId, host, parentStatus, agentName
109
120
  ? (query.split("\n")[0] ?? "").slice(0, 100) +
110
121
  (query.length > 100 ? "..." : "")
111
122
  : "";
112
- return (_jsxs("div", { children: [!isExpanded && (_jsx("div", { className: "w-full max-w-md", children: previewText ? (_jsx("p", { className: "text-paragraph-sm text-muted-foreground/70 truncate", children: previewText })) : queryFirstLine ? (_jsx("p", { className: "text-paragraph-sm text-muted-foreground/50 truncate", children: queryFirstLine })) : null })), isExpanded && (_jsxs("div", { className: "space-y-3", children: [(agentName || query) && (_jsxs("div", { children: [_jsx("div", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-1.5 font-sans", children: "Input" }), _jsxs("div", { className: "text-[11px] font-mono space-y-1", children: [agentName && (_jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: "agentName: " }), _jsx("span", { className: "text-foreground", children: agentName })] })), query && (_jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: "query: " }), _jsx("span", { className: "text-foreground", children: query })] }))] })] })), _jsxs("div", { children: [_jsxs("button", { type: "button", onClick: () => setIsThinkingExpanded(!isThinkingExpanded), className: "flex items-center gap-2 cursor-pointer bg-transparent border-none p-0 text-left group", children: [_jsx("div", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider font-sans", children: "Thinking" }), _jsx(ChevronDown, { className: `h-3 w-3 text-muted-foreground/70 transition-transform duration-200 ${isThinkingExpanded ? "rotate-180" : ""}` })] }), isThinkingExpanded && (_jsxs("div", { ref: thinkingContainerRef, className: "mt-2 rounded-md overflow-hidden bg-muted/30 border border-border/50 max-h-[200px] overflow-y-auto", children: [error && (_jsxs("div", { className: "px-2 py-2 text-[11px] text-destructive", children: ["Error: ", error] })), !error && !hasContent && isRunning && (_jsx("div", { className: "px-2 py-2 text-[11px] text-muted-foreground", children: "Waiting for sub-agent response..." })), currentMessage && (_jsxs("div", { className: "px-2 py-2 space-y-2", children: [currentMessage.contentBlocks &&
123
+ return (_jsxs("div", { children: [!isExpanded && (_jsx("div", { className: "w-full max-w-md", children: previewText ? (_jsx("p", { className: "text-paragraph-sm text-muted-foreground/70 truncate", children: previewText })) : queryFirstLine ? (_jsx("p", { className: "text-paragraph-sm text-muted-foreground/50 truncate", children: queryFirstLine })) : null })), isExpanded && (_jsxs("div", { className: "space-y-3", children: [(agentName || query) && (_jsxs("div", { children: [_jsx("div", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-1.5 font-sans", children: "Input" }), _jsxs("div", { className: "text-[11px] font-mono space-y-1", children: [agentName && (_jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: "agentName: " }), _jsx("span", { className: "text-foreground", children: agentName })] })), query && (_jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: "query: " }), _jsx("span", { className: "text-foreground", children: query })] }))] })] })), _jsxs("div", { children: [_jsxs("button", { type: "button", onClick: () => setIsThinkingExpanded(!isThinkingExpanded), className: "flex items-center gap-2 cursor-pointer bg-transparent border-none p-0 text-left group", children: [_jsx("div", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider font-sans", children: "Stream" }), _jsx(ChevronDown, { className: `h-3 w-3 text-muted-foreground/70 transition-transform duration-200 ${isThinkingExpanded ? "rotate-180" : ""}` })] }), isThinkingExpanded && (_jsxs("div", { ref: thinkingContainerRef, className: "mt-2 rounded-md overflow-hidden bg-muted/30 border border-border/50 max-h-[200px] overflow-y-auto", children: [error && (_jsxs("div", { className: "px-2 py-2 text-[11px] text-destructive", children: ["Error: ", error] })), !error && !hasContent && isRunning && (_jsx("div", { className: "px-2 py-2 text-[11px] text-muted-foreground", children: "Waiting for sub-agent response..." })), currentMessage && (_jsxs("div", { className: "px-2 py-2 space-y-2", children: [currentMessage.contentBlocks &&
113
124
  currentMessage.contentBlocks.length > 0
114
125
  ? // Render interleaved content blocks
115
126
  currentMessage.contentBlocks.map((block, idx) => block.type === "text" ? (_jsx("div", { className: "text-[11px] text-foreground prose prose-sm dark:prose-invert max-w-none prose-p:my-1 prose-pre:my-1 prose-code:text-[10px]", children: _jsx(MarkdownRenderer, { content: block.text }) }, `text-${idx}`)) : (_jsx(SubagentToolCallItem, { toolCall: block.toolCall }, block.toolCall.id)))
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ToolCall } from "./ToolCall.js";
2
+ import { ToolOperation } from "./ToolOperation.js";
3
3
  /**
4
4
  * ToolCallList component - renders a list of tool calls, optionally grouped
5
5
  */
@@ -15,8 +15,8 @@ export function ToolCallList({ toolCalls, groupBy = "chronological", }) {
15
15
  completed: toolCalls.filter((tc) => tc.status === "completed"),
16
16
  failed: toolCalls.filter((tc) => tc.status === "failed"),
17
17
  };
18
- return (_jsxs("div", { className: "space-y-4", children: [grouped.in_progress.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "In Progress" }), grouped.in_progress.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id)))] })), grouped.pending.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "Pending" }), grouped.pending.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id)))] })), grouped.completed.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "Completed" }), grouped.completed.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id)))] })), grouped.failed.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-2 pl-1", children: "Failed" }), grouped.failed.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id)))] }))] }));
18
+ return (_jsxs("div", { className: "space-y-4", children: [grouped.in_progress.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "In Progress" }), grouped.in_progress.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id)))] })), grouped.pending.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "Pending" }), grouped.pending.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id)))] })), grouped.completed.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "Completed" }), grouped.completed.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id)))] })), grouped.failed.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-2 pl-1", children: "Failed" }), grouped.failed.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id)))] }))] }));
19
19
  }
20
20
  // Default: chronological order
21
- return (_jsx("div", { className: "space-y-2", children: toolCalls.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id))) }));
21
+ return (_jsx("div", { className: "space-y-2", children: toolCalls.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id))) }));
22
22
  }
@@ -0,0 +1,11 @@
1
+ import type { ToolCall as ToolCallType } from "../../core/schemas/tool-call.js";
2
+ export interface ToolOperationProps {
3
+ toolCalls: ToolCallType[];
4
+ isGrouped?: boolean;
5
+ autoMinimize?: boolean;
6
+ }
7
+ /**
8
+ * ToolOperation component - unified display for tool calls
9
+ * Handles both individual and grouped tool calls with smooth transitions
10
+ */
11
+ export declare function ToolOperation({ toolCalls, isGrouped, autoMinimize, }: ToolOperationProps): import("react/jsx-runtime").JSX.Element;