chore: remove deprecated tmux example scripts and testing docs

- Delete `TESTING.md`
- Remove `tmux_cleanup.heroscript`
- Remove `tmux_setup.heroscript`
- Update `cleanup_test.heroscript` to delete session
This commit is contained in:
Mahmoud-Emad
2025-08-31 19:54:16 +03:00
parent 97760cfe87
commit 4afedc6541
5 changed files with 4 additions and 435 deletions

View File

@@ -1,218 +0,0 @@
# Testing the Declarative TMUX Implementation
## Prerequisites
1. **Build the hero binary** with the new tmux functionality:
```bash
cd /Users/mahmoud/code/github/freeflowuniverse/herolib
./cli/compile.vsh
```
2. **Ensure tmux is installed** on your system:
```bash
# macOS
brew install tmux
# Ubuntu/Debian
sudo apt install tmux
```
## Test Scripts
### 1. Simple Declarative Test (Recommended First Test)
```bash
/Users/mahmoud/hero/bin/hero run -p examples/tmux/simple_declarative_test.heroscript
```
**Expected Result:**
- Creates a session named "test"
- Creates a window "demo" with 2 panes
- Each pane displays a welcome message
**Verification:**
```bash
# List tmux sessions
tmux list-sessions
# Attach to the test session
tmux attach-session -t test
# You should see 2 panes side by side with messages
```
### 2. Full Declarative Example
```bash
/Users/mahmoud/hero/bin/hero run -p examples/tmux/declarative_example.heroscript
```
**Expected Result:**
- Creates "dev" session with 4-pane workspace
- Creates "monitoring" session with 2-pane system view
- Starts ttyd web access on ports 8080 and 8081
**Verification:**
```bash
# Check sessions
tmux list-sessions
# Check web access (if ttyd is installed)
open http://localhost:8080 # Dev session
open http://localhost:8081 # Monitoring session
# Attach to sessions
tmux attach-session -t dev
tmux attach-session -t monitoring
```
### 3. Paradigm Comparison Test
```bash
/Users/mahmoud/hero/bin/hero run -p examples/tmux/imperative_vs_declarative.heroscript
```
**Expected Result:**
- Creates "imperative_demo" session using step-by-step commands
- Creates "declarative_demo" session using state-based configuration
- Demonstrates both approaches working together
## Testing Individual Functions
### Test Session Ensure (Idempotent)
Create a test file:
```heroscript
!!tmux.session_ensure
name:"test_session"
```
Run it multiple times - should not create duplicates:
```bash
/Users/mahmoud/hero/bin/hero run -p test_session.heroscript
/Users/mahmoud/hero/bin/hero run -p test_session.heroscript # Should be safe to run again
```
### Test Window Layouts
Test different pane layouts:
```heroscript
!!tmux.session_ensure
name:"layout_test"
!!tmux.window_ensure
name:"layout_test|test_1pane"
cat:"1pane"
!!tmux.window_ensure
name:"layout_test|test_2pane"
cat:"2pane"
!!tmux.window_ensure
name:"layout_test|test_4pane"
cat:"4pane"
```
### Test Pane Configuration
```heroscript
!!tmux.session_ensure
name:"pane_test"
!!tmux.window_ensure
name:"pane_test|demo"
cat:"2pane"
!!tmux.pane_ensure
name:"pane_test|demo|1"
label:"first"
cmd:"echo Hello from pane 1"
!!tmux.pane_ensure
name:"pane_test|demo|2"
label:"second"
cmd:"htop"
env:"TERM=xterm-256color"
```
## Troubleshooting
### Common Issues
1. **"tmux server not running"**
```bash
# Start tmux server
tmux new-session -d -s temp
tmux kill-session -t temp
```
2. **"Permission denied" for ttyd**
```bash
# Install ttyd if needed
brew install ttyd # macOS
```
3. **Syntax errors in heroscript**
- Ensure no nested quotes in command strings
- Use double quotes for all parameter values
- Avoid special characters like `!` in commands
### Verification Commands
```bash
# List all tmux sessions
tmux list-sessions
# List windows in a session
tmux list-windows -t session_name
# List panes in a window
tmux list-panes -t session_name:window_name
# Kill all tmux sessions (cleanup)
tmux kill-server
```
## Expected Behavior
### Declarative Functions Should
1. **Be Idempotent**: Running the same script multiple times should not create duplicates
2. **Handle Dependencies**: Automatically create sessions if windows are requested
3. **Respect Layouts**: Create the correct number of panes based on category
4. **Execute Commands**: Run specified commands in the correct panes
5. **Set Environment**: Apply environment variables to panes
### Success Indicators
- ✅ Scripts run without syntax errors
- ✅ Sessions and windows are created as specified
- ✅ Pane layouts match the requested categories
- ✅ Commands execute in the correct panes
- ✅ Re-running scripts doesn't create duplicates
- ✅ Environment variables are properly set
## Cleanup
After testing, clean up tmux sessions:
```bash
# Kill specific sessions
tmux kill-session -t test
tmux kill-session -t dev
tmux kill-session -t monitoring
# Or kill all sessions
tmux kill-server

View File

@@ -1,66 +0,0 @@
#!/usr/bin/env hero
// Declarative TMUX Configuration Example
// This demonstrates the declarative paradigm where we define the desired state
// Ensure a development session exists
!!tmux.session_ensure
name:'dev'
// Ensure a monitoring session exists
// !!tmux.session_ensure
// name:'monitoring'
// Ensure a 4-pane development window exists
// !!tmux.window_ensure
// name:"dev|workspace"
// cat:"8pane"
// // Ensure a 2-pane monitoring window exists
// !!tmux.window_ensure
// name:"monitoring|system"
// cat:"2pane"
// // Ensure specific panes with commands
// !!tmux.pane_ensure
// name:"dev|workspace|1"
// label:"editor"
// cmd:"echo Starting editor... && sleep 1 && echo Editor ready"
// !!tmux.pane_ensure
// name:"dev|workspace|2"
// label:"server"
// cmd:"echo Starting development server... && sleep 2 && echo Server running on port 3000"
// env:"PORT=3000,NODE_ENV=development"
!!tmux.pane_ensure
name:"dev|workspace|3"
label:"logs"
cmd:"echo Monitoring logs... && tail -f /dev/null"
// !!tmux.pane_ensure
// name:"dev|workspace|4"
// label:"terminal"
// cmd:"echo Terminal ready for commands"
!!tmux.pane_ensure
name:"dev|mon|2"
label:"htop"
cmd:"htop"
// !!tmux.pane_ensure
// name:"monitoring|system|2"
// label:"network"
// cmd:"echo Network monitoring... && netstat -tuln"
// // Start web access for the development session
!!tmux.session_ttyd
name:'dev'
port:8089
editable:true
// // Start web access for the monitoring session
// !!tmux.session_ttyd
// name:'monitoring'
// port:8081
// editable:false

View File

@@ -47,3 +47,7 @@
name:"cleanup_test|complex|4"
label:"tail_logs"
cmd:"tail -f /dev/null"
// Delete the test session (should kill all processes)
!!tmux.session_delete
name:"cleanup_test"

View File

@@ -1,44 +0,0 @@
#!/usr/bin/env hero
// Tmux Cleanup Script - Tears down all tmux sessions, windows, and panes
// Run this after tmux_setup.heroscript to clean up everything
// Kill specific windows first (optional - sessions will kill all windows anyway)
// !!tmux.window_delete
// name:"dev|editor"
// !!tmux.window_delete
// name:"dev|server"
// !!tmux.window_delete
// name:"dev|logs"
// !!tmux.window_delete
// name:"dev|services"
// !!tmux.window_delete
// name:"monitoring|htop"
// !!tmux.window_delete
// name:"monitoring|network"
// Delete all sessions (this will kill all windows and panes within them)
!!tmux.session_delete
name:'dev'
!!tmux.session_delete
name:'monitoring'
// // Optional: Kill any remaining panes explicitly (usually not needed after session delete)
// !!tmux.pane_kill
// name:"dev|editor|main"
// !!tmux.pane_kill
// name:"dev|server|main"
// !!tmux.pane_kill
// name:"monitoring|htop|main"
// // Stop any remaining ttyd processes system-wide
// // This will clean up all ttyd processes regardless of which sessions exist
// !!tmux.ttyd_stop_all

View File

@@ -1,107 +0,0 @@
#!/usr/bin/env hero
// Create development session
!!tmux.session_create
name:'dev'
reset:true
// Create monitoring session
!!tmux.session_create
name:'monitoring'
reset:true
// Create development windows (use reset to ensure clean state)
!!tmux.window_create
name:"dev|editor"
cmd:'vim'
reset:true
!!tmux.window_create
name:"dev|server"
cmd:'python3 -m http.server 8000'
env:'PORT=8000,DEBUG=true'
reset:true
!!tmux.window_create
name:"dev|logs"
cmd:'tail -f /var/log/system.log'
reset:true
// Create monitoring windows
!!tmux.window_create
name:"monitoring|htop"
cmd:'htop'
reset:true
!!tmux.window_create
name:"monitoring|network"
cmd:'netstat -tuln'
reset:true
// Create a multi-service window with 4 panes
!!tmux.window_create
name:"dev|services"
cmd:'htop'
reset:true
// Split the services window into 4 panes (1 initial + 3 splits = 4 total)
!!tmux.pane_split
name:"dev|services"
cmd:'python3 -m http.server 3000'
horizontal:true
!!tmux.pane_split
name:"dev|services"
cmd:'watch -n 1 ps aux'
horizontal:false
!!tmux.pane_split
name:"dev|services"
cmd:'tail -f /var/log/system.log'
horizontal:true
!!tmux.pane_split
name:"dev|services"
cmd:'echo Fourth pane ready for commands'
horizontal:false
// Execute welcome commands in panes
!!tmux.pane_execute
name:"dev|editor|main"
cmd:'echo Welcome to the editor pane'
!!tmux.pane_execute
name:"dev|server|main"
cmd:'echo Starting development server'
!!tmux.pane_execute
name:"monitoring|htop|main"
cmd:'echo System monitoring active'
// Split panes for better workflow
!!tmux.pane_split
name:"dev|editor"
cmd:'echo Split pane for terminal'
horizontal:false
!!tmux.pane_split
name:"monitoring|htop"
cmd:'watch -n 1 df -h'
horizontal:true
// Expose sessions and windows via web browser using ttyd
!!tmux.session_ttyd
name:'dev'
port:8080
editable:true
!!tmux.window_ttyd
name:"monitoring|htop"
port:8081
editable:false
// Expose the 4-pane services window via web
!!tmux.window_ttyd
name:"dev|services"
port:7681
editable:false