@blocklet/pages-kit 0.2.322 → 0.2.323

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.
@@ -30,7 +30,7 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
30
30
  const { aid, agent } = useCurrentAgent();
31
31
  const [executeLoading, setExecuteLoading] = useState(false);
32
32
  const opening = useOpeningQuestions();
33
- const { execute } = useRuntimeState();
33
+ const { execute, checkLoginState } = useRuntimeState();
34
34
  const { running } = useCurrentSessionState((s) => s) || {};
35
35
  const { createSession, currentSessionId } = useSessionState((s) => s) || {};
36
36
  const { setCurrentMessageTaskId } = useV0RuntimeContext();
@@ -51,6 +51,7 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
51
51
  }, [defaultForm, autoFillLastForm, form, chatMode]);
52
52
  const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
53
53
  try {
54
+ yield checkLoginState();
54
55
  if (!(parameters === null || parameters === void 0 ? void 0 : parameters.question))
55
56
  return;
56
57
  setExecuteLoading(true);
@@ -1,10 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import ClickToCopy from '@arcblock/ux/lib/ClickToCopy';
3
- import { Box, Typography } from '@mui/material';
2
+ import ClickToCopy, { CopyButton } from '@arcblock/ux/lib/ClickToCopy';
3
+ import { Box, Tooltip, Typography } from '@mui/material';
4
4
  import { Avatar } from '../../../../../arcblock/ux';
5
5
  import { useLocaleContext } from '../../../../../locale';
6
6
  import { useSessionContext } from '../../../../../session';
7
7
  import { getLineClamp } from '../utils';
8
+ const BASE_QUESTION_SX = {
9
+ fontWeight: 500,
10
+ fontSize: 13,
11
+ };
8
12
  export default function UserQuestion({ question }) {
9
13
  var _a;
10
14
  const { session: authSession } = useSessionContext();
@@ -22,5 +26,6 @@ export default function UserQuestion({ question }) {
22
26
  borderRadius: 1,
23
27
  // borderTopLeftRadius: 0,
24
28
  backgroundColor: 'grey.200',
25
- }, children: _jsx(ClickToCopy, { locale: locale, unstyled: true, children: _jsx(Typography, { sx: Object.assign({ fontWeight: 500, fontSize: 13, maxWidth: 300, color: 'textColor', textAlign: 'left' }, getLineClamp(1)), children: question }) }) })] }));
29
+ maxWidth: 300,
30
+ }, children: _jsx(CopyButton, { locale: locale, unstyled: true, render: ({ containerRef }) => (_jsx(Box, { ref: containerRef, display: "flex", alignItems: "center", sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'textColor' }), children: _jsx(ClickToCopy, { locale: locale, unstyled: true, children: _jsx(Tooltip, { title: _jsx(Box, { children: _jsx(Typography, { sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'white' }), children: question }) }), children: _jsx(Typography, { sx: Object.assign(Object.assign(Object.assign({}, BASE_QUESTION_SX), { textAlign: 'left', alignItems: 'center' }), getLineClamp(1)), children: question }) }) }) })) }) })] }));
26
31
  }
@@ -13,7 +13,7 @@ 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;
16
+ var _a, _b;
17
17
  const { aid, working } = useRuntimeContext();
18
18
  const [agent] = useAgentState({ aid, working });
19
19
  const { session: authSession } = useSessionContext();
@@ -38,5 +38,11 @@ export function useRuntimeState() {
38
38
  }
39
39
  return exec(Object.assign(Object.assign({}, args), { working }));
40
40
  }), [authSession.user, exec, working, login]);
41
- return { aid, working, agent, execute };
41
+ const checkLoginState = useCallback(() => __awaiter(this, void 0, void 0, function* () {
42
+ var _c;
43
+ if (!((_c = authSession.user) === null || _c === void 0 ? void 0 : _c.did)) {
44
+ yield login();
45
+ }
46
+ }), [!((_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did)]);
47
+ return { aid, working, agent, execute, checkLoginState };
42
48
  }