Skip to content

Commit d289348

Browse files
committed
feat(tmux): add --binary flag for testing compiled CLI binaries
- Add -b/--binary flag to tmux-start.sh (defaults to ./cli/bin/codebuff) - Add CODEBUFF_BINARY env var support for specifying binary path - Record cli_mode (binary/dynamic) and cli_command in session-info.yaml - Update README.md and tmux-cli.sh help with binary testing docs This enables @cli-ui-tester to test compiled binaries vs dynamic dev mode.
1 parent 2617328 commit d289348

File tree

3 files changed

+96
-6
lines changed

3 files changed

+96
-6
lines changed

scripts/tmux/README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tmux send-keys -t session "hello world"
2929
## Quick Start
3030

3131
```bash
32-
# Start a test session
32+
# Start a test session (dynamic CLI via bun)
3333
SESSION=$(./scripts/tmux/tmux-cli.sh start)
3434
echo "Started session: $SESSION"
3535

@@ -43,6 +43,26 @@ echo "Started session: $SESSION"
4343
./scripts/tmux/tmux-cli.sh stop "$SESSION"
4444
```
4545

46+
## Testing Compiled Binaries
47+
48+
To test a compiled CLI binary instead of the dynamic development server:
49+
50+
```bash
51+
# Build the binary first
52+
cd cli && bun run build:binary
53+
54+
# Test with binary at default location (./cli/bin/codebuff)
55+
SESSION=$(./scripts/tmux/tmux-cli.sh start --binary)
56+
57+
# Or specify a custom binary path
58+
SESSION=$(./scripts/tmux/tmux-cli.sh start --binary /path/to/codebuff)
59+
60+
# Or use environment variable
61+
CODEBUFF_BINARY=./cli/bin/codebuff ./scripts/tmux/tmux-cli.sh start
62+
```
63+
64+
The session-info.yaml will record which mode was used (`cli_mode: binary` or `cli_mode: dynamic`).
65+
4666
## Scripts
4767

4868
### `tmux-cli.sh` (Unified Interface)
@@ -63,7 +83,7 @@ The main entry point with subcommands:
6383
Start a new tmux session with the CLI.
6484

6585
```bash
66-
# Default settings
86+
# Default settings (dynamic CLI)
6787
./scripts/tmux/tmux-start.sh
6888
# Output: cli-test-1234567890
6989

@@ -75,6 +95,15 @@ Start a new tmux session with the CLI.
7595

7696
# Custom wait time for CLI initialization
7797
./scripts/tmux/tmux-start.sh --wait 6
98+
99+
# Test a compiled binary (default location: ./cli/bin/codebuff)
100+
./scripts/tmux/tmux-start.sh --binary
101+
102+
# Test a compiled binary at custom path
103+
./scripts/tmux/tmux-start.sh --binary /path/to/binary
104+
105+
# Via environment variable
106+
CODEBUFF_BINARY=./my-binary ./scripts/tmux/tmux-start.sh
78107
```
79108

