@assistant-ui/react 0.15.33 → 0.15.35
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/dist/primitives/actionBar/ActionBarRefreshRun.d.ts +26 -0
- package/dist/primitives/actionBar/ActionBarRefreshRun.d.ts.map +1 -0
- package/dist/primitives/actionBar/ActionBarRefreshRun.js +26 -0
- package/dist/primitives/actionBar/ActionBarRefreshRun.js.map +1 -0
- package/dist/primitives/actionBar/ActionBarResume.d.ts +33 -0
- package/dist/primitives/actionBar/ActionBarResume.d.ts.map +1 -0
- package/dist/primitives/actionBar/ActionBarResume.js +33 -0
- package/dist/primitives/actionBar/ActionBarResume.js.map +1 -0
- package/dist/primitives/actionBar/ActionBarRoot.d.ts +4 -2
- package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.d.ts.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/actionBar.d.ts +2 -0
- package/dist/primitives/actionBar.d.ts.map +1 -1
- package/dist/primitives/actionBar.js +5 -1
- package/dist/primitives/actionBar.js.map +1 -1
- package/dist/primitives/error/ErrorRoot.d.ts +5 -0
- package/dist/primitives/error/ErrorRoot.d.ts.map +1 -1
- package/dist/primitives/error/ErrorRoot.js +30 -10
- package/dist/primitives/error/ErrorRoot.js.map +1 -1
- package/package.json +4 -4
- package/src/primitives/actionBar/ActionBarRefreshRun.ts +37 -0
- package/src/primitives/actionBar/ActionBarResume.ts +44 -0
- package/src/primitives/actionBar/ActionBarRoot.tsx +2 -1
- package/src/primitives/actionBar/useActionBarFloatStatus.ts +5 -1
- package/src/primitives/actionBar.ts +2 -0
- package/src/primitives/error/ErrorRoot.tsx +15 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ActionButtonElement, type ActionButtonProps } from "../../utils/createActionButton.js";
|
|
2
|
+
declare const useActionBarRefreshRun: () => (() => void) | null;
|
|
3
|
+
export declare namespace ActionBarPrimitiveRefreshRun {
|
|
4
|
+
type Element = ActionButtonElement;
|
|
5
|
+
type Props = ActionButtonProps<typeof useActionBarRefreshRun>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A button that re-reads an assistant message whose run another tab or
|
|
9
|
+
* session is still writing, so the thread shows its latest stored state
|
|
10
|
+
* without a page reload. The thread also re-reads it on its own around the
|
|
11
|
+
* moment the run would cross `staleAfter`. It renders disabled unless
|
|
12
|
+
* Assistant Cloud reported the run in progress elsewhere, and while a
|
|
13
|
+
* refresh is in flight.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <ActionBarPrimitive.RefreshRun>Refresh</ActionBarPrimitive.RefreshRun>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const ActionBarPrimitiveRefreshRun: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
21
|
+
asChild?: boolean | undefined;
|
|
22
|
+
}, "ref"> & {
|
|
23
|
+
render?: import("react").ReactElement | undefined;
|
|
24
|
+
} & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=ActionBarRefreshRun.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionBarRefreshRun.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarRefreshRun.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEvB,0CAAuC;AAGxC,QAAA,MAAM,sBAAsB,2BAI3B,CAAC;AAEF,yBAAiB,4BAA4B,CAAC;IAC5C,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,sBAAsB,CAAC,CAAC;CACtE;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B;;;;gHAGxC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createActionButton } from "../../utils/createActionButton.js";
|
|
3
|
+
import { useActionBarRefreshRun } from "@assistant-ui/core/react";
|
|
4
|
+
// src/primitives/actionBar/ActionBarRefreshRun.ts
|
|
5
|
+
const useActionBarRefreshRun$1 = () => {
|
|
6
|
+
const { disabled, refresh } = useActionBarRefreshRun();
|
|
7
|
+
if (disabled) return null;
|
|
8
|
+
return refresh;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A button that re-reads an assistant message whose run another tab or
|
|
12
|
+
* session is still writing, so the thread shows its latest stored state
|
|
13
|
+
* without a page reload. The thread also re-reads it on its own around the
|
|
14
|
+
* moment the run would cross `staleAfter`. It renders disabled unless
|
|
15
|
+
* Assistant Cloud reported the run in progress elsewhere, and while a
|
|
16
|
+
* refresh is in flight.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <ActionBarPrimitive.RefreshRun>Refresh</ActionBarPrimitive.RefreshRun>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const ActionBarPrimitiveRefreshRun = createActionButton("ActionBarPrimitive.RefreshRun", useActionBarRefreshRun$1);
|
|
24
|
+
export { ActionBarPrimitiveRefreshRun };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=ActionBarRefreshRun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionBarRefreshRun.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useActionBarRefreshRun","useActionBarRefreshRunBehavior","disabled","refresh","ActionBarPrimitiveRefreshRun","Element","Props","useActionBarRefreshRun","useActionBarRefreshRunBehavior"],"sources":["../../../src/primitives/actionBar/ActionBarRefreshRun.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useActionBarRefreshRun as useActionBarRefreshRunBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarRefreshRun = () => {\n const { disabled, refresh } = useActionBarRefreshRunBehavior();\n if (disabled) return null;\n return refresh;\n};\n\nexport namespace ActionBarPrimitiveRefreshRun {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarRefreshRun>;\n}\n\n/**\n * A button that re-reads an assistant message whose run another tab or\n * session is still writing, so the thread shows its latest stored state\n * without a page reload. The thread also re-reads it on its own around the\n * moment the run would cross `staleAfter`. It renders disabled unless\n * Assistant Cloud reported the run in progress elsewhere, and while a\n * refresh is in flight.\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.RefreshRun>Refresh</ActionBarPrimitive.RefreshRun>\n * ```\n */\nexport const ActionBarPrimitiveRefreshRun = createActionButton(\n \"ActionBarPrimitive.RefreshRun\",\n useActionBarRefreshRun,\n);\n"],"mappings":";;;;AASA,MAAMG,iCAAyB;CAC7B,MAAA,EAAAE,UAAAC,YAA8BF,uBAA+B;CAC7D,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAO;;;;;;;;;;;;;;AAqBhB,MAAaC,+BAA+BL,mBAC1C,iCACAC,wBACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ActionButtonElement, type ActionButtonProps } from "../../utils/createActionButton.js";
|
|
2
|
+
declare const useActionBarResume: () => (() => void) | null;
|
|
3
|
+
export declare namespace ActionBarPrimitiveResume {
|
|
4
|
+
type Element = ActionButtonElement;
|
|
5
|
+
type Props = ActionButtonProps<typeof useActionBarResume>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A button that answers again in place of an assistant message whose run
|
|
9
|
+
* stopped before it wrote anything (its tab closed or lost its connection).
|
|
10
|
+
* It deletes the empty reply and its stored row, then runs again from the
|
|
11
|
+
* reply's parent, so no branch is left beside it; a runtime that cannot
|
|
12
|
+
* delete messages starts a new branch instead. It renders disabled unless the
|
|
13
|
+
* message is the last one on its branch and its run went `staleAfter`
|
|
14
|
+
* without a heartbeat. A reply that wrote content before its run stopped is a
|
|
15
|
+
* regular error, answered again with Regenerate.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <MessagePrimitive.Error>
|
|
20
|
+
* <ErrorPrimitive.Root>
|
|
21
|
+
* <ErrorPrimitive.Message />
|
|
22
|
+
* <ActionBarPrimitive.Resume>Resume</ActionBarPrimitive.Resume>
|
|
23
|
+
* </ErrorPrimitive.Root>
|
|
24
|
+
* </MessagePrimitive.Error>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const ActionBarPrimitiveResume: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
28
|
+
asChild?: boolean | undefined;
|
|
29
|
+
}, "ref"> & {
|
|
30
|
+
render?: import("react").ReactElement | undefined;
|
|
31
|
+
} & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=ActionBarResume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionBarResume.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarResume.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEvB,0CAAuC;AAGxC,QAAA,MAAM,kBAAkB,2BAIvB,CAAC;AAEF,yBAAiB,wBAAwB,CAAC;IACxC,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,kBAAkB,CAAC,CAAC;CAClE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,wBAAwB;;;;gHAGpC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createActionButton } from "../../utils/createActionButton.js";
|
|
3
|
+
import { useActionBarResume } from "@assistant-ui/core/react";
|
|
4
|
+
// src/primitives/actionBar/ActionBarResume.ts
|
|
5
|
+
const useActionBarResume$1 = () => {
|
|
6
|
+
const { disabled, resume } = useActionBarResume();
|
|
7
|
+
if (disabled) return null;
|
|
8
|
+
return resume;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A button that answers again in place of an assistant message whose run
|
|
12
|
+
* stopped before it wrote anything (its tab closed or lost its connection).
|
|
13
|
+
* It deletes the empty reply and its stored row, then runs again from the
|
|
14
|
+
* reply's parent, so no branch is left beside it; a runtime that cannot
|
|
15
|
+
* delete messages starts a new branch instead. It renders disabled unless the
|
|
16
|
+
* message is the last one on its branch and its run went `staleAfter`
|
|
17
|
+
* without a heartbeat. A reply that wrote content before its run stopped is a
|
|
18
|
+
* regular error, answered again with Regenerate.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <MessagePrimitive.Error>
|
|
23
|
+
* <ErrorPrimitive.Root>
|
|
24
|
+
* <ErrorPrimitive.Message />
|
|
25
|
+
* <ActionBarPrimitive.Resume>Resume</ActionBarPrimitive.Resume>
|
|
26
|
+
* </ErrorPrimitive.Root>
|
|
27
|
+
* </MessagePrimitive.Error>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
const ActionBarPrimitiveResume = createActionButton("ActionBarPrimitive.Resume", useActionBarResume$1);
|
|
31
|
+
export { ActionBarPrimitiveResume };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=ActionBarResume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionBarResume.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useActionBarResume","useActionBarResumeBehavior","disabled","resume","ActionBarPrimitiveResume","Element","Props","useActionBarResume","useActionBarResumeBehavior"],"sources":["../../../src/primitives/actionBar/ActionBarResume.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useActionBarResume as useActionBarResumeBehavior } from \"@assistant-ui/core/react\";\n\nconst useActionBarResume = () => {\n const { disabled, resume } = useActionBarResumeBehavior();\n if (disabled) return null;\n return resume;\n};\n\nexport namespace ActionBarPrimitiveResume {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useActionBarResume>;\n}\n\n/**\n * A button that answers again in place of an assistant message whose run\n * stopped before it wrote anything (its tab closed or lost its connection).\n * It deletes the empty reply and its stored row, then runs again from the\n * reply's parent, so no branch is left beside it; a runtime that cannot\n * delete messages starts a new branch instead. It renders disabled unless the\n * message is the last one on its branch and its run went `staleAfter`\n * without a heartbeat. A reply that wrote content before its run stopped is a\n * regular error, answered again with Regenerate.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Error>\n * <ErrorPrimitive.Root>\n * <ErrorPrimitive.Message />\n * <ActionBarPrimitive.Resume>Resume</ActionBarPrimitive.Resume>\n * </ErrorPrimitive.Root>\n * </MessagePrimitive.Error>\n * ```\n */\nexport const ActionBarPrimitiveResume = createActionButton(\n \"ActionBarPrimitive.Resume\",\n useActionBarResume,\n);\n"],"mappings":";;;;AASA,MAAMG,6BAAqB;CACzB,MAAA,EAAAE,UAAAC,WAA6BF,mBAA2B;CACxD,IAAIC,UAAQ,OAAS;CAAK,OACnBC;AAAM;;;;;;;;;;;;;;;;;;;;;AA4Bf,MAAaC,2BAA2BL,mBACtC,6BACAC,oBACF"}
|
|
@@ -5,7 +5,8 @@ export declare namespace ActionBarPrimitiveRoot {
|
|
|
5
5
|
type Element = ComponentRef<typeof Primitive.div>;
|
|
6
6
|
type Props = PrimitiveDivProps & {
|
|
7
7
|
/**
|
|
8
|
-
* Whether to hide the action bar when the thread is running
|
|
8
|
+
* Whether to hide the action bar when the thread is running, or while
|
|
9
|
+
* another tab or session is still writing this message.
|
|
9
10
|
* @default false
|
|
10
11
|
*/
|
|
11
12
|
hideWhenRunning?: boolean | undefined;
|
|
@@ -53,7 +54,8 @@ export declare const ActionBarPrimitiveRoot: import("react").ForwardRefExoticCom
|
|
|
53
54
|
render?: import("react").ReactElement | undefined;
|
|
54
55
|
} & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
55
56
|
/**
|
|
56
|
-
* Whether to hide the action bar when the thread is running
|
|
57
|
+
* Whether to hide the action bar when the thread is running, or while
|
|
58
|
+
* another tab or session is still writing this message.
|
|
57
59
|
* @default false
|
|
58
60
|
*/
|
|
59
61
|
hideWhenRunning?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;AAClD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAI9B,MAAM,OAAO,CAAC;AAOf,KAAK,iBAAiB,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;AAExE,yBAAiB,sBAAsB,CAAC;IACtC,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD,KAAY,KAAK,GAAG,iBAAiB,GAAG;QACtC
|
|
1
|
+
{"version":3,"file":"ActionBarRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/ActionBarRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;AAClD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAI9B,MAAM,OAAO,CAAC;AAOf,KAAK,iBAAiB,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;AAExE,yBAAiB,sBAAsB,CAAC;IACtC,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD,KAAY,KAAK,GAAG,iBAAiB,GAAG;QACtC;;;;WAIG;QACH,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QACtC;;;;;;WAMG;QACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;QACvD;;;;;;WAMG;QACH,aAAa,CAAC,EAAE,QAAQ,GAAG,eAAe,GAAG,OAAO,GAAG,SAAS,CAAC;KAClE,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sBAAsB;;;;;IA7C/B;;;;OAIG;sBACe,OAAO,GAAG,SAAS;IACrC;;;;;;OAMG;eACQ,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS;IACtD;;;;;;OAMG;oBACa,QAAQ,GAAG,eAAe,GAAG,OAAO,GAAG,SAAS;kDAmElE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useMemo","useState","useActionBarFloatStatus","HideAndFloatStatus","ActionBarInteractionContext","PrimitiveDivProps","div","ActionBarPrimitiveRoot","Element","Props","hideWhenRunning","autohide","autohideFloat","t0","ref","$","rest","interactionCount","setInteractionCount","t1","Symbol","for","released","_temp","_temp2","acquireInteractionLock","t2","interactionContext","t3","t4","forceVisible","hideAndfloatStatus","Hidden","t5","Floating","t6","displayName","count","count_0","Math","max","_c"],"sources":["../../../src/primitives/actionBar/ActionBarRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport {\n useActionBarFloatStatus,\n HideAndFloatStatus,\n} from \"./useActionBarFloatStatus\";\nimport { ActionBarInteractionContext } from \"./ActionBarInteractionContext\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ActionBarPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps & {\n /**\n * Whether to hide the action bar when the thread is running.\n * @default false\n */\n hideWhenRunning?: boolean | undefined;\n /**\n * Controls when the action bar should automatically hide.\n * - \"always\": Always hide unless hovered\n * - \"not-last\": Hide unless this is the last message\n * - \"never\": Never auto-hide\n * @default \"never\"\n */\n autohide?: \"always\" | \"not-last\" | \"never\" | undefined;\n /**\n * Controls floating behavior when auto-hidden.\n * - \"always\": Always float when hidden\n * - \"single-branch\": Float only for single-branch messages\n * - \"never\": Never float\n * @default \"never\"\n */\n autohideFloat?: \"always\" | \"single-branch\" | \"never\" | undefined;\n };\n}\n\n/**\n * The root container for action bar components.\n *\n * This component provides intelligent visibility and floating behavior for action bars,\n * automatically hiding and showing based on message state, hover status, and configuration.\n * It supports floating mode for better UX when space is limited.\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Root\n * hideWhenRunning={true}\n * autohide=\"not-last\"\n * autohideFloat=\"single-branch\"\n * >\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * <ActionBarPrimitive.Reload />\n * </ActionBarPrimitive.Root>\n * ```\n */\nexport const ActionBarPrimitiveRoot = forwardRef<\n ActionBarPrimitiveRoot.Element,\n ActionBarPrimitiveRoot.Props\n>(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {\n const [interactionCount, setInteractionCount] = useState(0);\n\n const acquireInteractionLock = useCallback(() => {\n let released = false;\n\n setInteractionCount((count) => count + 1);\n\n return () => {\n if (released) return;\n released = true;\n setInteractionCount((count) => Math.max(0, count - 1));\n };\n }, []);\n\n const interactionContext = useMemo(\n () => ({ acquireInteractionLock }),\n [acquireInteractionLock],\n );\n\n const hideAndfloatStatus = useActionBarFloatStatus({\n hideWhenRunning,\n autohide,\n autohideFloat,\n forceVisible: interactionCount > 0,\n });\n\n if (hideAndfloatStatus === HideAndFloatStatus.Hidden) return null;\n\n return (\n <ActionBarInteractionContext.Provider value={interactionContext}>\n <Primitive.div\n {...(hideAndfloatStatus === HideAndFloatStatus.Floating\n ? { \"data-floating\": \"true\" }\n : null)}\n {...rest}\n ref={ref}\n />\n </ActionBarInteractionContext.Provider>\n );\n});\n\nActionBarPrimitiveRoot.displayName = \"ActionBarPrimitive.Root\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ActionBarRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useMemo","useState","useActionBarFloatStatus","HideAndFloatStatus","ActionBarInteractionContext","PrimitiveDivProps","div","ActionBarPrimitiveRoot","Element","Props","hideWhenRunning","autohide","autohideFloat","t0","ref","$","rest","interactionCount","setInteractionCount","t1","Symbol","for","released","_temp","_temp2","acquireInteractionLock","t2","interactionContext","t3","t4","forceVisible","hideAndfloatStatus","Hidden","t5","Floating","t6","displayName","count","count_0","Math","max","_c"],"sources":["../../../src/primitives/actionBar/ActionBarRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\nimport {\n useActionBarFloatStatus,\n HideAndFloatStatus,\n} from \"./useActionBarFloatStatus\";\nimport { ActionBarInteractionContext } from \"./ActionBarInteractionContext\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ActionBarPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps & {\n /**\n * Whether to hide the action bar when the thread is running, or while\n * another tab or session is still writing this message.\n * @default false\n */\n hideWhenRunning?: boolean | undefined;\n /**\n * Controls when the action bar should automatically hide.\n * - \"always\": Always hide unless hovered\n * - \"not-last\": Hide unless this is the last message\n * - \"never\": Never auto-hide\n * @default \"never\"\n */\n autohide?: \"always\" | \"not-last\" | \"never\" | undefined;\n /**\n * Controls floating behavior when auto-hidden.\n * - \"always\": Always float when hidden\n * - \"single-branch\": Float only for single-branch messages\n * - \"never\": Never float\n * @default \"never\"\n */\n autohideFloat?: \"always\" | \"single-branch\" | \"never\" | undefined;\n };\n}\n\n/**\n * The root container for action bar components.\n *\n * This component provides intelligent visibility and floating behavior for action bars,\n * automatically hiding and showing based on message state, hover status, and configuration.\n * It supports floating mode for better UX when space is limited.\n *\n * @example\n * ```tsx\n * <ActionBarPrimitive.Root\n * hideWhenRunning={true}\n * autohide=\"not-last\"\n * autohideFloat=\"single-branch\"\n * >\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * <ActionBarPrimitive.Reload />\n * </ActionBarPrimitive.Root>\n * ```\n */\nexport const ActionBarPrimitiveRoot = forwardRef<\n ActionBarPrimitiveRoot.Element,\n ActionBarPrimitiveRoot.Props\n>(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {\n const [interactionCount, setInteractionCount] = useState(0);\n\n const acquireInteractionLock = useCallback(() => {\n let released = false;\n\n setInteractionCount((count) => count + 1);\n\n return () => {\n if (released) return;\n released = true;\n setInteractionCount((count) => Math.max(0, count - 1));\n };\n }, []);\n\n const interactionContext = useMemo(\n () => ({ acquireInteractionLock }),\n [acquireInteractionLock],\n );\n\n const hideAndfloatStatus = useActionBarFloatStatus({\n hideWhenRunning,\n autohide,\n autohideFloat,\n forceVisible: interactionCount > 0,\n });\n\n if (hideAndfloatStatus === HideAndFloatStatus.Hidden) return null;\n\n return (\n <ActionBarInteractionContext.Provider value={interactionContext}>\n <Primitive.div\n {...(hideAndfloatStatus === HideAndFloatStatus.Floating\n ? { \"data-floating\": \"true\" }\n : null)}\n {...rest}\n ref={ref}\n />\n </ActionBarInteractionContext.Provider>\n );\n});\n\nActionBarPrimitiveRoot.displayName = \"ActionBarPrimitive.Root\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAac,yBAAyBV,YAGpCgB,IAAAC,QAAA;CAAA,MAAAC,IAAArB,EAAA,EAAA;CAAA,IAAAiB;CAAA,IAAAC;CAAA,IAAAF;CAAA,IAAAM;CAAA,IAAAD,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAH,iBAAAC,UAAAC,eAAA,GAAAI,QAAAH;EAAqDE,EAAA,KAAAF;EAAAE,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAL;EAAAK,EAAA,KAAAC;CAAA,OAAA;EAAAL,WAAAI,EAAA;EAAAH,gBAAAG,EAAA;EAAAL,kBAAAK,EAAA;EAAAC,OAAAD,EAAA;CAAA;CACtD,MAAA,CAAAE,kBAAAC,uBAAgDjB,SAAS,CAAC;CAAE,IAAAkB;CAAA,IAAAJ,EAAA,OAAAK,OAAAC,IAAA,2BAAA,GAAA;EAEjBF,WAAA;GACzC,IAAAG,WAAe;GAEfJ,oBAAoBK,KAAoB;GAAC,aAElC;IACL,IAAID,UAAQ;IACZA,WAAWA;IACXJ,oBAAoBM,MAAiC;GAAC;EACvD;EACFT,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAVD,MAAAU,yBAA+BN;CAUxB,IAAAO;CAAA,IAAAX,EAAA,OAAAK,OAAAC,IAAA,2BAAA,GAAA;EAGEK,KAAA,EAAAD,uBAAyB;EAACV,EAAA,KAAAW;CAAA,OAAAA,KAAAX,EAAA;CADnC,MAAAY,qBACSD;CAQO,MAAAE,KAAAX,mBAAmB;CAAC,IAAAY;CAAA,IAAAd,EAAA,OAAAJ,YAAAI,EAAA,OAAAH,iBAAAG,EAAA,OAAAL,mBAAAK,EAAA,QAAAa,IAAA;EAJeC,KAAA;GAAAnB;GAAAC;GAAAC;GAAAkB,cAInCF;EAChB;EAACb,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAL;EAAAK,EAAA,MAAAa;EAAAb,EAAA,MAAAc;CAAA,OAAAA,KAAAd,EAAA;CALD,MAAAgB,qBAA2B7B,wBAAwB2B,EAKlD;CAED,IAAIE,uBAAuB5B,mBAAkB6B,QAAO,OAAS;CAAK,IAAAC;CAAA,IAAAlB,EAAA,QAAAgB,oBAAA;EAKvDE,KAAAF,uBAAuB5B,mBAAkB+B,WAAzC,EAAA,iBACkB,OAChB,IAFF;EAEGnB,EAAA,MAAAgB;EAAAhB,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,IAAAoB;CAAA,IAAApB,EAAA,QAAAD,OAAAC,EAAA,QAAAC,QAAAD,EAAA,QAAAkB,IAAA;EAJZE,KAAA,oBAAA,4BAAA,UAAA;GAA6CR,OAAAA;GAC3C,UAAA,oBAAA,UAAA,KAAA;IAAA,GACOM;IAEG,GACJjB;IACCF;GAAG,CAAA;EAEZ,CAAA;EAAuCC,EAAA,MAAAD;EAAAC,EAAA,MAAAC;EAAAD,EAAA,MAAAkB;EAAAlB,EAAA,MAAAoB;CAAA,OAAAA,KAAApB,EAAA;CAAA,OARvCoB;AAQuC,CAE1C;AAED5B,uBAAuB6B,cAAc;AA1CnC,SAAAb,MAAAc,OAAA;CAAA,OAMiCA,QAAQ;AAAC;AAN1C,SAAAb,OAAAc,SAAA;CAAA,OAWmCC,KAAIC,IAAK,GAAGH,UAAQ,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionBarFloatStatus.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/useActionBarFloatStatus.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE/D,MAAM,MAAM,4BAA4B,GAAG;IACzC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IACvD,aAAa,CAAC,EAAE,QAAQ,GAAG,eAAe,GAAG,OAAO,GAAG,SAAS,CAAC;IACjE,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,6DAKrC,4BAA4B,
|
|
1
|
+
{"version":3,"file":"useActionBarFloatStatus.d.ts","sourceRoot":"","sources":["../../../src/primitives/actionBar/useActionBarFloatStatus.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE/D,MAAM,MAAM,4BAA4B,GAAG;IACzC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IACvD,aAAa,CAAC,EAAE,QAAQ,GAAG,eAAe,GAAG,OAAO,GAAG,SAAS,CAAC;IACjE,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,6DAKrC,4BAA4B,qCA2B9B,CAAC"}
|
|
@@ -13,7 +13,7 @@ const useActionBarFloatStatus = (t0) => {
|
|
|
13
13
|
let t1;
|
|
14
14
|
if ($[0] !== autohide || $[1] !== autohideFloat || $[2] !== forceVisible || $[3] !== hideWhenRunning) {
|
|
15
15
|
t1 = (s) => {
|
|
16
|
-
if (hideWhenRunning && s.thread.isRunning) return HideAndFloatStatus.Hidden;
|
|
16
|
+
if (hideWhenRunning && (s.thread.isRunning || s.message.runState === "in-progress")) return HideAndFloatStatus.Hidden;
|
|
17
17
|
const autohideEnabled = autohide === "always" || autohide === "not-last" && !s.message.isLast;
|
|
18
18
|
const isVisibleByInteraction = forceVisible || s.message.isHovering;
|
|
19
19
|
if (!autohideEnabled) return HideAndFloatStatus.Normal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionBarFloatStatus.js","names":["c","_c","useAuiState","HideAndFloatStatus","Hidden","Floating","Normal","const","UseActionBarFloatStatusProps","hideWhenRunning","autohide","autohideFloat","forceVisible","useActionBarFloatStatus","t0","$","t1","s","thread","isRunning","
|
|
1
|
+
{"version":3,"file":"useActionBarFloatStatus.js","names":["c","_c","useAuiState","HideAndFloatStatus","Hidden","Floating","Normal","const","UseActionBarFloatStatusProps","hideWhenRunning","autohide","autohideFloat","forceVisible","useActionBarFloatStatus","t0","$","t1","s","thread","isRunning","message","runState","autohideEnabled","isLast","isVisibleByInteraction","isHovering","branchCount","_c"],"sources":["../../../src/primitives/actionBar/useActionBarFloatStatus.ts"],"sourcesContent":["\"use client\";\n\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport const HideAndFloatStatus = {\n Hidden: \"hidden\",\n Floating: \"floating\",\n Normal: \"normal\",\n} as const;\nexport type HideAndFloatStatus =\n (typeof HideAndFloatStatus)[keyof typeof HideAndFloatStatus];\n\nexport type UseActionBarFloatStatusProps = {\n hideWhenRunning?: boolean | undefined;\n autohide?: \"always\" | \"not-last\" | \"never\" | undefined;\n autohideFloat?: \"always\" | \"single-branch\" | \"never\" | undefined;\n forceVisible?: boolean | undefined;\n};\n\nexport const useActionBarFloatStatus = ({\n hideWhenRunning,\n autohide,\n autohideFloat,\n forceVisible,\n}: UseActionBarFloatStatusProps) => {\n return useAuiState((s) => {\n if (\n hideWhenRunning &&\n (s.thread.isRunning || s.message.runState === \"in-progress\")\n )\n return HideAndFloatStatus.Hidden;\n\n const autohideEnabled =\n autohide === \"always\" || (autohide === \"not-last\" && !s.message.isLast);\n const isVisibleByInteraction = forceVisible || s.message.isHovering;\n\n // normal status\n if (!autohideEnabled) return HideAndFloatStatus.Normal;\n\n // hidden status\n if (!isVisibleByInteraction) return HideAndFloatStatus.Hidden;\n\n // floating status\n if (\n autohideFloat === \"always\" ||\n (autohideFloat === \"single-branch\" && s.message.branchCount <= 1)\n )\n return HideAndFloatStatus.Floating;\n\n return HideAndFloatStatus.Normal;\n });\n};\n"],"mappings":";;;;AAIA,MAAaG,qBAAqB;CAChCC,QAAQ;CACRC,UAAU;CACVC,QAAQ;AACV;AAWA,MAAaO,2BAA0BC,OAAA;CAAA,MAAAC,IAAAd,EAAA,CAAA;CAAC,MAAA,EAAAQ,iBAAAC,UAAAC,eAAAC,iBAAAE;CAKT,IAAAE;CAAA,IAAAD,EAAA,OAAAL,YAAAK,EAAA,OAAAJ,iBAAAI,EAAA,OAAAH,gBAAAG,EAAA,OAAAN,iBAAA;EACVO,MAAAC,MAAA;GACjB,IACER,oBACCQ,EAACC,OAAOC,aAAcF,EAACG,QAAQC,aAAc,gBAAc,OAErDlB,mBAAkBC;GAE3B,MAAAkB,kBACEZ,aAAa,YAAaA,aAAa,cAAb,CAA4BO,EAACG,QAAQG;GACjE,MAAAC,yBAA+BZ,gBAAgBK,EAACG,QAAQK;GAGxD,IAAI,CAACH,iBAAe,OAASnB,mBAAkBG;GAG/C,IAAI,CAACkB,wBAAsB,OAASrB,mBAAkBC;GAGtD,IACEO,kBAAkB,YACjBA,kBAAkB,mBAAmBM,EAACG,QAAQM,eAAgB,GAAE,OAE1DvB,mBAAkBE;GAAU,OAE9BF,mBAAkBG;EAAO;EACjCS,EAAA,KAAAL;EAAAK,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAN;EAAAM,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,OAzBMb,YAAYc,EAyBlB;AAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { ActionBarPrimitiveRoot as Root } from "./actionBar/ActionBarRoot.js";
|
|
2
2
|
export { ActionBarPrimitiveCopy as Copy } from "./actionBar/ActionBarCopy.js";
|
|
3
3
|
export { ActionBarPrimitiveReload as Reload } from "./actionBar/ActionBarReload.js";
|
|
4
|
+
export { ActionBarPrimitiveResume as Resume } from "./actionBar/ActionBarResume.js";
|
|
5
|
+
export { ActionBarPrimitiveRefreshRun as RefreshRun } from "./actionBar/ActionBarRefreshRun.js";
|
|
4
6
|
export { ActionBarPrimitiveEdit as Edit } from "./actionBar/ActionBarEdit.js";
|
|
5
7
|
export { ActionBarPrimitiveSpeak as Speak } from "./actionBar/ActionBarSpeak.js";
|
|
6
8
|
export { ActionBarPrimitiveStopSpeaking as StopSpeaking } from "./actionBar/ActionBarStopSpeaking.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionBar.d.ts","sourceRoot":"","sources":["../../src/primitives/actionBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,IAAI,EAAE,qCAAkC;AAC3E,OAAO,EAAE,sBAAsB,IAAI,IAAI,EAAE,qCAAkC;AAC3E,OAAO,EAAE,wBAAwB,IAAI,MAAM,EAAE,uCAAoC;AACjF,OAAO,EAAE,sBAAsB,IAAI,IAAI,EAAE,qCAAkC;AAC3E,OAAO,EAAE,uBAAuB,IAAI,KAAK,EAAE,sCAAmC;AAC9E,OAAO,EAAE,8BAA8B,IAAI,YAAY,EAAE,6CAA0C;AACnG,OAAO,EAAE,kCAAkC,IAAI,gBAAgB,EAAE,iDAA8C;AAC/G,OAAO,EAAE,kCAAkC,IAAI,gBAAgB,EAAE,iDAA8C;AAC/G,OAAO,EAAE,gCAAgC,IAAI,cAAc,EAAE,+CAA4C"}
|
|
1
|
+
{"version":3,"file":"actionBar.d.ts","sourceRoot":"","sources":["../../src/primitives/actionBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,IAAI,EAAE,qCAAkC;AAC3E,OAAO,EAAE,sBAAsB,IAAI,IAAI,EAAE,qCAAkC;AAC3E,OAAO,EAAE,wBAAwB,IAAI,MAAM,EAAE,uCAAoC;AACjF,OAAO,EAAE,wBAAwB,IAAI,MAAM,EAAE,uCAAoC;AACjF,OAAO,EAAE,4BAA4B,IAAI,UAAU,EAAE,2CAAwC;AAC7F,OAAO,EAAE,sBAAsB,IAAI,IAAI,EAAE,qCAAkC;AAC3E,OAAO,EAAE,uBAAuB,IAAI,KAAK,EAAE,sCAAmC;AAC9E,OAAO,EAAE,8BAA8B,IAAI,YAAY,EAAE,6CAA0C;AACnG,OAAO,EAAE,kCAAkC,IAAI,gBAAgB,EAAE,iDAA8C;AAC/G,OAAO,EAAE,kCAAkC,IAAI,gBAAgB,EAAE,iDAA8C;AAC/G,OAAO,EAAE,gCAAgC,IAAI,cAAc,EAAE,+CAA4C"}
|
|
@@ -2,6 +2,8 @@ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import { ActionBarPrimitiveRoot } from "./actionBar/ActionBarRoot.js";
|
|
3
3
|
import { ActionBarPrimitiveCopy } from "./actionBar/ActionBarCopy.js";
|
|
4
4
|
import { ActionBarPrimitiveReload } from "./actionBar/ActionBarReload.js";
|
|
5
|
+
import { ActionBarPrimitiveResume } from "./actionBar/ActionBarResume.js";
|
|
6
|
+
import { ActionBarPrimitiveRefreshRun } from "./actionBar/ActionBarRefreshRun.js";
|
|
5
7
|
import { ActionBarPrimitiveEdit } from "./actionBar/ActionBarEdit.js";
|
|
6
8
|
import { ActionBarPrimitiveSpeak } from "./actionBar/ActionBarSpeak.js";
|
|
7
9
|
import { ActionBarPrimitiveStopSpeaking } from "./actionBar/ActionBarStopSpeaking.js";
|
|
@@ -15,11 +17,13 @@ var actionBar_exports = /* @__PURE__ */ __exportAll({
|
|
|
15
17
|
ExportMarkdown: () => ActionBarPrimitiveExportMarkdown,
|
|
16
18
|
FeedbackNegative: () => ActionBarPrimitiveFeedbackNegative,
|
|
17
19
|
FeedbackPositive: () => ActionBarPrimitiveFeedbackPositive,
|
|
20
|
+
RefreshRun: () => ActionBarPrimitiveRefreshRun,
|
|
18
21
|
Reload: () => ActionBarPrimitiveReload,
|
|
22
|
+
Resume: () => ActionBarPrimitiveResume,
|
|
19
23
|
Root: () => ActionBarPrimitiveRoot,
|
|
20
24
|
Speak: () => ActionBarPrimitiveSpeak,
|
|
21
25
|
StopSpeaking: () => ActionBarPrimitiveStopSpeaking
|
|
22
26
|
});
|
|
23
|
-
export { ActionBarPrimitiveCopy as Copy, ActionBarPrimitiveEdit as Edit, ActionBarPrimitiveExportMarkdown as ExportMarkdown, ActionBarPrimitiveFeedbackNegative as FeedbackNegative, ActionBarPrimitiveFeedbackPositive as FeedbackPositive, ActionBarPrimitiveReload as Reload, ActionBarPrimitiveRoot as Root, ActionBarPrimitiveSpeak as Speak, ActionBarPrimitiveStopSpeaking as StopSpeaking, actionBar_exports };
|
|
27
|
+
export { ActionBarPrimitiveCopy as Copy, ActionBarPrimitiveEdit as Edit, ActionBarPrimitiveExportMarkdown as ExportMarkdown, ActionBarPrimitiveFeedbackNegative as FeedbackNegative, ActionBarPrimitiveFeedbackPositive as FeedbackPositive, ActionBarPrimitiveRefreshRun as RefreshRun, ActionBarPrimitiveReload as Reload, ActionBarPrimitiveResume as Resume, ActionBarPrimitiveRoot as Root, ActionBarPrimitiveSpeak as Speak, ActionBarPrimitiveStopSpeaking as StopSpeaking, actionBar_exports };
|
|
24
28
|
|
|
25
29
|
//# sourceMappingURL=actionBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionBar.js","names":["ActionBarPrimitiveRoot","Root","ActionBarPrimitiveCopy","Copy","ActionBarPrimitiveReload","Reload","ActionBarPrimitiveEdit","Edit","ActionBarPrimitiveSpeak","Speak","ActionBarPrimitiveStopSpeaking","StopSpeaking","ActionBarPrimitiveFeedbackPositive","FeedbackPositive","ActionBarPrimitiveFeedbackNegative","FeedbackNegative","ActionBarPrimitiveExportMarkdown","ExportMarkdown"],"sources":["../../src/primitives/actionBar.ts"],"sourcesContent":["export { ActionBarPrimitiveRoot as Root } from \"./actionBar/ActionBarRoot\";\nexport { ActionBarPrimitiveCopy as Copy } from \"./actionBar/ActionBarCopy\";\nexport { ActionBarPrimitiveReload as Reload } from \"./actionBar/ActionBarReload\";\nexport { ActionBarPrimitiveEdit as Edit } from \"./actionBar/ActionBarEdit\";\nexport { ActionBarPrimitiveSpeak as Speak } from \"./actionBar/ActionBarSpeak\";\nexport { ActionBarPrimitiveStopSpeaking as StopSpeaking } from \"./actionBar/ActionBarStopSpeaking\";\nexport { ActionBarPrimitiveFeedbackPositive as FeedbackPositive } from \"./actionBar/ActionBarFeedbackPositive\";\nexport { ActionBarPrimitiveFeedbackNegative as FeedbackNegative } from \"./actionBar/ActionBarFeedbackNegative\";\nexport { ActionBarPrimitiveExportMarkdown as ExportMarkdown } from \"./actionBar/ActionBarExportMarkdown\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"actionBar.js","names":["ActionBarPrimitiveRoot","Root","ActionBarPrimitiveCopy","Copy","ActionBarPrimitiveReload","Reload","ActionBarPrimitiveResume","Resume","ActionBarPrimitiveRefreshRun","RefreshRun","ActionBarPrimitiveEdit","Edit","ActionBarPrimitiveSpeak","Speak","ActionBarPrimitiveStopSpeaking","StopSpeaking","ActionBarPrimitiveFeedbackPositive","FeedbackPositive","ActionBarPrimitiveFeedbackNegative","FeedbackNegative","ActionBarPrimitiveExportMarkdown","ExportMarkdown"],"sources":["../../src/primitives/actionBar.ts"],"sourcesContent":["export { ActionBarPrimitiveRoot as Root } from \"./actionBar/ActionBarRoot\";\nexport { ActionBarPrimitiveCopy as Copy } from \"./actionBar/ActionBarCopy\";\nexport { ActionBarPrimitiveReload as Reload } from \"./actionBar/ActionBarReload\";\nexport { ActionBarPrimitiveResume as Resume } from \"./actionBar/ActionBarResume\";\nexport { ActionBarPrimitiveRefreshRun as RefreshRun } from \"./actionBar/ActionBarRefreshRun\";\nexport { ActionBarPrimitiveEdit as Edit } from \"./actionBar/ActionBarEdit\";\nexport { ActionBarPrimitiveSpeak as Speak } from \"./actionBar/ActionBarSpeak\";\nexport { ActionBarPrimitiveStopSpeaking as StopSpeaking } from \"./actionBar/ActionBarStopSpeaking\";\nexport { ActionBarPrimitiveFeedbackPositive as FeedbackPositive } from \"./actionBar/ActionBarFeedbackPositive\";\nexport { ActionBarPrimitiveFeedbackNegative as FeedbackNegative } from \"./actionBar/ActionBarFeedbackNegative\";\nexport { ActionBarPrimitiveExportMarkdown as ExportMarkdown } from \"./actionBar/ActionBarExportMarkdown\";\n"],"mappings":""}
|
|
@@ -4,6 +4,11 @@ export declare namespace ErrorPrimitiveRoot {
|
|
|
4
4
|
type Element = ComponentRef<typeof Primitive.div>;
|
|
5
5
|
type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* The container of a message's error. It carries `data-run-state` (`stale` or
|
|
9
|
+
* `in-progress`) when the error stands for a run another tab or session
|
|
10
|
+
* drove, and announces an in-progress run as a status instead of an alert.
|
|
11
|
+
*/
|
|
7
12
|
export declare const ErrorPrimitiveRoot: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
8
13
|
asChild?: boolean | undefined;
|
|
9
14
|
}, "ref"> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/error/ErrorRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;AAClD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAC9B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ErrorRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/error/ErrorRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAA8B;AAClD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAC9B,MAAM,OAAO,CAAC;AAGf,yBAAiB,kBAAkB,CAAC;IAClC,KAAY,OAAO,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACzD,KAAY,KAAK,GAAG,wBAAwB,CAAC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;CACpE;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;0GAa7B,CAAC"}
|
|
@@ -2,24 +2,44 @@
|
|
|
2
2
|
import { Primitive } from "../../utils/Primitive.js";
|
|
3
3
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
4
|
import { forwardRef } from "@assistant-ui/tap/react-shim";
|
|
5
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
// src/primitives/error/ErrorRoot.tsx
|
|
8
|
+
/**
|
|
9
|
+
* The container of a message's error. It carries `data-run-state` (`stale` or
|
|
10
|
+
* `in-progress`) when the error stands for a run another tab or session
|
|
11
|
+
* drove, and announces an in-progress run as a status instead of an alert.
|
|
12
|
+
*/
|
|
7
13
|
const ErrorPrimitiveRoot = forwardRef((props, forwardRef) => {
|
|
8
|
-
const $ = c(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
const $ = c(7);
|
|
15
|
+
const runState = useAuiState(_temp);
|
|
16
|
+
const t0 = runState === "in-progress" ? "status" : "alert";
|
|
17
|
+
let t1;
|
|
18
|
+
if ($[0] !== runState) {
|
|
19
|
+
t1 = runState ? { "data-run-state": runState } : void 0;
|
|
20
|
+
$[0] = runState;
|
|
21
|
+
$[1] = t1;
|
|
22
|
+
} else t1 = $[1];
|
|
23
|
+
let t2;
|
|
24
|
+
if ($[2] !== forwardRef || $[3] !== props || $[4] !== t0 || $[5] !== t1) {
|
|
25
|
+
t2 = /* @__PURE__ */ jsx(Primitive.div, {
|
|
26
|
+
role: t0,
|
|
27
|
+
...t1,
|
|
13
28
|
...props,
|
|
14
29
|
ref: forwardRef
|
|
15
30
|
});
|
|
16
|
-
$[
|
|
17
|
-
$[
|
|
18
|
-
$[
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
$[2] = forwardRef;
|
|
32
|
+
$[3] = props;
|
|
33
|
+
$[4] = t0;
|
|
34
|
+
$[5] = t1;
|
|
35
|
+
$[6] = t2;
|
|
36
|
+
} else t2 = $[6];
|
|
37
|
+
return t2;
|
|
21
38
|
});
|
|
22
39
|
ErrorPrimitiveRoot.displayName = "ErrorPrimitive.Root";
|
|
40
|
+
function _temp(s) {
|
|
41
|
+
return s.optional.message?.runState;
|
|
42
|
+
}
|
|
23
43
|
export { ErrorPrimitiveRoot };
|
|
24
44
|
|
|
25
45
|
//# sourceMappingURL=ErrorRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","ErrorPrimitiveRoot","Element","div","Props","props","$","t0","displayName","_c"],"sources":["../../../src/primitives/error/ErrorRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\n\nexport namespace ErrorPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\nexport const ErrorPrimitiveRoot = forwardRef<\n ErrorPrimitiveRoot.Element,\n ErrorPrimitiveRoot.Props\n>((props, forwardRef) => {\n return <Primitive.div
|
|
1
|
+
{"version":3,"file":"ErrorRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useAuiState","ErrorPrimitiveRoot","Element","div","Props","props","$","runState","_temp","t0","t1","undefined","t2","displayName","s","optional","message","_c"],"sources":["../../../src/primitives/error/ErrorRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace ErrorPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * The container of a message's error. It carries `data-run-state` (`stale` or\n * `in-progress`) when the error stands for a run another tab or session\n * drove, and announces an in-progress run as a status instead of an alert.\n */\nexport const ErrorPrimitiveRoot = forwardRef<\n ErrorPrimitiveRoot.Element,\n ErrorPrimitiveRoot.Props\n>((props, forwardRef) => {\n const runState = useAuiState((s) => s.optional.message?.runState);\n return (\n <Primitive.div\n role={runState === \"in-progress\" ? \"status\" : \"alert\"}\n {...(runState ? { \"data-run-state\": runState } : undefined)}\n {...props}\n ref={forwardRef}\n />\n );\n});\n\nErrorPrimitiveRoot.displayName = \"ErrorPrimitive.Root\";\n"],"mappings":";;;;;;;;;;;;AAoBA,MAAaO,qBAAqBH,YAGhCO,OAAAP,eAAA;CAAA,MAAAQ,IAAAX,EAAA,CAAA;CACA,MAAAY,WAAiBP,YAAYQ,KAAmC;CAGtD,MAAAC,KAAAF,aAAa,gBAAb,WAAA;CAA+C,IAAAG;CAAA,IAAAJ,EAAA,OAAAC,UAAA;EAChDG,KAAAH,WAAA,EAAA,kBAA+BA,SAAqB,IAApDI,KAAAA;EAAqDL,EAAA,KAAAC;EAAAD,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAM;CAAA,IAAAN,EAAA,OAAAR,cAAAQ,EAAA,OAAAD,SAAAC,EAAA,OAAAG,MAAAH,EAAA,OAAAI,IAAA;EAF5DE,KAAA,oBAAA,UAAA,KAAA;GACQ,MAAAH;GAA+C,GAChDC;GAAqD,GACtDL;GACCP,KAAAA;EAAU,CAAA;EACfQ,EAAA,KAAAR;EAAAQ,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,OALFM;AAKE,CAEL;AAEDX,mBAAmBY,cAAc;AAZ/B,SAAAL,MAAAM,GAAA;CAAA,OACoCA,EAACC,SAASC,SAAkBT;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.35",
|
|
4
4
|
"description": "Open-source TypeScript/React library for building production-grade AI chat experiences",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
],
|
|
56
56
|
"sideEffects": false,
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@assistant-ui/core": "^0.3.
|
|
58
|
+
"@assistant-ui/core": "^0.3.35",
|
|
59
59
|
"@assistant-ui/store": "^0.3.23",
|
|
60
60
|
"@assistant-ui/tap": "^0.9.25",
|
|
61
|
-
"assistant-cloud": "^0.2.
|
|
62
|
-
"assistant-stream": "^0.3.
|
|
61
|
+
"assistant-cloud": "^0.2.11",
|
|
62
|
+
"assistant-stream": "^0.3.57",
|
|
63
63
|
"radix-ui": "^1.8.1",
|
|
64
64
|
"react-textarea-autosize": "^8.5.9",
|
|
65
65
|
"safe-content-frame": "^0.0.34",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ActionButtonElement,
|
|
5
|
+
type ActionButtonProps,
|
|
6
|
+
createActionButton,
|
|
7
|
+
} from "../../utils/createActionButton";
|
|
8
|
+
import { useActionBarRefreshRun as useActionBarRefreshRunBehavior } from "@assistant-ui/core/react";
|
|
9
|
+
|
|
10
|
+
const useActionBarRefreshRun = () => {
|
|
11
|
+
const { disabled, refresh } = useActionBarRefreshRunBehavior();
|
|
12
|
+
if (disabled) return null;
|
|
13
|
+
return refresh;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export namespace ActionBarPrimitiveRefreshRun {
|
|
17
|
+
export type Element = ActionButtonElement;
|
|
18
|
+
export type Props = ActionButtonProps<typeof useActionBarRefreshRun>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A button that re-reads an assistant message whose run another tab or
|
|
23
|
+
* session is still writing, so the thread shows its latest stored state
|
|
24
|
+
* without a page reload. The thread also re-reads it on its own around the
|
|
25
|
+
* moment the run would cross `staleAfter`. It renders disabled unless
|
|
26
|
+
* Assistant Cloud reported the run in progress elsewhere, and while a
|
|
27
|
+
* refresh is in flight.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <ActionBarPrimitive.RefreshRun>Refresh</ActionBarPrimitive.RefreshRun>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const ActionBarPrimitiveRefreshRun = createActionButton(
|
|
35
|
+
"ActionBarPrimitive.RefreshRun",
|
|
36
|
+
useActionBarRefreshRun,
|
|
37
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ActionButtonElement,
|
|
5
|
+
type ActionButtonProps,
|
|
6
|
+
createActionButton,
|
|
7
|
+
} from "../../utils/createActionButton";
|
|
8
|
+
import { useActionBarResume as useActionBarResumeBehavior } from "@assistant-ui/core/react";
|
|
9
|
+
|
|
10
|
+
const useActionBarResume = () => {
|
|
11
|
+
const { disabled, resume } = useActionBarResumeBehavior();
|
|
12
|
+
if (disabled) return null;
|
|
13
|
+
return resume;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export namespace ActionBarPrimitiveResume {
|
|
17
|
+
export type Element = ActionButtonElement;
|
|
18
|
+
export type Props = ActionButtonProps<typeof useActionBarResume>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A button that answers again in place of an assistant message whose run
|
|
23
|
+
* stopped before it wrote anything (its tab closed or lost its connection).
|
|
24
|
+
* It deletes the empty reply and its stored row, then runs again from the
|
|
25
|
+
* reply's parent, so no branch is left beside it; a runtime that cannot
|
|
26
|
+
* delete messages starts a new branch instead. It renders disabled unless the
|
|
27
|
+
* message is the last one on its branch and its run went `staleAfter`
|
|
28
|
+
* without a heartbeat. A reply that wrote content before its run stopped is a
|
|
29
|
+
* regular error, answered again with Regenerate.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <MessagePrimitive.Error>
|
|
34
|
+
* <ErrorPrimitive.Root>
|
|
35
|
+
* <ErrorPrimitive.Message />
|
|
36
|
+
* <ActionBarPrimitive.Resume>Resume</ActionBarPrimitive.Resume>
|
|
37
|
+
* </ErrorPrimitive.Root>
|
|
38
|
+
* </MessagePrimitive.Error>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export const ActionBarPrimitiveResume = createActionButton(
|
|
42
|
+
"ActionBarPrimitive.Resume",
|
|
43
|
+
useActionBarResume,
|
|
44
|
+
);
|
|
@@ -21,7 +21,8 @@ export namespace ActionBarPrimitiveRoot {
|
|
|
21
21
|
export type Element = ComponentRef<typeof Primitive.div>;
|
|
22
22
|
export type Props = PrimitiveDivProps & {
|
|
23
23
|
/**
|
|
24
|
-
* Whether to hide the action bar when the thread is running
|
|
24
|
+
* Whether to hide the action bar when the thread is running, or while
|
|
25
|
+
* another tab or session is still writing this message.
|
|
25
26
|
* @default false
|
|
26
27
|
*/
|
|
27
28
|
hideWhenRunning?: boolean | undefined;
|
|
@@ -24,7 +24,11 @@ export const useActionBarFloatStatus = ({
|
|
|
24
24
|
forceVisible,
|
|
25
25
|
}: UseActionBarFloatStatusProps) => {
|
|
26
26
|
return useAuiState((s) => {
|
|
27
|
-
if (
|
|
27
|
+
if (
|
|
28
|
+
hideWhenRunning &&
|
|
29
|
+
(s.thread.isRunning || s.message.runState === "in-progress")
|
|
30
|
+
)
|
|
31
|
+
return HideAndFloatStatus.Hidden;
|
|
28
32
|
|
|
29
33
|
const autohideEnabled =
|
|
30
34
|
autohide === "always" || (autohide === "not-last" && !s.message.isLast);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { ActionBarPrimitiveRoot as Root } from "./actionBar/ActionBarRoot";
|
|
2
2
|
export { ActionBarPrimitiveCopy as Copy } from "./actionBar/ActionBarCopy";
|
|
3
3
|
export { ActionBarPrimitiveReload as Reload } from "./actionBar/ActionBarReload";
|
|
4
|
+
export { ActionBarPrimitiveResume as Resume } from "./actionBar/ActionBarResume";
|
|
5
|
+
export { ActionBarPrimitiveRefreshRun as RefreshRun } from "./actionBar/ActionBarRefreshRun";
|
|
4
6
|
export { ActionBarPrimitiveEdit as Edit } from "./actionBar/ActionBarEdit";
|
|
5
7
|
export { ActionBarPrimitiveSpeak as Speak } from "./actionBar/ActionBarSpeak";
|
|
6
8
|
export { ActionBarPrimitiveStopSpeaking as StopSpeaking } from "./actionBar/ActionBarStopSpeaking";
|
|
@@ -6,17 +6,31 @@ import {
|
|
|
6
6
|
forwardRef,
|
|
7
7
|
type ComponentPropsWithoutRef,
|
|
8
8
|
} from "react";
|
|
9
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
9
10
|
|
|
10
11
|
export namespace ErrorPrimitiveRoot {
|
|
11
12
|
export type Element = ComponentRef<typeof Primitive.div>;
|
|
12
13
|
export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The container of a message's error. It carries `data-run-state` (`stale` or
|
|
18
|
+
* `in-progress`) when the error stands for a run another tab or session
|
|
19
|
+
* drove, and announces an in-progress run as a status instead of an alert.
|
|
20
|
+
*/
|
|
15
21
|
export const ErrorPrimitiveRoot = forwardRef<
|
|
16
22
|
ErrorPrimitiveRoot.Element,
|
|
17
23
|
ErrorPrimitiveRoot.Props
|
|
18
24
|
>((props, forwardRef) => {
|
|
19
|
-
|
|
25
|
+
const runState = useAuiState((s) => s.optional.message?.runState);
|
|
26
|
+
return (
|
|
27
|
+
<Primitive.div
|
|
28
|
+
role={runState === "in-progress" ? "status" : "alert"}
|
|
29
|
+
{...(runState ? { "data-run-state": runState } : undefined)}
|
|
30
|
+
{...props}
|
|
31
|
+
ref={forwardRef}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
20
34
|
});
|
|
21
35
|
|
|
22
36
|
ErrorPrimitiveRoot.displayName = "ErrorPrimitive.Root";
|