@blocklet/pages-kit 0.2.382 → 0.2.384

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.
@@ -38,6 +38,8 @@ export default function GoogleSearchRelatedView({ output, outputValue, onlyLastM
38
38
  return undefined;
39
39
  return result.value;
40
40
  }, [outputValue]);
41
+ if (message === null || message === void 0 ? void 0 : message.loading)
42
+ return null;
41
43
  if ((!isLastMessage && onlyLastMessage) || !((_b = result === null || result === void 0 ? void 0 : result.related_questions) === null || _b === void 0 ? void 0 : _b.length))
42
44
  return null;
43
45
  return (_jsx(OutputFieldContainer, { output: output, children: _jsx(List, { dense: true, disablePadding: true, children: result.related_questions.map((item) => (_jsxs(_Fragment, { children: [_jsx(ListItemButton, { sx: { py: 1, px: 2 }, onClick: () => __awaiter(this, void 0, void 0, function* () {
@@ -31,7 +31,7 @@ export default function GoogleSearchSourcesView({ output, outputValue }) {
31
31
  const itemsToShow = showAll
32
32
  ? [...((searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results) || [])]
33
33
  : [...((searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results) || [])].slice(0, (list === null || list === void 0 ? void 0 : list.length) > 3 ? 2 : 3);
34
- return (_jsx(OutputFieldContainer, { output: output, children: _jsxs(Grid, { container: true, spacing: 1.5, children: [message.loading && (_jsxs(_Fragment, { children: [_jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemSkeleton, {}) }), _jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemSkeleton, {}) }), _jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemSkeleton, {}) })] })), _jsx(TransitionGroup, { component: null, children: itemsToShow.map((item) => (_jsx(CSSTransition, { timeout: 500, classNames: "item", children: _jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemView, { item: item }) }) }, item.link))) }), !showAll && list.length > 3 && (_jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(MoreItemView, { list: list, onMore: handleToggle }) }))] }) }));
34
+ return (_jsx(OutputFieldContainer, { output: output, children: _jsxs(Grid, { container: true, spacing: 1.5, children: [message.loading && !list.length && (_jsxs(_Fragment, { children: [_jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemSkeleton, {}) }), _jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemSkeleton, {}) }), _jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemSkeleton, {}) })] })), _jsx(TransitionGroup, { component: null, children: itemsToShow.map((item) => (_jsx(CSSTransition, { timeout: 500, classNames: "item", children: _jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemView, { item: item }) }) }, item.link))) }), !showAll && list.length > 3 && (_jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(MoreItemView, { list: list, onMore: handleToggle }) }))] }) }));
35
35
  }
36
36
  function ItemView({ item }) {
37
37
  var _a;
@@ -3,7 +3,7 @@ import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
3
3
  import { Stack } from '@mui/material';
4
4
  import { Suspense, useMemo } from 'react';
5
5
  import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
6
- import AgentErrorBoundary from '../../components/AgentErrorBoundary';
6
+ import AgentErrorBoundary, { AgentErrorView } from '../../components/AgentErrorBoundary';
7
7
  import { getDefaultOutputComponent } from '../../constants';
8
8
  import { useComponentPreferences } from '../../contexts/ComponentPreferences';
9
9
  import { useCurrentAgent } from '../../contexts/CurrentAgent';
@@ -19,8 +19,6 @@ export default function SimpleOutput() {
19
19
  const preferences = useComponentPreferences();
20
20
  const CustomComponentActionsComponent = preferences === null || preferences === void 0 ? void 0 : preferences.customOutputActionsComponent;
21
21
  const { message } = useCurrentMessage();
22
- if (message.error)
23
- throw message.error;
24
22
  const { agent } = useCurrentAgent();
25
23
  const outputs = useMemo(() => {
26
24
  var _a;
@@ -36,7 +34,7 @@ export default function SimpleOutput() {
36
34
  const value = output.name === RuntimeOutputVariable.text
37
35
  ? ((_a = message.outputs) === null || _a === void 0 ? void 0 : _a.content) ||
38
36
  ((_d = (_c = (_b = message.outputs) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.find((i) => i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.text])) === null || _d === void 0 ? void 0 : _d[RuntimeOutputVariable.text])
39
- : (_g = (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g[output.name];
37
+ : (_g = (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f.find((i) => i === null || i === void 0 ? void 0 : i[output.name])) === null || _g === void 0 ? void 0 : _g[output.name];
40
38
  return (_jsx(CustomComponentRenderer, { instanceId: output.id, componentId: output.appearance.componentId, properties: output.appearance.componentProperties, props: Object.assign({ output, outputValue: value, writing: output.name === RuntimeOutputVariable.text && message.loading }, (((_h = output === null || output === void 0 ? void 0 : output.appearance) === null || _h === void 0 ? void 0 : _h.componentProps) || {})) }, output.id));
41
- }), CustomComponentActionsComponent && (_jsx(AgentErrorBoundary, { children: _jsx(Suspense, { children: _jsx(CustomComponentActionsComponent, {}) }) }))] }));
39
+ }), message.error && _jsx(AgentErrorView, { error: message.error }), CustomComponentActionsComponent && (_jsx(AgentErrorBoundary, { children: _jsx(Suspense, { children: _jsx(CustomComponentActionsComponent, {}) }) }))] }));
42
40
  }
@@ -145,5 +145,5 @@ export function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, proper
145
145
  export const CodeRenderByMessageMemo = memo(CodeRenderByMessage);
146
146
  export function getCurrentCodeByTaskId(message) {
147
147
  var _a, _b, _c;
148
- return (_c = (_b = (_a = message === null || message === void 0 ? void 0 : message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[codeField];
148
+ return (_c = (_b = (_a = message === null || message === void 0 ? void 0 : message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((i) => i === null || i === void 0 ? void 0 : i[codeField])) === null || _c === void 0 ? void 0 : _c[codeField];
149
149
  }
@@ -330,11 +330,15 @@ export const createSessionState = ({ aid }) => {
330
330
  }
331
331
  catch (error) {
332
332
  set((state) => {
333
- var _a;
333
+ var _a, _b;
334
334
  const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
335
335
  if (!s)
336
336
  return;
337
- s.error = error;
337
+ const msg = message ? (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.id === message.id) : undefined;
338
+ if (msg)
339
+ msg.error = error;
340
+ else
341
+ s.error = error;
338
342
  });
339
343
  }
340
344
  finally {