feat(ui): smarter path truncation to show package names over generic dirs
Summary
When paths are truncated for display, shortenPath() now keeps distinguishing segments (like package names) instead of generic parent directories (like packages). This makes truncated paths much more useful in monorepos where packages/.../file.ts could match multiple packages.
Details
Added a set of generic directory names (packages, apps, libs, src, node_modules, etc.) that are deprioritized when truncating paths. The algorithm now finds the first non-generic segment and uses that as the anchor point.
Before: packages/.../src/router/index.ts After: .../frontend/src/router/index.ts
Also updated unrelated SessionBrowser snapshots that were failing due to month rollover (10mo -> 11mo).
Related Issues
Fixes #13973
How to Validate
- Run npm run test -- packages/core/src/utils/paths.test.ts
- Check the new monorepo-specific tests pass
- Verify existing path truncation tests still pass
Pre-Merge Checklist
- [ ] Updated relevant documentation and README (if needed)
- [x] Added/updated tests (if needed)
- [ ] Noted breaking changes (if any)
- [x] Validated on required platforms/methods:
- [x] MacOS
- [x] npm run
- [ ] npx
- [ ] Docker
- [ ] Podman
- [ ] Seatbelt
- [ ] Windows
- [ ] npm run
- [ ] npx
- [ ] Docker
- [ ] Linux
- [ ] npm run
- [ ] npx
- [ ] Docker
- [x] MacOS
Summary of Changes
Hello @afarber, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a significant improvement to how file paths are truncated and displayed within the UI, particularly benefiting users working in monorepository environments. The core change focuses on making truncated paths more meaningful by intelligently preserving unique identifiers, such as package or application names, rather than generic directory structures. This ensures that even when paths are shortened, they retain critical context, enhancing user experience and navigation.
Highlights
- Smarter Path Truncation: The path truncation logic has been enhanced to prioritize displaying distinguishing segments (like package or app names) over generic directory names (e.g., 'packages', 'src') in monorepo structures, making truncated paths more informative.
- Monorepo-Specific Handling: A new set of generic directory names has been defined, and the truncation algorithm now identifies and anchors around the first non-generic segment, improving readability for monorepo paths.
- Snapshot Updates: Unrelated
SessionBrowsersnapshots were updated to account for a month rollover, changing '10mo' to '11mo' in age displays.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.
You absolute psychopaths.
In most cases, there is no need for filename truncation at all. That present in the Gemini app at the moment is completely unnecessary.
I have a vast ocean of horizontal space on my monitor, but Gemini insists on showing me tiny snippets of filenames.
This is a UI problem on almost all Google products- Android file browers and file pickers showing only fragments of the complete filename and rendering them unusable, gMail, etc.
Hey, here's an idea. If you are going to continue showing tiny snippets, please make it a changeable option in the settings ❤️
My PR does not introduce truncation, it just improves it