mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix: fix auto add group member crash (#11387)
🐛 fix: fix auto add group member
This commit is contained in:
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { useUserStore } from '@/store/user';
|
||||
|
||||
import { useConversationStore } from '../../../../../store';
|
||||
import { useGroupMessage } from '../../../components/GroupContext';
|
||||
import { useMessageAggregationContext } from '../../../../Contexts/MessageAggregationContext';
|
||||
import { type ApprovalMode } from './index';
|
||||
|
||||
interface ApprovalActionsProps {
|
||||
@@ -34,7 +34,7 @@ const ApprovalActions = memo<ApprovalActionsProps>(
|
||||
// Disable actions while message is still being created (temp ID)
|
||||
const isMessageCreating = messageId.startsWith('tmp_');
|
||||
|
||||
const { assistantGroupId } = useGroupMessage();
|
||||
const { assistantGroupId } = useMessageAggregationContext();
|
||||
const [approveToolCall, rejectToolCall, rejectAndContinueToolCall] = useConversationStore(
|
||||
(s) => [s.approveToolCall, s.rejectToolCall, s.rejectAndContinueToolCall],
|
||||
);
|
||||
|
||||
@@ -12,6 +12,7 @@ import { toolSelectors } from '@/store/tool/selectors';
|
||||
import { getBuiltinRender } from '@/tools/renders';
|
||||
import { getBuiltinStreaming } from '@/tools/streamings';
|
||||
|
||||
import { ToolErrorBoundary } from '../../Tool/ErrorBoundary';
|
||||
import Actions from './Actions';
|
||||
import Inspectors from './Inspector';
|
||||
|
||||
@@ -145,21 +146,23 @@ const Tool = memo<GroupToolProps>(
|
||||
type={type}
|
||||
/>
|
||||
)}
|
||||
<Render
|
||||
apiName={apiName}
|
||||
arguments={requestArgs}
|
||||
identifier={identifier}
|
||||
intervention={intervention}
|
||||
isArgumentsStreaming={isArgumentsStreaming}
|
||||
isToolCalling={isToolCalling}
|
||||
messageId={assistantMessageId}
|
||||
result={result}
|
||||
setShowPluginRender={setShowPluginRender}
|
||||
showPluginRender={showPluginRender}
|
||||
toolCallId={id}
|
||||
toolMessageId={toolMessageId}
|
||||
type={type}
|
||||
/>
|
||||
<ToolErrorBoundary apiName={apiName} identifier={identifier}>
|
||||
<Render
|
||||
apiName={apiName}
|
||||
arguments={requestArgs}
|
||||
identifier={identifier}
|
||||
intervention={intervention}
|
||||
isArgumentsStreaming={isArgumentsStreaming}
|
||||
isToolCalling={isToolCalling}
|
||||
messageId={assistantMessageId}
|
||||
result={result}
|
||||
setShowPluginRender={setShowPluginRender}
|
||||
showPluginRender={showPluginRender}
|
||||
toolCallId={id}
|
||||
toolMessageId={toolMessageId}
|
||||
type={type}
|
||||
/>
|
||||
</ToolErrorBoundary>
|
||||
<Divider dashed style={{ marginBottom: 0, marginTop: 8 }} />
|
||||
</Flexbox>
|
||||
</AccordionItem>
|
||||
|
||||
@@ -6,8 +6,8 @@ import { memo, useMemo } from 'react';
|
||||
import { type AssistantContentBlock } from '@/types/index';
|
||||
|
||||
import { messageStateSelectors, useConversationStore } from '../../../store';
|
||||
import { MessageAggregationContext } from '../../Contexts/MessageAggregationContext';
|
||||
import { CollapsedMessage } from './CollapsedMessage';
|
||||
import { GroupMessageContext } from './GroupContext';
|
||||
import GroupItem from './GroupItem';
|
||||
|
||||
const styles = createStaticStyles(({ css }) => {
|
||||
@@ -44,7 +44,7 @@ const Group = memo<GroupChildrenProps>(
|
||||
);
|
||||
}
|
||||
return (
|
||||
<GroupMessageContext value={contextValue}>
|
||||
<MessageAggregationContext value={contextValue}>
|
||||
<Flexbox className={styles.container} gap={8}>
|
||||
{blocks.map((item) => {
|
||||
return (
|
||||
@@ -59,7 +59,7 @@ const Group = memo<GroupChildrenProps>(
|
||||
);
|
||||
})}
|
||||
</Flexbox>
|
||||
</GroupMessageContext>
|
||||
</MessageAggregationContext>
|
||||
);
|
||||
},
|
||||
isEqual,
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
interface GroupMessageContextValue {
|
||||
assistantGroupId: string;
|
||||
}
|
||||
|
||||
export const GroupMessageContext = createContext<GroupMessageContextValue | null>(null);
|
||||
|
||||
export const useGroupMessage = () => {
|
||||
const context = useContext(GroupMessageContext);
|
||||
if (!context) {
|
||||
throw new Error('useGroupMessage must be used within GroupMessageContext');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
interface GroupMessageContextValue {
|
||||
assistantGroupId: string;
|
||||
}
|
||||
|
||||
export const MessageAggregationContext = createContext<GroupMessageContextValue | null>(null);
|
||||
|
||||
export const useMessageAggregationContext = () => {
|
||||
const context = useContext(MessageAggregationContext);
|
||||
if (!context) {
|
||||
throw new Error('useMessageAggregationContext must be used within MessageAggregationContext');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -6,9 +6,9 @@ import { memo, useMemo } from 'react';
|
||||
import { type AssistantContentBlock } from '@/types/index';
|
||||
|
||||
import { messageStateSelectors, useConversationStore } from '../../../store';
|
||||
import { MessageAggregationContext } from '../../Contexts/MessageAggregationContext';
|
||||
import { CollapsedMessage } from './CollapsedMessage';
|
||||
import ContentBlock from './ContentBlock';
|
||||
import { GroupMessageContext } from './GroupContext';
|
||||
|
||||
const styles = createStaticStyles(({ css }) => {
|
||||
return {
|
||||
@@ -43,13 +43,13 @@ const Group = memo<GroupChildrenProps>(({ blocks, id, content }) => {
|
||||
);
|
||||
}
|
||||
return (
|
||||
<GroupMessageContext value={contextValue}>
|
||||
<MessageAggregationContext value={contextValue}>
|
||||
<Flexbox className={styles.container} gap={8}>
|
||||
{blocks.map((item) => {
|
||||
return <ContentBlock {...item} key={id + '.' + item.id} />;
|
||||
})}
|
||||
</Flexbox>
|
||||
</GroupMessageContext>
|
||||
</MessageAggregationContext>
|
||||
);
|
||||
}, isEqual);
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
interface GroupMessageContextValue {
|
||||
assistantGroupId: string;
|
||||
}
|
||||
|
||||
export const GroupMessageContext = createContext<GroupMessageContextValue | null>(null);
|
||||
|
||||
export const useGroupMessage = () => {
|
||||
const context = useContext(GroupMessageContext);
|
||||
if (!context) {
|
||||
throw new Error('useGroupMessage must be used within GroupMessageContext');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
Reference in New Issue
Block a user