Skip to content

Unique tab names#113

Open
stdout-se wants to merge 1 commit into
jorio:masterfrom
stdout-se:wip/unique-tab-names
Open

Unique tab names#113
stdout-se wants to merge 1 commit into
jorio:masterfrom
stdout-se:wip/unique-tab-names

Conversation

@stdout-se

Copy link
Copy Markdown
Contributor

Feedback request for a suggestion:

When multiple tabs are open with the same name, use parent folder names to create unique tab names.

I work in products that have a structured multi-repo layout, where one repo is always named "app", another is always named "tests", and so on. Most of the time I have several of these open at the same time. This can cause confusion.

image

Suggestion: Include parent folder names if tabs have identical names. Two parent levels are used. If they are identical, tabs will be named with an alphabetical prefix "A: tab", "B: tab" etc.

image

Examples:

  • "a/app" and "b/app" would produce tabs "a/app" and "b/app"
  • "a/android/app" and "b/android/app" would produce tabs "a/android/app" and "b/android/app"
  • "a/android/samples/app" and "b/android/samples/app" would produce tabs "A: app" and "B: app"

Lots of questions:

  1. Good idea?
  2. How to handle naming collisions?
  3. How to handle long names?
  4. Special cases to consider?

@stdout-se

Copy link
Copy Markdown
Contributor Author

Maybe truncate middle of path if there is a naming collision > 2 levels?

android/samples/ui/buttons/
ios/samples/ui/buttons/

Becomes
android/.../buttons
ios/.../buttons

@jorio

jorio commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Good idea?

Of course! I added the Repo Nickname feature for cases like these, but it's a manual step and it's not super discoverable (Repo -> Repo Settings), so your automatic solution makes for better UX out of the box.

How to handle long names?

We can rely on the tab bar to elide very long names. Users can always hover over the tab to see the full path.

(EDIT: A previous version of my message mentioned issues with tab name elision, but I fixed those today.)

Special cases to consider?

I think we should use something else than A: B: C: because a similar convention is already in place for superprojects and submodules: image

I like your suggestion of truncating the middle of the path. Find the "rightmost" disambiguating path components, and elide everything inbetween those and the workdir?

I also suggest pre-filtering the path with compactPath so that /home/you contracts to ~


Review notes:

The codebase as a whole isn't consistent in its use of os.path vs Path, so I understand your choice of os.path. But, I've been trying to steer the codebase toward Path, and it might be nice to use here:

parts = Path(workdir).parts  # instead of [p for p in os.path.normpath(workdir).split(os.sep) if p]
Path(*parts[-take:])         # instead of os.sep.join(parts[-take:])
# (by the way, workdir paths are supposed to be normalized already)

I suggest unit testing _disambiguateTabTitlesByPath with pytest.mark.parametrize so we can easily test edge cases without having to unpack and load actual repos.

Perhaps we can move the disambiguation routine to pathutils.py, too?

@stdout-se

Copy link
Copy Markdown
Contributor Author

I'll take a look, sounds like good ideas. I honestly didn't discover the repo nickname until you mentioned it. Could maybe be more visible? Right click on a tab -> nickname?

@stdout-se stdout-se force-pushed the wip/unique-tab-names branch 2 times, most recently from b7047c9 to f4d4c4e Compare June 22, 2026 10:35
@stdout-se

Copy link
Copy Markdown
Contributor Author

I implemented that identical parents should be hidden with the ellipsis character ("..."), and the home "~" char is used where appropriate.

Repo nicknames are preferred if they are set. Disambiguated names will not override nicknames. However, two things to keep in mind:

  • Duplicate nicknames are allowed, as nicknames are always preferred over unique tab names.
  • A repo which has a name that conflicts with another repo's nickname will not be disambiguated.
    • I.e. A repo nicknamed "app" and a repo named "app" will show up with the same name.

Comment thread test/test_gitfourchette.py Outdated
Comment on lines +368 to +369
path1 = os.path.join(tempDir.name, "a", "repo")
path2 = os.path.join(tempDir.name, "b", "repo")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap these two in os.path.realpath(...) and I think the test will pass on macOS

(On macOS tempDir.name is typically in /var/folders/..., realpath() turns that into /private/var/folders/..., and repo nicknames depend on "real" paths)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's never an issue in real use? Could always patch so symlinks is looked at when looking up nicknames

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repo paths that you open from the GUI or pass on the CLI all go through MainWindow._resolveWorkdir. This resolves the real path of the corresponding workdir (via pygit2).

So, by the time a user gets to set the nickname in the GUI, the real path has already been resolved. It's only an issue in unit tests where _resolveWorkdir is bypassed.

When multiple tabs are open with the same name, use parent folder names to create unique tab names.

E.g. two repos in folders "work/a/app" and "work/b/app" will be named "a/app" and "b/app".

If parents have identical names, look upward in the tree until unique parent name can be found and hide identical parts with ellipsis.

Notes:
* Duplicate nicknames are allowed, as nicknames are always preferred over unique tab names.
* A repo which has a name that conflicts with another repo's nickname will not be renamed.
@stdout-se stdout-se force-pushed the wip/unique-tab-names branch from f4d4c4e to 64d3b52 Compare June 22, 2026 12:29
@stdout-se stdout-se changed the title WIP: Unique tab names Unique tab names Jun 22, 2026
@jorio

jorio commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Currently, /a/repo /b/repo /z/a/repo becomes /…/repo /…/repo z/…/repo - should we handle this case?

@stdout-se

Copy link
Copy Markdown
Contributor Author

Hmm. It's a tricky one. Right now it's based on fixed depth formatting, so all matches get ellipses or none do. The quickest fix would be to name them a/.../repo b/.../repo z/.../repo. But it's not very intuitive. It would be better to do a/repo b/repo z/.../repo I think. It's a bigger code change though. Or we leave it as it is? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants