mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-12 08:59:02 +08:00
* ci: add GitHub issue tracker workflow with Feishu notifications (#10895) * feat: add GitHub issue tracker workflow with Feishu notifications * fix: add missing environment variable for Claude translator in GitHub issue tracker workflow * fix: update environment variable for Claude translator in GitHub issue tracker workflow * Add quiet hours handling and scheduled processing for GitHub issue notifications - Implement quiet hours detection (00:00-08:30 Beijing Time) with delayed notifications - Add scheduled workflow to process pending issues daily at 08:30 Beijing Time - Create new script to batch process and summarize multiple pending issues with Claude * Replace custom Node.js script with Claude Code Action for issue processing - Migrate from custom JavaScript implementation to Claude Code Action for AI-powered issue summarization and processing - Simplify workflow by leveraging Claude's built-in GitHub API integration and tool usage capabilities - Maintain same functionality: fetch pending issues, generate Chinese summaries, send Feishu notifications, and clean up labels - Update Claude action reference from version pin to main branch for latest features * Remove GitHub issue comment functionality - Delete automated AI summary comments on issues after processing - Remove documentation for manual issue commenting workflow - Keep Feishu notification system intact while streamlining issue interactions * feat: redirect macOS About menu to settings About page Add functionality to navigate to the About page in settings when clicking the About menu item in macOS menu bar. Changes: - Add Windows_NavigateToAbout IPC channel for communication between main and renderer processes - Create AppMenuService to setup macOS application menu with custom About handler - Add IPC handler in main process to show main window and trigger navigation - Add IPC listener in renderer NavigationHandler to navigate to /settings/about - Initialize AppMenuService on app startup for macOS platform 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * * feat: add GitHub issue tracker workflow with Feishu notifications * feat: add GitHub issue tracker workflow with Feishu notifications * fix: add missing environment variable for Claude translator in GitHub issue tracker workflow * fix: update environment variable for Claude translator in GitHub issue tracker workflow * Add quiet hours handling and scheduled processing for GitHub issue notifications - Implement quiet hours detection (00:00-08:30 Beijing Time) with delayed notifications - Add scheduled workflow to process pending issues daily at 08:30 Beijing Time - Create new script to batch process and summarize multiple pending issues with Claude * Replace custom Node.js script with Claude Code Action for issue processing - Migrate from custom JavaScript implementation to Claude Code Action for AI-powered issue summarization and processing - Simplify workflow by leveraging Claude's built-in GitHub API integration and tool usage capabilities - Maintain same functionality: fetch pending issues, generate Chinese summaries, send Feishu notifications, and clean up labels - Update Claude action reference from version pin to main branch for latest features * Remove GitHub issue comment functionality - Delete automated AI summary comments on issues after processing - Remove documentation for manual issue commenting workflow - Keep Feishu notification system intact while streamlining issue interactions * Add OIDC token permissions and GitHub token to Claude workflow - Add `id-token: write` permission for OIDC authentication in both jobs - Pass `github_token` to Claude action for proper GitHub API access - Maintain existing issue write and contents read permissions * fix: add GitHub issue tracker workflow with Feishu notifications * feat: add GitHub issue tracker workflow with Feishu notifications * fix: add missing environment variable for Claude translator in GitHub issue tracker workflow * fix: update environment variable for Claude translator in GitHub issue tracker workflow * Add quiet hours handling and scheduled processing for GitHub issue notifications - Implement quiet hours detection (00:00-08:30 Beijing Time) with delayed notifications - Add scheduled workflow to process pending issues daily at 08:30 Beijing Time - Create new script to batch process and summarize multiple pending issues with Claude * Replace custom Node.js script with Claude Code Action for issue processing - Migrate from custom JavaScript implementation to Claude Code Action for AI-powered issue summarization and processing - Simplify workflow by leveraging Claude's built-in GitHub API integration and tool usage capabilities - Maintain same functionality: fetch pending issues, generate Chinese summaries, send Feishu notifications, and clean up labels - Update Claude action reference from version pin to main branch for latest features * Remove GitHub issue comment functionality - Delete automated AI summary comments on issues after processing - Remove documentation for manual issue commenting workflow - Keep Feishu notification system intact while streamlining issue interactions * Add OIDC token permissions and GitHub token to Claude workflow - Add `id-token: write` permission for OIDC authentication in both jobs - Pass `github_token` to Claude action for proper GitHub API access - Maintain existing issue write and contents read permissions * Enhance GitHub issue automation workflow with Claude integration - Refactor Claude action to handle issue analysis, Feishu notification, and comment creation in single step - Add tool permissions for Bash commands and custom notification script execution - Update prompt with detailed task instructions including summary generation and automated actions - Remove separate notification step by integrating all operations into Claude action workflow * fix * 删除AI总结评论的添加步骤和注意事项 * fix comments * refactor(AppMenuService): streamline WindowService usage Updated the AppMenuService to directly import and use the windowService for retrieving the main window and showing it, enhancing code clarity and maintainability. * add i18n * fix(AppMenuService): handle macOS application menu setup conditionally Updated the AppMenuService to only instantiate when running on macOS, preventing potential null reference errors. Additionally, added optional chaining in the main index file for safer menu setup. * fix(i18n): Auto update translations for PR #10902 --------- Co-authored-by: SuYao <sy20010504@gmail.com> Co-authored-by: Payne Fu <payne@Paynes-MacBook-Pro.local> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: GitHub Action <action@github.com>
247 lines
7.7 KiB
TypeScript
247 lines
7.7 KiB
TypeScript
// don't reorder this file, it's used to initialize the app data dir and
|
|
// other which should be run before the main process is ready
|
|
// eslint-disable-next-line
|
|
import './bootstrap'
|
|
|
|
import '@main/config'
|
|
|
|
import { loggerService } from '@logger'
|
|
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
|
import { replaceDevtoolsFont } from '@main/utils/windowUtil'
|
|
import { app } from 'electron'
|
|
import installExtension, { REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } from 'electron-devtools-installer'
|
|
import { isDev, isLinux, isWin } from './constant'
|
|
|
|
import process from 'node:process'
|
|
|
|
import { registerIpc } from './ipc'
|
|
import { agentService } from './services/agents'
|
|
import { apiServerService } from './services/ApiServerService'
|
|
import { appMenuService } from './services/AppMenuService'
|
|
import { configManager } from './services/ConfigManager'
|
|
import mcpService from './services/MCPService'
|
|
import { nodeTraceService } from './services/NodeTraceService'
|
|
import {
|
|
CHERRY_STUDIO_PROTOCOL,
|
|
handleProtocolUrl,
|
|
registerProtocolClient,
|
|
setupAppImageDeepLink
|
|
} from './services/ProtocolClient'
|
|
import selectionService, { initSelectionService } from './services/SelectionService'
|
|
import { registerShortcuts } from './services/ShortcutService'
|
|
import { TrayService } from './services/TrayService'
|
|
import { windowService } from './services/WindowService'
|
|
import { initWebviewHotkeys } from './services/WebviewService'
|
|
|
|
const logger = loggerService.withContext('MainEntry')
|
|
|
|
/**
|
|
* Disable hardware acceleration if setting is enabled
|
|
*/
|
|
const disableHardwareAcceleration = configManager.getDisableHardwareAcceleration()
|
|
if (disableHardwareAcceleration) {
|
|
app.disableHardwareAcceleration()
|
|
}
|
|
|
|
/**
|
|
* Disable chromium's window animations
|
|
* main purpose for this is to avoid the transparent window flashing when it is shown
|
|
* (especially on Windows for SelectionAssistant Toolbar)
|
|
* Know Issue: https://github.com/electron/electron/issues/12130#issuecomment-627198990
|
|
*/
|
|
if (isWin) {
|
|
app.commandLine.appendSwitch('wm-window-animations-disabled')
|
|
}
|
|
|
|
/**
|
|
* Enable GlobalShortcutsPortal for Linux Wayland Protocol
|
|
* see: https://www.electronjs.org/docs/latest/api/global-shortcut
|
|
*/
|
|
if (isLinux && process.env.XDG_SESSION_TYPE === 'wayland') {
|
|
app.commandLine.appendSwitch('enable-features', 'GlobalShortcutsPortal')
|
|
}
|
|
|
|
// DocumentPolicyIncludeJSCallStacksInCrashReports: Enable features for unresponsive renderer js call stacks
|
|
// EarlyEstablishGpuChannel,EstablishGpuChannelAsync: Enable features for early establish gpu channel
|
|
// speed up the startup time
|
|
// https://github.com/microsoft/vscode/pull/241640/files
|
|
app.commandLine.appendSwitch(
|
|
'enable-features',
|
|
'DocumentPolicyIncludeJSCallStacksInCrashReports,EarlyEstablishGpuChannel,EstablishGpuChannelAsync'
|
|
)
|
|
app.on('web-contents-created', (_, webContents) => {
|
|
webContents.session.webRequest.onHeadersReceived((details, callback) => {
|
|
callback({
|
|
responseHeaders: {
|
|
...details.responseHeaders,
|
|
'Document-Policy': ['include-js-call-stacks-in-crash-reports']
|
|
}
|
|
})
|
|
})
|
|
|
|
webContents.on('unresponsive', async () => {
|
|
// Interrupt execution and collect call stack from unresponsive renderer
|
|
logger.error('Renderer unresponsive start')
|
|
const callStack = await webContents.mainFrame.collectJavaScriptCallStack()
|
|
logger.error(`Renderer unresponsive js call stack\n ${callStack}`)
|
|
})
|
|
})
|
|
|
|
// in production mode, handle uncaught exception and unhandled rejection globally
|
|
if (!isDev) {
|
|
// handle uncaught exception
|
|
process.on('uncaughtException', (error) => {
|
|
logger.error('Uncaught Exception:', error)
|
|
})
|
|
|
|
// handle unhandled rejection
|
|
process.on('unhandledRejection', (reason, promise) => {
|
|
logger.error(`Unhandled Rejection at: ${promise} reason: ${reason}`)
|
|
})
|
|
}
|
|
|
|
// Check for single instance lock
|
|
if (!app.requestSingleInstanceLock()) {
|
|
app.quit()
|
|
process.exit(0)
|
|
} else {
|
|
// This method will be called when Electron has finished
|
|
// initialization and is ready to create browser windows.
|
|
// Some APIs can only be used after this event occurs.
|
|
|
|
app.whenReady().then(async () => {
|
|
initWebviewHotkeys()
|
|
// Set app user model id for windows
|
|
electronApp.setAppUserModelId(import.meta.env.VITE_MAIN_BUNDLE_ID || 'com.kangfenmao.CherryStudio')
|
|
|
|
// Mac: Hide dock icon before window creation when launch to tray is set
|
|
const isLaunchToTray = configManager.getLaunchToTray()
|
|
if (isLaunchToTray) {
|
|
app.dock?.hide()
|
|
}
|
|
|
|
const mainWindow = windowService.createMainWindow()
|
|
new TrayService()
|
|
|
|
// Setup macOS application menu
|
|
appMenuService?.setupApplicationMenu()
|
|
|
|
nodeTraceService.init()
|
|
|
|
app.on('activate', function () {
|
|
const mainWindow = windowService.getMainWindow()
|
|
if (!mainWindow || mainWindow.isDestroyed()) {
|
|
windowService.createMainWindow()
|
|
} else {
|
|
windowService.showMainWindow()
|
|
}
|
|
})
|
|
|
|
registerShortcuts(mainWindow)
|
|
|
|
registerIpc(mainWindow, app)
|
|
|
|
replaceDevtoolsFont(mainWindow)
|
|
|
|
// Setup deep link for AppImage on Linux
|
|
await setupAppImageDeepLink()
|
|
|
|
if (isDev) {
|
|
installExtension([REDUX_DEVTOOLS, REACT_DEVELOPER_TOOLS])
|
|
.then((name) => logger.info(`Added Extension: ${name}`))
|
|
.catch((err) => logger.error('An error occurred: ', err))
|
|
}
|
|
|
|
//start selection assistant service
|
|
initSelectionService()
|
|
|
|
// Initialize Agent Service
|
|
try {
|
|
await agentService.initialize()
|
|
logger.info('Agent service initialized successfully')
|
|
} catch (error: any) {
|
|
logger.error('Failed to initialize Agent service:', error)
|
|
}
|
|
|
|
// Start API server if enabled or if agents exist
|
|
try {
|
|
const config = await apiServerService.getCurrentConfig()
|
|
logger.info('API server config:', config)
|
|
|
|
// Check if there are any agents
|
|
let shouldStart = config.enabled
|
|
if (!shouldStart) {
|
|
try {
|
|
const { total } = await agentService.listAgents({ limit: 1 })
|
|
if (total > 0) {
|
|
shouldStart = true
|
|
logger.info(`Detected ${total} agent(s), auto-starting API server`)
|
|
}
|
|
} catch (error: any) {
|
|
logger.warn('Failed to check agent count:', error)
|
|
}
|
|
}
|
|
|
|
if (shouldStart) {
|
|
await apiServerService.start()
|
|
}
|
|
} catch (error: any) {
|
|
logger.error('Failed to check/start API server:', error)
|
|
}
|
|
})
|
|
|
|
registerProtocolClient(app)
|
|
|
|
// macOS specific: handle protocol when app is already running
|
|
|
|
app.on('open-url', (event, url) => {
|
|
event.preventDefault()
|
|
handleProtocolUrl(url)
|
|
})
|
|
|
|
const handleOpenUrl = (args: string[]) => {
|
|
const url = args.find((arg) => arg.startsWith(CHERRY_STUDIO_PROTOCOL + '://'))
|
|
if (url) handleProtocolUrl(url)
|
|
}
|
|
|
|
// for windows to start with url
|
|
handleOpenUrl(process.argv)
|
|
|
|
// Listen for second instance
|
|
app.on('second-instance', (_event, argv) => {
|
|
windowService.showMainWindow()
|
|
|
|
// Protocol handler for Windows/Linux
|
|
// The commandLine is an array of strings where the last item might be the URL
|
|
handleOpenUrl(argv)
|
|
})
|
|
|
|
app.on('browser-window-created', (_, window) => {
|
|
optimizer.watchWindowShortcuts(window)
|
|
})
|
|
|
|
app.on('before-quit', () => {
|
|
app.isQuitting = true
|
|
|
|
// quit selection service
|
|
if (selectionService) {
|
|
selectionService.quit()
|
|
}
|
|
})
|
|
|
|
app.on('will-quit', async () => {
|
|
// 简单的资源清理,不阻塞退出流程
|
|
try {
|
|
await mcpService.cleanup()
|
|
await apiServerService.stop()
|
|
} catch (error) {
|
|
logger.warn('Error cleaning up MCP service:', error as Error)
|
|
}
|
|
// finish the logger
|
|
logger.finish()
|
|
})
|
|
|
|
// In this file you can include the rest of your app"s specific main process
|
|
// code. You can also put them in separate files and require them here.
|
|
}
|