fix(Wukong):Enhance WukongInput with logging for availability checks#132
fix(Wukong):Enhance WukongInput with logging for availability checks#132z1queue wants to merge 7 commits into
Conversation
…e 的 entry 的 gen_ai.agent.system 字段为 unknown
resolveAgentSystem('opencode') 返回 'unknown',导致 OTLP trace 中 opencode 的 entry 的 gen_ai.agent.system 字段为 unknown
问题:
1、即使wukong进程不在, ~/.real/daemon.sock依然存在
2、如果wukong进程不存在,执行./wukong-cli agent data list_tasks --json {\"limit\":50} 命令,会触发打开悟空界面窗口
修复方案:
// Verify the Wukong process is actually running before spawning
// wukong-cli. Avoids unnecessary CLI spawns and timeouts when the app
// has been quit but the daemon socket file lingers.
ralf0131
left a comment
There was a problem hiding this comment.
LGTM. Clean fix with good error handling and debug logging.
The fix correctly addresses two real issues:
- Lingering daemon socket file after Wukong app quit — now verified with
isProcessRunning()before spawning CLI. - Unintentional UI window trigger —
pgrep/tasklistcheck prevents spawningwukong-cliwhen the process is not running.
Platform-specific process detection (pgrep on macOS/Linux, tasklist on Windows) with safe ENOENT fallback is well implemented. Logging is helpful and appropriately scoped (stdout truncated to 200 chars).
Automated review by github-manager-bot
There was a problem hiding this comment.
Pull request overview
This PR hardens the Wukong agent’s availability detection in src/inputs/wukong/ by adding debug logging and an extra “process is actually running” gate before invoking wukong-cli, to avoid unnecessary CLI spawns/timeouts and prevent triggering the Wukong UI when the daemon socket file lingers after the app quits.
Changes:
- Added a dedicated logger and debug logs around the availability check path.
- Added a platform-specific process liveness check (
pgrep/tasklist) before runningwukong-cli service status. - Improved observability for CLI service status output/failures.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // macOS: match full app bundle path; Linux: match process name | ||
| const pattern = process.platform === 'darwin' | ||
| ? '/Wukong.app/Contents/MacOS/DingTalkReal' | ||
| : 'DingTalkReal'; | ||
| await execFile('pgrep', ['-fl', pattern], { timeout: 3000 }); |
| } catch (err) { | ||
| // pgrep/tasklist not available — cannot confirm, assume running (fall | ||
| // back to the socket + CLI service status check that follows) | ||
| const e = err as NodeJS.ErrnoException; | ||
| if (e.code === 'ENOENT') return true; | ||
| // pgrep ran but no matching process found | ||
| return false; | ||
| } |
| // Verify the Wukong process is actually running before spawning | ||
| // wukong-cli. Avoids unnecessary CLI spawns and timeouts when the app | ||
| // has been quit but the daemon socket file lingers. | ||
| if (!(await WukongInput.isProcessRunning())) { | ||
| wukongLogger.debug('checkAvailability: process not running'); | ||
| return false; | ||
| } | ||
| wukongLogger.debug('checkAvailability: process running, checking CLI service status'); |
问题:
1、即使wukong进程不在, ~/.real/daemon.sock依然存在
2、如果wukong进程不存在,执行./wukong-cli agent data list_tasks --json {"limit":50} 命令,会触发打开悟空界面窗口
修复方案:
// Verify the Wukong process is actually running before spawning
// wukong-cli. Avoids unnecessary CLI spawns and timeouts when the app
// has been quit but the daemon socket file lingers.