80109
### `tmux-send.sh`
@@ -183,6 +212,8 @@ started_local: Wed Jan 1 12:00:00 PST 2025
183212
dimensions:
184213
width: 120
185214
height: 30
215+
cli_mode: dynamic # or "binary"
216+
cli_command: bun --cwd=cli run dev # or path to binary
186217
status: active
187218
```
188219

scripts/tmux/tmux-cli.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
# ./scripts/tmux/tmux-cli.sh capture "$SESSION" --wait 3
4646
# ./scripts/tmux/tmux-cli.sh stop "$SESSION"
4747
#
48+
# # Test a compiled binary (instead of dynamic CLI)
49+
# SESSION=$(./scripts/tmux/tmux-cli.sh start --binary)
50+
# # Or with custom path:
51+
# SESSION=$(./scripts/tmux/tmux-cli.sh start --binary ./path/to/codebuff)
52+
#
4853
# # Stop all test sessions
4954
# ./scripts/tmux/tmux-cli.sh stop --all
5055
#

scripts/tmux/tmux-start.sh

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# -w, --width WIDTH Terminal width (default: 120)
1818
# -h, --height HEIGHT Terminal height (default: 80)
1919
# --wait SECONDS Seconds to wait for CLI to initialize (default: 4)
20+
# -b, --binary [PATH] Use compiled binary instead of dynamic CLI
21+
# If PATH omitted, uses ./cli/bin/codebuff
22+
# Can also set CODEBUFF_BINARY env var
2023
# --help Show this help message
2124
#
2225
# SESSION LOGS:
@@ -36,6 +39,15 @@
3639
# # Start with custom dimensions
3740
# ./scripts/tmux/tmux-start.sh -w 160 -h 40
3841
#
42+
# # Test a compiled binary (default location)
43+
# ./scripts/tmux/tmux-start.sh --binary
44+
#
45+
# # Test a compiled binary at custom path
46+
# ./scripts/tmux/tmux-start.sh --binary ./path/to/codebuff
47+
#
48+
# # Via environment variable
49+
# CODEBUFF_BINARY=./cli/bin/codebuff ./scripts/tmux/tmux-start.sh
50+
#
3951
# EXIT CODES:
4052
# 0 - Success (session name printed to stdout)
4153
# 1 - Error (tmux not found or session creation failed)
@@ -44,11 +56,17 @@
4456

4557
set -e
4658

59+
# Get project root early (needed for defaults)
60+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
61+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
62+
4763
# Defaults
4864
SESSION_NAME=""
4965
WIDTH=120
5066
HEIGHT=30 # Reasonable default that matches typical terminal heights
5167
WAIT_SECONDS=4
68+
DEFAULT_BINARY="$PROJECT_ROOT/cli/bin/codebuff"
69+
BINARY_PATH="${CODEBUFF_BINARY:-}" # Environment variable takes precedence
5270

5371
# Parse arguments
5472
while [[ $# -gt 0 ]]; do
@@ -69,8 +87,19 @@ while [[ $# -gt 0 ]]; do
6987
WAIT_SECONDS="$2"
7088
shift 2
7189
;;
90+
-b|--binary)
91+
# Check if next arg is a path (not another flag or missing)
92+
if [[ -n "${2:-}" && "${2:-}" != -* ]]; then
93+
BINARY_PATH="$2"
94+
shift 2
95+
else
96+
# --binary alone uses default location
97+
BINARY_PATH="$DEFAULT_BINARY"
98+
shift
99+
fi
100+
;;
72101
--help)
73-
head -n 40 "$0" | tail -n +2 | sed 's/^# //' | sed 's/^#//'
102+
head -n 50 "$0" | tail -n +2 | sed 's/^# //' | sed 's/^#//'
74103
exit 0
75104
;;
76105
*)
@@ -96,13 +125,36 @@ if ! command -v tmux &> /dev/null; then
96125
exit 1
97126
fi
98127

99-
# Get project root (assuming script is in scripts/tmux/)
100-
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
128+
# Determine CLI command (binary vs dynamic)
129+
if [[ -n "$BINARY_PATH" ]]; then
130+
# Binary mode - validate the binary exists and is executable
131+
if [[ ! -f "$BINARY_PATH" ]]; then
132+
echo "❌ Binary not found: $BINARY_PATH" >&2
133+
echo "" >&2
134+
echo "💡 Build the binary first:" >&2
135+
echo " cd cli && bun run build:binary" >&2
136+
exit 1
137+
fi
138+
if [[ ! -x "$BINARY_PATH" ]]; then
139+
echo "❌ Binary not executable: $BINARY_PATH" >&2
140+
echo "" >&2
141+
echo "💡 Fix with: chmod +x '$BINARY_PATH'" >&2
142+
exit 1
143+
fi
144+
CLI_CMD="cd '$PROJECT_ROOT' && '$BINARY_PATH' 2>&1"
145+
CLI_MODE="binary"
146+
CLI_DISPLAY="$BINARY_PATH"
147+
else
148+
# Dynamic mode (default) - run via bun
149+
CLI_CMD="cd '$PROJECT_ROOT' && bun --cwd=cli run dev 2>&1"
150+
CLI_MODE="dynamic"
151+
CLI_DISPLAY="bun --cwd=cli run dev"
152+
fi
101153

102154
# Create tmux session running CLI
103155
if ! tmux new-session -d -s "$SESSION_NAME" \
104156
-x "$WIDTH" -y "$HEIGHT" \
105-
"cd '$PROJECT_ROOT' && bun --cwd=cli run dev 2>&1" 2>/dev/null; then
157+
"$CLI_CMD" 2>/dev/null; then
106158
echo "❌ Failed to create tmux session" >&2
107159
exit 1
108160
fi
@@ -119,6 +171,8 @@ started_local: $(date)
119171
dimensions:
120172
width: $WIDTH
121173
height: $HEIGHT
174+
cli_mode: $CLI_MODE
175+
cli_command: $CLI_DISPLAY
122176
status: active
123177
EOF
124178

0 commit comments

Comments
 (0)