Background agent Ctrl+S resolves to wrong directory when sibling directory is a prefix match

Open 💬 0 comments Opened Jun 8, 2026 by gleotescu1

When a background agent is launched from a directory whose name has a sibling that is a strict prefix of it, pressing Ctrl+S in the Agent view navigates to the shorter sibling instead of the correct working directory.

Steps to reproduce

  1. Have two sibling directories where one name is a prefix of the other, e.g.:

``
/home/user/projects/app
/home/user/projects/app_dashboard
``

  1. cd /home/user/projects/app_dashboard
  2. claude --bg
  3. Open the Agent view in the UI
  4. Press Ctrl+S

Expected

Ctrl+S targets /home/user/projects/app_dashboard (the directory the agent was launched from).

Actual

Ctrl+S targets /home/user/projects/app (the shorter prefix-matching sibling).

Notes

  • The agent's actual working directory is correct — pwd inside the session returns the right path, and the Agent view header also shows the correct path.
  • The issue is only in the Ctrl+S path resolution.
  • Likely cause: the path lookup uses a prefix or fuzzy match and returns the first/shortest hit rather than requiring an exact match.

View original on GitHub ↗