mirror of
https://github.com/jlengrand/Maestro.git
synced 2026-03-10 08:31:19 +00:00
MAESTRO: Wire up SSH context to worktree batch processing hooks
- Added sshRemoteId parameter to useWorktreeValidation deps interface - Updated worktreeInfo() and getRepoRoot() calls to pass SSH context - Added sshRemoteId to WorktreeConfig interface in useWorktreeManager - Updated worktreeSetup() and worktreeCheckout() to use sshRemoteId - Modified useBatchProcessor to inject session.sshRemoteId into worktree config This ensures batch processing worktree operations work correctly on remote SSH sessions, completing the SSH remote support implementation. All 12 existing worktree validation tests pass.
This commit is contained in:
@@ -401,7 +401,9 @@ export function useBatchProcessor({
|
||||
delete errorResolutionRefs.current[sessionId];
|
||||
|
||||
// Set up worktree if enabled using extracted hook
|
||||
const worktreeResult = await worktreeManager.setupWorktree(session.cwd, worktree);
|
||||
// Inject sshRemoteId from session into worktree config for remote worktree operations
|
||||
const worktreeWithSsh = worktree ? { ...worktree, sshRemoteId: session.sshRemoteId } : undefined;
|
||||
const worktreeResult = await worktreeManager.setupWorktree(session.cwd, worktreeWithSsh);
|
||||
if (!worktreeResult.success) {
|
||||
window.maestro.logger.log('error', 'Worktree setup failed', 'BatchProcessor', { sessionId, error: worktreeResult.error });
|
||||
return;
|
||||
|
||||
@@ -26,6 +26,8 @@ export interface WorktreeConfig {
|
||||
prTargetBranch?: string;
|
||||
/** Path to gh CLI binary (if not in PATH) */
|
||||
ghPath?: string;
|
||||
/** SSH remote ID for remote sessions (optional) */
|
||||
sshRemoteId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +169,8 @@ ${docList}
|
||||
const setupResult = await window.maestro.git.worktreeSetup(
|
||||
sessionCwd,
|
||||
worktree.path,
|
||||
worktree.branchName
|
||||
worktree.branchName,
|
||||
worktree.sshRemoteId
|
||||
);
|
||||
|
||||
window.maestro.logger.log('info', 'worktreeSetup result', 'WorktreeManager', {
|
||||
@@ -205,7 +208,8 @@ ${docList}
|
||||
const checkoutResult = await window.maestro.git.worktreeCheckout(
|
||||
worktree.path,
|
||||
worktree.branchName,
|
||||
true // createIfMissing
|
||||
true, // createIfMissing
|
||||
worktree.sshRemoteId
|
||||
);
|
||||
|
||||
window.maestro.logger.log('info', 'worktreeCheckout result', 'WorktreeManager', {
|
||||
|
||||
@@ -38,6 +38,8 @@ export interface UseWorktreeValidationDeps {
|
||||
worktreeEnabled: boolean;
|
||||
/** The session's current working directory (main repo) */
|
||||
sessionCwd: string;
|
||||
/** SSH remote ID for remote sessions (optional) */
|
||||
sshRemoteId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +92,7 @@ export function useWorktreeValidation({
|
||||
branchName,
|
||||
worktreeEnabled,
|
||||
sessionCwd,
|
||||
sshRemoteId,
|
||||
}: UseWorktreeValidationDeps): UseWorktreeValidationReturn {
|
||||
const [validation, setValidation] = useState<WorktreeValidationState>(INITIAL_VALIDATION_STATE);
|
||||
|
||||
@@ -108,7 +111,7 @@ export function useWorktreeValidation({
|
||||
const timeoutId = setTimeout(async () => {
|
||||
try {
|
||||
// Check if the path exists and get worktree info
|
||||
const worktreeInfoResult = await window.maestro.git.worktreeInfo(worktreePath);
|
||||
const worktreeInfoResult = await window.maestro.git.worktreeInfo(worktreePath, sshRemoteId);
|
||||
|
||||
if (!worktreeInfoResult.success) {
|
||||
setValidation({
|
||||
@@ -138,7 +141,7 @@ export function useWorktreeValidation({
|
||||
|
||||
// Path exists - check if it's part of the same repo
|
||||
// If there's no repoRoot, the directory exists but isn't a git repo - that's fine for a new worktree
|
||||
const mainRepoRootResult = await window.maestro.git.getRepoRoot(sessionCwd);
|
||||
const mainRepoRootResult = await window.maestro.git.getRepoRoot(sessionCwd, sshRemoteId);
|
||||
const sameRepo =
|
||||
!worktreeInfoResult.repoRoot ||
|
||||
(mainRepoRootResult.success && worktreeInfoResult.repoRoot === mainRepoRootResult.root);
|
||||
@@ -190,7 +193,7 @@ export function useWorktreeValidation({
|
||||
|
||||
// Cleanup timeout on unmount or when dependencies change
|
||||
return () => clearTimeout(timeoutId);
|
||||
}, [worktreePath, branchName, worktreeEnabled, sessionCwd]);
|
||||
}, [worktreePath, branchName, worktreeEnabled, sessionCwd, sshRemoteId]);
|
||||
|
||||
return { validation };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user