fix: complete runtime and workspace workflows

Restore Ask workspace reads and output paging without granting write access,
and let programming Subagents reuse their parent's browser page. Allocate
browser resources only when used, keep Agent pages aligned with workbar tabs,
recover released bindings, and remove unused automatic screenshot work.

Preserve inherited Runtime selections during remote usage persistence and
manual compression. Keep viable channel model fallbacks, display the actual
scheduled-task mode and Harness model source, and avoid rediscovery delays
when calling healthy MCP tools. Fix directory/history refresh, case-only
renames, rename-aware commit diffs, and FastGPT probe success reporting.

Add regression coverage and align feature documentation. The Agent-side
connection timeout fix requires deploying an updated Agent; existing Ask
read-only and Execute authorization boundaries remain unchanged.

Final validation: 3839 tests passed, 66 skipped; typecheck, lint, development
build, and diff checks passed. Isolated Electron UI/MCP workflows passed with
a loopback model fixture. Current-source Linux x64 Host checks passed with
three successful real model requests. Chromium loadURL rejection was not
reproduced in the UI; released-binding recovery has automated coverage.

Release note: 修复 Ask 读取项目文件、浏览器页面显示与恢复、文件管理及模型配置跟随中的不一致,并减少无用截图和 MCP 等待。定时任务显示实际工作模式,远程会话可正常保存继承 Runtime 的用量;远端连接超时修复需更新 Agent 后生效。
This commit is contained in:
mesalogo
2026-09-10 12:48:30 +08:00
parent 020a9ad0dc
commit c037d7fb20
62 changed files with 2637 additions and 521 deletions
+49
View File
@@ -6,6 +6,7 @@ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/
import type { KnowledgeService } from '../src/main/knowledge/knowledge-service'
import { KnowledgeMcpGateway } from '../src/main/agent/knowledge-mcp-gateway'
import { BrowserService } from '../src/main/browser/browser-service'
import type { BrowserLiveState } from '../src/shared/contracts'
const conversationId = 'browser-tabs-electron-e2e'
const otherConversationId = 'browser-tabs-electron-e2e-other'
@@ -50,6 +51,54 @@ async function main(): Promise<void> {
let client: Client | undefined
let token: string | undefined
try {
const beforeReservations = webContents.getAllWebContents().length
const states: BrowserLiveState[] = []
const removeStateListener = browser.onState((state) => states.push(state))
const unused = Array.from({ length: 4 }, (_, index) =>
browser.reserveRequestTab(`unused-request-${index}`, `request-${index}`, window.webContents.id)
)
assert.equal(browser.getSessionCount(), 0)
assert.equal(browser.getTabCount(), 0)
assert.equal(webContents.getAllWebContents().length, beforeReservations)
assert.equal(states.length, 0)
for (const lease of unused) {
lease.release()
assert.equal(browser.getOwnerWindowId(lease.conversationId), undefined)
}
console.log('Four unused request reservations created no Electron sessions, WebContents, or UI events')
const reserved = browser.reserveRequestTab(conversationId, 'reserved-request', window.webContents.id)
await gateway.start()
token = gateway.grant('reserved-request', [], controller.signal, 'none', undefined, conversationId, reserved.tabId, reserved)
assert(token)
client = new Client({ name: 'reserved-browser-electron-e2e', version: '1.0.0' })
await client.connect(new StreamableHTTPClientTransport(new URL(gateway.getEndpoint()!), {
requestInit: { headers: { Authorization: `Bearer ${token}` } }
}))
assert.equal(browser.getSessionCount(), 0)
const reservedNavigation = await client.callTool({ name: 'browser_navigate', arguments: { url: `${origin}/mcp` } })
assert.notEqual(reservedNavigation.isError, true)
assert.equal(browser.getSessionCount(), 1)
assert.equal(states[0]?.status, 'creating')
assert.equal(states[0]?.tabId, reserved.tabId)
assert.equal(states[0]?.workbarInstanceId, reserved.tabId)
assert(states.every((state) => state.workbarInstanceId === reserved.tabId && !('frameDataUrl' in state)))
const restoredRequestTab = await browser.createTab(conversationId, window.webContents.id, controller.signal, reserved.tabId)
assert.equal(restoredRequestTab.tabId, reserved.tabId)
assert.equal(restoredRequestTab.workbarInstanceId, reserved.tabId)
assert.equal(browser.getTabCount(), 1)
assert.match(JSON.stringify(await client.callTool({ name: 'browser_snapshot', arguments: {} })), /MCP target/u)
await assert.rejects(browser.closeTab(conversationId, reserved.tabId, window.webContents.id), /正在被.*请求使用/u)
gateway.revoke(token)
token = undefined
await client.close()
client = undefined
await browser.closeTab(conversationId, reserved.tabId, window.webContents.id)
await browser.closeTab(conversationId, reserved.tabId, window.webContents.id)
assert.equal(browser.getSessionCount(), 0)
removeStateListener()
console.log('MCP navigation materialized the exact reserved tab/workbar identity and released its request lease')
await browser.navigate(conversationId, `${origin}/first`, controller.signal, undefined, window.webContents.id)
const [unownedPrimary] = browser.listTabs(conversationId, window.webContents.id)
assert(unownedPrimary)