Skip to content

Conversation

@chr1syy
Copy link

@chr1syy chr1syy commented Jan 13, 2026

Improving / Fixing Remote SSH Agent Connection from Windows Client .exe (Portable/Setup)

Summary

This PR significantly improves Maestro’s SSH remote execution on Windows by fixing binary detection, stabilizing stdin handling for large prompts, and enhancing the Wizard’s SSH session awareness.

For me, this meant i couldn't use the App at all after the first installation, now i got working agents within Maestro.

Key Changes

SSH Execution & Stdin Handling

Maestro gets to a point where prompts are getting pretty long. In some cases, for example the Onboarding, the messages are longer than the Windows PowerShell allows. This leads to errors in the agent execution.

  • Ensures large prompts are forwarded correctly by switching to exec‑based SSH invocation.
  • Adds a useStdin flag and improves stdin piping to avoid Windows command‑line length limits.
  • Avoids forcing TTY for stream-json to prevent broken remote streams.

Wizard SSH Session Awareness

The Wizard wasn't SSH Session aware. From actually discovering an agent to chatting with him, that information was kind of lost and Maestro tried to re-discover the agent.

  • Adds SSH session awareness from phases 1 through 5 of the Wizard.
  • Skips agent availability checks during SSH Wizard sessions to avoid false negatives.
  • Fixes Wizard SSH remote support and ensures correct environment sourcing.

Discovering GitHub Repo (Wizard Phase 2)

The Wizard couldn't discover the GitHub Repo in my remote directory directly. This got fixed by establishing the correct SSH connection. Also the input field got debounced, because every keyboard hit led to a new ssh-call.

Environment & Shell Improvements

  • Sources bash profiles to correctly locate the Claude Code binary in remote environments.

WIP / REVIEW REQUIRED

This PR still needs review. Since i am only developing a solution for "my case" - the changes need to be verified to keep cross-platform compatibility working. This means macOS, linux and windows local agents have to be verified.

Also still not working and in progress:

  • Manual Agent Window
  • FileSystem on the main Window
  • Documentation for building on Windows

Issues

This addresses #181, #131,
Related: #56

Test-Coverage / Linting

Currently ~ 20 Test files that have to be sorted, only a small part of that is actually through changes in the ssh code.
Linting has 2 Errors remaining.

@chr1syy chr1syy force-pushed the fix-win-ssh-remote branch from ad95897 to c5c5474 Compare January 14, 2026 22:32
@chr1syy chr1syy marked this pull request as draft January 14, 2026 22:40
@chr1syy
Copy link
Author

chr1syy commented Jan 14, 2026

  • Reverted PR back to Draft, i'm still cleaning up after me
  • FileBrowser and other Bugs fixed with 28fb58e

@chr1syy chr1syy force-pushed the fix-win-ssh-remote branch from 2ab94f5 to c93d872 Compare January 15, 2026 10:20
@chr1syy
Copy link
Author

chr1syy commented Jan 15, 2026

  • updated to newest changes from pedramamini:main
  • fixed failing windows build c93d872
  • cleaned up commit mess
  • added startup script for windows, equivalent to npm run dev by running npm run dev:win

@chr1syy chr1syy marked this pull request as ready for review January 15, 2026 12:05
@chr1syy chr1syy changed the title Fix/WIP: Remote SSH Agent Sessions (Windows) Fix: Remote SSH Agent Sessions (Windows) Jan 15, 2026
@chr1syy
Copy link
Author

chr1syy commented Jan 15, 2026

  • fixes inline wizard
  • fixed synopsis
  • fixed ssh/local pathing issues

@chr1syy
Copy link
Author

chr1syy commented Jan 17, 2026

as per discord, i fixed:

  • agent arg building in both wizards
  • grooming was hardcoded to claude, should use codex and opencode with their configurable limits now

@chr1syy
Copy link
Author

chr1syy commented Jan 17, 2026

fixed the causes for failing tests through code changes

Test Files: 328 passed | 1 skipped

chr1syy and others added 7 commits January 26, 2026 12:38
…wizard, IPC, and agent detection

- Added full SSH remote support to the wizard, including propagation of SSH config through all phases
- Ensured SSH config flows correctly through IPC bridge (renderer → preload → main)
- Improved agent detection with optional sshRemoteId and remote `which` resolution
- Fixed SSH config transfer during manual agent creation and auto-selection flows
- Added extensive debugging and structured logging for SSH execution, agent availability, and wizard message flow
- Improved stdin/JSON streaming for large prompts and remote execution
- Added input/output JSON stream handling and enhanced logging for SSH transport
- Added sourcing of bash profiles to correctly resolve claude-code binary paths on remote hosts
… and process manager

- Added extensive DEBUG-level logging for SSH command execution, spawn details, exit codes, and configuration flow
- Improved Wizard SSH remote support:
  - Debounced remote directory validation to reduce excessive SSH calls
  - Fixed git.isRepo() to correctly pass remoteCwd for remote checks
  - Persisted SSH config in SerializableWizardState and validated directories over SSH
  - Ensured ConversationScreen and ConversationSession consistently pass SSH config for remote agent execution
  - Fixed "agent not available" errors by forwarding stdin via exec and enabling stream-json mode for large prompts
- Enhanced remote agent execution logic in ProcessManager with stdin streaming, exec-based forwarding, and useStdin flag
- Improved SSH file browser behavior:
  - Added resolveSshPath() to locate SSH binaries on Windows (Electron spawn PATH issue)
  - Corrected getSshContext() handling of enabled/remoteId states
  - Ensured synopsis background tasks run via SSH instead of local paths
- Added Windows development improvements: dev:win script and PowerShell launcher for separate renderer/main terminals
- Added additional SSH directory debugging logs for remote-fs and wizard flows

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…utils and resolving TypeScript errors

- Added Python 3.11 to Windows CI to restore distutils support required by node-gyp
- Ensured native module rebuilds (better-sqlite3, node-pty) succeed on Windows runners
- Fixed TypeScript build errors to restore clean compilation across all platforms
- Use full agent path (claude.exe) on Windows to avoid shell:true
  which breaks stdin piping for stream-json input mode
- Fix SSH condition to check enabled flag, not just config existence
- Pass sessionSshRemoteConfig through inline wizard to enable remote execution
- Add synopsis SSH inheritance from parent session as backend workaround

Fixes local wizard crashing with exit code 1 and SSH sessions
incorrectly using local paths when SSH was disabled.
@chr1syy chr1syy force-pushed the fix-win-ssh-remote branch from 3d77404 to e5ecacc Compare January 26, 2026 18:52
Copy link
Owner

@pedramamini pedramamini left a comment

Choose a reason for hiding this comment

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

Thanks for this substantial PR to fix SSH remote execution on Windows! The core functionality looks solid, but there are several issues that need to be addressed before this can be merged.

Critical Issues

1. Duplicated debug logging block

In src/main/ipc/handlers/process.ts around lines 420-465, the SSH command debug logging block is duplicated verbatim twice in a row:

logger.debug(`SSH command details for debugging`, LOG_CONTEXT, { ... });
// ... exact same block repeated immediately after
logger.debug(`SSH command details for debugging`, LOG_CONTEXT, { ... });

Please remove the duplicate.

2. Duplicated availability check

In src/renderer/components/Wizard/services/conversationManager.ts around lines 1321-1367, the same if (!isRemoteSession && !agent.available) block appears twice back-to-back. Remove the duplicate.

3. Unused variable

In src/main/ipc/handlers/process.ts:321:

const shouldSendPromptViaStdin = false;

This variable is never modified and always false. Either remove it or implement the logic it was intended for.

Code Quality Issues

4. Excessive console.log statements

Several files have raw console.log statements that should be removed or converted to the proper debug logger:

  • src/renderer/hooks/git/useFileTreeManagement.ts has 5 debug logs
  • src/renderer/components/Wizard/services/conversationManager.ts has several
  • src/renderer/services/inlineWizardConversation.ts

5. Inconsistent indentation

Multiple files have mixed 2-space and 4-space indentation (e.g., ssh-command-builder.ts, DirectorySelectionScreen.tsx, conversationManager.ts). Please run the linter to normalize.

6. Empty blank line in workflow file

.github/workflows/release.yml adds an empty blank line at line 9 that serves no purpose - please remove.

Architectural Concerns

7. Backend workaround for frontend state issue

In src/main/ipc/handlers/process.ts:352-373, the comment explicitly states this is a workaround:

// Synopsis SSH Fix: If this is a synopsis session and it's missing SSH config,
// try to inherit it from the parent session. This is a backend workaround for
// a suspected frontend state issue where the remote config isn't passed.

Please either fix this properly in the frontend, or create an issue to track fixing it and add a // TODO(#issue-number) comment.

8. Shell portability concern

The change from $SHELL -ilc to hardcoded bash -lc with explicit profile sourcing may break for users with zsh or fish as their default shell. The original $SHELL approach was more portable. Please consider:

  • Reverting to use $SHELL
  • Or documenting this as a known limitation
  • Or adding logic to detect the remote shell

Once these are addressed, please ensure all tests pass and linting is clean (PR mentions 2 remaining lint errors). Looking forward to the updated version!

- Ensure prompts for remote SSH agents are sent via stdin as JSON in stream-json mode, fixing agent crashes with large prompts
- Always run background synopsis (history tab) on the correct remote host by propagating SSH config from the main session
- Improve wizard error handling: treat nonzero agent exit codes as success if output parses as a valid response, preventing false error states in confidence-building chat
- General reliability improvements for remote agent session management and output parsing
… remote git IPC handlers

- Ensure remoteCwd is set for all remote git operations (isRepo, status, diff, branch, remote, numstat, tags, branches, info)
- Resolves warning about missing remote working directory
- Enables correct git repo detection and status for remote directories in wizard and agent flows
@chr1syy
Copy link
Author

chr1syy commented Jan 27, 2026

Thank you for the code review, here's the updated code to address those issues.

Critical Issues

  1. Duplicated debug logging block

Duplications removed.

  1. Duplicated availability check

Duplication removed.

  1. Unused variable

Using StdIn is valued correctly, unused artifacts removed.

Code Quality Issues

  1. Excessive console.log statements

Correct logger used where necessary, removed excessive console.log and console.debug.

  1. Inconsistent indentation

Files normalized, Whitespace errors are fixed

  1. Empty blank line in workflow file

removed

Architectural Concerns

  1. Backend workaround for frontend state issue

Synopsize handles SSH-State correctly without using a Backend-Workaround now.

  1. Shell portability concern

Reverted back to using $SHELL with profile/PATH sourcing for different remote shells.

Also fixed now:
Remote Git discovery. Folders are correctly discovered as git repos now, changes and branches are shown correctly.

Tests & Linting

No Errors remaining.

@chr1syy chr1syy requested a review from pedramamini January 27, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RC Getting soak time in RC branch now

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants