Skip to main content

jupyterlab_terminal_cpr_escape_fix

GitHub Actions npm version PyPI version Total PyPI downloads JupyterLab 4 Brought To You By KOLOMOLO Donate PayPal

[!TIP] This fix is part of the stellars_jupyterlab_fixes metapackage. Install all Stellars fixes at once: pip install stellars_jupyterlab_fixes

[!WARNING] This extension provides a workaround for a known JupyterLab/terminado issue. It will be deprecated once JupyterLab addresses this problem in a GA release. Monitor the upstream issue tracker for official fixes.

Fix the JupyterLab terminado issue where returning to an idle terminal causes cursor position report (CPR) escape sequences to appear as literal text. This is particularly noticeable with fish shell, where sequences like [2;2R[3;1R or [?1;2c[>0;276;0c appear at the prompt after reconnecting.

How it works

When a JupyterLab terminal sits idle, the shell (especially fish) periodically queries terminal capabilities. These queries accumulate in terminado's buffer. On reconnect, the buffer drains and the responses appear as literal text because xterm.js can't process them fast enough.

This extension patches TermSocket.on_pty_read() server-side to filter terminal query responses before they reach the browser. It handles both ESC-prefixed sequences and bare remnants where fish shell has stripped the ESC byte.

Filtered sequences (terminal query responses):

  • CPR - Cursor Position Report (ESC[row;colR)
  • DA/DA2 - Device Attributes (ESC[?...c, ESC[>...c)
  • DECRPM - DEC Report Mode (ESC[?mode;value$y)
  • OSC 4/10/11/12 - Color query responses

Preserved sequences (functional terminal output):

  • All SGR color codes, cursor movement, erase, scroll
  • OSC 0 (window/tab title), OSC 7 (cwd), OSC 8 (hyperlinks)
  • OSC 52 (clipboard - used by companion clipboard extension)
  • OSC 133 (shell integration prompt marks)
  • Bracketed paste mode, alternate screen, all DEC private modes

Repaint on attach (window refresh recovery):

  • After a client attaches and the buffer replay drains, the PTY is nudged one row taller and back
  • The kernel delivers SIGWINCH, so the foreground app (Claude Code, vim, htop) repaints its full screen
  • Without it, a refreshed browser shows a torn screen: the replay holds only incremental diff frames, so static regions (status line, input box) are never delivered and never self-heal
  • Toggle: DEFAULTS['repaint_on_attach'] in __init__.py (default on), debounced 5s per terminal

Requirements

  • JupyterLab >= 4.0.0

Installation

pip install jupyterlab_terminal_cpr_escape_fix

Uninstall

pip uninstall jupyterlab_terminal_cpr_escape_fix

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab_terminal_cpr_escape_fix-1.0.13.tar.gz (365.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file jupyterlab_terminal_cpr_escape_fix-1.0.13.tar.gz.

File metadata

File hashes

Hashes for jupyterlab_terminal_cpr_escape_fix-1.0.13.tar.gz
Algorithm Hash digest
SHA256 fce46d44b61bdee64ed46fc345c3905012df6ae39cceff9099d3552d006e699e
MD5 ab3e911e69c68a4332300e761903d284
BLAKE2b-256 edf174e6fbb8d71eaf0be1c3dcfe40ff9df20641003915b3e2dc350a74fb2a4d

See more details on using hashes here.

File details

Details for the file jupyterlab_terminal_cpr_escape_fix-1.0.13-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_terminal_cpr_escape_fix-1.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 1da7e67cc60102138f5997caaa2a56e604b5281f515e4049970578ef867ff8b4
MD5 53c7e62f6ecaf15210d742fc9c95231c
BLAKE2b-256 72e9c39e3fe0f8d0af9669234fa58df303cd0901f47a2534ba6c8219a72afd35

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.14

2 files

This release

1.0.13 This release

2 files

1.0.12

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

0.9.23

2 files

0.9.22

2 files

0.9.21

2 files

0.9.19

2 files

0.9.18

2 files

0.9.14

2 files

0.9.8

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page