mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-28 10:26:33 +02:00
feat(detection): implement multi-page token detection system
- Add extractTwitterTokens() to detect $TOKEN mentions (e.g., $BONK, $SOL) - Add extractContractAddresses() for Solana (base58) and Ethereum (0x) addresses - Add extractTradingPairs() to detect TOKEN/SOL, TOKEN/USDT patterns - Update extractPageContext() to use new detection functions - Add detectedTokens field to PageContext interface - Create DetectedTokensList component to display detected tokens - Integrate DetectedTokensList into ChatInterface - Add handleDetectedTokenClick to analyze selected tokens - Support auto-detection on Twitter, generic pages, and DexScreener Implements Task 2: Multi-Page Token Detection Part of hybrid token detection system (manual search + auto-detect)
This commit is contained in:
parent
cb879fca37
commit
e89824db0f
4 changed files with 251 additions and 0 deletions
|
|
@ -21,7 +21,9 @@ import {
|
|||
import { SafetyScoreDisplay } from "../crypto/SafetyScoreDisplay";
|
||||
import { WatchlistPanel } from "../crypto/WatchlistPanel";
|
||||
import { AlertConfigModal } from "../crypto/AlertConfigModal";
|
||||
import { DetectedTokensList } from "../components/DetectedTokensList";
|
||||
import type { WatchlistItem } from "../widgets";
|
||||
import type { TokenData } from "../context/PageContextProvider";
|
||||
|
||||
type ViewMode = "chat" | "watchlist" | "safety";
|
||||
|
||||
|
|
@ -471,6 +473,14 @@ What would you like to know?`;
|
|||
}, 500);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle detected token click
|
||||
*/
|
||||
const handleDetectedTokenClick = (token: TokenData) => {
|
||||
const query = token.tokenSymbol || token.pairAddress;
|
||||
handleTokenSearch(query);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-full">
|
||||
{/* Header with space selector and settings */}
|
||||
|
|
@ -495,6 +505,14 @@ What would you like to know?`;
|
|||
/>
|
||||
)}
|
||||
|
||||
{/* Detected tokens list (on Twitter and other pages) */}
|
||||
{context?.detectedTokens && context.detectedTokens.length > 0 && viewMode === "chat" && (
|
||||
<DetectedTokensList
|
||||
tokens={context.detectedTokens}
|
||||
onTokenClick={handleDetectedTokenClick}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Main content area */}
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
{viewMode === "chat" && (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue