Repository navigation
Conversation
…enclaw#98872) split(home) matched sibling directories whose name shares the home prefix (e.g. /home/alice2 when home is /home/alice), corrupting displayed paths to ~2/project. The fix only replaces home + "/" in the input string, and handles the exact home-directory case separately.
Contributor
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(utils): only shorten home dir when followed by path separator (#98872) This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Contributor
Author
|
Closing: #98876 fixes the correct location (packages/terminal-core/src/display-string.ts per ClawSweeper guidance). This PR fixed the wrong alias in src/utils.ts. |
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.
Fixes #98872.
What Problem This Solves
shortenHomeInStringusedsplit(home).join(prefix)to shorten home paths in display text. This matches any substring equal to the home directory — including sibling directories like/home/alice2when home is/home/alice. The rendered path becomes~2/projectinstead of/home/alice2/project.Why This Change Was Made
Changed the split to
split(home + "/")and added an exact-match case for the bare home directory. This ensures only the exact home directory or paths under it are shortened.User Impact
Path display in terminal tables and other
displayString/displayPathcontexts is correct for sibling directories. No user action needed.Evidence
Behavior addressed:
shortenHomeInStringcorrupts sibling paths whose name shares the home prefix.Real environment tested: Node 22.19+, local OpenClaw checkout.
Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: Sibling directories with names that share the home prefix are left unchanged. Paths under the home directory continue to be shortened correctly.
What was not tested: Full terminal table rendering end-to-end. The fix is verified through unit tests and direct function invocation.
Regression Test Plan
node scripts/run-vitest.mjs src/utils.test.ts --run— 18 passed (+1 sibling regression test)node scripts/run-oxlint.mjs src/utils.ts src/utils.test.ts— exit 0Root Cause
shortenHomeInStringline 159 usedinput.split(display.home).join(display.prefix)which replaces every occurrence of the home path string anywhere in the input. When home is/home/alice, the path/home/alice2/projectgets split into["", "2/project"]and joined as~2/project. The fix splits onhome + "/"so only the home directory followed by a path separator is matched.AI Assistance