Skip to content

test(tmux): add 14 integration tests for tmux session management#245

Merged
frankbria merged 3 commits into
mainfrom
feature/issue-14-tmux-integration-tests
Apr 4, 2026
Merged

test(tmux): add 14 integration tests for tmux session management#245
frankbria merged 3 commits into
mainfrom
feature/issue-14-tmux-integration-tests

Conversation

@frankbria
Copy link
Copy Markdown
Owner

@frankbria frankbria commented Apr 4, 2026

Summary

Closes #14

  • Adds tests/integration/test_tmux_integration.bats with 14 tests covering tmux session management
  • Uses inline function definitions (matching the pattern from test_backup_rollback.bats)
  • File-based tmux call tracking so assertions survive run's subshell boundary

Key adaptations from the original plan

  • 3 panes, not 2setup_tmux_session() creates: left (Ralph loop), right-top (Claude output via tail -f), right-bottom (ralph-monitor). Tests cover both split-window -h and split-window -v.
  • Window title is "Ralph: Loop | Output | Status" — not "Ralph: Loop | Monitor" as the issue plan stated.
  • check_tmux_available() calls exit 1 (not return 1) — tests run it via run; test 2 skips gracefully when tmux is installed in the environment.
  • setup_tmux_session() ends with exit 0 — running via run lets the exit only kill the subshell; the tmux call log file captures all assertions.
  • Added get_tmux_base_index() test — this helper affects pane targeting and warrants explicit coverage.

Test plan

  • All 14 tests pass locally (bats tests/integration/test_tmux_integration.bats)
  • Full suite passes: 660 tests, 0 failures (was 646)
  • CI passes

Summary by CodeRabbit

  • Tests
    • Added an integration test suite for tmux-driven session setup. Verifies tmux availability checks, base-index handling, pane/window layout and titles, launched processes per pane, assembled left-pane command flags, printed detach/reattach guidance, and that concurrent runs create distinct sessions. Tests use an isolated environment and mocked tmux invocations to enable reproducible assertions.

Tests check_tmux_available(), get_tmux_base_index(), and setup_tmux_session()
using inline function definitions and a file-based tmux call tracker.

Covers: session creation, 3-pane layout (split-window -h and -v), live log
tail in pane 1, monitor in pane 2, loop command in pane 0 (no --monitor flag),
window title, pane focus, and custom flag forwarding (--calls, --prompt).

Total tests: 660 (was 646, +14)
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 4, 2026

Walkthrough

Adds a new Bats integration test tests/integration/test_tmux_integration.bats that mocks tmux, creates an isolated env, and tests check_tmux_available(), get_tmux_base_index(), and setup_tmux_session() with assertions on tmux call sequences, session naming, pane layout, and forwarded CLI flags.

Changes

Cohort / File(s) Summary
Tmux integration tests
tests/integration/test_tmux_integration.bats
New integration test file (+~460 lines). Defines test helpers (log_status, check_tmux_available, get_tmux_base_index, setup_tmux_session, assert_tmux_called_with), installs a mocked tmux() that logs invocations to $TMUX_CALL_LOG, sets up an isolated temp env and ralph-related env vars, and implements tests validating tmux availability, base-index handling, session creation, pane layout/targets, command forwarding (many CLI flags including --calls/--prompt/--backup), detach/reattach messaging, and concurrent session uniqueness.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I mocked the panes and gave them a cheer,
Logs on the right and a loop over here.
Session names tick with each little hop,
Two sessions spun up — then I called it a stop.
Hooray for tests that make tmux go boppity-boop!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding 14 integration tests for tmux session management in a new test file.
Linked Issues check ✅ Passed The PR implements all 12 required tests plus 2 additional ones, covering session creation, pane splitting, monitor/loop startup, window titles, pane focus, custom flags, tmux availability checks, session uniqueness, detach/reattach workflow, and concurrent sessions.
Out of Scope Changes check ✅ Passed All changes are scoped to adding integration tests for tmux session management in tests/integration/test_tmux_integration.bats; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/issue-14-tmux-integration-tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/integration/test_tmux_integration.bats`:
- Around line 229-405: Add tests that cover session-name uniqueness,
detach/reattach flows, and concurrent sessions: 1) For setup_tmux_session, add a
test that invokes setup_tmux_session multiple times in rapid succession and
asserts tmux new-session -d -s ralph-[0-9]+ was called with unique session
suffixes by inspecting TMUX_CALL_LOG for duplicate names; 2) Add a test that
simulates detach/reattach by calling setup_tmux_session, then invoking the
mocked tmux detach-client/select-session sequence and asserting the script calls
the correct tmux attach or select commands; 3) Add a test that runs multiple
parallel setup_tmux_session invocations (background jobs) and asserts multiple
distinct ralph- sessions are created and that subsequent pane setup/send-keys
calls are routed to the correct session identifiers; use existing helpers like
assert_tmux_called_with and TMUX_CALL_LOG to validate calls.
- Around line 11-14: The test re-defines the real functions inline (see the
INLINE FUNCTION DEFINITIONS block) which duplicates production logic and weakens
test validity; instead remove those duplicated function bodies from
tests/integration/test_tmux_integration.bats and source or invoke the real
implementations from ralph_loop.sh (e.g., source ralph_loop.sh and call the
actual ralph_loop/start/stop/session-management functions), leaving only
environment and tmux mocking scaffolding in the test file so the tests exercise
the real code paths for session management and edge cases.
- Around line 370-375: The test "setup_tmux_session focuses left pane (pane 0)
after setup" uses a too-broad regex in assert_tmux_called_with that also matches
title-setting calls; update the assertion in that test to ensure select-pane is
called with the -t target for pane 0 and not the -T title flag (for example
require "-t <session>:0.0" explicitly or use a tighter regex like 'tmux
select-pane -t [^ ]+\.0($| )' or include a negative lookahead for '-T'); modify
the assert_tmux_called_with call in the setup_tmux_session test to use the
tighter pattern so only actual focus commands match.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4f06964-b95e-4b1f-b5d8-30e91322f479

📥 Commits

Reviewing files that changed from the base of the PR and between 40bb335 and cc11651.

📒 Files selected for processing (1)
  • tests/integration/test_tmux_integration.bats

Comment on lines +11 to +14
# INLINE FUNCTION DEFINITIONS FOR TESTING
# These mirror the implementations in ralph_loop.sh.
# IMPORTANT: Keep in sync if ralph_loop.sh changes.
# ==============================================================================
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Inline duplicated function bodies weaken integration-test validity.

These tests re-implement the functions under test instead of executing the real ralph_loop.sh implementations, so regressions in production code can go undetected. Please source/invoke the real functions and keep only environment/tmux mocks in this test file.

Based on learnings: "Test suite must achieve 100% test pass rate with comprehensive coverage of ... session management ... edge cases."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/test_tmux_integration.bats` around lines 11 - 14, The test
re-defines the real functions inline (see the INLINE FUNCTION DEFINITIONS block)
which duplicates production logic and weakens test validity; instead remove
those duplicated function bodies from
tests/integration/test_tmux_integration.bats and source or invoke the real
implementations from ralph_loop.sh (e.g., source ralph_loop.sh and call the
actual ralph_loop/start/stop/session-management functions), leaving only
environment and tmux mocking scaffolding in the test file so the tests exercise
the real code paths for session management and edge cases.

Comment thread tests/integration/test_tmux_integration.bats
Comment thread tests/integration/test_tmux_integration.bats
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 4, 2026

PR Review: test(tmux) - 14 integration tests for tmux session management

Good addition - the file-based call tracking pattern (TMUX_CALL_LOG) is the right solution for subshell boundary issues with run, and the tests are well-structured.

What is working well

  • File-based tmux call log survives run's subshell - smart and consistent with test_backup_rollback.bats
  • Test No. 9 explicitly guards against --monitor recursion - this is the most important behavioral contract to lock down
  • Test No. 10 confirms --live is always injected in tmux sessions
  • The setup/teardown is clean and the mock captures all invocations correctly

Issues to address

1. Inline copy diverges from production code

The inline setup_tmux_session() in the test file is missing 4 log lines that exist in ralph_loop.sh (lines 384-388):

log_status "INFO" "  Left:         Ralph loop"
log_status "INFO" "  Right-top:    Claude Code live output"
log_status "INFO" "  Right-bottom: Status monitor"
log_status "INFO" ""

The comment says "Keep in sync if ralph_loop.sh changes" - but it is already out of sync with main. These lines do not affect test assertions, but worth correcting before the pattern drifts further.

2. No test for base-index = 1 (the most common non-default)

Test No. 3 only validates the default (0). Users with set-option -g base-index 1 in their .tmux.conf will have sessions where all pane references are wrong if get_tmux_base_index() returns 1 but panes are still targeted as .0/.1/.2. A test that overrides the mock to return "1" and asserts split-window targets :1.1 instead of :0.1 would catch a regression here.

3. Several flag-forwarding paths have no test coverage

Tests 13 and 14 cover --calls and --prompt, but these flags are untested:

  • --verbose (VERBOSE_PROGRESS=true)
  • --timeout (CLAUDE_TIMEOUT_MINUTES != 15)
  • --no-continue (CLAUDE_USE_CONTINUE=false)
  • --auto-reset-circuit (CB_AUTO_RESET=true)
  • --backup (ENABLE_BACKUP=true)

Since this test file is the explicit home for flag-forwarding validation, comprehensive coverage here is preferable to discovering a regression when a flag silently stops being forwarded.


Minor observations

  • Test No. 3 assertion: assert_tmux_called_with "tmux show-options" could be tightened to "tmux show-options -gv base-index" to distinguish it from any future show-options call for other options.

  • pane-base-index not handled in production: The production code reads base-index (window numbering) but not pane-base-index. Users with set-option -g pane-base-index 1 will get incorrect pane targeting. Pre-existing production gap, not introduced here - worth a follow-up issue.


Summary

Tests No. 1-6 and 9-12 are solid. The two main items to address are the diverged inline copy (easy fix) and missing coverage for non-zero base-index (the most likely user-facing failure mode). Covering the remaining flag-forwarding paths would round out this file nicely before merging.

- Tighten select-pane assertion: anchor to end-of-line so title-setting
  calls (select-pane -T) do not produce false positives (CR finding 3)
- Add test 15: session name follows ralph-EPOCH format (CR finding 2)
- Add test 16: detach/reattach log instructions present (CR finding 2)
- Add test 17: two invocations create two distinct new-session calls (CR finding 2)
- Improve INLINE block comment to explain why sourcing ralph_loop.sh
  directly is not practical (CR finding 1)

Total tests: 663 (was 660, +3)
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 4, 2026

Follow-up Review: test(tmux) - PR updated to address feedback

The commit 3aa2f05 added tests No. 15-17 and tightened the pane-focus assertion in test No. 12 — good responses to CodeRabbit feedback.


Still unresolved from previous review

1. Inline copy is still missing production log lines

The inline setup_tmux_session() in the test file does not include these four lines from ralph_loop.sh (approx. lines 384-388):

log_status "INFO" "  Left:         Ralph loop"
log_status "INFO" "  Right-top:    Claude Code live output"
log_status "INFO" "  Right-bottom: Status monitor"
log_status "INFO" ""

These do not affect any current test assertion, but the divergence will grow silently. The comment at the top says "Keep in sync if ralph_loop.sh changes" — it is already out of sync.

2. No test for base-index = 1

Only the default (0) is covered. Adding a test that overrides the mock to return "1" and asserts split-window -v -t targets :${base_win}.1 would catch the most common non-default tmux configuration.

3. Several flag-forwarding paths still have no coverage

Tests 13 and 14 cover --calls and --prompt. These are still untested:

  • --verbose (VERBOSE_PROGRESS=true)
  • --timeout (CLAUDE_TIMEOUT_MINUTES != 15)
  • --no-continue (CLAUDE_USE_CONTINUE=false)
  • --auto-reset-circuit (CB_AUTO_RESET=true)
  • --backup (ENABLE_BACKUP=true)

These are low-effort additions following the same pattern as tests 13 and 14.


Minor items

PR title/description mismatch: The title still says "add 14 integration tests" but the file now has 17. Worth updating the PR description.

Test No. 17 uses sleep 1: The sleep 1 guards uniqueness by relying on epoch-second granularity. This adds real wall-clock time to CI. Mocking date to return distinct values would be more reliable.

Test No. 3 assertion still broad: assert_tmux_called_with "tmux show-options" would match any future show-options call. Tightening to "tmux show-options -gv base-index" makes this more precise.


What was done well in this update

  • Test No. 12 end-of-line anchor (^tmux select-pane -t [^ ]+\.0$) correctly excludes the title-setting -T calls. Good fix.
  • Test No. 15 checks the ralph-EPOCH format directly from the call log, more robust than relying on MOCK_TMUX_SESSION_NAME.
  • Test No. 17 validates uniqueness across invocations without requiring real tmux — the approach is sound.

The three main items to resolve before merging are: the inline copy divergence, the missing base-index-1 test, and the incomplete flag-forwarding coverage.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
tests/integration/test_tmux_integration.bats (2)

441-459: ⚠️ Potential issue | 🟠 Major

Concurrent session behavior is still not actually covered.

Line 441-Line 459 runs two sequential calls with sleep 1; this avoids same-second collisions rather than testing rapid/concurrent creation. The linked objective calls out multiple concurrent sessions explicitly.

Based on learnings: "Test suite must achieve 100% test pass rate with comprehensive coverage of: ... session management ... edge cases."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/test_tmux_integration.bats` around lines 441 - 459, The
test currently calls setup_tmux_session twice sequentially with sleep 1; change
it to exercise concurrent creation by launching two setup_tmux_session
invocations in parallel (background/subshell) and wait for both to finish, then
assert TMUX_CALL_LOG contains two "tmux new-session" entries and two distinct
session names; update the test block (referencing the test name and the
setup_tmux_session function and TMUX_CALL_LOG variable) to start both
invocations concurrently, wait, then perform the existing grep/count and
name-uniqueness checks.

11-20: ⚠️ Potential issue | 🟠 Major

Inline re-implementation still weakens integration-test trust.

At Line 11-Line 20, this suite still validates copied function bodies instead of exercising ralph_loop.sh behavior directly, so production regressions can pass unnoticed when implementations drift.

Based on learnings: "Test suite must achieve 100% test pass rate with comprehensive coverage of: ... session management ... edge cases."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/test_tmux_integration.bats` around lines 11 - 20, The tests
inline function bodies from ralph_loop.sh which weakens integration coverage;
instead extract the reusable functions into a new library (e.g.,
ralph_loop_lib.sh) and have both ralph_loop.sh source that lib and
tests/integration/test_tmux_integration.bats source the same lib so the tests
exercise the real implementations; ensure the refactor preserves exported
variables (RALPH_DIR, LOG_DIR) by keeping top-level assignments in ralph_loop.sh
(not the lib) or provide a sourcing guard (e.g., only define functions when not
already defined) so sourcing the lib in tests does not execute production
top-level assignments.
🧹 Nitpick comments (1)
tests/integration/test_tmux_integration.bats (1)

419-424: Test 15 duplicates Test 4’s assertion.

Line 419-Line 424 overlaps with Line 284-Line 288 (new-session + ralph-[0-9]+). Consider merging or repurposing this case to cover an untested behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/test_tmux_integration.bats` around lines 419 - 424, The
test "setup_tmux_session generates session name in ralph-EPOCH format"
duplicates the earlier assertion that tmux was called with "new-session -d -s
ralph-[0-9]+"; update the tests so they are not redundant by either removing
this duplicate block or changing it to exercise a different behavior of
setup_tmux_session (for example verify session name prefix only, verify
environment variables passed, or assert the call includes a specific flag).
Locate the test function name setup_tmux_session and the assertion
assert_tmux_called_with "^tmux new-session -d -s ralph-[0-9]+" and replace or
modify this second occurrence accordingly so each test covers a unique case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/integration/test_tmux_integration.bats`:
- Around line 441-459: The test currently calls setup_tmux_session twice
sequentially with sleep 1; change it to exercise concurrent creation by
launching two setup_tmux_session invocations in parallel (background/subshell)
and wait for both to finish, then assert TMUX_CALL_LOG contains two "tmux
new-session" entries and two distinct session names; update the test block
(referencing the test name and the setup_tmux_session function and TMUX_CALL_LOG
variable) to start both invocations concurrently, wait, then perform the
existing grep/count and name-uniqueness checks.
- Around line 11-20: The tests inline function bodies from ralph_loop.sh which
weakens integration coverage; instead extract the reusable functions into a new
library (e.g., ralph_loop_lib.sh) and have both ralph_loop.sh source that lib
and tests/integration/test_tmux_integration.bats source the same lib so the
tests exercise the real implementations; ensure the refactor preserves exported
variables (RALPH_DIR, LOG_DIR) by keeping top-level assignments in ralph_loop.sh
(not the lib) or provide a sourcing guard (e.g., only define functions when not
already defined) so sourcing the lib in tests does not execute production
top-level assignments.

---

Nitpick comments:
In `@tests/integration/test_tmux_integration.bats`:
- Around line 419-424: The test "setup_tmux_session generates session name in
ralph-EPOCH format" duplicates the earlier assertion that tmux was called with
"new-session -d -s ralph-[0-9]+"; update the tests so they are not redundant by
either removing this duplicate block or changing it to exercise a different
behavior of setup_tmux_session (for example verify session name prefix only,
verify environment variables passed, or assert the call includes a specific
flag). Locate the test function name setup_tmux_session and the assertion
assert_tmux_called_with "^tmux new-session -d -s ralph-[0-9]+" and replace or
modify this second occurrence accordingly so each test covers a unique case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 36fbb0fe-a098-4102-952a-b018b7d57a2f

📥 Commits

Reviewing files that changed from the base of the PR and between cc11651 and 3aa2f05.

📒 Files selected for processing (1)
  • tests/integration/test_tmux_integration.bats

- Test 17: replace sequential sleep-1 calls with true concurrent background
  subshells; assert count=2 new-session entries in shared log (CR Major)
- Test 15: replace duplicate format check with timestamp-currency check —
  verifies epoch is within 5s of test execution, not just matching [0-9]+
  (CR Nitpick — was duplicate of test 4)

Skipped: extracting tmux functions to ralph_loop_lib.sh — this requires
modifying ralph_loop.sh and is out of scope for a test-only PR. Tracked
as a future improvement.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
tests/integration/test_tmux_integration.bats (2)

11-156: ⚠️ Potential issue | 🟠 Major

Use production implementations instead of inline mirrors for integration validity.

