Files
metona-ollama-desktop/src/main/menu.ts
T
thzxx c9adc764ae feat: v0.10.0 — 全面增强网络搜索、Agent Loop、工具稳定性与性能
网络搜索增强:
- web_search: 4引擎并行(Bing+百度+DuckDuckGo+Google), LRU缓存5min, URL可达性预检, 结构化JSON输出
- web_fetch: 自动重试(指数退避2次), 移动端UA切换, SPA页面自动升级浏览器渲染

Agent Loop增强:
- 流式调用超时保护(默认180s可配置)
- Final Answer多模式检测 + 内容长度验证
- 预算警告改用ephemeral标记(context优先丢弃)
- Token感知动态迭代预算(>80%自动缩减到3轮)
- 工具缓存TTL(搜索5min/网页10min/文件30min)
- 自动子任务拆解(并行关键词检测+spawn子代理)
- 增量记忆提取(每20轮触发)
- 智能批次划分: 16个只读工具加入ALWAYS_PARALLEL白名单
- 旧工具结果超过10轮自动截断到500字符

工具增强:
- read_multiple_files: 串行→并行Promise.all
- diff_files: 三级回退(diff -u → git diff → builtin)
- search_files: 新增use_regex正则搜索
- list_directory: 新增offset分页
- Git: stash参数修复, clone/push/pull超时保护
- browser: 提取ensureBrowserReady()消除重复, browser_open切换URL自动重建

文档更新:
- 帮助面板新增Agent Loop v0.10.0增强章节
- README中英文同步更新(四引擎搜索/工具描述)
- SOUL.md/AGENT.md更新(v0.10.0能力描述/SPA规则翻转)
2026-06-05 21:20:03 +08:00

130 lines
3.4 KiB
TypeScript

/**
* Metona Ollama Desktop - 原生菜单
*/
import { Menu, dialog, shell, app } from 'electron';
import { mainWindow, setQuitting, getIconPath } from './main.js';
export function createMenu(): void {
const template: Electron.MenuItemConstructorOptions[] = [
{
label: '文件',
submenu: [
{
label: '新建会话',
accelerator: 'Ctrl+N',
click: () => mainWindow?.webContents.send('menu-action', 'new-chat')
},
{ type: 'separator' },
{
label: '导入会话',
click: () => mainWindow?.webContents.send('menu-action', 'import')
},
{
label: '导出会话',
accelerator: 'Ctrl+Shift+E',
click: () => mainWindow?.webContents.send('menu-action', 'export')
},
{ type: 'separator' },
{
label: '退出',
accelerator: 'Ctrl+Q',
click: () => {
setQuitting();
app.quit();
}
}
]
},
{
label: '编辑',
submenu: [
{ role: 'undo', label: '撤销' },
{ role: 'redo', label: '重做' },
{ type: 'separator' },
{ role: 'cut', label: '剪切' },
{ role: 'copy', label: '复制' },
{ role: 'paste', label: '粘贴' },
{ role: 'selectAll', label: '全选' }
]
},
{
label: '视图',
submenu: [
{ role: 'reload', label: '刷新' },
{ role: 'forceReload', label: '强制刷新' },
{ type: 'separator' },
{ role: 'zoomIn', label: '放大' },
{ role: 'zoomOut', label: '缩小' },
{ role: 'resetZoom', label: '重置缩放' },
{ type: 'separator' },
{ role: 'togglefullscreen', label: '全屏' }
]
},
{
label: '窗口',
submenu: [
{ role: 'minimize', label: '最小化' },
{
label: '最大化/还原',
click: () => {
if (mainWindow?.isMaximized()) mainWindow.unmaximize();
else mainWindow?.maximize();
}
},
{ type: 'separator' },
{
label: '置顶',
type: 'checkbox',
checked: false,
click: (menuItem: Electron.MenuItem) => {
mainWindow?.setAlwaysOnTop(menuItem.checked);
}
}
]
},
{
label: '帮助',
submenu: [
{
label: '使用帮助',
click: () => mainWindow?.webContents.send('menu-action', 'help')
},
{ type: 'separator' },
{
label: '关于 Ollama',
click: () => shell.openExternal('https://ollama.com')
},
{
label: '关于 Metona',
click: () => {
dialog.showMessageBox(mainWindow!, {
type: 'info',
title: '关于 Metona Ollama',
message: 'Metona Ollama Desktop v0.10.0',
detail: 'TypeScript + Electron Ollama AI 聊天客户端\n\nhttps://gitee.com/thzxx/metona-ollama',
icon: getIconPath()
});
}
}
]
}
];
if (!app.isPackaged) {
template.push({
label: 'Dev',
submenu: [
{
label: '切换开发者工具',
accelerator: 'F12',
click: () => mainWindow?.webContents.toggleDevTools()
}
]
});
}
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
}