feat: Add Non-polling Waiters (Deterministic Channels & Delta-Polling)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 38/100
Direzione di ricerca
Start by reading the linked libtmux-mcp implementations in wait_for_tools.py and pane_tools/wait.py, then inspect libtmux's Server, Pane, and ControlMode entry points. Done means defining and validating both proposed waiter APIs, including channel timeouts and absolute-grid delta matching, while treating the Control Mode listener as future scope.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
As libtmux has evolved with the 0.57.0 "Neo" ORM parity, we've solved the N+1 problem for object hydration. However, synchronizing with terminal output still largely relies on client-side loop polling via capture_pane().
We propose introducing a two-tier waiter system modeled after the patterns battle-tested in libtmux-mcp. This brings "Wait, Don't Poll" semantics natively to libtmux.
1. Best-of-Breed: Deterministic Channel Sync (Server.wait_for_channel)
For commands where the user controls the execution, we should avoid scraping scrollback entirely and rely on tmux's native OS-level IPC blocks.
- The Concept: Bracket shell commands with
tmux wait-for -S <channel>and block thelibtmuxclient until the signal fires. - libtmux-mcp Prior Art: See
wait_for_tools.pywhich implementswait_for_channelviasubprocess.run(timeout=timeout). - tmux Internals: This leverages tmux's
cmd-wait-for.c(tmux/tmux@18ddda4), allowing the Python thread to sleep completely until tmux wakes it. - Proposed API:
pane.send_keys("pytest; tmux wait-for -S tests_done") server.wait_for_channel("tests_done", timeout=60.0)
2. Intelligent Fallback: Delta Polling (Pane.wait_for_text)
When observing third-party output (where we can't inject a signal), we must poll. However, naive capture_pane loops often match stale screen paint. We need Absolute Grid Anchoring.
- The Concept: At entry, snapshot the grid's absolute baseline (
history_size + cursor_y). On each tick, capture only the rows below this absolute anchor to ensure we strictly match new text. - libtmux-mcp Prior Art: See
pane_tools/wait.pyfor the anchor math and scrollback limit protections. - tmux Internals: This approach is grounded in how tmux defines the grid (see
format_cb_history_bytesandformat_cb_history_sizeinformat.cat 3.2a). It ensures compatibility withgrid_collect_historyandclear-historyshifts. - Proposed API:
# Under the hood, this will use Neo-style batch hydration # to fetch `#{history_size}|#{cursor_y}` in a single IPC turn. pane.wait_for_text("READY", timeout=8.0)
3. Future Scope: Control Mode Listener
A long-term architectural goal could involve spawning a background tmux -C client (as currently used in libtmux testing via ControlMode) to listen for %output or %pane-mode-changed streams, offering a completely event-driven API.
- Lingua principale
- Python
- Stelle
- 1.2k
- Fork
- 127
- Merge medio
- 2h 13m
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tmux-python/libtmux
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
tmux-python/libtmux#759 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
tmux-python/libtmux#745 · 2 commenti ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
tmux-python/libtmux#744 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tmux-python/libtmux#731 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
tmux-python/libtmux#654 ·
Tutte le issue di tmux-python/libtmux
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
use-agent-os/agent-os#3314 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BasedHardware/omi#15662 · 1 commento ·
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
AiursoftWeb/AnduinOS-2#19 ·