Add browser use as MCP to providers (#889)

This commit is contained in:
Simos Mikelatos
2026-06-17 22:06:17 +02:00
committed by GitHub
parent c03ddb25fe
commit e88539170e
39 changed files with 5480 additions and 117 deletions

View File

@@ -1,15 +1,17 @@
import React, { useEffect } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import ChatInterface from '../../chat/view/ChatInterface';
import FileTree from '../../file-tree/view/FileTree';
import StandaloneShell from '../../standalone-shell/view/StandaloneShell';
import GitPanel from '../../git-panel/view/GitPanel';
import PluginTabContent from '../../plugins/view/PluginTabContent';
import { BrowserUsePanel } from '../../browser-use';
import type { MainContentProps } from '../types/types';
import { useTaskMaster } from '../../../contexts/TaskMasterContext';
import { usePaletteOpsRegister } from '../../../contexts/PaletteOpsContext';
import { useTasksSettings } from '../../../contexts/TasksSettingsContext';
import { useUiPreferences } from '../../../hooks/useUiPreferences';
import { authenticatedFetch } from '../../../utils/api';
import { useEditorSidebar } from '../../code-editor/hooks/useEditorSidebar';
import EditorSidebar from '../../code-editor/view/EditorSidebar';
import type { Project } from '../../../types/app';
@@ -55,8 +57,10 @@ function MainContent({
const { currentProject, setCurrentProject } = useTaskMaster() as TaskMasterContextValue;
const { tasksEnabled, isTaskMasterInstalled } = useTasksSettings() as TasksSettingsContextValue;
const [browserUseEnabled, setBrowserUseEnabled] = useState(false);
const shouldShowTasksTab = Boolean(tasksEnabled && isTaskMasterInstalled);
const shouldShowBrowserTab = browserUseEnabled;
const {
editingFile,
@@ -90,6 +94,28 @@ function MainContent({
}
}, [shouldShowTasksTab, activeTab, setActiveTab]);
const loadBrowserUseSettings = useCallback(async () => {
try {
const response = await authenticatedFetch('/api/browser-use/settings');
const data = await response.json();
setBrowserUseEnabled(Boolean(response.ok && data?.success !== false && data?.data?.settings?.enabled));
} catch {
setBrowserUseEnabled(false);
}
}, []);
useEffect(() => {
void loadBrowserUseSettings();
window.addEventListener('browserUseSettingsChanged', loadBrowserUseSettings);
return () => window.removeEventListener('browserUseSettingsChanged', loadBrowserUseSettings);
}, [loadBrowserUseSettings]);
useEffect(() => {
if (!shouldShowBrowserTab && activeTab === 'browser') {
setActiveTab('chat');
}
}, [shouldShowBrowserTab, activeTab, setActiveTab]);
usePaletteOpsRegister({
openFile: (filePath: string) => {
setActiveTab('files');
@@ -113,6 +139,7 @@ function MainContent({
selectedProject={selectedProject}
selectedSession={selectedSession}
shouldShowTasksTab={shouldShowTasksTab}
shouldShowBrowserTab={shouldShowBrowserTab}
isMobile={isMobile}
onMenuClick={onMenuClick}
/>
@@ -171,7 +198,11 @@ function MainContent({
{shouldShowTasksTab && <TaskMasterPanel isVisible={activeTab === 'tasks'} />}
<div className={`h-full overflow-hidden ${activeTab === 'preview' ? 'block' : 'hidden'}`} />
{shouldShowBrowserTab && activeTab === 'browser' && (
<div className="h-full overflow-hidden">
<BrowserUsePanel isVisible={activeTab === 'browser'} onShowSettings={onShowSettings} />
</div>
)}
{activeTab.startsWith('plugin:') && (
<div className="h-full overflow-hidden">