Skip to content

[RFC] Add worktree-aware directory switcher - #8450

Merged
DOsinga merged 6 commits into
aaif-goose:mainfrom
vincenzopalazzo:feature/chat-search-rework
May 12, 2026
Merged

[RFC] Add worktree-aware directory switcher#8450
DOsinga merged 6 commits into
aaif-goose:mainfrom
vincenzopalazzo:feature/chat-search-rework

Conversation

@vincenzopalazzo

@vincenzopalazzo vincenzopalazzo commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a worktree-aware directory switcher to the desktop chat input bottom bar
  • replace the old click-to-open-directory-picker behavior with a dropdown menu
  • show the current directory, detected Git worktrees for the active repo, and recent directories
  • keep quick actions for choosing another directory and opening the current directory in the system file manager
  • expose Electron APIs for recent directories and Git worktree discovery
  • add i18n strings for the new directory switcher UI

Why

Working on multiple branches and tasks at the same time is much smoother when each task lives in its own Git worktree. Right now, switching the Goose desktop app between those worktrees is slower than it needs to be because the only path is reopening a directory picker or creating separate windows manually.

This RFC proposes a lightweight in-app worktree toggle so users can jump between related worktrees directly from the chat input, similar to the workflow Claude supports. The goal is to make parallel task switching faster and more discoverable without changing the broader session model.

Test plan

  • source bin/activate-hermit && cd ui/desktop && pnpm run typecheck
  • source bin/activate-hermit && cd ui/desktop && pnpm run lint:check

@vincenzopalazzo
vincenzopalazzo force-pushed the feature/chat-search-rework branch from e27dc7c to 038910b Compare April 9, 2026 18:21

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

Copy link
Copy Markdown

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: e27dc7c6f9

ℹ️ 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 thread ui/desktop/src/components/conversation/ChatHistorySearch.tsx Outdated
Comment thread ui/desktop/src/components/conversation/ChatHistorySearch.tsx Outdated
@vincenzopalazzo
vincenzopalazzo force-pushed the feature/chat-search-rework branch from 038910b to a1928e8 Compare April 9, 2026 18:29

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

Copy link
Copy Markdown

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: 901ed0e99c

ℹ️ 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 thread ui/desktop/src/components/conversation/ChatHistorySearch.tsx Outdated
Comment thread ui/desktop/src/components/conversation/ChatHistorySearch.tsx Outdated
@vincenzopalazzo
vincenzopalazzo force-pushed the feature/chat-search-rework branch from 901ed0e to 452ed70 Compare April 9, 2026 19:17
@vincenzopalazzo vincenzopalazzo changed the title Honor Ollama timeout during streaming [RFC] Add worktree-aware directory switcher Apr 9, 2026

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

Copy link
Copy Markdown

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: 452ed708e0

ℹ️ 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 thread ui/desktop/src/components/bottom_menu/DirSwitcher.tsx
vincenzopalazzo and others added 3 commits April 16, 2026 00:49
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Add a version counter ref so that out-of-order IPC responses from
listRecentDirs/listGitWorktreeDirs are discarded when a newer refresh
has already been started.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: goose <goose@aaif.dev>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@vincenzopalazzo
vincenzopalazzo force-pushed the feature/chat-search-rework branch from 39ac580 to 68bf21e Compare April 15, 2026 22:59

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

Copy link
Copy Markdown

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: 68bf21e9a1

ℹ️ 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 +85 to +90
useEffect(() => {
if (!isMenuOpen) {
return;
}

const newDir = result.filePaths[0];
void refreshMenuData();

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 Clear stale worktree options when opening the switcher

worktreeDirs is rendered immediately from component state, but this effect only refreshes data asynchronously after the menu opens and does nothing while closed. If workingDir changes between openings, the previous repo’s worktree entries remain visible and clickable until refreshMenuData() finishes, so a fast click can switch the user to an unrelated directory. Reset or hide worktree options until the fetch for the current workingDir completes.

Useful? React with 👍 / 👎.

Co-authored-by: goose <goose@aaif.dev>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity for 23 days.

What happens next?

  • If no further activity occurs, this PR will be automatically closed in 7 days
  • To keep this PR active, simply add a comment, push new commits, or add the keep-open label
  • If you believe this PR was marked as stale in error, please comment and we'll review it

Thank you for your contribution! 🚀

@github-actions github-actions Bot added the stale label May 9, 2026
Douwe Osinga added 2 commits May 12, 2026 13:46
…ework

Signed-off-by: Douwe Osinga <douwe@squareup.com>

# Conflicts:
#	crates/goose/src/providers/chatgpt_codex.rs
#	crates/goose/src/providers/init.rs
#	ui/desktop/src/i18n/messages/en.json
Addresses Codex review comment: when workingDir changes between menu
openings, previous entries were briefly visible until the async refresh
completed. Now we clear state immediately before fetching.

Signed-off-by: Douwe Osinga <douwe@squareup.com>
@DOsinga

DOsinga commented May 12, 2026

Copy link
Copy Markdown
Collaborator

I merged origin/main into the branch to resolve the stale Rust commits (the ChatGPT Codex OAuth fix was already merged via #8569 — those commits were producing merge conflicts).

I also addressed the remaining Codex review comment about stale worktree/recent entries being visible when the menu opens after a workingDir change: refreshMenuData now clears both recentDirs and worktreeDirs immediately before fetching, so users never see entries from a previous directory.

All checks pass: cargo clippy, cargo build, pnpm lint, and pnpm typecheck are clean.

@DOsinga DOsinga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM — the worktree-aware directory switcher is well-implemented, uses existing patterns (dropdown-menu component, i18n, loadRecentDirs), and the stale-state issues from Codex review are now addressed.

@DOsinga

DOsinga commented May 12, 2026

Copy link
Copy Markdown
Collaborator

One thing: commit 45d912fddf8 ("fix: guard against stale directory list responses in DirSwitcher") is missing the DCO sign-off. Please amend it with git commit --amend -s and force-push so the DCO check passes.

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

Copy link
Copy Markdown

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: 69beb34713

ℹ️ 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".

}

const newDir = result.filePaths[0];
void refreshMenuData();

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 Reset directory lists before opening the dropdown

The menu can render stale worktreeDirs/recentDirs for one frame when reopened because the reset/fetch is deferred to useEffect after isMenuOpen becomes true. If workingDir changed while closed (or an earlier fetch completed after close), users briefly see and can select entries from the previous repo before refreshMenuData() clears them, which can switch to the wrong directory. Clear/hide menu data synchronously in the onOpenChange open path (or invalidate on close) so stale items are never interactive.

Useful? React with 👍 / 👎.

@DOsinga
DOsinga added this pull request to the merge queue May 12, 2026
Merged via the queue into aaif-goose:main with commit 2c8d7f1 May 12, 2026
21 checks passed
shafqatevo pushed a commit to shafqatevo/goose that referenced this pull request Aug 7, 2026
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: goose <goose@aaif.dev>
Co-authored-by: Douwe Osinga <douwe@squareup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants