Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions pages/content/src/render_prescript/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const DEFAULT_CONFIG: FunctionCallRendererConfig = {
targetSelectors: ['pre', 'code'],
enableDirectMonitoring: true,
streamingContainerSelectors: ['.pre', '.code'],
function_result_selector: [], // Empty by default, will be populated by website-specific configs
// streamingContainerSelectors: ['.message-content', '.chat-message', '.message-body', '.message'],
updateThrottle: 25,
streamingMonitoringInterval: 100,
Expand Down Expand Up @@ -65,83 +64,55 @@ export const WEBSITE_CONFIGS: Array<{
config: {
targetSelectors: ['pre'],
streamingContainerSelectors: ['.pre'],
function_result_selector: ['div.chat-turn-container'],
},
},
{
urlPattern: 'perplexity',
config: {
targetSelectors: ['pre'],
streamingContainerSelectors: ['.pre'],
function_result_selector: ['div.group\\/query', '.group\\/query', 'div[class*="group/query"]'],
},
},
{
urlPattern: 'gemini',
config: {
targetSelectors: ['code-block'],
streamingContainerSelectors: ['.code-block'],
function_result_selector: ['div.query-content'],
},
},
{
urlPattern: 'grok.com',
config: {
targetSelectors: ['code'],
streamingContainerSelectors: ['code'],
function_result_selector: ['div.relative.items-end'],
},
},
{
urlPattern: 'openrouter.ai',
config: {
targetSelectors: ['pre'],
streamingContainerSelectors: ['pre'],
function_result_selector: [
'div.flex.max-w-full.flex-col.relative.overflow-auto.gap-1.items-end',
'div.flex',
'div.flex.items-end'
],
},
},
{
urlPattern: 'chatgpt.com',
config: {
targetSelectors: ['pre'],
streamingContainerSelectors: ['pre'],
function_result_selector: ['div[data-message-author-role="user"]'],
},
},
{
urlPattern: 'chat.openai.com',
config: {
targetSelectors: ['pre'],
streamingContainerSelectors: ['pre'],
function_result_selector: ['div[data-message-author-role="user"]'],
},
},
{
urlPattern: 'kagi.com',
config: {
targetSelectors: ['.codehilite'],
streamingContainerSelectors: ['pre'],
function_result_selector: ['div[data-author="user"]'],
},
},
{
urlPattern: 'chat.deepseek.com',
config: {
targetSelectors: ['pre'],
streamingContainerSelectors: ['pre'],
function_result_selector: ['div._9663006'],
},
},
{
urlPattern: 't3.chat',
config: {
targetSelectors: ['pre'],
streamingContainerSelectors: ['pre'],
function_result_selector: ['div[aria-label="Your message"]'],
},
},
// Add more website-specific configurations as needed
Expand Down
1 change: 0 additions & 1 deletion pages/content/src/render_prescript/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface FunctionCallRendererConfig {
targetSelectors: string[];
enableDirectMonitoring: boolean;
streamingContainerSelectors: string[];
function_result_selector?: string[];
updateThrottle: number;
streamingMonitoringInterval: number;
largeContentThreshold: number;
Expand Down
37 changes: 0 additions & 37 deletions pages/content/src/render_prescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import {
startDirectMonitoring,
stopDirectMonitoring,
initializeObserver,
processFunctionResults,
checkForUnprocessedFunctionResults,
startFunctionResultMonitoring,
stopFunctionResultMonitoring,
initializeFunctionResultObserver,
processUpdateQueue,
checkStreamingUpdates,
checkStalledStreams,
Expand Down Expand Up @@ -48,11 +43,6 @@ const initializeRenderer = () => {

injectStyles();
processFunctionCalls(); // Initial processing of existing blocks

// Process function results if selectors are configured
if (CONFIG.function_result_selector && CONFIG.function_result_selector.length > 0) {
processFunctionResults(); // Initial processing of existing function results
}

// Register the global event listener for function call rendering before starting the observer
// document.addEventListener('render-function-call', (event: Event) => {
Expand All @@ -70,11 +60,6 @@ const initializeRenderer = () => {
// Initialize the mutation observer
initializeObserver(); // Start the main MutationObserver
startDirectMonitoring(); // Start direct monitoring if enabled

// Initialize the function result observer if selectors are configured
if (CONFIG.function_result_selector && CONFIG.function_result_selector.length > 0) {
initializeFunctionResultObserver(); // Start the function result observer
}

// Make sure stalled stream detection is explicitly started
startStalledStreamDetection();
Expand Down Expand Up @@ -120,17 +105,6 @@ const configure = (options: Partial<FunctionCallRendererConfig>) => {
}
if (userOptions.streamingContainerSelectors !== undefined)
CONFIG.streamingContainerSelectors = [...userOptions.streamingContainerSelectors];
if (userOptions.function_result_selector !== undefined) {
const oldLength = CONFIG.function_result_selector?.length || 0;
CONFIG.function_result_selector = [...userOptions.function_result_selector];

// If function_result_selector was empty before and now has items, or vice versa,
// we need to restart monitoring
if ((oldLength === 0 && CONFIG.function_result_selector.length > 0) ||
(oldLength > 0 && CONFIG.function_result_selector.length === 0)) {
monitoringRestart = true;
}
}
if (userOptions.streamingMonitoringInterval !== undefined) {
CONFIG.streamingMonitoringInterval = userOptions.streamingMonitoringInterval;
monitoringRestart = true;
Expand Down Expand Up @@ -162,17 +136,10 @@ const configure = (options: Partial<FunctionCallRendererConfig>) => {
}

if (monitoringRestart) {
// Restart function call monitoring
stopDirectMonitoring();
if (CONFIG.enableDirectMonitoring) {
startDirectMonitoring();
}

// Restart function result monitoring if selectors are configured
stopFunctionResultMonitoring();
if (CONFIG.function_result_selector && CONFIG.function_result_selector.length > 0) {
startFunctionResultMonitoring();
}
}

console.debug('Function call renderer configuration updated:', CONFIG);
Expand Down Expand Up @@ -208,12 +175,8 @@ export {
styles,
processFunctionCalls,
checkForUnprocessedFunctionCalls,
processFunctionResults,
checkForUnprocessedFunctionResults,
startDirectMonitoring,
stopDirectMonitoring,
startFunctionResultMonitoring,
stopFunctionResultMonitoring,
configure as configureFunctionCallRenderer,
initializeRenderer as initialize,
processUpdateQueue as forceStreamingUpdate,
Expand Down
Loading