* fix: use dynamic merge-base for git commits to filter main branch commits
When a feature branch is rebased on main, the stored base_commit_sha
becomes outdated. Using git log base_commit..HEAD would include main
branch commits that were merged after the stored base commit.
This fix adds dynamic merge-base calculation using the session's
base_branch (target branch like origin/main). When fetching commits:
- The backend computes git merge-base HEAD target_branch
- This returns only commits not yet merged into the target branch
- Works correctly even after rebases
Changes:
- Extended SessionReader interface with GetSessionBaseBranch method
- Added GetMergeBase to GitOperator for computing merge-base
- Updated git log API to accept target_branch parameter
- Modified wsGitCommits handler to pass target branch for filtering
* fix: update executor_test mock to match new GetGitLog signature
* fix: update remaining mocks to match new GetGitLog signature
* fix: update integration test mock for GetGitLog signature
* fix: address code review feedback
- Use GetOrEnsureExecution in wsGitCommits to recover workspaces after backend restarts
- Fix archive snapshot to use baseBranch for merge-base when baseCommit is empty
- Extended ExecutionLookup interface with GetOrEnsureExecution method
* fix: distinguish not-ready errors from unexpected errors in wsGitCommits
Address CodeRabbit review feedback:
- Use errors.Is() to detect ErrSessionWorkspaceNotReady sentinel error
- Return ready:false gracefully for workspace-not-ready and session-not-ready errors
- Return actual errors for unexpected failures (database errors, etc.)
- Add comprehensive tests for error handling paths
* feat(mcp): add start_agent and local_path params to create_task
Add control over task creation behavior in MCP create_task tool:
- Add start_agent boolean param (default true) to optionally skip
auto-starting an agent when creating tasks
- Add local_path param for specifying local repository folder path
when creating top-level tasks (worktree flow)
- Add repository_id and base_branch params for explicit repo config
- Improve tool description with clear guidance on when to use
parent_id='self' vs creating top-level tasks
- Update backend handler to respect start_agent flag
- Relax description requirement for subtasks when start_agent=false
This fixes the issue where agents creating tasks from plans would
always auto-start immediately and couldn't specify repositories
for top-level tasks.
* test(mcp): add integration tests for source_task_id inheritance paths
Cover the source-task path in resolveTaskRepositories that had no test
coverage at any layer: valid source_task_id inherits repos and missing
source_task_id silently falls through rather than failing.
Co-authored-by: João Salavisa <undefined@users.noreply.github.com>
---------
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: João Salavisa <undefined@users.noreply.github.com>
* fix(worktree): handle submodules in worktree creation
Repos with git submodules failed during worktree creation when git-crypt
was also present. The `git checkout HEAD -- .` command in
unlockGitCryptAndCheckout() tried to process submodule gitlink entries,
but git resolved their git dirs relative to the worktree-specific git
dir instead of the common dir, causing "not a git repository" errors.
- Detect submodule paths via `git ls-tree -r HEAD` (mode 160000)
- Exclude submodule paths from git-crypt checkout using :(exclude) pathspecs
- Initialize submodules after worktree creation via `git submodule update --init`
(non-fatal — unreachable URLs are logged as warnings)
- Add submodule init to all worktree creation paths (git-crypt and non-git-crypt)
* fix(worktree): address review — recursive submodule init, consistent call sites
- Add --recursive to git submodule update --init for nested submodules
- Call initSubmodules unconditionally in git-crypt path (matching manager.go)
* fix(worktree): restore submodule index entries after git-crypt checkout
The :(exclude) pathspec used to skip submodules during git checkout also
prevents their gitlink entries from being written to the index. This
leaves git status showing them as staged deletions.
After checkout, run git reset HEAD for each excluded submodule path to
copy the gitlink entry from HEAD back into the index.
* test(worktree): add git status assertion to submodule unlock test
Validate that the index reset after :(exclude) checkout leaves no
staged deletions for submodule paths.
* fix(worktree): use literal pathspec for submodule exclusion
Use :(literal,exclude) instead of :(exclude) to prevent glob
metacharacters in submodule paths from being interpreted as patterns.
* fix(worktree): fix initSubmodules docstring to match --recursive flag
When creating a worktree from a remote-tracking ref (e.g. origin/feature/foo),
git automatically sets the new branch's upstream to that ref. This caused new
task branches to incorrectly track the original remote branch instead of
starting with no upstream.
Add -c branch.autoSetupMerge=false to gitAddWorktree and
gitAddWorktreeWithGitCrypt. The explicit CheckoutBranch flow (PR reviews)
is unaffected — it sets upstream via setUpstreamIfExists after creation.
* fix(github): reliable PR-task association across all launch paths
Three bugs caused inconsistent PR detection for agent-opened PRs:
- StartCreatedSession never called ensureSessionPRWatch
- Push detection bailed out when a pr_number=0 watch existed
- PR watch branch was never updated after agent branch switches
* fix: extract searchPRForExistingWatch to reduce nesting depth
* fix: address review feedback and fix e2e test timeouts
- Fix UNIQUE constraint error when associatePRFromPush was called with
an existing watch (update pr_number instead of creating new watch)
- Add UpdatePRWatchPRNumber to GitHubService interface
- Fix e2e test timeouts: increase budget to 180s, remove unnecessary
clickTab("Changes"), replace 35s hard wait with polling assertion
* fix(e2e): accept both /t/ and /s/ URL patterns in PR detection tests
Task cards in the Done column navigate to /t/<task-id> (task view),
not /s/<session-id> (session view). The toHaveURL assertion must
accept both URL patterns.