fix: stop duplicating directory lines in the reverse-prompt file tree - #145
Open
eeshsaxena wants to merge 3 commits into
Open
fix: stop duplicating directory lines in the reverse-prompt file tree#145eeshsaxena wants to merge 3 commits into
eeshsaxena wants to merge 3 commits into
Conversation
treeToString printed every non-root node twice: once from the parent's child loop and again from the node's own `if (!isRoot)` block on recursion. The second copy also used the child-continuation prefix, so nested directories rendered as e.g. `| util/` right after the correct `|-- util/` line. app/api/reverse-prompt feeds this tree into the LLM prompt, so the doubled listing degrades the generated prompt. Remove the redundant self-print; every node is now emitted once by its parent's loop.
|
@eeshsaxena is attempting to deploy a commit to the filiksyos' projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Author
|
@filiksyos the only red check here is the Vercel preview deploy, which is waiting on a team member to authorize it (Vercel requires that for PRs from outside forks). The GitGuardian security check passes. Could you authorize the deploy when you get a chance? The change itself is a small 4-line fix that stops the reverse-prompt file tree from printing each directory twice. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
treeToStringinlib/file-tree-formatter.tsprints every directory twice.Each node is emitted once by its parent's child loop:
and then again at the top of its own recursive call:
The second copy uses the child-continuation prefix rather than the branch connector, so a nested directory also shows up as a stray
│ util/line right after the correct├── util/one.For example, given:
the current output is:
app/api/reverse-prompt/route.tsbuilds the repo tree withformatAsFilteredTree, which runs throughtreeToString, so the doubled listing goes straight into the prompt sent to the model.Removing the redundant
if (!isRoot)self-print fixes it. Every node is already printed once by its parent's loop, so each entry now appears exactly once:Files are unaffected since they never recurse, and the root level is unchanged.