Skip to content

Conversation

@exitcode0
Copy link
Contributor

Summary

Track the current working directory in module-level state so that creating a new chat uses the user's most recent directory choice, not the original directory from window creation

hard refresh (command + shift + R) still causes a reset to the original directory

Type of Change

  • Feature
  • Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

These changes were tested manually by running the application locally using just run-ui

Related Issues

Relates to #ISSUE_ID
Discussion: LINK (if any)

Screenshots/Demos (for UX changes)

Before:

After:

Track the current working directory in module-level state so that
creating a new chat uses the user's most recent directory choice,
not the original directory from window creation.

Known limitation: hard refresh resets to the original directory.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 28, 2026 23:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where creating a new chat window would use the original working directory from window creation instead of the user's most recent directory choice. The fix introduces module-level state to track the current working directory, which is updated when users change directories and consulted when creating new sessions.

Changes:

  • Added module-level state tracking for the current working directory
  • Modified getInitialWorkingDir() to return the tracked directory when available
  • Integrated directory tracking into the DirSwitcher component

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
ui/desktop/src/utils/workingDir.ts Added module-level state and setter function to track current working directory; modified getInitialWorkingDir() to prioritize tracked state
ui/desktop/src/components/bottom_menu/DirSwitcher.tsx Imported and called setCurrentWorkingDir() when user selects a new directory to update module state

const newDir = result.filePaths[0];

window.electron.addRecentDir(newDir);
setCurrentWorkingDir(newDir);
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The Hub component (ui/desktop/src/components/Hub.tsx:40) maintains its own workingDir state initialized from getInitialWorkingDir(). When a user changes the directory in the Hub view, the module-level state is updated, but Hub's local state is not. This means if a user changes the directory while in Hub view, then creates a new chat, the new chat will get the updated directory from getInitialWorkingDir(), but Hub's ChatInput will still display the old directory. Consider calling onWorkingDirChange?.(newDir) unconditionally before the if (sessionId) check to ensure all components stay in sync.

Copilot uses AI. Check for mistakes.
@zanesq zanesq self-assigned this Jan 28, 2026
Copy link
Collaborator

@zanesq zanesq left a comment

Choose a reason for hiding this comment

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

Thanks this works for now but eventually we will need to move it to something more global for the refresh case.

@zanesq zanesq merged commit 9f586cb into block:main Jan 30, 2026
23 checks passed
zanesq added a commit that referenced this pull request Jan 30, 2026
* 'main' of github.com:block/goose:
  fix(ui): preserve working directory when creating new chat (#6789)
  blog: add 5 tips for building MCP Apps that work (#6855)
  docs: session isolation (#6846)
lifeizhou-ap added a commit that referenced this pull request Feb 2, 2026
* main:
  fix: fixed the broken release (#6887)
  feat: Streamable HTTP transport for ACP + goose-acp usage (#6741)
  Add Laminar for Observability (#6514)
  Missed a couple of places that hard code J for the newline key (#6853)
  fix(ui): preserve working directory when creating new chat (#6789)
  blog: add 5 tips for building MCP Apps that work (#6855)
  docs: session isolation (#6846)
  upgrade react and electron to latest (#6845)
  Fix: Small update UI settings prompt injection (#6830)
  Remove autogenerated .gooseignore files that don't belong in repo (#6824)
  Fix case-insensitive matching for builtin extension names (#6825)
  docs: cli newline keybinding (#6823)
  Update version to 1.22.0 (#6821)
  Refactor: move persisting extension to session outside of route (#6685)
  acp: load configured extensions and refactor tests (#6803)
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.

2 participants