Skip to content

Check terminfo for ts capability to determine title setting support#10037

Merged
faho merged 2 commits into
fish-shell:masterfrom
gpanders:terminfo-title
Sep 30, 2023
Merged

Check terminfo for ts capability to determine title setting support#10037
faho merged 2 commits into
fish-shell:masterfrom
gpanders:terminfo-title

Conversation

@gpanders
Copy link
Copy Markdown
Contributor

Description

Check terminfo for the ts capability to determine if a terminal supports setting the window title.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

This was stabilized in Rust 1.70.0, but CI uses 1.67.0 where this function was
still marked unstable.
@faho
Copy link
Copy Markdown
Member

faho commented Sep 29, 2023

Are you seeing problems or is this for theoretical correctness?

Unfortunately the terminfo system has pretty huge problems (most terminals claim to be "xterm" so it's usually ineffectual, and the ones that don't might have problems because the terminfo database doesn't have the entry).

That means it's also just a heuristic and often other things might be more helpful. Depends on the case you're seeing, which is why I'm asking.

@gpanders
Copy link
Copy Markdown
Contributor Author

Are you seeing problems or is this for theoretical correctness?

It is a real problem for a new terminal emulator that I'm helping to test. It's not listed in the known list of terminals, so fish incorrectly assumes it's not capable of setting the title. This terminal does ship its own terminfo entry that contains the ts capability.

Unfortunately the terminfo system has pretty huge problems (most terminals claim to be "xterm" so it's usually ineffectual, and the ones that don't might have problems because the terminfo database doesn't have the entry).

Understood, but in this case I think it's low risk. If the check fails it falls back to the existing heuristics. So this only impacts terminals which ship a terminfo that contains the ts capability.

Another alternative would be to query support from the terminal itself using OSC 60, but I have no idea how widely that is implemented.

@faho
Copy link
Copy Markdown
Member

faho commented Sep 29, 2023

It is a real problem for a new terminal emulator that I'm helping to test. It's not listed in the known list of terminals

Does this terminal have a name or is that not public knowledge?

Another alternative would be to query support from the terminal itself using OSC 60, but I have no idea how widely that is implemented.

Querying scares me. I don't like the idea of sending something and getting a response maybe, possibly, but later. How long do we wait?

And I've seen terminals spew querying escapes, so I don't like it.

Understood, but in this case I think it's low risk. If the check fails it falls back to the existing heuristics.

My "fear" is that something may pick a terminfo entry that does list ts, but doesn't actually support it. Maybe it's just a bug in that entry on that OS - the terminfo database is annoyingly sticky, especially on things like macOS (do they list italics for terminal.app yet?).

Still, terminfo may be the least bad option.

(tbh my favorite solution would be for all terminals to simply support this enough to be able to just ignore a title, so we could just set it unconditionally)

@gpanders
Copy link
Copy Markdown
Contributor Author

Does this terminal have a name or is that not public knowledge?

It is called ghostty. It's currently in a closed beta testing period.

Querying scares me. I don't like the idea of sending something and getting a response maybe, possibly, but later. How long do we wait?

Yea I agree, I mentioned it as a possibility but it's not my preference in this case either.

My "fear" is that something may pick a terminfo entry that does list ts, but doesn't actually support it. Maybe it's just a bug in that entry on that OS - the terminfo database is annoyingly sticky, especially on things like macOS (do they list italics for terminal.app yet?).

Still, terminfo may be the least bad option.

We could reduce this risk further by only checking for ts after some of the other heuristics have failed.

So before falling back to checking the stdin TTY device name, check ts. But this would only happen when $TERM does not match any of the terminals in the known good list or any of the other terminals in the known bad list.

@faho faho merged commit b32cc65 into fish-shell:master Sep 30, 2023
@faho
Copy link
Copy Markdown
Member

faho commented Sep 30, 2023

After further consideration I'm just gonna merge this as-is. It's not like the terminal title is some new obscure feature.

It should be table stakes. Any good terminal standard would just enforce that the sequence is understood (sadly we do not live in a world with a good terminal standard).

I'm still extremely sad at the state of current terminal cross-compatibility and that we're still relying on the broken and near useless terminfo.

@faho faho added this to the fish next-3.x milestone Sep 30, 2023
@gpanders gpanders deleted the terminfo-title branch September 30, 2023 11:43
krobelus added a commit to krobelus/fish-shell that referenced this pull request Mar 31, 2024
Terminal titles are set with an OSC 0 sequence.  I don't think we want to
support terminals that react badly to unknown OSC (or CSI) sequences.

So let's remove our feature detection.

This will fix future false negatives along the lines of
fish-shell#10037
krobelus added a commit to krobelus/fish-shell that referenced this pull request Apr 1, 2024
Terminal titles are set with an OSC 0 sequence.  I don't think we want to
support terminals that react badly to unknown OSC (or CSI) sequences.

So let's remove our feature detection.

This will fix future false negatives along the lines of
fish-shell#10037
krobelus added a commit to krobelus/fish-shell that referenced this pull request Apr 1, 2024
Terminal titles are set with an OSC 0 sequence.  I don't think we want to
support terminals that react badly to unknown OSC (or CSI) sequences.

So let's remove our feature detection.

This will fix future false negatives along the lines of
fish-shell#10037
krobelus added a commit to krobelus/fish-shell that referenced this pull request Apr 2, 2024
Terminal titles are set with an OSC 0 sequence.  I don't think we want to
support terminals that react badly to unknown OSC (or CSI) sequences.

So let's remove our feature detection.

This will fix future false negatives along the lines of
fish-shell#10037
krobelus added a commit to krobelus/fish-shell that referenced this pull request Apr 2, 2024
Terminal titles are set with an OSC 0 sequence.  I don't think we want to
support terminals that react badly to unknown OSC (or CSI) sequences.

So let's remove our feature detection.

This will fix future false negatives along the lines of
fish-shell#10037
krobelus added a commit to krobelus/fish-shell that referenced this pull request Apr 2, 2024
Terminal titles are set with an OSC 0 sequence.  I don't think we want to
support terminals that react badly to unknown OSC (or CSI) sequences.

So let's remove our feature detection.

This will fix future false negatives along the lines of
fish-shell#10037
krobelus added a commit that referenced this pull request Apr 2, 2024
Terminal titles are set with an OSC 0 sequence.  I don't think we want to
support terminals that react badly to unknown OSC (or CSI) sequences.

So let's remove our feature detection.

This will fix future false negatives along the lines of
#10037
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants