feat: add web URL content fetcher for chat context
Add ability to fetch and inject web page content into chat as context. Includes SSRF protection (blocks private IPs, localhost), content extraction (strips scripts/styles/nav), and a clean popover UI. Reimplements the concept from PR #1703 without the issues (duplicated ChatBox, dual API routes, SSRF vulnerability, window.prompt UX). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -594,6 +594,20 @@ export const ChatImpl = memo(
|
||||
Cookies.set('selectedProvider', newProvider.name, { expires: 30 });
|
||||
};
|
||||
|
||||
const handleWebSearchResult = useCallback(
|
||||
(result: string) => {
|
||||
const currentInput = input || '';
|
||||
const newInput = currentInput.length > 0 ? `${result}\n\n${currentInput}` : result;
|
||||
|
||||
// Update the input via the same mechanism as handleInputChange
|
||||
const syntheticEvent = {
|
||||
target: { value: newInput },
|
||||
} as React.ChangeEvent<HTMLTextAreaElement>;
|
||||
handleInputChange(syntheticEvent);
|
||||
},
|
||||
[input, handleInputChange],
|
||||
);
|
||||
|
||||
return (
|
||||
<BaseChat
|
||||
ref={animationScope}
|
||||
@@ -664,6 +678,7 @@ export const ChatImpl = memo(
|
||||
selectedElement={selectedElement}
|
||||
setSelectedElement={setSelectedElement}
|
||||
addToolResult={addToolResult}
|
||||
onWebSearchResult={handleWebSearchResult}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user