Skip to content

feat: follow mode for scratch pane#21

Open
petergaultney wants to merge 1 commit intomainfrom
lemonaid/persistent-scratch-pane
Open

feat: follow mode for scratch pane#21
petergaultney wants to merge 1 commit intomainfrom
lemonaid/persistent-scratch-pane

Conversation

@petergaultney
Copy link
Copy Markdown
Owner

@petergaultney petergaultney commented Mar 25, 2026

Summary

The scratch pane can now follow across window/session switches. When enabled, switching windows or sessions in tmux automatically moves the scratch pane into the new window — keeping a persistent bird's-eye view of lemonaid sessions.

  • Shell-based hooks (~5ms per switch, no Python on the hot path). The hook script reads state files and calls tmux join-pane directly.
  • Height preservation — user resizes are saved before each move and restored on the other side.
  • Focus stays on the main pane after a switch (not stolen by the scratch pane).
  • prefix+l in follow mode toggles focus between scratch and main pane instead of hiding.
  • q in lma temporarily parks the pane; next prefix+l brings it back with follow still active.
  • --follow / --unfollow CLI to enable/disable per-server. Prints copy-pasteable set-hook lines for .tmux.conf if not already present.
  • Config: scratch_height — default pane height, configurable in [tmux-session]. No more --height flag needed in keybindings.
  • Config: follow_scratch — bootstraps follow state for new tmux servers on first scratch pane creation.

Per-server state files in ~/.local/state/lemonaid/:

  • tmux-scratch-<server>-follow — "on" or empty
  • tmux-scratch-<server>-pane — pane ID (plain text, migrated from JSON)
  • tmux-scratch-<server>-height — last known height in rows

Test plan

  • 122 existing tests pass
  • lemonaid tmux scratch --follow enables + prints .tmux.conf lines
  • Switching sessions/windows moves scratch pane to new window
  • Resizing scratch pane persists across switches
  • prefix+l toggles focus, doesn't hide pane
  • q parks pane, hooks no-op until next prefix+l
  • --unfollow disables, hooks become no-op
  • Non-follow mode unchanged
  • scratch_height config respected by all paths

@petergaultney petergaultney force-pushed the lemonaid/persistent-scratch-pane branch 13 times, most recently from 13f3fa0 to 7b3e183 Compare March 26, 2026 17:55
The scratch pane can now follow across window/session switches via
shell-based tmux hooks (~5ms per switch, no Python on the hot path).

Per-server state files in ~/.local/state/lemonaid/:
  scratch-follow-<server>  — "on" or empty
  scratch-pane-<server>    — pane ID (plain text, was JSON)
  scratch-height-<server>  — preserved height across switches
  scratch-follow.sh        — shell hook script, generated once

Setup: `lemonaid tmux scratch --follow` enables follow and prints
the set-hook lines to add to .tmux.conf. --unfollow disables.

Config: follow_scratch in [tmux-session] bootstraps the follow file
on first run for new servers.

In follow mode:
- prefix+l toggles focus between scratch and main pane (never hides)
- q in lma hides the pane; hooks no-op until next prefix+l
- Pane height is saved before switches and restored by the hook
- Selecting a notification doesn't auto-hide the pane
@petergaultney petergaultney force-pushed the lemonaid/persistent-scratch-pane branch from 7b3e183 to 004034a Compare March 26, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant