perf: Push QueryList filters to tmux via -f format filter

Abierto
#646 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python
Área
api, cli

Línea de trabajo

Start at the server.panes.filter(...) entry point and compare it with the libtmux-mcp search_panes proof of concept, which calls server.cmd('list-panes', '-a', '-f', ...). Decide whether this should be a new tmux_filter method or a transparent filter optimization, then verify compatible filters are applied by tmux while existing QueryList behavior remains correct.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement

Problem

server.panes.filter(pane_current_command__contains="vim") fetches ALL panes from tmux, then filters in Python. For servers with many sessions/windows, this is unnecessarily slow.

tmux native support

tmux's list-panes, list-windows, and list-sessions commands support a -f flag that applies a format-string filter server-side:

Filter panes by command (done in C, not Python):

$ tmux list-panes -a -f "#{m:*vim*,#{pane_current_command}}"

Filter panes by content (C-level grid search):

$ tmux list-panes -a -f "#{C:search_term}"

Case-insensitive metadata match:

$ tmux list-panes -a -f "#{m/i:*pattern*,#{window_name}}"

Format matching operators:

  • #{m:glob,text} — glob match (wraps with *...* for contains)
  • #{m/i:glob,text} — case-insensitive glob
  • #{m/r:regex,text} — POSIX extended regex
  • #{C:text} — content search (visible pane text)

Proposed approach

Add a method or option to push compatible QueryList filters into tmux's -f flag:

# Option A: New method
server.panes.tmux_filter(pane_current_command__contains="vim")

# Option B: Optimize existing .filter() transparently
# Detect when filters can be pushed to tmux and do so automatically

Performance impact

For a server with 50 panes, Python-side filtering requires fetching and parsing all 50 pane objects. Tmux-side filtering returns only matching panes, reducing both IPC and object creation overhead.

Context

The libtmux-mcp search_panes tool uses server.cmd('list-panes', '-a', '-f', ...) directly as a proof of concept for tmux-side filtering. See also #645 for the content search API.

Lenguaje dominante
Python
Estrellas
1.2k
Forks
127
Merge medio
2 h 13 min
PR fusionados (30 d)
1

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de tmux-python/libtmux

Todos los issues de tmux-python/libtmux

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.