Idle filter: pivot per-distro → per-pane via TILETOPIA_PANE_ID env marker

Per-distro suppression (shipped earlier today) broke tiletopia's primary
use case — multiple claude panes per distro means as soon as one runs
claude, ALL Ubuntu panes go silent. Tested live: user couldn't reproduce
idle on any pane because PID 46848 (their main session) tripped the gate.

New mechanism, per-pane via env-var marker:

1. pty.rs tags every WSL spawn with TILETOPIA_PANE_ID=<id> as a Windows
   env var, plus WSLENV=...TILETOPIA_PANE_ID/u (appended to any pre-
   existing WSLENV) so the var forwards into the distro. Pane id is now
   reserved BEFORE build_command so the tag is available at spawn time.
2. probe.rs rewritten — is_watch_process_running(distro, pane_id) runs
   a bash one-liner that pgreps for each watched name, then for each PID
   checks /proc/<pid>/environ for the matching TILETOPIA_PANE_ID line.
   Env inheritance does the work: shell inherits from wsl.exe, claude
   inherits from shell. Cache keyed by (distro, pane_id).
3. Fail-safe INVERTED: probe failure now returns false (don't suppress)
   instead of true (suppress). A transient error should never silence
   the idle indicator permanently. Frontend catch updated to match.
4. LeafPane tracks PaneId in paneIdRef set by onPaneSpawned; idle ticks
   before spawn-completion pass 0, which won't match any real marker so
   the pane idles normally.

Existing panes won't have the marker until respawned — they'll always
show idle (since probe never matches). User opens fresh panes once after
deploying this. Documented in memory.md follow-ups.

pnpm check clean. Rust validation: cargo test --lib on Windows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-05-26 17:58:51 +01:00
parent d3474d33b0
commit 6772b8db37
6 changed files with 230 additions and 124 deletions

View file

@ -40,12 +40,17 @@ export interface SshHost {
export const listDistros = (): Promise<string[]> => invoke("list_distros");
/** Ask the backend whether any built-in "watched" process (currently just
* `claude`) is running in the given WSL distro. Cached per-distro for ~3s
* on the Rust side. Fail-safe: probe failures resolve to `true` so the
* caller suppresses the idle indicator. Only meaningful for WSL panes
* PowerShell + SSH should skip this and fall back to always-notify. */
export const isWatchProcessRunning = (distro: string): Promise<boolean> =>
invoke("is_watch_process_running", { distro });
* `claude`) is running in THIS specific pane (not just somewhere in the
* distro). Per-pane detection works via a `TILETOPIA_PANE_ID` env marker
* injected at spawn see src-tauri/src/probe.rs. Cached per (distro,
* pane_id) for ~3s. Probe failures resolve to `false` (don't suppress)
* better to occasionally over-notify than permanently silence. Only
* meaningful for WSL panes; PS + SSH should skip this. */
export const isWatchProcessRunning = (
distro: string,
paneId: number,
): Promise<boolean> =>
invoke("is_watch_process_running", { distro, paneId });
export const spawnPane = (args: {
spec: SpawnSpec;