You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/specs/terminal-escapes.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,14 +20,14 @@ Rule of thumb: CSI talks to the screen, OSC talks to the application hosting the
20
20
21
21
OSC sequences are introduced by `ESC ]` and terminated by either `BEL` (`\x07`) or `ST` (`ESC \`). A `BEL` that terminates an OSC is part of that OSC sequence, not a standalone bell notification. Both terminators are accepted across all supported sequences, and the parser handles split chunks across PTY reads.
22
22
23
-
Supported OSCs are parsed at the PTY data boundary in the platform adapter:
23
+
State-driving and security-sensitive OSCs are parsed at the PTY data boundary in the platform adapter:
24
24
25
25
- VS Code: in the extension host (`message-router.ts` / `pty-manager.ts`), before `pty:data` is forwarded to the webview.
26
26
- Standalone and fake adapters: in the frontend adapter, before xterm.js sees the bytes.
27
27
28
-
After parsing, supported sequences are consumed and not re-emitted. Known unsupported iTerm2/clipboard-capable OSCs listed in [Known-unimplemented iTerm2 and clipboard-capable sequences](#known-unimplemented-iterm2-and-clipboard-capable-sequences) are also consumed and ignored. The platform sends two streams to the webview:
28
+
After parsing, state-driving supported sequences are consumed and not re-emitted. `OSC 8` hyperlinks are the exception: the parser leaves them in `pty:data` so xterm.js owns hyperlink regions and hover rendering, while MouseTerm supplies the activation handler. Known unsupported iTerm2/clipboard-capable OSCs listed in [Known-unimplemented iTerm2 and clipboard-capable sequences](#known-unimplemented-iterm2-and-clipboard-capable-sequences) are also consumed and ignored. The platform sends two streams to the webview:
-`pty:data` — terminal output with state-driving supported OSCs already parsed/stripped and `OSC 8` hyperlinks preserved. Feeds xterm.js.
31
31
-`terminal:semanticEvents` — normalized semantic events parsed in the platform (CWD, prompt/command boundaries, titles). Feeds `TerminalPaneState`; command boundaries also feed the command-exit alert track defined in `docs/specs/alert.md`.
32
32
- Notification-derived state is delivered through `AlertManager` calls / `alert:state` messages, not through `pty:data`.
33
33
@@ -40,6 +40,10 @@ The parser also classifies each PTY data chunk for activity-monitor purposes:
40
40
41
41
Unknown non-iTerm2 OSC families pass through to xterm.js unchanged so xterm.js can handle standard terminal behavior MouseTerm does not model. Security-sensitive or iTerm2-identity-triggered OSCs must not rely on xterm.js defaults: if they are not in [Supported OSCs](#supported-oscs), MouseTerm consumes and ignores them without visible terminal garbage, clipboard access, file access, focus changes, or other side effects.
42
42
43
+
### OSC 8 hyperlinks
44
+
45
+
`OSC 8 ; <params> ; <URI> ST` starts a hyperlink region and `OSC 8 ; ; ST` closes it. `params` may be empty or include `id=<group-id>` for multi-line/shared link regions. MouseTerm does not parse the `params` or URI at the PTY boundary; it passes the sequence through to xterm.js. `terminal-lifecycle.ts` sets xterm.js's `linkHandler` so activation normalizes the URI through `normalizeExternalUri()`, allowing only `http:`, `https:`, and `mailto:` before calling the platform adapter's external-open path. VS Code revalidates in the extension host before `vscode.env.openExternal`; standalone and fake adapters also revalidate before opening.
46
+
43
47
## Supported OSCs
44
48
45
49
| Sequence | Purpose | Spec |
@@ -48,6 +52,7 @@ Unknown non-iTerm2 OSC families pass through to xterm.js unchanged so xterm.js c
48
52
|`OSC 0 ; <title> ST`| Window/icon title |[terminal-state.md](terminal-state.md#supported-osc-inputs)|
49
53
|`OSC 2 ; <title> ST`| Window title |[terminal-state.md](terminal-state.md#supported-osc-inputs)|
|`OSC 8 ; <params> ; <URI> ST ... OSC 8 ; ; ST`| Explicit hyperlink region; passed through to xterm.js for rendering and opened through MouseTerm's external-link allowlist (`http:`, `https:`, `mailto:`). | This spec |
Copy file name to clipboardExpand all lines: docs/specs/transport.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,7 @@ Message types live in `vscode-ext/src/message-types.ts` (the canonical schema; o
77
77
|`pty:getCwd`| Query PTY working directory (request-response via requestId) |
78
78
|`pty:getScrollback`| Query PTY scrollback buffer (request-response via requestId) |
79
79
|`pty:getShells`| Query available shells (request-response via requestId) |
80
+
|`mouseterm:openExternal`| Request the host to open an already-sanitized external URI from an OSC 8 hyperlink. Hosts must revalidate and only allow `http:`, `https:`, and `mailto:`. |
80
81
|`mouseterm:init`| Trigger resume: get PTY list + replay data |
81
82
|`mouseterm:saveState`| Frontend persisting session state |
82
83
|`mouseterm:flushSessionSaveDone`| Ack for host-triggered flush (matched by requestId) |
@@ -96,7 +97,7 @@ Message types live in `vscode-ext/src/message-types.ts` (the canonical schema; o
96
97
97
98
| Message | Purpose |
98
99
|---------|---------|
99
-
|`pty:data`| PTY output after supported OSC sequences have been parsed/stripped (routed only to owning router) |
100
+
|`pty:data`| PTY output after state-driving supported OSC sequences have been parsed/stripped; `OSC 8` hyperlinks are preserved for xterm.js (routed only to owning router) |
100
101
|`pty:exit`| PTY process exited (with exitCode) |
101
102
|`terminal:semanticEvents`| Normalized CWD/title/prompt/command events parsed in the host from live PTY data |
102
103
|`pty:list`| List of all resumable PTYs (response to `mouseterm:init`) |
0 commit comments