Skip to content

goose2 session working dir#8624

Merged
baxen merged 7 commits intomainfrom
lifei/goose2-working-dir
Apr 17, 2026
Merged

goose2 session working dir#8624
baxen merged 7 commits intomainfrom
lifei/goose2-working-dir

Conversation

@lifeizhou-ap
Copy link
Copy Markdown
Collaborator

@lifeizhou-ap lifeizhou-ap commented Apr 17, 2026

Summary

This PR cleans up ui/goose2 ACP session working directory handling.

Changes

  • Renamed path-related variables and state so their purpose is clearer.

  • Introduced sessionCwdSelection.ts to centralize ACP session working directory resolution.

  • Added a Tauri-backed path resolver so path joining and ~ expansion are centralized instead of built ad hoc in ts.

  • Cleaned up the ACP boundary so acpPrepareSession now requires a real workingDir.

Discussion

I intentionally kept the Tauri backend thin in this PR. The backend only handles low-level path resolution, while frontend still decides which path should be used for the ACP session working directory. This gives us one place for OS-specific path handling like joining segments and expanding ~, without moving app concept (eg project) into the Tauri backend.

I also thought about pushing more of this into goose serve or even Goose core. But it becomes a bigger design question, we need to decide whether Goose core should know about project-related concepts , and if so, how the domain like project, workspace, artifact root, and session working directory should be represented (eg domain design)

Testing

Related Issues

Relates to #ISSUE_ID
Discussion: LINK (if any)

Screenshots/Demos (for UX changes)

Before:

After:

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9cd0731ad8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +243 to +246
const workingDir = await resolveSessionCwd(
nextProject,
activeWorkspace?.path,
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Ignore stale workspace path when switching projects

handleProjectChange resolves the next session cwd using activeWorkspace?.path, but this value still points to the previous project's worktree at the moment the project is changed. Because resolveSessionCwd prioritizes activeWorkspacePath, ACP can be re-prepared with the old project directory before clearActiveWorkspace runs, so messages may continue executing in the wrong filesystem location (especially when no model is selected, since useChat may skip a later re-prepare). Resolve cwd from nextProject alone (or clear workspace first) during project switches.

Useful? React with 👍 / 👎.

@lifeizhou-ap lifeizhou-ap changed the title Lifei/goose2 working dir goose2 session working dir Apr 17, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d09464cab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

export async function defaultGlobalArtifactRoot(): Promise<string> {
return (await resolvePath({ parts: ["~", ".goose", "artifacts"] })).path;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize global artifact root separators

defaultGlobalArtifactRoot now returns the Tauri-resolved path verbatim, which is backslash-separated on Windows. Downstream artifact-policy logic still assumes /-separated roots (for example homeArtifactsRootFromRoots and stripRootArtifactsSegment in ArtifactPolicyContext), so Windows users can lose home-artifact root detection and fallback artifact link resolution/open behavior. Normalize this returned root (or normalize roots before policy checks) to keep path matching consistent across platforms.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

@baxen baxen left a comment

Choose a reason for hiding this comment

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

This looks good directionally. A few followups around the default path and artifact dir conventions but i plan to just send a followup PR instead - i think we can merge this one!

@baxen baxen added this pull request to the merge queue Apr 17, 2026
Merged via the queue into main with commit 2533765 Apr 17, 2026
25 checks passed
@baxen baxen deleted the lifei/goose2-working-dir branch April 17, 2026 19:04
@jamadeo
Copy link
Copy Markdown
Member

jamadeo commented Apr 17, 2026

Yes I think this is the right way to do this. An alternative would be https://v2.tauri.app/plugin/file-system/. As for goose core, I think we'll want to settle on how projects should be implemented before we'd move it into there

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.

3 participants