OSC 7 proxy icon ignores unknown hosts, including blank host (file:/// URL) #2681
Replies: 3 comments 3 replies
-
If you want to use this issue to just fix |
Beta Was this translation helpful? Give feedback.
-
Converted to a discussion. As far as I know, OSC7 has now been specified (kind of) via terminal-wg: https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/20 As part of this specification, the hostname is now required and is always validated against the local hostname. I haven't re-read this in detail recently so I'll keep this discussion open, but terminal-wg is going to supersede Terminal.app for me if this ends up being true. Following that, seeing what the majority of terminals do will also supersede Terminal.app. |
Beta Was this translation helpful? Give feedback.
-
As you suggested, I’m somewhat willing to relax these requirements for the sake of the proxy icon, since it’s a unique thing that’s only implemented on macOS and only by Terminal. I’m not trying to build a Terminal.app clone though so I want to carefully consider if this is the right thing to do or not. If we go that route, I think we should create a new apprt action that reports unverified URLs directly from OSC7. Then the macOS app can handle that on its own separate from the Ghostty core which can remain adherent to the de facto spec. |
Beta Was this translation helpful? Give feedback.
-
The OSC 7 proxy icon handling ignores any attempts to set it with a hostname that doesn't match the current system. I'd file this as a discussion except that it's also treating the empty string as an unknown hostname, e.g.
printf '\e]7;file:///Users/lily\a'
is ignored. For that matter someone setting it to a path without thefile://
prefix is also being ignored, though Terminal.app handles that just fine.I do think all of this should be supported, but at the very least using
file:///path/to/foo
should work since the inclusion of a hostname is merely recommended rather than required.The behavior for an unknown hostname is to turn it into a remote URL. Here's an example of what that looks like in Terminal.app:
I'm pretty sure you can do this simply by taking the file:// URL you're given and hand it to
NSWindow
as-is, instead of parsing it for a path and then using that path to reconstruct aURL
. Checking the hostname to see if it's local makes sense for the code that opens new windows at the same path though1, so I think the right thing to do is to keep both apwd
and aproxyIconURL
and when you get an OSC 7 you unconditionally setproxyIconURL
to that but keep the hostname check before settingpwd
(though again, you'll probably want to treatfile:///
with no hostname as a local path). This way if I cd to another directory, then ssh to a remote server that sends OSC 7 codes, a new window will open at the same local path that the first window was in prior to ssh'ing.Footnotes
Interestingly, Terminal.app doesn't do this! If I give it a remote file URL and then open a new tab, it still tries to spawn the new shell in the path of that remote URL (and falls back to the home folder if the path doesn't exist locally). I consider that a bug though, it should just separately remember the last local path to use. ↩
Beta Was this translation helpful? Give feedback.
All reactions