mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-28 02:23:53 +02:00
docs: update PRD with comprehensive extension features and UX integration strategy
- Added UX strategy: Extension for Quick Actions, Frontend for Management - Organized features into 4 phases (Phase 1 completed) - Added 14 new extension features (FR-EXT-07 to FR-EXT-17): * Smart Monitoring: Price alerts, whale tracking, rug pull detection * Trading Intelligence: Token analysis, entry/exit suggestions, portfolio tracker * Content Creation: Chart screenshots, AI thread generator * Productivity: Quick actions, notifications, keyboard shortcuts - Added Feature Responsibility Matrix showing Extension vs Frontend roles - Added Settings Sync strategy (FR-EXT-06) with deep links to frontend - Documented state sync architecture: Extension ↔ Backend API ↔ Frontend
This commit is contained in:
parent
fd9eddf7fa
commit
a052b01a68
27 changed files with 5163 additions and 88 deletions
|
|
@ -0,0 +1,72 @@
|
|||
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
|
||||
|
||||
/**
|
||||
* Page context types
|
||||
*/
|
||||
export type PageType = "dexscreener" | "coingecko" | "twitter" | "generic";
|
||||
|
||||
export interface TokenData {
|
||||
chain: string;
|
||||
pairAddress: string;
|
||||
tokenSymbol?: string;
|
||||
price?: string;
|
||||
volume24h?: string;
|
||||
liquidity?: string;
|
||||
}
|
||||
|
||||
export interface PageContext {
|
||||
url: string;
|
||||
title: string;
|
||||
pageType: PageType;
|
||||
tokenData?: TokenData;
|
||||
}
|
||||
|
||||
interface PageContextValue {
|
||||
context: PageContext | null;
|
||||
updateContext: (context: PageContext) => void;
|
||||
}
|
||||
|
||||
const PageContextContext = createContext<PageContextValue>({
|
||||
context: null,
|
||||
updateContext: () => { },
|
||||
});
|
||||
|
||||
export function usePageContext() {
|
||||
return useContext(PageContextContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for page context detection
|
||||
* Listens to messages from content scripts
|
||||
*/
|
||||
export function PageContextProvider({ children }: { children: ReactNode }) {
|
||||
const [context, setContext] = useState<PageContext | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Listen for page context updates from content script
|
||||
const handleMessage = (message: any) => {
|
||||
if (message.type === "PAGE_CONTEXT_UPDATE") {
|
||||
setContext(message.data);
|
||||
}
|
||||
};
|
||||
|
||||
chrome.runtime.onMessage.addListener(handleMessage);
|
||||
|
||||
// Request initial context
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
||||
if (tabs[0]?.id) {
|
||||
chrome.tabs.sendMessage(tabs[0].id, { type: "GET_PAGE_CONTEXT" });
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
chrome.runtime.onMessage.removeListener(handleMessage);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PageContextContext.Provider value={{ context, updateContext: setContext }}>
|
||||
{children}
|
||||
</PageContextContext.Provider>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue