Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/claude/claudeRemoteLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class ClaudeRemoteLauncher extends RemoteLauncherBase {
session.client.sendSessionEvent({ type: 'message', message: 'Aborted by user' });
}
} catch (e) {
logger.debug('[remote]: launch error', e);
logger.debug('[remote]: launch error', e instanceof Error ? `${e.name}: ${e.message}\n${e.stack}` : JSON.stringify(e));
if (!this.exitReason) {
session.client.sendSessionEvent({ type: 'message', message: 'Process exited unexpectedly' });
continue;
Expand Down
17 changes: 8 additions & 9 deletions cli/src/claude/sdk/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ export function query(config: {
if (disallowedTools.length > 0) args.push('--disallowedTools', disallowedTools.join(','))
if (additionalDirectories.length > 0) args.push('--add-dir', ...additionalDirectories)
if (strictMcpConfig) args.push('--strict-mcp-config')
if (permissionMode) args.push('--permission-mode', permissionMode)
if (permissionMode && !(canCallTool && permissionMode === 'bypassPermissions')) {
args.push('--permission-mode', permissionMode)
}

if (fallbackModel) {
if (model && fallbackModel === model) {
Expand Down Expand Up @@ -361,12 +363,10 @@ export function query(config: {
childStdin = child.stdin
}

// Handle stderr in debug mode
if (process.env.DEBUG) {
child.stderr.on('data', (data) => {
console.error('Claude Code stderr:', data.toString())
})
}
// Handle stderr - always capture for diagnostics
child.stderr.on('data', (data) => {
logDebug('Claude Code stderr: ' + data.toString())
})

// Setup cleanup
const cleanup = () => {
Expand All @@ -383,8 +383,7 @@ export function query(config: {
child.on('close', (code) => {
if (config.options?.abort?.aborted) {
query.setError(new AbortError('Claude Code process aborted by user'))
}
if (code !== 0) {
} else if (code !== 0) {
query.setError(new Error(`Claude Code process exited with code ${code}`))
} else {
resolve()
Expand Down
6 changes: 1 addition & 5 deletions hub/src/sync/syncEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,9 @@ export class SyncEngine {
const hostMatch = onlineMachines.find((machine) => machine.metadata?.host === metadata.host)
if (hostMatch) return hostMatch
}
return null
return onlineMachines[0]

Choose a reason for hiding this comment

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

[MAJOR] [Correctness] Resume can target wrong machine

Why this is a problem: When metadata.machineId or metadata.host is set but no match is online, this now falls back to the first online machine. Resume then uses metadata.path on a different machine, risking wrong workspace or unintended session creation.

Suggested fix:

const targetMachine = (() => {
    if (metadata.machineId) {
        const exact = onlineMachines.find((machine) => machine.id === metadata.machineId)
        if (exact) return exact
        return null
    }
    if (metadata.host) {
        const hostMatch = onlineMachines.find((machine) => machine.metadata?.host === metadata.host)
        if (hostMatch) return hostMatch
        return null
    }
    return onlineMachines[0]
})()

if (!targetMachine) {
    return { type: 'error', message: 'No matching machine online', code: 'no_machine_online' }
}

})()

if (!targetMachine) {
return { type: 'error', message: 'No machine online', code: 'no_machine_online' }
}

const spawnResult = await this.rpcGateway.spawnSession(
targetMachine.id,
metadata.path,
Expand Down