Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: use correct working directory for monorepo subpaths#19

Merged
baxen merged 3 commits intomainfrom
baxen/cwd-fix
Feb 10, 2026
Merged

fix: use correct working directory for monorepo subpaths#19
baxen merged 3 commits intomainfrom
baxen/cwd-fix

Conversation

@baxen
Copy link
Collaborator

@baxen baxen commented Feb 10, 2026

Summary

Fix the agent's working directory when a project has a subpath set (monorepos). Previously, the agent was launched in the worktree root instead of the correct subdirectory.

Changes

Fix subpath handling (28bec4d)

  • Backend (start_branch_session): Look up the project's subpath and join it to the worktree path before passing as working_dir
  • Frontend (BranchCard → SessionModal): Pass projectSubpath through so that resume_session also uses the correct subpath-adjusted working directory

Consolidate working directory on the backend (bdd5a96)

  • Add working_dir column to sessions table (schema version 1 → 2)
  • Persist working_dir on session creation so resume_session reads it from the database instead of receiving it from the frontend
  • Remove frontend responsibility for computing effective working directories
  • Simplify frontend components: remove workingDir param from resumeSession(), remove projectSubpath pass-through from BranchCard/ProjectSection

Version bump (7327c88)

  • Bump app version to 0.3.0 for the schema break (v1 → v2)
  • Tag v0.2 on main as a rollback target for users with existing databases

Files changed

  • src-tauri/src/session_commands.rs — subpath join + working_dir plumbing
  • src-tauri/src/store/models.rs — add working_dir to Session
  • src-tauri/src/store/sessions.rs — schema migration, persist/read working_dir
  • src-tauri/src/store/mod.rs — schema version bump
  • src-tauri/src/store/tests.rs — updated tests
  • src/lib/commands.ts — remove workingDir from resumeSession
  • src/lib/*.svelte — simplify component props
  • package.json, Cargo.toml, tauri.conf.json — version 0.3.0
  • .github/workflows/staged-ci.yml — CI adjustments

baxen added 3 commits February 9, 2026 20:58
When a project has a subpath set (for monorepos), the agent's working
directory was incorrectly set to the worktree root instead of the
subdirectory within the worktree.

Fixed in two places:
- Backend (start_branch_session): Look up the project's subpath and
  join it to the worktree path before passing as working_dir
- Frontend (BranchCard → SessionModal): Pass projectSubpath from
  ProjectSection through BranchCard so that resume_session also uses
  the correct subpath-adjusted working directory
Store working_dir on the Session model so that resume_session can read
it from the database instead of receiving it from the frontend. This
consolidates the subpath logic in one place (the backend) and removes
the need for the frontend to compute effective working directories.

Backend changes:
- Add working_dir column to sessions table (schema version 1 → 2)
- Add working_dir field to Session struct, accepted in new_running()
- start_session and start_branch_session persist working_dir on create
- resume_session reads working_dir from the session record

Frontend changes:
- Remove workingDir param from resumeSession() in commands.ts
- Remove workingDir prop from SessionModal
- Remove projectSubpath prop and effectiveWorkingDir from BranchCard
- Remove projectSubpath pass-through from ProjectSection
- Remove workingDir="/tmp" from SessionLauncher
The schema version bump (1 → 2) in the previous commit introduces a
backwards-incompatible database change. Users whose database was created
under v0.2 will be prompted to reset it.

To give users a rollback path:
- Tag v0.2 on main at the last commit before the schema break
- Bump the app version to 0.3.0 so the compatibility dialog can say
  "v0.3 requires a database update — install v0.2 to go back"
@baxen baxen requested a review from wesbillman as a code owner February 10, 2026 06:00
@baxen baxen merged commit 87350bc into main Feb 10, 2026
1 of 2 checks passed
@baxen baxen deleted the baxen/cwd-fix branch February 10, 2026 06:02
loganj added a commit that referenced this pull request Feb 26, 2026
Refine selection and hover colors for consistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant