fix: add goose execution override for h5 chat
This commit is contained in:
@@ -144,7 +144,7 @@ export function ChatPanel({
|
||||
text: string,
|
||||
imageUrls?: string[],
|
||||
previewImageUrls?: string[],
|
||||
options?: { messageId?: string },
|
||||
options?: { messageId?: string; forceGoose?: boolean },
|
||||
) => void | Promise<void>;
|
||||
onUploadImage?: (
|
||||
file: File,
|
||||
@@ -167,6 +167,7 @@ export function ChatPanel({
|
||||
const [pageSource, setPageSource] = useState<Message | null>(null);
|
||||
const [sharePreviewSource, setSharePreviewSource] = useState<Message | null>(null);
|
||||
const [voiceNotice, setVoiceNotice] = useState<string | null>(null);
|
||||
const [forceGoose, setForceGoose] = useState(false);
|
||||
const [pendingImages, setPendingImages] = useState<PendingChatImage[]>([]);
|
||||
const [uploadingImage, setUploadingImage] = useState(false);
|
||||
const [imageError, setImageError] = useState<string | null>(null);
|
||||
@@ -514,7 +515,10 @@ export function ChatPanel({
|
||||
}));
|
||||
const imagesToSend = uploadedUrls.filter(Boolean);
|
||||
const previewImagesToSend = imagesToSend;
|
||||
await onSubmit(trimmed, imagesToSend, previewImagesToSend, { messageId: outgoingMessageId });
|
||||
await onSubmit(trimmed, imagesToSend, previewImagesToSend, {
|
||||
messageId: outgoingMessageId,
|
||||
forceGoose,
|
||||
});
|
||||
uploadedImages.forEach(revokePendingImage);
|
||||
setPendingImages([]);
|
||||
} catch (err) {
|
||||
@@ -530,7 +534,7 @@ export function ChatPanel({
|
||||
}
|
||||
setUploadingImage(false);
|
||||
suppressVoiceUpdateRef.current = false;
|
||||
}, [input, onSubmit, onUploadImage, pendingImages, revokePendingImage, voiceDisabled, voiceRecording]);
|
||||
}, [forceGoose, input, onSubmit, onUploadImage, pendingImages, revokePendingImage, voiceDisabled, voiceRecording]);
|
||||
|
||||
const handleSubmit = useCallback(async () => {
|
||||
await submitText();
|
||||
@@ -822,6 +826,20 @@ export function ChatPanel({
|
||||
onPrefill={setInput}
|
||||
/>
|
||||
)}
|
||||
{!showHomeWelcome && (
|
||||
<label
|
||||
className={`chat-force-goose-toggle${forceGoose ? ' is-active' : ''}`}
|
||||
title="勾选后,本轮消息强制交给 Goose 执行"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={forceGoose}
|
||||
disabled={voiceDisabled}
|
||||
onChange={(event) => setForceGoose(event.target.checked)}
|
||||
/>
|
||||
<span>强制走 Goose</span>
|
||||
</label>
|
||||
)}
|
||||
{chatState === 'streaming' ? (
|
||||
<button type="button" className="danger-btn chat-input-action" onClick={() => void onStop()}>
|
||||
停止
|
||||
|
||||
@@ -541,7 +541,12 @@ export function ChatView({
|
||||
capabilities={capabilities}
|
||||
grantedSkills={grantedSkills}
|
||||
onSubmit={(text, imageUrls, previewImageUrls, options) =>
|
||||
void submit(text, { messageId: options?.messageId }, imageUrls, previewImageUrls)
|
||||
void submit(
|
||||
text,
|
||||
{ messageId: options?.messageId, forceGoose: options?.forceGoose },
|
||||
imageUrls,
|
||||
previewImageUrls,
|
||||
)
|
||||
}
|
||||
onUploadImage={(file, onProgress, options) =>
|
||||
uploadChatImage(file, onProgress, { messageId: options?.messageId })
|
||||
|
||||
@@ -140,8 +140,22 @@ export function SpaceChatPanel({
|
||||
grantedSkills={grantedSkills}
|
||||
onSubmit={(text, imageUrls, previewImageUrls, options) =>
|
||||
chatBridge
|
||||
? void submit(text, { ...context, messageId: options?.messageId }, imageUrls, previewImageUrls)
|
||||
: void submit(text, { mindspaceContext: context, messageId: options?.messageId }, imageUrls, previewImageUrls)
|
||||
? void submit(
|
||||
text,
|
||||
{ ...context, messageId: options?.messageId, forceGoose: options?.forceGoose },
|
||||
imageUrls,
|
||||
previewImageUrls,
|
||||
)
|
||||
: void submit(
|
||||
text,
|
||||
{
|
||||
mindspaceContext: context,
|
||||
messageId: options?.messageId,
|
||||
forceGoose: options?.forceGoose,
|
||||
},
|
||||
imageUrls,
|
||||
previewImageUrls,
|
||||
)
|
||||
}
|
||||
onUploadImage={(file, onProgress, options) =>
|
||||
uploadChatImage(file, onProgress, { messageId: options?.messageId })
|
||||
|
||||
Reference in New Issue
Block a user