@dashx/react 0.1.17 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/button.js +1 -1
- package/dist/cjs/components/button.js.map +1 -1
- package/dist/cjs/components/flex.d.ts +4 -332
- package/dist/cjs/components/form.d.ts +3 -3
- package/dist/cjs/components/form.js +1 -1
- package/dist/cjs/components/form.js.map +1 -1
- package/dist/cjs/components/link.js.map +1 -1
- package/dist/cjs/hooks/use-agent.d.ts +8 -3
- package/dist/cjs/hooks/use-agent.js +1 -1
- package/dist/cjs/hooks/use-agent.js.map +3 -3
- package/dist/cjs/hooks/use-in-app.d.ts +5 -5
- package/dist/cjs/hooks/use-in-app.js +1 -1
- package/dist/cjs/hooks/use-in-app.js.map +3 -3
- package/dist/cjs/hooks/use-product-release.js +1 -1
- package/dist/cjs/hooks/use-product-release.js.map +2 -2
- package/dist/cjs/providers/DashXProvider.js +1 -1
- package/dist/cjs/providers/DashXProvider.js.map +2 -2
- package/dist/cjs/variants/avatar.d.ts +3 -117
- package/dist/cjs/variants/base-element.d.ts +2 -86
- package/dist/cjs/variants/base-field.d.ts +3 -129
- package/dist/cjs/variants/base-input.d.ts +1 -1
- package/dist/cjs/variants/button.d.ts +3 -138
- package/dist/cjs/variants/card.d.ts +2 -62
- package/dist/cjs/variants/checkbox.d.ts +1 -19
- package/dist/cjs/variants/field-error.d.ts +2 -86
- package/dist/cjs/variants/heading.d.ts +3 -234
- package/dist/cjs/variants/link.d.ts +4 -259
- package/dist/cjs/variants/popover.d.ts +5 -61
- package/dist/cjs/variants/text-area.d.ts +4 -161
- package/dist/cjs/variants/text-field.d.ts +4 -161
- package/dist/cjs/variants/text.d.ts +3 -235
- package/dist/cjs/variants/tooltip.d.ts +1 -1
- package/dist/cjs/variants/typography.d.ts +2 -182
- package/dist/cjs/widgets/ChatBody.d.ts +3 -2
- package/dist/cjs/widgets/ChatBody.js +1 -1
- package/dist/cjs/widgets/ChatBody.js.map +2 -2
- package/dist/cjs/widgets/MessageBell.d.ts +2 -0
- package/dist/cjs/widgets/MessageBell.js +2 -0
- package/dist/cjs/widgets/MessageBell.js.map +7 -0
- package/dist/cjs/widgets/index.d.ts +1 -1
- package/dist/cjs/widgets/index.js +1 -1
- package/dist/cjs/widgets/index.js.map +3 -3
- package/dist/esm/components/button.js +1 -1
- package/dist/esm/components/button.js.map +1 -1
- package/dist/esm/components/flex.d.ts +4 -332
- package/dist/esm/components/form.d.ts +3 -3
- package/dist/esm/components/form.js +1 -1
- package/dist/esm/components/form.js.map +1 -1
- package/dist/esm/components/link.js.map +1 -1
- package/dist/esm/hooks/use-agent.d.ts +8 -3
- package/dist/esm/hooks/use-agent.js +1 -1
- package/dist/esm/hooks/use-agent.js.map +3 -3
- package/dist/esm/hooks/use-in-app.d.ts +5 -5
- package/dist/esm/hooks/use-in-app.js +1 -1
- package/dist/esm/hooks/use-in-app.js.map +3 -3
- package/dist/esm/hooks/use-product-release.js +1 -1
- package/dist/esm/hooks/use-product-release.js.map +2 -2
- package/dist/esm/providers/DashXProvider.js +1 -1
- package/dist/esm/providers/DashXProvider.js.map +2 -2
- package/dist/esm/variants/avatar.d.ts +3 -117
- package/dist/esm/variants/base-element.d.ts +2 -86
- package/dist/esm/variants/base-field.d.ts +3 -129
- package/dist/esm/variants/base-input.d.ts +1 -1
- package/dist/esm/variants/button.d.ts +3 -138
- package/dist/esm/variants/card.d.ts +2 -62
- package/dist/esm/variants/checkbox.d.ts +1 -19
- package/dist/esm/variants/field-error.d.ts +2 -86
- package/dist/esm/variants/heading.d.ts +3 -234
- package/dist/esm/variants/link.d.ts +4 -259
- package/dist/esm/variants/popover.d.ts +5 -61
- package/dist/esm/variants/text-area.d.ts +4 -161
- package/dist/esm/variants/text-field.d.ts +4 -161
- package/dist/esm/variants/text.d.ts +3 -235
- package/dist/esm/variants/tooltip.d.ts +1 -1
- package/dist/esm/variants/typography.d.ts +2 -182
- package/dist/esm/widgets/ChatBody.d.ts +3 -2
- package/dist/esm/widgets/ChatBody.js +1 -1
- package/dist/esm/widgets/ChatBody.js.map +2 -2
- package/dist/esm/widgets/MessageBell.d.ts +2 -0
- package/dist/esm/widgets/MessageBell.js +2 -0
- package/dist/esm/widgets/MessageBell.js.map +7 -0
- package/dist/esm/widgets/index.d.ts +1 -1
- package/dist/esm/widgets/index.js +1 -1
- package/dist/esm/widgets/index.js.map +2 -2
- package/package.json +50 -51
- package/src/components/button.tsx +1 -1
- package/src/components/form.tsx +3 -3
- package/src/components/link.tsx +1 -1
- package/src/hooks/use-agent.ts +28 -9
- package/src/hooks/use-in-app.ts +20 -20
- package/src/hooks/use-product-release.ts +1 -0
- package/src/providers/DashXProvider.tsx +1 -1
- package/src/widgets/ChatBody.tsx +4 -3
- package/src/widgets/{NotificationBell.tsx → MessageBell.tsx} +21 -21
- package/src/widgets/index.ts +1 -1
- package/styles.css +537 -566
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashx/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -75,61 +75,60 @@
|
|
|
75
75
|
"clean": "rm -rf .turbo node_modules dist tokens layout *.css"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@dashx/browser": "^0.
|
|
78
|
+
"@dashx/browser": "^0.7.2",
|
|
79
79
|
"@radix-ui/colors": "^3.0.0",
|
|
80
|
-
"@radix-ui/primitive": "^1.
|
|
81
|
-
"@radix-ui/react-accessible-icon": "^1.
|
|
82
|
-
"@radix-ui/react-alert-dialog": "^1.
|
|
83
|
-
"@radix-ui/react-aspect-ratio": "^1.
|
|
84
|
-
"@radix-ui/react-avatar": "^1.
|
|
85
|
-
"@radix-ui/react-checkbox": "^1.
|
|
86
|
-
"@radix-ui/react-compose-refs": "^1.
|
|
87
|
-
"@radix-ui/react-context": "^1.
|
|
88
|
-
"@radix-ui/react-context-menu": "^2.
|
|
89
|
-
"@radix-ui/react-dialog": "^1.
|
|
90
|
-
"@radix-ui/react-direction": "^1.
|
|
91
|
-
"@radix-ui/react-dropdown-menu": "^2.
|
|
92
|
-
"@radix-ui/react-form": "^0.
|
|
93
|
-
"@radix-ui/react-hover-card": "^1.
|
|
94
|
-
"@radix-ui/react-navigation-menu": "^1.
|
|
95
|
-
"@radix-ui/react-popover": "^1.
|
|
96
|
-
"@radix-ui/react-portal": "^1.
|
|
97
|
-
"@radix-ui/react-primitive": "^1.
|
|
98
|
-
"@radix-ui/react-progress": "^1.
|
|
99
|
-
"@radix-ui/react-radio-group": "^1.
|
|
100
|
-
"@radix-ui/react-roving-focus": "^1.
|
|
101
|
-
"@radix-ui/react-scroll-area": "^1.
|
|
102
|
-
"@radix-ui/react-select": "^2.
|
|
103
|
-
"@radix-ui/react-slider": "^1.
|
|
104
|
-
"@radix-ui/react-slot": "^1.
|
|
105
|
-
"@radix-ui/react-switch": "^1.
|
|
106
|
-
"@radix-ui/react-tabs": "^1.
|
|
107
|
-
"@radix-ui/react-toggle-group": "^1.
|
|
108
|
-
"@radix-ui/react-tooltip": "^1.
|
|
109
|
-
"@radix-ui/react-use-callback-ref": "^1.
|
|
110
|
-
"@radix-ui/react-use-controllable-state": "^1.
|
|
111
|
-
"@radix-ui/react-use-rect": "^1.1.
|
|
112
|
-
"@radix-ui/react-visually-hidden": "^1.
|
|
113
|
-
"@react-aria/utils": "^3.
|
|
114
|
-
"@react-spectrum/button": "^3.
|
|
115
|
-
"@react-spectrum/utils": "^3.
|
|
116
|
-
"@react-types/shared": "^3.
|
|
117
|
-
"@tailwindcss/postcss": "^4.
|
|
118
|
-
"class-variance-authority": "^0.7.
|
|
80
|
+
"@radix-ui/primitive": "^1.1.3",
|
|
81
|
+
"@radix-ui/react-accessible-icon": "^1.1.8",
|
|
82
|
+
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
83
|
+
"@radix-ui/react-aspect-ratio": "^1.1.8",
|
|
84
|
+
"@radix-ui/react-avatar": "^1.1.11",
|
|
85
|
+
"@radix-ui/react-checkbox": "^1.3.3",
|
|
86
|
+
"@radix-ui/react-compose-refs": "^1.1.2",
|
|
87
|
+
"@radix-ui/react-context": "^1.1.3",
|
|
88
|
+
"@radix-ui/react-context-menu": "^2.2.16",
|
|
89
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
90
|
+
"@radix-ui/react-direction": "^1.1.1",
|
|
91
|
+
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
92
|
+
"@radix-ui/react-form": "^0.1.8",
|
|
93
|
+
"@radix-ui/react-hover-card": "^1.1.15",
|
|
94
|
+
"@radix-ui/react-navigation-menu": "^1.2.14",
|
|
95
|
+
"@radix-ui/react-popover": "^1.1.15",
|
|
96
|
+
"@radix-ui/react-portal": "^1.1.10",
|
|
97
|
+
"@radix-ui/react-primitive": "^2.1.4",
|
|
98
|
+
"@radix-ui/react-progress": "^1.1.8",
|
|
99
|
+
"@radix-ui/react-radio-group": "^1.3.8",
|
|
100
|
+
"@radix-ui/react-roving-focus": "^1.1.11",
|
|
101
|
+
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
102
|
+
"@radix-ui/react-select": "^2.2.6",
|
|
103
|
+
"@radix-ui/react-slider": "^1.3.6",
|
|
104
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
105
|
+
"@radix-ui/react-switch": "^1.2.6",
|
|
106
|
+
"@radix-ui/react-tabs": "^1.1.13",
|
|
107
|
+
"@radix-ui/react-toggle-group": "^1.1.11",
|
|
108
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
109
|
+
"@radix-ui/react-use-callback-ref": "^1.1.1",
|
|
110
|
+
"@radix-ui/react-use-controllable-state": "^1.2.2",
|
|
111
|
+
"@radix-ui/react-use-rect": "^1.1.1",
|
|
112
|
+
"@radix-ui/react-visually-hidden": "^1.2.4",
|
|
113
|
+
"@react-aria/utils": "^3.34.1",
|
|
114
|
+
"@react-spectrum/button": "^3.18.1",
|
|
115
|
+
"@react-spectrum/utils": "^3.13.1",
|
|
116
|
+
"@react-types/shared": "^3.35.0",
|
|
117
|
+
"@tailwindcss/postcss": "^4.3.0",
|
|
118
|
+
"class-variance-authority": "^0.7.1",
|
|
119
119
|
"classnames": "^2.5.1",
|
|
120
|
-
"date-fns": "^
|
|
121
|
-
"lucide-react": "^
|
|
122
|
-
"
|
|
123
|
-
"react-
|
|
124
|
-
"react-hot-toast": "^2.4.1",
|
|
120
|
+
"date-fns": "^4.4.0",
|
|
121
|
+
"lucide-react": "^1.17.0",
|
|
122
|
+
"react-aria": "^3.49.0",
|
|
123
|
+
"react-hot-toast": "^2.6.0",
|
|
125
124
|
"react-markdown": "^10.1.0",
|
|
126
|
-
"react-remove-scroll-bar": "2.3.
|
|
125
|
+
"react-remove-scroll-bar": "2.3.8",
|
|
127
126
|
"react-use-websocket": "^4.8.1",
|
|
128
|
-
"tailwind-merge": "^
|
|
129
|
-
"tailwind-variants": "^
|
|
130
|
-
"tailwindcss": "^4.
|
|
127
|
+
"tailwind-merge": "^3.6.0",
|
|
128
|
+
"tailwind-variants": "^3.2.2",
|
|
129
|
+
"tailwindcss": "^4.3.0",
|
|
131
130
|
"tailwindcss-animate": "^1.0.7",
|
|
132
|
-
"tailwindcss-react-aria-components": "^1.1
|
|
131
|
+
"tailwindcss-react-aria-components": "^2.1.1",
|
|
133
132
|
"uuid-random": "^1.3.2"
|
|
134
133
|
},
|
|
135
134
|
"peerDependencies": {
|
|
@@ -63,7 +63,7 @@ function _Button(props: ButtonProps, ref: React.ForwardedRef<HTMLButtonElement>)
|
|
|
63
63
|
{...filterDOMProps(props)}
|
|
64
64
|
{...mergeProps(buttonProps, focusProps, hoverProps)}
|
|
65
65
|
slot={props.slot || undefined}
|
|
66
|
-
ref={mergeRefs(ref, innerRef)}
|
|
66
|
+
ref={mergeRefs(ref, innerRef) as React.Ref<HTMLElement>}
|
|
67
67
|
data-disabled={props.isDisabled || undefined}
|
|
68
68
|
data-pressed={isPressed || undefined}
|
|
69
69
|
data-hovered={isHovered || undefined}
|
package/src/components/form.tsx
CHANGED
|
@@ -2,15 +2,15 @@ import { FormContext } from 'react-aria-components';
|
|
|
2
2
|
import { FormValidationContext } from 'react-stately';
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
|
|
5
|
-
import type { FormProps as _FormProps } from '@react-types/form';
|
|
6
5
|
import type { CSSProperties, ForwardedRef, ReactNode } from 'react';
|
|
7
|
-
import type { DOMProps } from '@react-types/shared';
|
|
6
|
+
import type { DOMProps, ValidationErrors } from '@react-types/shared';
|
|
8
7
|
|
|
9
|
-
export interface FormProps extends
|
|
8
|
+
export interface FormProps extends DOMProps {
|
|
10
9
|
className?: string;
|
|
11
10
|
style?: CSSProperties;
|
|
12
11
|
children?: ReactNode;
|
|
13
12
|
noValidate?: boolean;
|
|
13
|
+
validationErrors?: ValidationErrors;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function _Form(props: FormProps, ref: ForwardedRef<HTMLFormElement>) {
|
package/src/components/link.tsx
CHANGED
|
@@ -71,7 +71,7 @@ function _Link(props: LinkProps, ref: ForwardedRef<HTMLAnchorElement>) {
|
|
|
71
71
|
{...filterDOMProps(props)}
|
|
72
72
|
{...mergeProps(linkProps, focusProps, hoverProps)}
|
|
73
73
|
slot={props.slot || undefined}
|
|
74
|
-
ref={mergeRefs(ref, innerRef)}
|
|
74
|
+
ref={mergeRefs(ref, innerRef) as any}
|
|
75
75
|
data-disabled={props.isDisabled || undefined}
|
|
76
76
|
data-pressed={isPressed || undefined}
|
|
77
77
|
data-hovered={isHovered || undefined}
|
package/src/hooks/use-agent.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import uuid from 'uuid-random';
|
|
2
2
|
import { useState, useEffect, useCallback } from 'react';
|
|
3
|
-
import type { AiAgent
|
|
3
|
+
import type { AiAgent } from '@dashx/browser';
|
|
4
4
|
|
|
5
5
|
import useDashXProvider from './use-dashx-provider.js';
|
|
6
6
|
|
|
@@ -8,10 +8,19 @@ type UseAgentHookProps = {
|
|
|
8
8
|
publicEmbedKey: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
// UI-level chat message. `aiRole` is a presentation concern maintained by the
|
|
12
|
+
// hook (the SDK's invokeAiAgent messages don't carry a role) to distinguish
|
|
13
|
+
// user-entered messages from agent responses.
|
|
14
|
+
type AiMessage = {
|
|
15
|
+
id: string;
|
|
16
|
+
aiRole: 'user' | 'assistant';
|
|
17
|
+
renderedContent: any;
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
type UseAgentHookResponse = {
|
|
12
21
|
agent?: AiAgent;
|
|
13
22
|
conversationId: string | null;
|
|
14
|
-
messages:
|
|
23
|
+
messages: AiMessage[];
|
|
15
24
|
isThinking: boolean;
|
|
16
25
|
error: string | null;
|
|
17
26
|
sendMessage: (text: string) => Promise<void>;
|
|
@@ -23,7 +32,7 @@ const useAgent = ({ publicEmbedKey }: UseAgentHookProps): UseAgentHookResponse =
|
|
|
23
32
|
const [agent, setAgent] = useState<AiAgent>();
|
|
24
33
|
|
|
25
34
|
const [conversationId, setConversationId] = useState<string | null>(null);
|
|
26
|
-
const [messages, setMessages] = useState<
|
|
35
|
+
const [messages, setMessages] = useState<AiMessage[]>([]);
|
|
27
36
|
const [isThinking, setIsThinking] = useState(false);
|
|
28
37
|
const [error, setError] = useState<string | null>(null);
|
|
29
38
|
|
|
@@ -49,8 +58,8 @@ const useAgent = ({ publicEmbedKey }: UseAgentHookProps): UseAgentHookResponse =
|
|
|
49
58
|
setMessages((prev) => [...prev, {
|
|
50
59
|
id: uuid(),
|
|
51
60
|
aiRole: 'user',
|
|
52
|
-
renderedContent: text
|
|
53
|
-
}
|
|
61
|
+
renderedContent: text,
|
|
62
|
+
}]);
|
|
54
63
|
setIsThinking(true);
|
|
55
64
|
setError(null);
|
|
56
65
|
|
|
@@ -60,11 +69,21 @@ const useAgent = ({ publicEmbedKey }: UseAgentHookProps): UseAgentHookResponse =
|
|
|
60
69
|
publicEmbedKey,
|
|
61
70
|
});
|
|
62
71
|
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
const responseConversationId = response.messages.find(
|
|
73
|
+
(message) => message.conversationId,
|
|
74
|
+
)?.conversationId;
|
|
75
|
+
if (responseConversationId && !conversationId) {
|
|
76
|
+
setConversationId(responseConversationId);
|
|
65
77
|
}
|
|
66
78
|
|
|
67
|
-
setMessages((prev) => [
|
|
79
|
+
setMessages((prev) => [
|
|
80
|
+
...prev,
|
|
81
|
+
...response.messages.map((message) => ({
|
|
82
|
+
id: message.id,
|
|
83
|
+
aiRole: 'assistant' as const,
|
|
84
|
+
renderedContent: message.renderedContent,
|
|
85
|
+
})),
|
|
86
|
+
]);
|
|
68
87
|
} catch (err) {
|
|
69
88
|
setError('Failed to send message');
|
|
70
89
|
} finally {
|
|
@@ -84,6 +103,6 @@ const useAgent = ({ publicEmbedKey }: UseAgentHookProps): UseAgentHookResponse =
|
|
|
84
103
|
};
|
|
85
104
|
};
|
|
86
105
|
|
|
87
|
-
export type { UseAgentHookProps, UseAgentHookResponse };
|
|
106
|
+
export type { UseAgentHookProps, UseAgentHookResponse, AiMessage };
|
|
88
107
|
|
|
89
108
|
export default useAgent;
|
package/src/hooks/use-in-app.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import toast from 'react-hot-toast';
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { WebsocketMessage } from '@dashx/browser';
|
|
4
|
-
import type {
|
|
4
|
+
import type { InAppMessages, WebsocketMessageType } from '@dashx/browser';
|
|
5
5
|
|
|
6
6
|
import useDashXProvider from './use-dashx-provider.js';
|
|
7
7
|
import { useWebSocket } from '../providers/DashXProvider.js';
|
|
8
8
|
|
|
9
9
|
type UseInAppHookResponse = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
messages: InAppMessages;
|
|
11
|
+
unreadMessagesCount: number | null;
|
|
12
|
+
markMessageAsRead: (id: string) => Promise<any>;
|
|
13
|
+
markMessageAsUnread: (id: string) => Promise<any>;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const useInApp = (): UseInAppHookResponse => {
|
|
17
17
|
let dashX = useDashXProvider();
|
|
18
18
|
const { subscribe } = useWebSocket();
|
|
19
|
-
const [
|
|
20
|
-
const [
|
|
19
|
+
const [messages, setMessages] = useState<InAppMessages>([]);
|
|
20
|
+
const [unreadMessagesCount, setUnreadMessagesCount] = useState<number | null>(null);
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const markMessageAsRead = (id: string) => dashX.trackMessage({ id, status: 'READ' });
|
|
23
23
|
|
|
24
|
-
const
|
|
25
|
-
dashX.
|
|
24
|
+
const markMessageAsUnread = async (id: string) =>
|
|
25
|
+
dashX.trackMessage({ id, status: 'UNREAD' });
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
29
|
-
// Set up
|
|
30
|
-
dashX.
|
|
31
|
-
dashX.
|
|
29
|
+
// Set up in-app message watchers (automatically refetch on WebSocket reconnection)
|
|
30
|
+
dashX.watchFetchInAppMessages(setMessages);
|
|
31
|
+
dashX.watchFetchInAppMessagesAggregate(setUnreadMessagesCount);
|
|
32
32
|
}, [dashX]);
|
|
33
33
|
|
|
34
34
|
useEffect(() => {
|
|
35
|
-
// Subscribe to WebSocket messages for
|
|
35
|
+
// Subscribe to WebSocket messages for in-app messages
|
|
36
36
|
const unsubscribe = subscribe((message: WebsocketMessageType) => {
|
|
37
|
-
// Handle only
|
|
37
|
+
// Handle only IN_APP_MESSAGE for toast display
|
|
38
38
|
// The client handles all other message processing internally
|
|
39
|
-
if (message?.type === WebsocketMessage.
|
|
39
|
+
if (message?.type === WebsocketMessage.IN_APP_MESSAGE) {
|
|
40
40
|
toast(message.data.renderedContent.body);
|
|
41
41
|
}
|
|
42
42
|
});
|
|
@@ -45,10 +45,10 @@ const useInApp = (): UseInAppHookResponse => {
|
|
|
45
45
|
}, [subscribe]);
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
messages,
|
|
49
|
+
unreadMessagesCount,
|
|
50
|
+
markMessageAsRead,
|
|
51
|
+
markMessageAsUnread,
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
|
|
@@ -20,6 +20,7 @@ const useProductRelease = (): UseProductReleaseHookResponse => {
|
|
|
20
20
|
dashX
|
|
21
21
|
.fetchProductVariantRelease()
|
|
22
22
|
.then(setProductVariantRelease)
|
|
23
|
+
.catch(() => setProductVariantRelease(null));
|
|
23
24
|
// Set up product variant release rule watcher (automatically refetch on WebSocket reconnection)
|
|
24
25
|
dashX.watchFetchProductVariantReleaseRule(setProductVariantReleaseRule);
|
|
25
26
|
}, [dashX]);
|
package/src/widgets/ChatBody.tsx
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import * as ScrollArea from '@radix-ui/react-scroll-area';
|
|
2
2
|
import React, { useEffect, useRef, useCallback } from 'react';
|
|
3
|
-
import type { AiAgent,
|
|
3
|
+
import type { AiAgent, AiAgentStarterSuggestion } from '@dashx/browser';
|
|
4
4
|
|
|
5
5
|
import { Button, Flex, Text } from '../components';
|
|
6
6
|
import { cn } from '../utils/cn.js';
|
|
7
7
|
import { MarkdownRenderer } from '../components/markdown-renderer.js';
|
|
8
8
|
import useAutoScroll from '../hooks/use-auto-scroll.js';
|
|
9
|
+
import type { AiMessage } from '../hooks/use-agent.js';
|
|
9
10
|
|
|
10
11
|
const AGENT_MESSAGE_WIDTH_CLASS = 'max-w-[max(80%,350px)]';
|
|
11
12
|
const USER_MESSAGE_WIDTH_CLASS = 'max-w-[80%]';
|
|
12
13
|
|
|
13
14
|
type ChatBodyProps = {
|
|
14
15
|
agent: AiAgent;
|
|
15
|
-
messages:
|
|
16
|
+
messages: AiMessage[];
|
|
16
17
|
isThinking: boolean;
|
|
17
18
|
error: string | null;
|
|
18
19
|
sendMessage: (message: string) => void;
|
|
@@ -84,7 +85,7 @@ const ChatBody = ({
|
|
|
84
85
|
sendMessage(suggestion.content);
|
|
85
86
|
};
|
|
86
87
|
|
|
87
|
-
const renderMessage = (message:
|
|
88
|
+
const renderMessage = (message: AiMessage, index: number) => {
|
|
88
89
|
const isUser = message.aiRole === 'user';
|
|
89
90
|
const isLastMessage = index === messages.length - 1;
|
|
90
91
|
const isLastAgentMessage = isLastMessage && !isUser;
|
|
@@ -4,12 +4,12 @@ import { useInApp } from '../hooks/index.js';
|
|
|
4
4
|
import { Button, Card, Flex, Heading, Popover, Text, Theme, Tooltip } from '../components';
|
|
5
5
|
import { Inbox, Mail, MailOpen, X } from '../icons/index.js';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const MessageBell = () => {
|
|
8
8
|
let {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
markMessageAsRead,
|
|
10
|
+
markMessageAsUnread,
|
|
11
|
+
messages,
|
|
12
|
+
unreadMessagesCount,
|
|
13
13
|
} = useInApp();
|
|
14
14
|
|
|
15
15
|
return (
|
|
@@ -21,18 +21,18 @@ const NotificationBell = () => {
|
|
|
21
21
|
<Button
|
|
22
22
|
shape="square"
|
|
23
23
|
roundness="full"
|
|
24
|
-
variant={
|
|
24
|
+
variant={unreadMessagesCount ? 'fill' : 'ghost'}
|
|
25
25
|
>
|
|
26
26
|
<Inbox />
|
|
27
27
|
</Button>
|
|
28
28
|
</Popover.Trigger>
|
|
29
29
|
</Tooltip.Trigger>
|
|
30
|
-
<Tooltip.Content content="
|
|
30
|
+
<Tooltip.Content content="Messages" />
|
|
31
31
|
</Tooltip.Root>
|
|
32
32
|
<Popover.Content spacing="large" width="350px" height="450px">
|
|
33
33
|
<Popover.Header asChild>
|
|
34
34
|
<Flex justify="between" align="center">
|
|
35
|
-
<Heading size={3}>
|
|
35
|
+
<Heading size={3}>Messages</Heading>
|
|
36
36
|
<Popover.Close>
|
|
37
37
|
<Button shape="square" roundness="full" variant="ghost" mode="subtle" inset="right">
|
|
38
38
|
<X />
|
|
@@ -42,22 +42,22 @@ const NotificationBell = () => {
|
|
|
42
42
|
</Popover.Header>
|
|
43
43
|
<Popover.Body>
|
|
44
44
|
<Flex direction="column" gap={1}>
|
|
45
|
-
{
|
|
45
|
+
{messages.length === 0 && (
|
|
46
46
|
<Flex justify="center" align="center">
|
|
47
47
|
<Text variant="tertiary" size={2}>
|
|
48
|
-
No
|
|
48
|
+
No messages yet.
|
|
49
49
|
</Text>
|
|
50
50
|
</Flex>
|
|
51
51
|
)}
|
|
52
|
-
{
|
|
53
|
-
<Card key={
|
|
52
|
+
{messages.map((message) => (
|
|
53
|
+
<Card key={message.id}>
|
|
54
54
|
<Flex align="center" gap={4} justify="between">
|
|
55
55
|
<Flex direction="column" gap={1}>
|
|
56
56
|
<Text as="p" variant="secondary" weight="semibold" size={2}>
|
|
57
|
-
{
|
|
57
|
+
{message.renderedContent.body}
|
|
58
58
|
</Text>
|
|
59
59
|
<Text size={1} variant="tertiary">
|
|
60
|
-
{intlFormatDistance(
|
|
60
|
+
{intlFormatDistance(message.sentAt, new Date())}
|
|
61
61
|
</Text>
|
|
62
62
|
</Flex>
|
|
63
63
|
<Tooltip.Root>
|
|
@@ -66,20 +66,20 @@ const NotificationBell = () => {
|
|
|
66
66
|
shape="square"
|
|
67
67
|
variant="ghost"
|
|
68
68
|
roundness="full"
|
|
69
|
-
mode={
|
|
69
|
+
mode={message.readAt ? 'subtle' : 'distinct'}
|
|
70
70
|
onPress={() => {
|
|
71
|
-
if (
|
|
72
|
-
|
|
71
|
+
if (message.readAt) {
|
|
72
|
+
markMessageAsUnread(message.id);
|
|
73
73
|
} else {
|
|
74
|
-
|
|
74
|
+
markMessageAsRead(message.id);
|
|
75
75
|
}
|
|
76
76
|
}}
|
|
77
77
|
>
|
|
78
|
-
{
|
|
78
|
+
{message.readAt ? <MailOpen /> : <Mail />}
|
|
79
79
|
</Button>
|
|
80
80
|
</Tooltip.Trigger>
|
|
81
81
|
<Tooltip.Content
|
|
82
|
-
content={
|
|
82
|
+
content={message.readAt ? 'Mark as unread' : 'Mark as read'}
|
|
83
83
|
/>
|
|
84
84
|
</Tooltip.Root>
|
|
85
85
|
</Flex>
|
|
@@ -98,4 +98,4 @@ const NotificationBell = () => {
|
|
|
98
98
|
);
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
export default
|
|
101
|
+
export default MessageBell;
|
package/src/widgets/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as Chat } from './Chat.js';
|
|
2
2
|
export { default as ChatPopover } from './ChatPopover.js';
|
|
3
|
-
export { default as
|
|
3
|
+
export { default as MessageBell } from './MessageBell.js';
|
|
4
4
|
export { default as Preference } from './Preference.js';
|
|
5
5
|
export { default as Preferences } from './Preferences.js';
|