diff --git a/cli/src/claude/claudeRemoteLauncher.ts b/cli/src/claude/claudeRemoteLauncher.ts index ba65fdac9..4847adf14 100644 --- a/cli/src/claude/claudeRemoteLauncher.ts +++ b/cli/src/claude/claudeRemoteLauncher.ts @@ -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; diff --git a/cli/src/claude/sdk/query.ts b/cli/src/claude/sdk/query.ts index 725cb3ba5..f8422cb2f 100644 --- a/cli/src/claude/sdk/query.ts +++ b/cli/src/claude/sdk/query.ts @@ -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) { @@ -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 = () => { @@ -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() diff --git a/hub/src/sync/syncEngine.ts b/hub/src/sync/syncEngine.ts index 23ae63767..94c59d9ef 100644 --- a/hub/src/sync/syncEngine.ts +++ b/hub/src/sync/syncEngine.ts @@ -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] })() - if (!targetMachine) { - return { type: 'error', message: 'No machine online', code: 'no_machine_online' } - } - const spawnResult = await this.rpcGateway.spawnSession( targetMachine.id, metadata.path,