At Line 11 onward, these tests duplicate the tmux functions instead of executing the real ralph_loop.sh code path, so production regressions can slip through while tests still pass. Keep tmux/environment mocks, but source/invoke the real implementation (or a shared extracted library) for these assertions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/test_tmux_integration.bats` around lines 11 - 156, The test
currently duplicates production functions (log_status, check_tmux_available,
get_tmux_base_index, setup_tmux_session) which masks regressions; instead remove
these inline mirrors and source or invoke the real implementations (or a shared
extracted library) used by ralph_loop.sh so tests exercise production code
paths. Concretely, replace the inline definitions with sourcing of a
functions-only file (or refactor ralph_loop.sh to export these functions) and
keep only lightweight tmux/environment mocks in the test; ensure
setup_tmux_session, get_tmux_base_index and check_tmux_available calls in the
test resolve to the production implementations rather than the inline copies.

436-460: ⚠️ Potential issue | 🟠 Major

Coverage is still too weak for session uniqueness/reattach behavior.

Line 447-459 only checks that two new-session calls happened, not that the session names are distinct. Line 436-441 checks printed guidance text, but not actual attach/select call behavior. This can pass even if multi-session handling regresses.

Suggested tightening
 `@test` "two concurrent setup_tmux_session invocations each create a tmux new-session call" {
@@
-    local count
-    count=$(grep -c "^tmux new-session" "$TMUX_CALL_LOG")
-    [ "$count" -eq 2 ]
+    local count
+    count=$(grep -c "^tmux new-session" "$TMUX_CALL_LOG")
+    [ "$count" -eq 2 ]
+
+    local s1 s2
+    s1=$(grep "^tmux new-session" "$TMUX_CALL_LOG" | sed -n '1s/.*-s \(ralph-[0-9]\+\).*/\1/p')
+    s2=$(grep "^tmux new-session" "$TMUX_CALL_LOG" | sed -n '2s/.*-s \(ralph-[0-9]\+\).*/\1/p')
+    [ -n "$s1" ] && [ -n "$s2" ]
+    [ "$s1" != "$s2" ]
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/test_tmux_integration.bats` around lines 436 - 460, The
tests only assert two "tmux new-session" entries and some printed guidance;
tighten them to verify actual distinct session names and attach/select behavior:
in the concurrent test (referencing setup_tmux_session and TMUX_CALL_LOG) parse
the session names from the "tmux new-session" log lines (e.g. extract the -s
<name> token) and assert there are two different names, and also assert the
TMUX_CALL_LOG contains corresponding "tmux attach -t <name>" or "tmux
select-window -t <name>" lines for those names; likewise, for the guidance test
that calls setup_tmux_session, assert the command output includes the concrete
session name or attach command (not just "Ctrl+B" and "tmux attach") so the test
ensures printed reattach instructions reference the actual session created.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/integration/test_tmux_integration.bats`:
- Around line 11-156: The test currently duplicates production functions
(log_status, check_tmux_available, get_tmux_base_index, setup_tmux_session)
which masks regressions; instead remove these inline mirrors and source or
invoke the real implementations (or a shared extracted library) used by
ralph_loop.sh so tests exercise production code paths. Concretely, replace the
inline definitions with sourcing of a functions-only file (or refactor
ralph_loop.sh to export these functions) and keep only lightweight
tmux/environment mocks in the test; ensure setup_tmux_session,
get_tmux_base_index and check_tmux_available calls in the test resolve to the
production implementations rather than the inline copies.
- Around line 436-460: The tests only assert two "tmux new-session" entries and
some printed guidance; tighten them to verify actual distinct session names and
attach/select behavior: in the concurrent test (referencing setup_tmux_session
and TMUX_CALL_LOG) parse the session names from the "tmux new-session" log lines
(e.g. extract the -s <name> token) and assert there are two different names, and
also assert the TMUX_CALL_LOG contains corresponding "tmux attach -t <name>" or
"tmux select-window -t <name>" lines for those names; likewise, for the guidance
test that calls setup_tmux_session, assert the command output includes the
concrete session name or attach command (not just "Ctrl+B" and "tmux attach") so
the test ensures printed reattach instructions reference the actual session
created.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b171572-6c6d-4d22-9f2f-b813b48bb355

📥 Commits

Reviewing files that changed from the base of the PR and between 3aa2f05 and f3535b0.

📒 Files selected for processing (1)
  • tests/integration/test_tmux_integration.bats

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 4, 2026

Round-3 Review: test(tmux) addressing round-2 CodeRabbit feedback

The changes in f3535b0 are clean and correct responses to the CodeRabbit round-2 findings.

Test 15: Timestamp-currency check (delta -le 5) is a meaningful improvement over the prior duplicate format check.

Test 17: True concurrent background subshells with a shared log file is the right way to test session isolation.


Still open from previous reviews

INLINE COPY MISSING 4 LOG LINES

This was raised in both the first and second reviews and remains unresolved. The inline setup_tmux_session() in the test file omits four log_status lines that exist in ralph_loop.sh (lines 383-394).

Current inline copy goes directly from:
log_status "SUCCESS" "Tmux session created with 3 panes:"
to:
log_status "INFO" "Use Ctrl+B then D to detach from session"

Production code has four additional lines between those two:
log_status "INFO" " Left: Ralph loop"
log_status "INFO" " Right-top: Claude Code live output"
log_status "INFO" " Right-bottom: Status monitor"
log_status "INFO" ""

The inline comment says "Keep in sync if ralph_loop.sh changes" but these lines were never included. Test 16 only checks for Ctrl+B and tmux attach, so it passes against the incomplete copy and would not catch regressions in the pane-description output.

Fix: Add the 4 missing lines to the inline function. Optionally extend Test 16 to assert on pane descriptions, e.g. [[ "$output" == "Right-top" ]]


Minor: PR description still says 14 tests but the file now has 17. Worth updating before merge.

@frankbria frankbria merged commit 49a705f into main Apr 4, 2026
6 checks passed
@frankbria frankbria deleted the feature/issue-14-tmux-integration-tests branch April 4, 2026 18:49
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.

[P2] Phase 4.4: Implement tmux integration tests

1 participant