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:
parent
d3474d33b0
commit
6772b8db37
6 changed files with 230 additions and 124 deletions
42
memory.md
42
memory.md
|
|
@ -29,7 +29,7 @@ Durable memory for this project. Read at session start, update before session en
|
|||
- [x] ~~**M4 — orchestration.** Broadcast input, idle notifications, Ctrl+K palette.~~ Done 2026-05-22.
|
||||
- [x] ~~**Auto-save debouncing.**~~ 500ms timer in `App.svelte` `$effect`.
|
||||
- [x] ~~**HMR distro picker reset.**~~ No longer an issue — per-pane distro selection.
|
||||
- [x] ~~**Idle detection: filter by "claude is foreground."** Currently every pane notifies after 5s silence, which fires too eagerly when the user is reading a `claude` response. Want to detect that `claude` (or any user-specified process) is actually running in the pane's shell before notifying.~~ Done 2026-05-26 — per-distro probe via `wsl.exe -d <distro> -- pgrep -x claude`, cached 3s on the Rust side. WSL panes only; PS + SSH fall back to legacy always-notify. Watched list hardcoded to `["claude"]` — `[[user-watch-list]]` follow-up below.
|
||||
- [x] ~~**Idle detection: filter by "claude is foreground."** Currently every pane notifies after 5s silence, which fires too eagerly when the user is reading a `claude` response. Want to detect that `claude` (or any user-specified process) is actually running in the pane's shell before notifying.~~ Done 2026-05-26 — **per-pane** probe (revised from initial per-distro design which broke tiletopia's primary use case of multiple claude panes per distro). Each WSL spawn tags itself with `TILETOPIA_PANE_ID=<id>` propagated via `WSLENV`; the probe runs `pgrep -x claude` in the distro then reads each match's `/proc/<pid>/environ` for the matching marker. Cached 3s by `(distro, pane_id)` on the Rust side. WSL panes only; PS + SSH fall back to legacy always-notify. Watched list hardcoded to `["claude"]` — `[[user-watch-list]]` follow-up below.
|
||||
- [ ] **`[[user-watch-list]]` — user-configurable idle-suppress process list.** v1 hardcodes `DEFAULT_WATCH_PROCESSES = ["claude"]` in `src-tauri/src/probe.rs`. Move to a workspace-config field (or dedicated `watch.json`) so users can add `cargo`, `npm test`, `pytest`, etc. without a recompile. Two design notes: (1) the values are passed straight to `pgrep -x`, so user-supplied strings must be validated (no shell metachars / leading `-`) before reaching `probe_one`; (2) the cache key is currently just the distro name — if the watched-list becomes per-pane / per-workspace, key the cache by `(distro, sorted_watch_list)` to prevent stale answers.
|
||||
- [ ] **Native OS notifications.** Right now toasts only show while the app is focused. `tauri-plugin-notification` would push to Windows Action Center; useful for "claude finished" when the app is minimized. Worth adding if/when the user actually backgrounds the app while waiting for sessions.
|
||||
- [ ] **Configurable idle threshold.** Hardcoded 5000ms in `LeafPane.svelte`. Should move into a settings panel; M5 territory.
|
||||
|
|
@ -53,6 +53,46 @@ Durable memory for this project. Read at session start, update before session en
|
|||
|
||||
## Session log
|
||||
|
||||
### 2026-05-26 — Idle filter pivot: per-distro → per-pane (env-var marker)
|
||||
|
||||
The per-distro probe shipped earlier today (see entry below) had the wrong granularity for tiletopia's actual use case. CLAUDE.md says the app is "built primarily to manage multiple `claude` sessions across projects in parallel" — i.e. multiple claude panes per distro is THE point. Per-distro suppression silenced every pane the moment one ran claude. Tested live: user saw all Ubuntu panes stop reporting idle because one pane (this session) was running claude.
|
||||
|
||||
Fix: pivot to per-pane detection via env-var marker.
|
||||
|
||||
**Mechanism:**
|
||||
|
||||
1. `pty.rs` — every WSL spawn now sets `TILETOPIA_PANE_ID=<id>` as a Windows-side env var on the `wsl.exe` invocation, plus `WSLENV=TILETOPIA_PANE_ID/u` (appended to any pre-existing WSLENV) so the var gets forwarded into the distro. Reserves the `id` BEFORE `build_command` instead of after (since the env tag needs to know the id at spawn time).
|
||||
2. `probe.rs` — rewritten. New shape: `is_watch_process_running(distro, pane_id)`. Runs a bash one-liner inside the distro that `pgrep -x <name>`s for each watched process, then for each PID checks `/proc/<pid>/environ` for an exact `TILETOPIA_PANE_ID=<target>` line (using `tr '\0' '\n' | grep -qxF`). Inheritance does the work — claude inherits env from the shell, shell inherits from wsl.exe via WSLENV. Cache keyed by `(distro, pane_id)`.
|
||||
3. **Fail-safe inverted.** v1 returned `true` (suppress) on probe failure — meant a transient error silenced idle forever until the cache TTL turned over and re-failed. v2 returns `false` (don't suppress) — better to occasionally over-notify than permanently silence. Frontend `catch` also no longer flips to suppression.
|
||||
4. `commands.rs` + `ipc.ts` + `LeafPane.tsx` updated to thread `pane_id` through. LeafPane tracks the backend PaneId in a ref (`paneIdRef`), set by `onPaneSpawned`. Ticks before the spawn completes pass `0` — won't match any real pane's marker, so probe returns false and the pane idles normally.
|
||||
|
||||
**Verification path** (user runs):
|
||||
|
||||
```powershell
|
||||
# In one Ubuntu pane: launch claude. Wait 5s.
|
||||
# Expect: red border does NOT appear (this pane has claude).
|
||||
# In another Ubuntu pane: do nothing. Wait 5s.
|
||||
# Expect: red border DOES appear (this pane has no claude).
|
||||
# Exit claude in the first pane. Wait 5s.
|
||||
# Expect: red border appears there too.
|
||||
```
|
||||
|
||||
**Files touched:**
|
||||
|
||||
- `src-tauri/src/pty.rs` — env tagging on WSL spawns (~25 lines).
|
||||
- `src-tauri/src/probe.rs` — rewritten (~150 lines, similar size).
|
||||
- `src-tauri/src/commands.rs` — sig change (1 extra arg).
|
||||
- `src/ipc.ts` — sig change + doc comment.
|
||||
- `src/lib/layout/LeafPane.tsx` — paneIdRef + pass to probe call + updated comments.
|
||||
|
||||
**Validated:** `pnpm check` clean. Rust validation needs `cargo build / cargo test --lib` from Windows.
|
||||
|
||||
Open follow-ups specific to this session:
|
||||
|
||||
- **WSLENV escaping.** If a user has `WSLENV` already set with weird chars (spaces, semicolons, embedded `:`), the simple `format!("{existing}:TILETOPIA_PANE_ID/u")` may or may not behave as expected. Most users have no WSLENV set; if it becomes an issue, parse/validate before appending.
|
||||
- **Probe ergonomics on minimal distros.** New fail-safe is "no match" instead of "suppress", so a distro missing `pgrep` or `bash` (rare but possible for stripped Alpine etc.) just gets always-notify. Acceptable; document if anyone hits it.
|
||||
- **Tagging existing panes.** The env tag only applies to NEW spawns. Panes already running from before this change won't have the marker — they'll always show idle (since the probe won't find their TILETOPIA_PANE_ID). User needs to close + respawn each WSL pane once after deploying this fix. Worth mentioning in the upgrade note if we ever cut a release.
|
||||
|
||||
### 2026-05-26 — Idle filter: suppress when `claude` is running in the distro
|
||||
|
||||
The idle indicator used to fire 5s after any silence, regardless of what the pane was doing. While the user reads a long `claude` response the pane is silent (claude is processing or the human is reading) and the red border + titlebar "N idle" count is just noise. Fixed: WSL panes now probe the backend before flagging idle, and stay quiet if `claude` is running anywhere in the distro.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue