Skip to content

Bug: modlens fails in DSH Desktop Electron app — process.execPath is Electron binary, not node #46

Description

@yeruizhi

Bug Report

Environment: DeepSeek Harness (DSH) Desktop Electron app on macOS
modlens version: 3.10.0
DSH profile: @liustack/modlens/dsh loaded via cordis patch

What happens

When pasting an image into the DSH Desktop Electron app, modlens reports:

A pasted image could not be read by modlens: error: too many arguments for 'analyze'. Expected 0 arguments but got 1.

The same paste works perfectly in the DSH web dev instance (node process, port 3080).

Root cause

In dsh/index.js, both read_image.execute() and the paste-unlock readImageBlock() spawn the CLI with:

run(process.execPath, [cli, '-i', file, '--timeout', String(CLI_TIMEOUT_MS)], signal)

In the Electron desktop app, process.execPath is the Electron binary (DeepSeek Harness.app/Contents/MacOS/DeepSeek Harness), not node. When Electron spawns itself with [dist/main.js, '-i', <path>, ...], it consumes/reorders the -i flag as an Electron/Chromium switch. Commander then sees <path> as a positional argument to the default analyze command and throws:

error: too many arguments for 'analyze'. Expected 0 arguments but got 1.

Reproduction

# Works (node):
node dist/main.js -i /path/to/image.jpg --timeout 180000   # ✅ returns JSON

# Fails (Electron binary = DSH desktop app's process.execPath):
/Applications/DeepSeek\ Harness.app/Contents/MacOS/DeepSeek\ Harness dist/main.js -i /path/to/image.jpg --timeout 180000
#  error: too many arguments for 'analyze'. Expected 0 arguments but got 1.

Suggested fix

Use a fixed node path instead of process.execPath:

// Option A: resolve node from PATH or use env override
const NODE_BIN = process.env.MODLENS_NODE ?? process.execPath;
run(NODE_BIN, [cli, '-i', file, '--timeout', String(CLI_TIMEOUT_MS)], signal);

Or detect Electron at runtime:

const isElectron = typeof process !== 'undefined' && process.versions?.electron != null;
const runner = isElectron ? 'node' : process.execPath;
run(runner, [cli, '-i', file, '--timeout', String(CLI_TIMEOUT_MS)], signal);

Both execute() (the read_image tool) and readImageBlock() (paste unlock) need this fix.

Workaround for users

Run DSH in Chrome (npx @deepseek-ai/dsh web) instead of the Desktop Electron app — there process.execPath is node and modlens works correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions