# assistant_slash_commands: Fix AI text thread path display bugs on Windows and all platforms \(\#41880\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/54c4302cdb2c362ec578f447209e505b9af47eeb)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 54c4302cdb2c362ec578f447209e505b9af47eeb

Requested commit: 54c4302cdb2c362ec578f447209e505b9af47eeb

Commit: 54c4302cdb2c362ec578f447209e505b9af47eeb

Tree: 48f7cfcc14fc260c2bdc0e667ba1a736ce3b953f

Author: Lay Sheth

Committer: GitHub

## Message

```
assistant_slash_commands: Fix AI text thread path display bugs on Windows and all platforms (#41880)

## Fix incorrect directory path folding in slash command file collection

**Description:**
This PR fixes a bug in the `collect_files` function where the directory
folding logic (used to compact chains like `.github/workflows`) failed
to reset its state when traversing out of a folded branch.

**The Issue:**
The `folded_directory_names` accumulator was persisting across loop
iterations. If the traversal moved from a folded directory (e.g.,
`.github/workflows`) to a sibling directory (e.g., `.zed`), the sibling
would incorrectly inherit the prefix of the previously folded path,
resulting in incorrect paths like `.github/.zed`.

**The Fix:**
* Introduced `folded_directory_path` to track the specific path
currently being folded.
* Added a check to reset `folded_directory_names` whenever the traversal
encounters an entry that is not a child of the currently folded path.
* Ensured state is cleared immediately after a folded directory is
rendered.

**Release Notes:**
- Fixed an issue where using slash commands to collect files would
sometimes display incorrect directory paths (e.g., showing
`.github/.zed` instead of `.zed`) when adjacent directories were
automatically folded.

---------

Co-authored-by: Lukas Wirth <lukas@zed.dev>
```

## Parents

- [3db2d03bb3cfc4ad8acaa2d644519d2470599d7f](https://git.cafe/gitcafe/zed/commit/3db2d03bb3cfc4ad8acaa2d644519d2470599d7f?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/54c4302cdb2c362ec578f447209e505b9af47eeb?format=markdown)
