Files
l0ng-ai 03c3081a6e feat(ports): detect and forward what a remote pane is serving
A remote workspace's ports were never listed. The pane lives in the
peer's registry and QueryProcs asks this machine's daemon, which has
never heard of it, so the answer was an empty list — indistinguishable
on screen from a pane serving nothing. Add a control request so the peer
answers instead, gated on a feature so an older server says "I cannot
tell you" rather than "nothing is listening".

With the ports visible, the forward becomes something the user should
not have to think about: a port opens on a click, and a new one is
forwarded unasked, at the same number where that number is free here.
The watch runs with the panel shut, which is when a port appearing is
most worth saying something about.

Ports and Forwards were two sections that never mentioned each other; a
row is now a port, and the forward is where that row says it comes out.
Adding one by hand asks for one number instead of five fields, with the
rest of the ssh -L grammar one disclosure away.

Claude-Session: https://claude.ai/code/session_01TPXrptp2rCGKjXaz4xE3Lq
2026-09-08 21:01:50 +08:00

83 lines
3.2 KiB
Plaintext

---
title: "Links"
description: "Opening URLs, files, and localhost ports straight out of the terminal."
---
Hold <kbd>⌘</kbd> (<kbd>Ctrl</kbd> on Windows and Linux) and links under the
pointer underline; click to open one.
## URLs
Anything that looks like a URL is detected, including one the shell wrapped
across two lines — tty7 stitches it back together before opening it.
Turn detection off with **Settings → Terminal → Links → Detect URLs**
(`link_url: false`).
## Files
A file path in the output — a compiler error, a test failure, a `grep -n` hit —
opens in tty7's own editor, on the line the link named, and the Files panel
selects it if it is open. A path to a directory opens the Files panel on it
instead.
Both absolute and relative paths are detected. A relative one is measured
against the directory the pane is working in, and then against the repository
around it — which is what makes a path a build tool printed from the workspace
root resolve while the shell sits in a member directory. A path that matches
nothing under either says so rather than doing nothing.
Paths in a pane connected to another machine are resolved *on that machine*,
so the underline appears a moment after the pointer settles rather than
instantly. A pane running `ssh` typed into a local shell has no host that can
answer for its paths, so file links are off there.
**Settings → Terminal → Links → Open files with** picks what a click opens:
| Mode | Opens in |
| --- | --- |
| Built-in editor | tty7's editor, at `:line:column`. The default. |
| Default app | Whatever the OS associates with the file type. |
| Command | A command of your own — see below. |
A file on another machine always opens in the built-in editor, whichever mode
is set: a path that was just resolved on the far side means nothing to a local
`open` or `code`, which would show this machine's copy of that path or nothing
at all.
Under **Command**, the command runs with placeholders substituted:
```
code --goto {path}:{line}:{column}
zed {path}:{line}
herdr edit {path} --line={line}
```
`{path}`, `{line}`, and `{column}` are filled in from the link. A flag whose
value is not available is dropped rather than passed empty — so
`--line={line}` simply disappears when the link had no line number.
The settings are `link_file_open` (`internal`, `system`, or `command`) and
`link_file_command` in `config.json`. A config written before `link_file_open`
existed keeps working: one that set a command stays on **Command**, and one
that did not moves to the built-in editor.
## localhost ports
<kbd>⌘</kbd>-clicking `localhost:3000` opens it in your browser, which is only
useful if the server is on this machine.
When the pane is inside an SSH session it usually is not, so tty7 opens a port
forward through that connection first and points the browser at the local end.
The forward is built on the click if it is not there already.
This is on by default; **Settings → Terminal → Links → Forward remote ports**
(`ssh_loopback_forward`) turns it off, along with the automatic forwarding of
ports a remote pane starts serving.
<Tip>
Every port a remote pane is listening on is listed in the Info panel, whether
or not its URL was ever printed — see [port
forwarding](/remote/port-forwarding).
</Tip>