Skip to content

fix(Wukong):Enhance WukongInput with logging for availability checks#132

Open
z1queue wants to merge 7 commits into
alibaba:mainfrom
z1queue:main
Open

fix(Wukong):Enhance WukongInput with logging for availability checks#132
z1queue wants to merge 7 commits into
alibaba:mainfrom
z1queue:main

Conversation

@z1queue

@z1queue z1queue commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

问题:
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.

z1queue added 7 commits June 16, 2026 12:38
…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.
@z1queue z1queue changed the title Enhance WukongInput with logging for availability checks fix(Wukong):Enhance WukongInput with logging for availability checks Jul 10, 2026

@ralf0131 ralf0131 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean fix with good error handling and debug logging.

The fix correctly addresses two real issues:

  1. Lingering daemon socket file after Wukong app quit — now verified with isProcessRunning() before spawning CLI.
  2. Unintentional UI window trigger — pgrep/tasklist check prevents spawning wukong-cli when 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 running wukong-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.

Comment on lines +176 to +180
// 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 });
Comment on lines +182 to 189
} 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;
}
Comment on lines +136 to +143
// 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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants