fix: Auto Run docs directory resolves to worktree path (#584)#589
fix: Auto Run docs directory resolves to worktree path (#584)#589jSydorowicz21 wants to merge 7 commits intoRunMaestro:rcfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughCopies queued Auto Run documents from a parent session into a worktree's Auto Run folder when dispatching batch runs to a different session, rebases worktree autoRunFolderPath onto the worktree root when needed, and adds cross-platform path utilities plus expanded tests for resolution and containment logic. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Active as Active Session (parent)
participant Handler as useAutoRunHandlers
participant FS as File System
participant Worktree as Worktree Session
participant Batch as Batch Processor
User->>Handler: Trigger batch run (target session)
activate Handler
alt target ≠ active
Handler->>Active: Read queued docs from parent autoRunFolderPath
Active->>FS: Read files
FS-->>Handler: File contents
Handler->>Worktree: Write files into worktree autoRunFolderPath
Worktree->>FS: Write files
FS-->>Handler: Write results
Handler->>Handler: Set folderPath = worktree autoRunFolderPath
else target = active
Handler->>Handler: Use activeSession.autoRunFolderPath
end
Handler->>Batch: startBatchRun(folderPath)
Batch->>FS: Process files at folderPath
FS-->>Batch: Execution results
deactivate Handler
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a bug where worktree sessions inherited their parent's Key issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User (Parent Session)
participant H as handleStartBatchRun
participant WT as buildWorktreeSession
participant FS as Filesystem (autorun.readDoc/writeDoc)
participant BP as startBatchRun
U->>H: dispatch with worktreeTarget
alt create-new / existing-closed
H->>WT: spawnWorktreeAgentAndDispatch()
WT->>WT: resolveWorktreeAutoRunPath(parentPath, parentCwd, worktreeCwd)
WT-->>H: newSessionId (session stored with own autoRunFolderPath)
else existing-open
H->>H: find targetSession in store
end
H->>H: folderPath = activeSession.autoRunFolderPath
alt targetSession.autoRunFolderPath ≠ folderPath
loop each queued document
H->>FS: readDoc(parentFolder, doc.md)
FS-->>H: content
H->>FS: writeDoc(worktreeFolder, doc.md, content)
end
H->>H: folderPath = worktreeFolder
end
H->>BP: startBatchRun(targetSessionId, config, folderPath)
note over U,BP: On app restore, useSessionRestoration migrates\nstale worktree autoRunFolderPath → projectRoot/AUTO_RUN_FOLDER_NAME
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/renderer/utils/worktreeSession.ts`:
- Around line 43-55: isPathUnderRoot currently detects Windows by testing only
filePath which misclassifies cases where root is a Windows absolute path and
filePath is relative; update the platform detection in isPathUnderRoot to test
both filePath and root (e.g., check for a drive-letter pattern on either input),
then use the resulting isWin branch when comparing normalizedFile and
normalizedRoot (perform case-insensitive comparisons when isWin is true and
preserve the existing prefix logic using normalizedRoot). Ensure you reference
the existing symbols normalizedFile, normalizedRoot, prefix, and isWin when
making the change so comparisons and startsWith checks behave correctly for
Windows roots.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 659812ca-0e85-4b6d-bae6-1b5501fb726c
📒 Files selected for processing (6)
src/__tests__/renderer/hooks/batch/useAutoRunHandlers.worktree.test.tssrc/__tests__/renderer/utils/worktreeSession.test.tssrc/renderer/hooks/batch/useAutoRunHandlers.tssrc/renderer/hooks/batch/useBatchProcessor.tssrc/renderer/hooks/session/useSessionRestoration.tssrc/renderer/utils/worktreeSession.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/renderer/utils/worktreeSession.ts`:
- Around line 77-80: The bug is caused by slicing parentAutoRunPath using
normalizedParentCwd that may include or exclude a trailing separator; update the
logic in worktreeSession.ts to normalize the parent CWD consistently before
slicing: compute a canonical parent prefix (using normSep) that either always
ends with the path separator or always has the trailing separator removed, then
derive relativePart by removing that canonical prefix from normalized
(parentAutoRunPath); finally build result via joining normSep(worktreeCwd) and
the relativePart with a separator (or use a safe join) so symbols to edit are
normalizedParentCwd, normalized, relativePart, result and the helper
normSep/worktreeCwd/parentAutoRunPath.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9e19b0df-2171-4108-824d-9b59ad5c1b68
📒 Files selected for processing (2)
src/renderer/hooks/batch/useAutoRunHandlers.tssrc/renderer/utils/worktreeSession.ts
|
This one needs some test time so I'm going to retarget RC so it can have some time to bake |
acf1bbe to
de9f022
Compare
buildWorktreeSession() previously copied the parent session's autoRunFolderPath verbatim, causing worktree sessions to use the parent repo's Auto Run folder instead of their own. Added resolveWorktreeAutoRunPath() that rebases absolute paths under the parent cwd onto the worktree cwd, keeps relative and external absolute paths unchanged, and handles Windows backslash separators.
When dispatching a batch run to a worktree session, look up the target session's autoRunFolderPath (resolved relative to its cwd) instead of always using the parent/active session's path. Falls back to the active session's path if the target doesn't have one set. Also verified useAutoRunDocumentLoader.ts - it already uses the active session's own autoRunFolderPath via selectActiveSession, so it's correct after the worktreeSession.ts fix. Fixes RunMaestro#584
…ndently Confirmed that handleAutoRunFolderSelected already stores the selected folder path directly on the active session with no parent-session resolution logic. Added clarifying comment documenting this behavior for worktree sessions.
…o#584) Worktree sessions now resolve their Auto Run folder path relative to their own working directory instead of inheriting the parent repo's absolute path. Batch run dispatch also now uses the target session's resolved path. Changes in this commit: - Add case-insensitive path comparison for Windows in resolveWorktreeAutoRunPath to handle mixed-case drive letters - Update stale comment in useBatchProcessor.ts to reflect that folderPath may come from the target worktree session - Add edge case tests: empty string path, path-equals-cwd, and case-insensitive Windows matching
…isPathUnderRoot helper - Extract shared `isPathUnderRoot()` and `normSep()` into worktreeSession.ts - Copy-on-dispatch: when dispatching from parent to worktree, copy only the queued docs to the worktree's Auto Run folder via Promise.all - Show toast on partial copy failure so users know if docs are missing - Add session restoration migration for pre-existing worktree sessions whose autoRunFolderPath still points at the parent directory - Platform-aware: Windows case-insensitive, Unix case-sensitive comparison - Add 6 direct unit tests for isPathUnderRoot, update dispatch test
…gs for Windows detection - Log warning when readDoc returns success:false so "Check logs" toast is useful - Check both filePath and root for drive letter in isPathUnderRoot
de9f022 to
55d867b
Compare
Summary
autoRunFolderPathto their own directory instead of inheriting the parent's path verbatimAuto Run Docs/folder so subsequent runs find them locallyChanges
worktreeSession.tsisPathUnderRoot()helper +normSep(), use inresolveWorktreeAutoRunPathuseAutoRunHandlers.tsPromise.all. Toast on partial failureuseSessionRestoration.tsautoRunFolderPathpoints at parentuseBatchProcessor.tsworktreeSession.test.tsisPathUnderRoot, 1 Unix case-sensitivity forbuildWorktreeSessionuseAutoRunHandlers.worktree.test.tsTest plan
Auto Run Docs/autoRunFolderPathshould migrate to worktree's directorygit worktree add) is discovered with correct pathcloses #584
Summary by CodeRabbit
Improvements
Tests