@blocklet/pages-kit 0.2.324 → 0.2.326

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 (30) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/{MarkdownRenderer.js → MarkdownRenderer/index.js} +6 -12
  2. package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +1 -1
  3. package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +5 -2
  4. package/lib/cjs/builtin/async/ai-runtime/constants.js +5 -1
  5. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +24 -9
  6. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +1 -2
  7. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +20 -7
  8. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +4 -1
  9. package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +8 -6
  10. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  11. package/lib/esm/builtin/async/ai-runtime/components/{MarkdownRenderer.js → MarkdownRenderer/index.js} +6 -12
  12. package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +1 -1
  13. package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +5 -2
  14. package/lib/esm/builtin/async/ai-runtime/constants.js +4 -0
  15. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +22 -9
  16. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +1 -2
  17. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +22 -9
  18. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +4 -1
  19. package/lib/esm/builtin/async/ai-runtime/state/runtime.js +8 -6
  20. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  21. package/lib/types/builtin/async/ai-runtime/constants.d.ts +1 -0
  22. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.d.ts +4 -0
  23. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.d.ts +3 -1
  24. package/lib/types/builtin/session.d.ts +1 -0
  25. package/lib/types/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +3 -3
  27. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.js +0 -20
  28. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.js +0 -14
  29. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.d.ts +0 -1
  30. /package/lib/types/builtin/async/ai-runtime/components/{MarkdownRenderer.d.ts → MarkdownRenderer/index.d.ts} +0 -0
@@ -15,19 +15,12 @@ import { Box, Stack, styled } from '@mui/material';
15
15
  import React, { Suspense } from 'react';
16
16
  import Markdown from 'react-markdown';
17
17
  import remarkGfm from 'remark-gfm';
18
- import { useLocaleContext } from '../../../locale';
19
- import ReactSyntaxHighlighterAsync from '../../react-syntax-highlighter';
20
- import ActionButton from './ActionButton';
18
+ import { useLocaleContext } from '../../../../locale';
19
+ import ReactSyntaxHighlighterAsync from '../../../react-syntax-highlighter';
20
+ import ActionButton from '../ActionButton';
21
21
  const ReactSyntaxHighlighter = React.lazy(() => ReactSyntaxHighlighterAsync().then((m) => ({ default: m.Prism })));
22
22
  const MarkdownRenderer = styled((props) => (_jsx(Markdown, Object.assign({}, props, { remarkPlugins: [remarkGfm], components: {
23
23
  pre: MarkdownPre,
24
- code: (_a) => {
25
- var { node, inline, className, children } = _a, props = __rest(_a, ["node", "inline", "className", "children"]);
26
- if (!children)
27
- return null;
28
- const match = /language-(\w+)/.exec(className || '');
29
- return !inline ? (_jsx(Suspense, { children: _jsx(Box, Object.assign({ component: ReactSyntaxHighlighter, language: match === null || match === void 0 ? void 0 : match[1] }, props, { sx: { borderRadius: 1 }, children: String(children).replace(/\n$/, '') })) })) : (_jsx(Box, Object.assign({ component: "code", className: className }, props, { children: children })));
30
- },
31
24
  table: ({ className, children }) => {
32
25
  return (_jsx(Box, { sx: { overflow: 'auto', my: 1 }, children: _jsx("table", { className: className, children: children }) }));
33
26
  },
@@ -106,7 +99,8 @@ const MarkdownRenderer = styled((props) => (_jsx(Markdown, Object.assign({}, pro
106
99
  }
107
100
  `;
108
101
  export default MarkdownRenderer;
109
- function MarkdownPre({ children }) {
102
+ function MarkdownPre(_a) {
103
+ var { children } = _a, props = __rest(_a, ["children"]);
110
104
  const { t } = useLocaleContext();
111
105
  const childrenProps = children === null || children === void 0 ? void 0 : children.props;
112
106
  if (!(childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.children))
@@ -120,5 +114,5 @@ function MarkdownPre({ children }) {
120
114
  '> pre': { mt: '0 !important' },
121
115
  }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", p: 0.5, pl: 1.5, borderBottom: 1, borderColor: "grey.200", children: [_jsx(Box, { children: language }), _jsx(Box, { flex: 1 }), _jsx(ActionButton, { autoReset: true, tip: t('copyToClipboard'), tipSucceed: t('copied'), title: _jsx(Icon, { icon: "tabler:copy" }), titleSucceed: _jsx(Icon, { icon: "tabler:copy-check" }), sx: { minWidth: 32, minHeight: 32, p: 0, fontSize: 18 }, onClick: () => {
122
116
  window.navigator.clipboard.writeText(childrenProps.children);
123
- } })] }), children] }));
117
+ } })] }), _jsx(Suspense, { children: _jsx(Box, Object.assign({ component: ReactSyntaxHighlighter, language: match === null || match === void 0 ? void 0 : match[1] }, props, { sx: { borderRadius: 1, bgcolor: 'red' }, children: String(childrenProps.children).replace(/\n$/, '') })) })] }));
124
118
  }
@@ -76,7 +76,7 @@ function ShareCopy() {
76
76
  const image = (_f = (_e = (_d = (_c = (_b = message.result) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.find((i) => { var _a; return (_a = i.data[RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _d === void 0 ? void 0 : _d.data[RuntimeOutputVariable.images]) === null || _e === void 0 ? void 0 : _e.at(0)) === null || _f === void 0 ? void 0 : _f.url;
77
77
  if (!content && !image)
78
78
  return null;
79
- return (_jsx(StyledActionButton, { tip: t('copy'), tipSucceed: t('copied'), title: _jsx(Icon, { icon: "tabler:copy" }), titleSucceed: _jsx(Icon, { icon: "tabler:copy-check" }), onClick: () => __awaiter(this, void 0, void 0, function* () {
79
+ return (_jsx(StyledActionButton, { autoReset: true, tip: t('copy'), tipSucceed: t('copied'), title: _jsx(Icon, { icon: "tabler:copy" }), titleSucceed: _jsx(Icon, { icon: "tabler:copy-check" }), onClick: () => __awaiter(this, void 0, void 0, function* () {
80
80
  if (content) {
81
81
  window.navigator.clipboard.writeText(content);
82
82
  }
@@ -57,6 +57,9 @@ export function SocialShareMenu(_a) {
57
57
  gap: 1.5,
58
58
  minWidth: 120,
59
59
  lineHeight: '1!important',
60
+ width: '100%',
61
+ border: 'none',
62
+ bgcolor: 'transparent',
60
63
  };
61
64
  const iconProps = {
62
65
  bgStyle: { fill: '#fff' },
@@ -65,14 +68,14 @@ export function SocialShareMenu(_a) {
65
68
  borderRadius: '6px',
66
69
  },
67
70
  };
68
- return (_jsx(MenuButton, Object.assign({ MenuProps: MenuProps, menus: [
71
+ return (_jsx(MenuButton, Object.assign({ MenuProps: Object.assign(Object.assign({}, MenuProps), { sx: { li: { p: 0, button: { px: '8px !important', py: '4px !important' } } } }), menus: [
69
72
  _jsx(MenuItem, { children: _jsxs(Box, { component: XShareButton, url: url, title: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: XIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToX') })] }) }, "shareOnX"),
70
73
  _jsx(MenuItem, { children: _jsxs(Box, { component: TelegramShareButton, url: url, title: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: TelegramIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToTelegram') })] }) }, "shareOnTelegram"),
71
74
  _jsx(MenuItem, { children: _jsxs(Box, { component: RedditShareButton, url: url, title: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: RedditIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToReddit') })] }) }, "shareOnReddit"),
72
75
  _jsx(MenuItem, { children: _jsxs(Box, { component: WeiboShareButton, url: url, title: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: WeiboIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToWeibo') })] }) }, "shareOnWeibo"),
73
76
  _jsx(MenuItem, { children: _jsxs(Box, { component: FacebookShareButton, url: url, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: FacebookIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToFacebook') })] }) }, "shareOnFacebook"),
74
77
  _jsx(MenuItem, { children: _jsxs(Box, { component: LinkedinShareButton, url: url, summary: content, sx: buttonSx, children: [_jsx(Box, Object.assign({ component: LinkedinIcon, sx: itemIconSx, round: true }, iconProps)), _jsx("span", { children: t('socialShare.shareToLinkedin') })] }) }, "shareOnLinkedin"),
75
- !disableCopyLink && (_jsx(MenuItem, { children: _jsxs(Box, { component: "div", sx: buttonSx, onClick: () => {
78
+ !disableCopyLink && (_jsx(MenuItem, { children: _jsxs(Box, { component: "button", sx: buttonSx, onClick: () => {
76
79
  window.navigator.clipboard.writeText(url);
77
80
  }, children: [_jsx(Box, Object.assign({ sx: itemIconSx, round: true }, iconProps, { children: _jsx(Icon, { icon: "tabler:link" }) })), _jsx("span", { children: t('socialShare.copyLink') })] }) }, "copyToClipboard")),
78
81
  ].filter(Boolean) }, restProps, { children: children })));
@@ -9,6 +9,7 @@ export const SUGGESTED_QUESTIONS_VIEW_ID = '6u8m11ss7fvu8t7i';
9
9
  export const REFERENCED_LINKS_VIEW_ID = 'baqmaoccdntqwayc';
10
10
  export const SHARE_VIEW_ID = 'jfq3df9z8lkk9not';
11
11
  export const IMAGES_VIEW_ID = 'txirtdgx8h2bmo7s';
12
+ export const OPENING_QUESTIONS_VIEW_ID = 'vgsgsvnhud0cq37v';
12
13
  export const DEFAULT_OUTPUT_COMPONENTS = {
13
14
  [RuntimeOutputVariable.text]: {
14
15
  componentId: MARKDOWN_VIEW_ID,
@@ -28,6 +29,9 @@ export const DEFAULT_OUTPUT_COMPONENTS = {
28
29
  [RuntimeOutputVariable.share]: {
29
30
  componentId: SHARE_VIEW_ID,
30
31
  },
32
+ [RuntimeOutputVariable.openingQuestions]: {
33
+ componentId: OPENING_QUESTIONS_VIEW_ID,
34
+ },
31
35
  };
32
36
  export function getDefaultOutputComponent(output) {
33
37
  return DEFAULT_OUTPUT_COMPONENTS[output.name];
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
13
  import { Box, Stack } from '@mui/material';
3
14
  import { memo } from 'react';
@@ -17,14 +28,16 @@ const MessageView = memo(({ message }) => {
17
28
  const { hideAgentAvatar, hideUserInputs } = (_a = useComponentPreferences()) !== null && _a !== void 0 ? _a : {};
18
29
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
19
30
  return null;
20
- return (_jsx(CurrentAgentProvider, { agentId: message.assistantId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsxs(Stack, { gap: 2, children: [!hideUserInputs && (_jsx(Box, { children: _jsx(UserInfo, { name: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.fullName, did: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.did, avatar: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", children: _jsx(Stack, { sx: { alignItems: 'flex-end' }, children: _jsx(Box, { sx: {
21
- borderRadius: 1,
22
- borderTopRightRadius: '2px',
23
- px: 2,
24
- py: 1,
25
- marginTop: 0.5,
26
- maxWidth: 'calc(100% - 40px)',
27
- bgcolor: 'rgba(239, 246, 255, 1)',
28
- }, children: _jsx(UserMessageView, {}) }) }) }) })), _jsx(Box, { children: !hideAgentAvatar ? (_jsx(UserInfo, { name: profile.name, did: (_e = globalThis.blocklet) === null || _e === void 0 ? void 0 : _e.appId, avatar: profile.avatar, time: message.createdAt, alignItems: "flex-start", children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) })) : (_jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties })) })] }) }) }));
31
+ const agentMessage = (_jsx(MessageBodyContainer, { messageRole: "assistant", children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }));
32
+ return (_jsx(CurrentAgentProvider, { agentId: message.assistantId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsxs(Stack, { gap: 2, children: [!hideUserInputs && (_jsx(Box, { children: _jsx(UserInfo, { name: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.fullName, did: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.did, avatar: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", children: _jsx(Stack, { sx: { alignItems: 'flex-end' }, children: _jsx(MessageBodyContainer, { messageRole: "user", children: _jsx(UserMessageView, {}) }) }) }) })), _jsx(Box, { children: !hideAgentAvatar ? (_jsx(UserInfo, { name: profile.name, did: (_e = globalThis.blocklet) === null || _e === void 0 ? void 0 : _e.appId, avatar: profile.avatar, time: message.createdAt, alignItems: "flex-start", children: agentMessage })) : (agentMessage) })] }) }) }));
29
33
  });
30
34
  export default MessageView;
35
+ export function MessageBodyContainer(_a) {
36
+ var _b;
37
+ var { messageRole } = _a, props = __rest(_a, ["messageRole"]);
38
+ const preferences = useComponentPreferences();
39
+ const hasBg = !!((_b = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _b === void 0 ? void 0 : _b.url);
40
+ const hideUserMessage = preferences === null || preferences === void 0 ? void 0 : preferences.hideUserInputs;
41
+ return (_jsx(Box, Object.assign({}, props, { sx: hasBg
42
+ ? Object.assign({ borderRadius: 1, borderTopRightRadius: messageRole === 'user' ? 2 : undefined, borderTopLeftRadius: messageRole !== 'user' ? 2 : undefined, px: 2, py: 1, marginTop: 0.5, maxWidth: hideUserMessage ? 'unset' : 'calc(100% - 40px)', bgcolor: 'rgba(239, 246, 255, 1)' }, props.sx) : Object.assign({}, props.sx) })));
43
+ }
@@ -15,7 +15,6 @@ import { useComponentPreferences } from '../../contexts/ComponentPreferences';
15
15
  import { useCurrentSessionState, useSessionState } from '../../state/session';
16
16
  import MessageView from './MessageView';
17
17
  import OpeningMessageView from './OpeningMessageView';
18
- import OpeningQuestionsView from './OpeningQuestionsView';
19
18
  export default function MessagesView(_a) {
20
19
  var _b;
21
20
  var props = __rest(_a, []);
@@ -23,5 +22,5 @@ export default function MessagesView(_a) {
23
22
  const loaded = useSessionState((s) => s.loaded);
24
23
  const showOpening = useCurrentSessionState((s) => !s || (s === null || s === void 0 ? void 0 : s.loaded)) && loaded;
25
24
  const divider = (_b = useComponentPreferences()) === null || _b === void 0 ? void 0 : _b.divider;
26
- return (_jsxs(Stack, Object.assign({ gap: 2 }, props, { children: [showOpening && _jsx(OpeningMessageView, {}), messages === null || messages === void 0 ? void 0 : messages.map((message, index) => (_jsxs(_Fragment, { children: [_jsx(MessageView, { message: message }, message.taskId), divider && index !== messages.length - 1 ? _jsx(Divider, { sx: { my: 2 } }) : undefined] }))), showOpening && !(messages === null || messages === void 0 ? void 0 : messages.length) && _jsx(OpeningQuestionsView, {})] })));
25
+ return (_jsxs(Stack, Object.assign({ gap: 2 }, props, { children: [showOpening && _jsx(OpeningMessageView, { isMessagesEmpty: !(messages === null || messages === void 0 ? void 0 : messages.length) }), messages === null || messages === void 0 ? void 0 : messages.map((message, index) => (_jsxs(_Fragment, { children: [_jsx(MessageView, { message: message }, message.taskId), divider && index !== messages.length - 1 ? _jsx(Divider, { sx: { my: 2 } }) : undefined] })))] })));
27
26
  }
@@ -1,18 +1,31 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
3
3
  import { memo, useMemo } from 'react';
4
4
  import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
5
5
  import UserInfo from '../../components/UserInfo';
6
+ import { DEFAULT_OUTPUT_COMPONENTS } from '../../constants';
6
7
  import { useComponentPreferences } from '../../contexts/ComponentPreferences';
7
- import { useOpeningMessage } from '../../hooks/use-appearances';
8
- const OpeningMessageView = memo(() => {
9
- var _a, _b, _c, _d, _e;
8
+ import { useCurrentAgent } from '../../contexts/CurrentAgent';
9
+ import { useOpeningMessage, useOpeningQuestions, useProfile } from '../../hooks/use-appearances';
10
+ import { MessageBodyContainer } from './MessageView';
11
+ const OpeningMessageView = memo(({ isMessagesEmpty }) => {
12
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
10
13
  const { hideAgentAvatar } = (_a = useComponentPreferences()) !== null && _a !== void 0 ? _a : {};
11
- const opening = useOpeningMessage();
12
- const output = useMemo(() => { var _a; return (_a = opening === null || opening === void 0 ? void 0 : opening.agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.openingMessage); }, [opening === null || opening === void 0 ? void 0 : opening.agent]);
13
- const componentId = (_b = output === null || output === void 0 ? void 0 : output.appearance) === null || _b === void 0 ? void 0 : _b.componentId;
14
- if (!output || !(opening === null || opening === void 0 ? void 0 : opening.message) || !componentId)
14
+ const openingMessage = useOpeningMessage();
15
+ const openingMessageOutput = useMemo(() => { var _a; return (_a = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.openingMessage); }, [openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.agent]);
16
+ const openingMessageComponentId = ((_b = openingMessageOutput === null || openingMessageOutput === void 0 ? void 0 : openingMessageOutput.appearance) === null || _b === void 0 ? void 0 : _b.componentId) ||
17
+ ((_c = DEFAULT_OUTPUT_COMPONENTS[RuntimeOutputVariable.openingMessage]) === null || _c === void 0 ? void 0 : _c.componentId);
18
+ const profile = useProfile();
19
+ const { agent } = useCurrentAgent();
20
+ const openingQuestions = useOpeningQuestions();
21
+ const openingQuestionsOutput = useMemo(() => { var _a; return (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.openingQuestions); }, [agent.outputVariables]);
22
+ const openingQuestionsComponentId = ((_d = openingQuestionsOutput === null || openingQuestionsOutput === void 0 ? void 0 : openingQuestionsOutput.appearance) === null || _d === void 0 ? void 0 : _d.componentId) ||
23
+ ((_e = DEFAULT_OUTPUT_COMPONENTS[RuntimeOutputVariable.openingQuestions]) === null || _e === void 0 ? void 0 : _e.componentId);
24
+ if ((!(openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.message) || !openingMessageComponentId) &&
25
+ (!openingQuestionsComponentId || !(openingQuestions === null || openingQuestions === void 0 ? void 0 : openingQuestions.questions.length) || !isMessagesEmpty)) {
15
26
  return null;
16
- return hideAgentAvatar ? (_jsx(CustomComponentRenderer, { instanceId: output.id, componentId: componentId, properties: (_c = output.appearance) === null || _c === void 0 ? void 0 : _c.componentProperties, props: { output, outputValue: opening.message } })) : (_jsx(UserInfo, { name: opening.profile.name, did: (_d = globalThis.blocklet) === null || _d === void 0 ? void 0 : _d.appId, avatar: opening.profile.avatar, alignItems: "flex-start", children: _jsx(CustomComponentRenderer, { instanceId: output.id, componentId: componentId, properties: (_e = output.appearance) === null || _e === void 0 ? void 0 : _e.componentProperties, props: { output, outputValue: opening.message } }) }));
27
+ }
28
+ const children = (_jsxs(MessageBodyContainer, { children: [openingMessage && openingMessageOutput && openingMessageComponentId && (_jsx(CustomComponentRenderer, { instanceId: openingMessageOutput.id, componentId: openingMessageComponentId, properties: (_f = openingMessageOutput.appearance) === null || _f === void 0 ? void 0 : _f.componentProperties, props: { output: openingMessageOutput, outputValue: openingMessage.message } })), isMessagesEmpty && openingQuestionsComponentId && (_jsx(CustomComponentRenderer, { instanceId: agent.id, componentId: openingQuestionsComponentId, properties: (_g = openingQuestionsOutput === null || openingQuestionsOutput === void 0 ? void 0 : openingQuestionsOutput.appearance) === null || _g === void 0 ? void 0 : _g.componentProperties, props: { output: openingQuestionsOutput } }))] }));
29
+ return hideAgentAvatar ? (children) : (_jsx(UserInfo, { name: ((_h = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _h !== void 0 ? _h : profile).name, did: (_j = globalThis.blocklet) === null || _j === void 0 ? void 0 : _j.appId, avatar: ((_k = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _k !== void 0 ? _k : profile).avatar, alignItems: "flex-start", children: children }));
17
30
  });
18
31
  export default OpeningMessageView;
@@ -47,7 +47,7 @@ export default function V0Output() {
47
47
  backgroundColor: 'white',
48
48
  borderColor: 'rgba(0, 0, 0, 0.1) !important',
49
49
  // rewrite disabled style
50
- '&.Mui-disabled': {
50
+ '&.frame-button.Mui-disabled': {
51
51
  backgroundColor: 'primary.main',
52
52
  color: 'white',
53
53
  },
@@ -57,6 +57,7 @@ export default function V0Output() {
57
57
  key: 'Desktop',
58
58
  icon: 'tabler:device-desktop',
59
59
  props: {
60
+ className: 'frame-button',
60
61
  disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Desktop',
61
62
  sx: Object.assign({}, responsiveSx),
62
63
  onClick: () => setCodePreviewExtraProps({
@@ -70,6 +71,7 @@ export default function V0Output() {
70
71
  key: 'Tablet',
71
72
  icon: 'tabler:device-tablet',
72
73
  props: {
74
+ className: 'frame-button',
73
75
  disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Tablet',
74
76
  sx: Object.assign({}, responsiveSx),
75
77
  onClick: () => setCodePreviewExtraProps({
@@ -86,6 +88,7 @@ export default function V0Output() {
86
88
  key: 'Mobile',
87
89
  icon: 'tabler:device-mobile',
88
90
  props: {
91
+ className: 'frame-button',
89
92
  disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Mobile',
90
93
  sx: Object.assign({}, responsiveSx),
91
94
  onClick: () => setCodePreviewExtraProps({
@@ -13,19 +13,21 @@ import { useRuntimeContext } from '../contexts/Runtime';
13
13
  import { useAgentState } from './agent';
14
14
  import { createSessionState } from './session';
15
15
  export function useRuntimeState() {
16
- var _a;
17
16
  const { aid, working } = useRuntimeContext();
18
17
  const [agent] = useAgentState({ aid, working });
19
- const { session: authSession } = useSessionContext();
18
+ const { session: authSession, events } = useSessionContext();
20
19
  const sessionState = useMemo(() => createSessionState({ aid }), [aid]);
21
20
  const exec = sessionState((s) => s.execute);
22
21
  // reset state after logged out
23
22
  useEffect(() => {
24
- var _a;
25
- if (!((_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did)) {
23
+ const onLogout = () => {
26
24
  sessionState.getState().reset();
27
- }
28
- }, [(_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did, sessionState]);
25
+ };
26
+ events.on('logout', onLogout);
27
+ return () => {
28
+ events.off('logout', onLogout);
29
+ };
30
+ }, []);
29
31
  const login = useCallback(() => __awaiter(this, void 0, void 0, function* () {
30
32
  yield new Promise((resolve) => {
31
33
  authSession.login(() => resolve());