feat: share built-in browser across runtimes
The built-in browser was limited to direct-model tools, and its Agent switch also blocked manual Browser workbar actions. It is now a request-scoped GoodBuddy capability assignable to direct models, managed OpenCode, and Continue, while manual browser controls remain available when Agent access is off. Existing browser enablement migrates to capability settings version 6. DeepSeek Harness remains unsupported. Release note: 内置浏览器现在可分配给直连模型、OpenCode 和 Continue;关闭 Agent 浏览器能力不会影响用户在浏览器工作栏中的手动操作。
This commit is contained in:
@@ -376,9 +376,6 @@ export function McpSettingsSection({
|
||||
}
|
||||
|
||||
const computerCapabilities = snapshot?.computerCapabilities ?? []
|
||||
const browserCapability = computerCapabilities.find(
|
||||
(capability) => capability.id === 'host-browser-control'
|
||||
)
|
||||
const desktopCapabilities = computerCapabilities.filter(
|
||||
(capability) => capability.id !== 'host-browser-control'
|
||||
)
|
||||
@@ -588,13 +585,21 @@ export function McpSettingsSection({
|
||||
const panelId = `mcp-server-tools-${server.id}`
|
||||
const state = builtinMcpStates.get(server.id) ?? {
|
||||
id: server.id,
|
||||
enabled: true,
|
||||
enabled: server.id !== 'builtin-browser',
|
||||
assignments:
|
||||
[...server.supportedAssignments] as CapabilityAssignments
|
||||
}
|
||||
const computerCapability =
|
||||
'computerCapabilityId' in server
|
||||
? computerCapabilities.find(
|
||||
(capability) =>
|
||||
capability.id === server.computerCapabilityId
|
||||
)
|
||||
: undefined
|
||||
const featureAvailable =
|
||||
!('requiresFeature' in server) ||
|
||||
magicNotesEnabled === true
|
||||
(!('requiresFeature' in server) ||
|
||||
magicNotesEnabled === true) &&
|
||||
(!computerCapability || computerCapability.supported)
|
||||
return (
|
||||
<article
|
||||
className={`capability-card builtin-mcp-card${
|
||||
@@ -610,11 +615,14 @@ export function McpSettingsSection({
|
||||
<small>
|
||||
{!state.enabled
|
||||
? t('mcp.builtin.disabled')
|
||||
: computerCapability &&
|
||||
!computerCapability.supported
|
||||
? t('mcp.browser.unsupported')
|
||||
: !featureAvailable
|
||||
? t('mcp.builtin.serverSummaryDisabled')
|
||||
: server.access === 'mixed'
|
||||
? t('mcp.builtin.serverSummaryMixed')
|
||||
: t('mcp.builtin.serverSummaryReadOnly')}
|
||||
? t('mcp.builtin.serverSummaryDisabled')
|
||||
: server.access === 'mixed'
|
||||
? t('mcp.builtin.serverSummaryMixed')
|
||||
: t('mcp.builtin.serverSummaryReadOnly')}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
@@ -624,7 +632,7 @@ export function McpSettingsSection({
|
||||
name: server.name
|
||||
})}
|
||||
checked={state.enabled}
|
||||
disabled={Boolean(busy)}
|
||||
disabled={Boolean(busy) || !featureAvailable}
|
||||
onChange={(event) =>
|
||||
void run(`builtin:toggle:${server.id}`, () =>
|
||||
window.goodbuddy.capabilities.setBuiltinMcpServerEnabled(
|
||||
@@ -646,9 +654,64 @@ export function McpSettingsSection({
|
||||
{!featureAvailable && (
|
||||
<p className="computer-capability-risk">
|
||||
<CircleAlert aria-hidden="true" size={13} />
|
||||
{t('mcp.builtin.featureDisabled')}
|
||||
{computerCapability
|
||||
? t('mcp.browser.unsupported')
|
||||
: t('mcp.builtin.featureDisabled')}
|
||||
</p>
|
||||
)}
|
||||
{computerCapability && (
|
||||
<>
|
||||
<p className="computer-capability-risk">
|
||||
<CircleAlert aria-hidden="true" size={13} />
|
||||
{computerCapability.riskSummary}
|
||||
</p>
|
||||
<div className="capability-diagnostic">
|
||||
<button
|
||||
aria-label={t('mcp.browser.diagnoseAriaLabel')}
|
||||
className="secondary-button"
|
||||
disabled={Boolean(busy)}
|
||||
onClick={() =>
|
||||
void diagnose(computerCapability.id)
|
||||
}
|
||||
type="button"
|
||||
>
|
||||
<RefreshCw size={13} />
|
||||
{busy ===
|
||||
`diagnose:${computerCapability.id}`
|
||||
? t('mcp.computer.diagnosing')
|
||||
: t('mcp.computer.diagnose')}
|
||||
</button>
|
||||
{diagnostics[computerCapability.id] && (
|
||||
<div
|
||||
aria-live="polite"
|
||||
className="capability-diagnostic__result"
|
||||
>
|
||||
<strong>
|
||||
{t('mcp.computer.result', {
|
||||
status:
|
||||
diagnosticStatusLabels[
|
||||
diagnostics[computerCapability.id]!
|
||||
.status
|
||||
]
|
||||
})}
|
||||
</strong>
|
||||
{diagnostics[
|
||||
computerCapability.id
|
||||
]!.checks.map((check) => (
|
||||
<p key={check.id}>
|
||||
{check.summary}
|
||||
{check.remedy
|
||||
? t('mcp.computer.remedy', {
|
||||
remedy: check.remedy
|
||||
})
|
||||
: ''}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="runtime-assignments">
|
||||
<small>{t('mcp.builtin.assignedTo')}</small>
|
||||
{configurableMcpTargets.map((target) => {
|
||||
@@ -932,18 +995,8 @@ export function McpSettingsSection({
|
||||
const expansionId = `model-tools:${group.id}`
|
||||
const expanded = expandedItemIds.has(expansionId)
|
||||
const panelId = `model-tool-group-${group.id}`
|
||||
const groupName =
|
||||
group.id === 'browser'
|
||||
? t('mcp.browser.title')
|
||||
: group.name
|
||||
const groupDescription =
|
||||
group.id === 'browser'
|
||||
? t('mcp.browser.description')
|
||||
: group.description
|
||||
const report =
|
||||
group.id === 'browser' && browserCapability
|
||||
? diagnostics[browserCapability.id]
|
||||
: undefined
|
||||
const groupName = group.name
|
||||
const groupDescription = group.description
|
||||
return (
|
||||
<article className="mcp-server-card" key={group.id}>
|
||||
<button
|
||||
@@ -962,9 +1015,7 @@ export function McpSettingsSection({
|
||||
<div>
|
||||
<strong>{groupName}</strong>
|
||||
<small>
|
||||
{group.id === 'browser'
|
||||
? t('mcp.browser.subtitle')
|
||||
: t('mcp.modelTools.summary')}
|
||||
{t('mcp.modelTools.summary')}
|
||||
</small>
|
||||
</div>
|
||||
<span className="mcp-server-card__summary">
|
||||
@@ -984,105 +1035,11 @@ export function McpSettingsSection({
|
||||
</button>
|
||||
{expanded && (
|
||||
<div className="mcp-server-card__body" id={panelId}>
|
||||
{group.id === 'browser' && browserCapability ? (
|
||||
<>
|
||||
<label className="toggle-row">
|
||||
<input
|
||||
aria-label={t(
|
||||
'mcp.browser.enableAriaLabel'
|
||||
)}
|
||||
checked={browserCapability.enabled}
|
||||
disabled={
|
||||
Boolean(busy) ||
|
||||
!browserCapability.supported
|
||||
}
|
||||
onChange={(event) =>
|
||||
void run(
|
||||
`browser:${browserCapability.id}`,
|
||||
() =>
|
||||
window.goodbuddy.capabilities.setComputerCapabilityEnabled?.(
|
||||
browserCapability.id,
|
||||
event.target.checked
|
||||
) ??
|
||||
Promise.reject(
|
||||
new Error(
|
||||
t(
|
||||
'mcp.errors.unsupportedBuiltinBrowser'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
role="switch"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>
|
||||
{browserCapability.enabled
|
||||
? t('mcp.browser.enabled')
|
||||
: t('mcp.browser.disabled')}
|
||||
</span>
|
||||
</label>
|
||||
<p>{groupDescription}</p>
|
||||
<p className="computer-capability-risk">
|
||||
<CircleAlert aria-hidden="true" size={13} />
|
||||
{t('mcp.browser.control')}
|
||||
</p>
|
||||
<div className="capability-diagnostic">
|
||||
<button
|
||||
aria-label={t(
|
||||
'mcp.browser.diagnoseAriaLabel'
|
||||
)}
|
||||
className="secondary-button"
|
||||
disabled={Boolean(busy)}
|
||||
onClick={() =>
|
||||
void diagnose(browserCapability.id)
|
||||
}
|
||||
type="button"
|
||||
>
|
||||
<RefreshCw size={13} />
|
||||
{busy ===
|
||||
`diagnose:${browserCapability.id}`
|
||||
? t('mcp.computer.diagnosing')
|
||||
: t('mcp.computer.diagnose')}
|
||||
</button>
|
||||
{report && (
|
||||
<div
|
||||
aria-live="polite"
|
||||
className="capability-diagnostic__result"
|
||||
>
|
||||
<strong>
|
||||
{t('mcp.computer.result', {
|
||||
status:
|
||||
diagnosticStatusLabels[
|
||||
report.status
|
||||
]
|
||||
})}
|
||||
</strong>
|
||||
{report.checks.map((check) => (
|
||||
<p key={check.id}>
|
||||
{check.summary}
|
||||
{check.remedy
|
||||
? t('mcp.computer.remedy', {
|
||||
remedy: check.remedy
|
||||
})
|
||||
: ''}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<p>{groupDescription}</p>
|
||||
)}
|
||||
<p>{groupDescription}</p>
|
||||
<section
|
||||
aria-label={
|
||||
group.id === 'browser'
|
||||
? t('mcp.browser.toolsAriaLabel')
|
||||
: t('mcp.builtin.toolsAriaLabel', {
|
||||
name: groupName
|
||||
})
|
||||
}
|
||||
aria-label={t('mcp.builtin.toolsAriaLabel', {
|
||||
name: groupName
|
||||
})}
|
||||
className="mcp-server-tools"
|
||||
>
|
||||
<div className="mcp-server-tools__heading">
|
||||
|
||||
@@ -282,6 +282,15 @@ const capabilitySnapshot = {
|
||||
| 'opencode'
|
||||
| 'continue'
|
||||
)[]
|
||||
},
|
||||
{
|
||||
id: 'builtin-browser' as const,
|
||||
enabled: false,
|
||||
assignments: ['model', 'opencode', 'continue'] as (
|
||||
| 'model'
|
||||
| 'opencode'
|
||||
| 'continue'
|
||||
)[]
|
||||
}
|
||||
],
|
||||
mcpServers: [] as CapabilitySnapshot['mcpServers'],
|
||||
@@ -299,7 +308,8 @@ const capabilitySnapshot = {
|
||||
enabled: false,
|
||||
supported: true,
|
||||
browserProfileId: null,
|
||||
riskSummary: '可读取网页内容并代表用户操作网站。'
|
||||
riskSummary:
|
||||
'总开关关闭时不会向任何 Runtime 提供浏览器工具;开启后,已分配的 Runtime 可在 Execute 模式直接读取网页并操作网站,不再逐次询问。'
|
||||
},
|
||||
{
|
||||
id: 'linux-desktop-control' as const,
|
||||
@@ -4994,6 +5004,63 @@ describe('SettingsPanel runtime files', () => {
|
||||
false
|
||||
)
|
||||
)
|
||||
const browserBuiltinCard = screen
|
||||
.getByRole('switch', {
|
||||
name: '启用 内置浏览器 内置 MCP'
|
||||
})
|
||||
.closest('article')
|
||||
expect(browserBuiltinCard).not.toBeNull()
|
||||
expect(
|
||||
within(browserBuiltinCard!).getByLabelText(
|
||||
/内置浏览器 无法分配给 DeepSeek Harness/
|
||||
)
|
||||
).toBeDisabled()
|
||||
fireEvent.click(
|
||||
within(browserBuiltinCard!).getByLabelText('Continue')
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(setBuiltinMcpServerAssignments).toHaveBeenCalledWith(
|
||||
'builtin-browser',
|
||||
['model', 'opencode']
|
||||
)
|
||||
)
|
||||
fireEvent.click(
|
||||
screen.getByRole('switch', {
|
||||
name: '启用 内置浏览器 内置 MCP'
|
||||
})
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(setBuiltinMcpServerEnabled).toHaveBeenCalledWith(
|
||||
'builtin-browser',
|
||||
true
|
||||
)
|
||||
)
|
||||
const builtinBrowserToggle = screen.getByRole('button', {
|
||||
name: '展开服务器 内置浏览器'
|
||||
})
|
||||
fireEvent.click(builtinBrowserToggle)
|
||||
expect(builtinBrowserToggle).toHaveAttribute(
|
||||
'aria-expanded',
|
||||
'true'
|
||||
)
|
||||
expect(
|
||||
screen.getByText(/不会控制客户端已安装的浏览器/)
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByText(/关闭时不会向任何 Runtime 提供浏览器工具/)
|
||||
).toHaveTextContent('不再逐次询问')
|
||||
expect(
|
||||
screen.getByRole('region', { name: '内置浏览器 工具' })
|
||||
).toContainElement(screen.getByText('browser_navigate'))
|
||||
fireEvent.click(
|
||||
screen.getByRole('button', { name: '诊断内置浏览器' })
|
||||
)
|
||||
expect(
|
||||
await screen.findByText('诊断结果:部分可用')
|
||||
).toBeInTheDocument()
|
||||
expect(diagnoseComputerCapability).toHaveBeenCalledWith(
|
||||
'host-browser-control'
|
||||
)
|
||||
fireEvent.click(
|
||||
within(mcpTabs).getByRole('tab', { name: '电脑控制' })
|
||||
)
|
||||
@@ -5003,7 +5070,7 @@ describe('SettingsPanel runtime files', () => {
|
||||
).not.toBeInTheDocument()
|
||||
expect(
|
||||
screen.queryByRole('switch', {
|
||||
name: '启用直连模型内置浏览器'
|
||||
name: '启用 内置浏览器 内置 MCP'
|
||||
})
|
||||
).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('托管浏览器配置')).not.toBeInTheDocument()
|
||||
@@ -5026,7 +5093,7 @@ describe('SettingsPanel runtime files', () => {
|
||||
within(mcpTabs).getByRole('tab', { name: '直连模型' })
|
||||
)
|
||||
expect(await screen.findByText('文件系统操作')).toBeInTheDocument()
|
||||
expect(screen.getByText('内置浏览器')).toBeInTheDocument()
|
||||
expect(screen.queryByText('内置浏览器')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('联网搜索')).toBeInTheDocument()
|
||||
expect(screen.getByText('编程能力')).toBeInTheDocument()
|
||||
const programmingToggle = screen.getByRole('button', {
|
||||
@@ -5039,42 +5106,6 @@ describe('SettingsPanel runtime files', () => {
|
||||
within(programmingToggle.closest('article')!)
|
||||
.queryByRole('switch')
|
||||
).not.toBeInTheDocument()
|
||||
expect(
|
||||
screen.queryByRole('switch', {
|
||||
name: '启用直连模型内置浏览器'
|
||||
})
|
||||
).not.toBeInTheDocument()
|
||||
const builtinBrowserToggle = screen.getByRole('button', {
|
||||
name: '展开工具组 内置浏览器'
|
||||
})
|
||||
fireEvent.click(builtinBrowserToggle)
|
||||
expect(builtinBrowserToggle).toHaveAttribute('aria-expanded', 'true')
|
||||
expect(
|
||||
screen.getByText(/不会控制客户端已安装的 Chrome、Edge/)
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByText(/此总开关完全由你控制/)
|
||||
).toHaveTextContent('不再逐次询问')
|
||||
fireEvent.click(
|
||||
screen.getByRole('switch', {
|
||||
name: '启用直连模型内置浏览器'
|
||||
})
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(setComputerCapabilityEnabled).toHaveBeenCalledWith(
|
||||
'host-browser-control',
|
||||
true
|
||||
)
|
||||
)
|
||||
fireEvent.click(
|
||||
screen.getByRole('button', { name: '诊断内置浏览器' })
|
||||
)
|
||||
expect(
|
||||
await screen.findByText('诊断结果:部分可用')
|
||||
).toBeInTheDocument()
|
||||
expect(diagnoseComputerCapability).toHaveBeenCalledWith(
|
||||
'host-browser-control'
|
||||
)
|
||||
expect(screen.queryByText('托管浏览器配置')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('内置浏览器配置')).not.toBeInTheDocument()
|
||||
expect(screen.queryByLabelText('新配置名称')).not.toBeInTheDocument()
|
||||
@@ -5084,12 +5115,10 @@ describe('SettingsPanel runtime files', () => {
|
||||
})
|
||||
).not.toBeInTheDocument()
|
||||
expect(
|
||||
screen.getByRole('switch', {
|
||||
name: '启用直连模型内置浏览器'
|
||||
screen.queryByRole('switch', {
|
||||
name: '启用 内置浏览器 内置 MCP'
|
||||
})
|
||||
).toBeInTheDocument()
|
||||
fireEvent.click(builtinBrowserToggle)
|
||||
expect(builtinBrowserToggle).toHaveAttribute('aria-expanded', 'false')
|
||||
).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('web_search')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('web_fetch')).not.toBeInTheDocument()
|
||||
const webSearchToggle = screen.getByRole('button', {
|
||||
@@ -5164,7 +5193,7 @@ describe('SettingsPanel runtime files', () => {
|
||||
).toBeInTheDocument()
|
||||
expect(
|
||||
screen.getAllByRole('button', {
|
||||
name: /(?:展开|收起)服务器 (?:知识库|笔记|GoodBuddy 配置)/u
|
||||
name: /(?:展开|收起)服务器 (?:知识库|笔记|GoodBuddy 配置|内置浏览器)/u
|
||||
})
|
||||
).toHaveLength(builtinMcpServers.length)
|
||||
expect(
|
||||
@@ -5179,15 +5208,11 @@ describe('SettingsPanel runtime files', () => {
|
||||
const filesystemToggle = screen.getByRole('button', {
|
||||
name: '展开工具组 文件系统操作'
|
||||
})
|
||||
const browserToggle = screen.getByRole('button', {
|
||||
name: '展开工具组 内置浏览器'
|
||||
})
|
||||
fireEvent.click(filesystemToggle)
|
||||
expect(screen.getByText('读取工作区文本')).toBeInTheDocument()
|
||||
expect(screen.getByText('列出工作区目录')).toBeInTheDocument()
|
||||
expect(screen.getByText('写入工作区文本')).toBeInTheDocument()
|
||||
fireEvent.click(browserToggle)
|
||||
expect(screen.getByText('浏览器导航')).toBeInTheDocument()
|
||||
expect(screen.queryByText('浏览器导航')).not.toBeInTheDocument()
|
||||
expect(
|
||||
screen.getAllByRole('button', { name: /工具组/u })
|
||||
).toHaveLength(builtinModelToolGroups.length)
|
||||
|
||||
@@ -233,16 +233,17 @@ export const integrations = {
|
||||
},
|
||||
browser: {
|
||||
title: 'Built-in browser',
|
||||
subtitle: 'Direct-model tool · Isolated GoodBuddy browser · Execute',
|
||||
subtitle: 'Built-in GoodBuddy capability · Isolated browser · Execute',
|
||||
description:
|
||||
'Opens and operates webpages in GoodBuddy’s temporary isolated browser. It does not control Chrome, Edge, or another browser installed on the client computer.',
|
||||
control:
|
||||
'You control this master switch. When off, browser tools are unavailable to direct models. When on, direct models can use them directly in Execute mode without per-action prompts.',
|
||||
enableAriaLabel: 'Enable the direct-model built-in browser',
|
||||
'This switch controls Agent access only. When off, browser tools are unavailable to every runtime, but you can still operate the browser manually from the workbar. When on, assigned runtimes can use them directly in Execute mode without per-action prompts.',
|
||||
enableAriaLabel: 'Enable the built-in GoodBuddy browser',
|
||||
enabled: 'Enabled',
|
||||
disabled: 'Disabled',
|
||||
unsupported: 'The built-in browser is unsupported on this device',
|
||||
diagnoseAriaLabel: 'Diagnose the built-in browser',
|
||||
toolsAriaLabel: 'Direct-model built-in browser tools'
|
||||
toolsAriaLabel: 'Built-in GoodBuddy browser tools'
|
||||
},
|
||||
webSearch: {
|
||||
title: 'Web search',
|
||||
|
||||
@@ -217,16 +217,17 @@ export const integrations = {
|
||||
},
|
||||
browser: {
|
||||
title: '内置浏览器',
|
||||
subtitle: '直连模型工具 · GoodBuddy 隔离浏览器 · Execute',
|
||||
subtitle: 'GoodBuddy 内置能力 · 隔离浏览器 · Execute',
|
||||
description:
|
||||
'在 GoodBuddy 内置的临时隔离浏览器中打开并操作网页,不会控制客户端已安装的 Chrome、Edge 或其他浏览器。',
|
||||
control:
|
||||
'此总开关完全由你控制:关闭时不向直连模型提供浏览器工具;开启后,直连模型可在 Execute 模式直接使用,不再逐次询问。',
|
||||
enableAriaLabel: '启用直连模型内置浏览器',
|
||||
'此开关只控制 Agent:关闭时不向任何 Runtime 提供浏览器工具,但不影响你在浏览器工作栏中手动操作;开启后,已分配的 Runtime 可在 Execute 模式直接使用,不再逐次询问。',
|
||||
enableAriaLabel: '启用 GoodBuddy 内置浏览器',
|
||||
enabled: '已启用',
|
||||
disabled: '已停用',
|
||||
unsupported: '当前设备不支持内置浏览器',
|
||||
diagnoseAriaLabel: '诊断内置浏览器',
|
||||
toolsAriaLabel: '直连模型内置浏览器工具'
|
||||
toolsAriaLabel: 'GoodBuddy 内置浏览器工具'
|
||||
},
|
||||
webSearch: {
|
||||
title: '联网搜索',
|
||||
|
||||
Reference in New Issue
Block a user