feat: forward OSC 7 (working directory) to parent terminal (#4867)

* feat: capture OSC 7 working directory on Grid and expose via Pane trait

Add osc7_payload field to Grid, handle the b"7" OSC sequence in
osc_dispatch, expose it via a Grid accessor, add osc7_payload() to
the Pane trait (default None), and implement it on TerminalPane by
delegating to the Grid. Follows the has_bell/consume_bell pattern.

* feat: forward OSC 7 from focused pane to parent terminal on render

* fix: validate OSC 7 URI and clean up state on client disconnect

Reject URIs containing control characters (< 0x20 or 0x7f) to prevent
injection into the parent terminal when the URI is re-emitted via OSC 7
forwarding. Also remove per-client OSC 7 forwarding state in
remove_client() to avoid stale entries accumulating after disconnect.

* style: fix formatting in OSC 7 tests

* fix: add control char test, clear osc7 on reset, doc comment

- Add test for control character rejection in OSC 7 URIs
- Clear osc7_payload in reset_terminal_state() (RIS/\ec)
- Add doc comment on osc7_payload() getter

* fix: address PR review feedback

- Reject C1 control characters (U+0080..U+009F) in OSC 7 URIs using
  char::is_control() instead of byte-level check
- Reject entire OSC 7 if any param segment has invalid UTF-8 instead
  of silently dropping bad segments
- Avoid String allocation in render hot path by comparing borrowed
  &str, only allocating when the value actually changes
- Add test for C1 control character rejection

* fix: integrate OSC 7 forwarding with upstream CWD tracking

* add some more tests

* docs: update changelog

---------

Co-authored-by: Aram Drevekenin <[email protected]>
This commit is contained in:
Marcio Granzotto Rodrigues
2026-09-14 18:26:14 +02:00
committed by GitHub
co-authored by Aram Drevekenin
parent 232c93721d
commit 474ea0cef6
8 changed files with 672 additions and 1 deletions
+1
View File
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased]
* fix: forward OSC7 (cwd changes) to host terminal (https://github.com/zellij-org/zellij/pull/4867)
## [0.45.1] - 2026-08-28
* fix: nested-session detection over SSH (https://github.com/zellij-org/zellij/pull/5522)