-
Notifications
You must be signed in to change notification settings - Fork 91
fix(frontend): fix history chat cannot continue issue #1022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -452,6 +452,16 @@ export function useChatStreamHandlers({ | |||||||||||||||||
| const message = overrideMessage?.trim() || taskInputMessage.trim() | ||||||||||||||||||
| if (!message && !shouldHideChatInput) return | ||||||||||||||||||
|
|
||||||||||||||||||
| // Check if team is selected before sending | ||||||||||||||||||
| if (!selectedTeam?.id) { | ||||||||||||||||||
| toast({ | ||||||||||||||||||
| variant: 'destructive', | ||||||||||||||||||
| title: t('chat:errors.team_not_selected') || '请选择智能体', | ||||||||||||||||||
| description: t('chat:errors.team_not_selected_description') || '请从列表中选择一个智能体后开始对话', | ||||||||||||||||||
|
Comment on lines
+459
to
+460
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: fd -t f "useChatStreamHandlers.tsx"Repository: wecode-ai/Wegent Length of output: 129 🏁 Script executed: head -n 850 frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | tail -n +450 | head -n 50Repository: wecode-ai/Wegent Length of output: 1595 🏁 Script executed: grep -n "handleSendMessage" frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | head -20Repository: wecode-ai/Wegent Length of output: 728 🏁 Script executed: # Get the full context around lines 459-460 and dependency array
sed -n '450,470p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsxRepository: wecode-ai/Wegent Length of output: 736 🏁 Script executed: # Look for the useCallback/useMemo hook that defines handleSendMessage and its dependencies
ast-grep --pattern 'const handleSendMessage = useCallback($$$, [$$$])'Repository: wecode-ai/Wegent Length of output: 40050 🏁 Script executed: head -n 100 frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | grep -E "import|useTranslation|useUnifiedMessages"Repository: wecode-ai/Wegent Length of output: 1284 🏁 Script executed: # Search for all toast calls in the file to see if this is a pattern
grep -n "toast({" frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | head -20Repository: wecode-ai/Wegent Length of output: 325 🏁 Script executed: # Check if useUnifiedMessages is used elsewhere in this file
grep -n "useUnifiedMessages\|messages" frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | head -20Repository: wecode-ai/Wegent Length of output: 685 🏁 Script executed: # Get the full import statement for useTranslation
sed -n '1,50p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | grep -A 5 "useTranslation"Repository: wecode-ai/Wegent Length of output: 422 🏁 Script executed: # Check how t is used - find the destructuring or usage
grep -n "const.*=.*useTranslation\|const.*t.*=" frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | head -5Repository: wecode-ai/Wegent Length of output: 248 🏁 Script executed: # Search for where t is actually initialized in the hook
sed -n '100,200p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsxRepository: wecode-ai/Wegent Length of output: 3029 🏁 Script executed: # Verify if there are other useCallback hooks with t() usage in the file
grep -B 10 "t('chat:" frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | grep -E "useCallback|t\(" | head -20Repository: wecode-ai/Wegent Length of output: 610 🏁 Script executed: # Check the specific lines 764-804 to see the full dependency array
sed -n '764,804p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsxRepository: wecode-ai/Wegent Length of output: 977 🏁 Script executed: # Check if there are ESLint overrides or if react-hooks/exhaustive-deps would catch this
grep -r "exhaustive-deps\|eslint-disable" frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsxRepository: wecode-ai/Wegent Length of output: 42 🏁 Script executed: # Check other useCallback hooks to see if they also have the same issue with t
grep -B 5 -A 50 "const handleRetry = useCallback" frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | grep -E "useCallback|t\(|^\s*\[" | head -30Repository: wecode-ai/Wegent Length of output: 299 🏁 Script executed: # Check for eslint config and react-hooks/exhaustive-deps settings
fd -t f ".eslintrc*|eslint.config.*" frontend/Repository: wecode-ai/Wegent Length of output: 86 🏁 Script executed: # Let's see if there's a package.json with eslint setup
head -n 100 package.json | grep -A 10 "eslint"Repository: wecode-ai/Wegent Length of output: 131 🏁 Script executed: cat frontend/eslint.config.mjsRepository: wecode-ai/Wegent Length of output: 1016 🏁 Script executed: # Look for handleSendMessageWithModel too, which was mentioned in the "Also applies to" comment
grep -B 5 -A 50 "const handleSendMessageWithModel = useCallback" frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | head -80Repository: wecode-ai/Wegent Length of output: 2008 🏁 Script executed: # Find the complete handleSendMessageWithModel dependency array
sed -n '814,1050p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | grep -n -A 50 "^\s*\[" | head -60Repository: wecode-ai/Wegent Length of output: 2110 🏁 Script executed: # Get the complete handleSendMessageWithModel dependency array more precisely
sed -n '1000,1050p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsxRepository: wecode-ai/Wegent Length of output: 1189 🏁 Script executed: # Find createRetryButton useCallback and its dependency array
grep -n "createRetryButton" frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsxRepository: wecode-ai/Wegent Length of output: 205 🏁 Script executed: # Get the context around createRetryButton
sed -n '390,430p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsxRepository: wecode-ai/Wegent Length of output: 1510 🏁 Script executed: # Double-check handleSendMessage uses t() at other places too
sed -n '450,763p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsx | grep -n "t('chat:" | head -10Repository: wecode-ai/Wegent Length of output: 224 🏁 Script executed: # Verify the full context - where does handleSendMessage end and what's at 764-804
sed -n '800,810p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsxRepository: wecode-ai/Wegent Length of output: 498 🏁 Script executed: # Confirm the exact line where handleSendMessage dependency array starts and ends
sed -n '760,806p' frontend/src/features/tasks/components/chat/useChatStreamHandlers.tsxRepository: wecode-ai/Wegent Length of output: 1029 Add The callback uses Proposed fix effectiveDeviceId,
effectiveRequiresWorkspace,
additionalSkills,
+ t,
generateParams,
]📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| }) | ||||||||||||||||||
| return | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+455
to
+463
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apply the team guard to model-override sends too.
Proposed fix const message = overrideMessage.trim()
if (!message && !shouldHideChatInput) return
+ if (!selectedTeam?.id) {
+ toast({
+ variant: 'destructive',
+ title: t('chat:errors.team_not_selected') || '请选择智能体',
+ description:
+ t('chat:errors.team_not_selected_description') ||
+ '请从列表中选择一个智能体后开始对话',
+ })
+ return
+ }
+
if (!isAttachmentReadyToSend) {
toast({
variant: 'destructive',
title: t('chat:upload.wait_for_upload'),
@@
- team_id: selectedTeam?.id ?? 0,
+ team_id: selectedTeam.id,Also applies to: 938-942 🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| if (!isAttachmentReadyToSend) { | ||||||||||||||||||
| toast({ | ||||||||||||||||||
| variant: 'destructive', | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
selectedTask.team_idbefore task detail resolves.The fallback is computed, but Case 1 still requires
selectedTaskDetail?.id, so a history click can leaveselectedTeamunset/old until detail loading finishes. Sync fromselectedTaskwhen it matches the URL task ID.Proposed fix
const detailTeamId = selectedTaskDetail?.team ? typeof selectedTaskDetail.team === 'number' ? selectedTaskDetail.team : (selectedTaskDetail.team as Team).id - : selectedTask?.team_id || null + : null + + const selectedTaskMatchesUrl = + taskIdFromUrl && selectedTask?.id.toString() === taskIdFromUrl + + if (selectedTaskMatchesUrl && selectedTask.team_id) { + const teamFromTask = filteredTeams.find(t => t.id === selectedTask.team_id) + if ( + teamFromTask && + (lastSyncedTaskIdRef.current !== selectedTask.id || + selectedTeam?.id !== selectedTask.team_id) + ) { + handleTeamChange(teamFromTask) + lastSyncedTaskIdRef.current = selectedTask.id + hasInitializedTeamRef.current = true + return + } + } // Case 1: Sync from task detail (HIGHEST PRIORITY)Also applies to: 316-327, 392-400
🤖 Prompt for AI Agents