Skip to content

bug(test): TestRunArgsNoCommandLaunchesTUI hangs and times out (10m) in headless/TTY-mixed environments #254

Description

@0xMar

Pre-flight Checklist

  • I have searched existing issues and this is not a duplicate
  • I understand that PRs will be rejected if the linked issue does not have status:approved

📝 Bug Description

Running the full Go test suite can hang for ~10 minutes due to TestRunArgsNoCommandLaunchesTUI launching Bubbletea with real terminal I/O.
In some Linux environments, instead of returning quickly with a TTY-related error (or nil), the test blocks inside Bubbletea until Go’s package timeout triggers.

This causes flaky CI/local runs and very long feedback loops.

🔄 Steps to Reproduce

  1. Run:
    go test -count=1 -v ./...
  2. Observe progress reaching:
    ok github.com/gentleman-programming/gentle-ai/internal/agents/windsurf ...
    
  3. Execution appears stuck before next package output, then eventually fails after ~10 minutes in internal/app.

✅ Expected Behavior

TestRunArgsNoCommandLaunchesTUI should be deterministic and complete quickly in all environments (including headless/CI), without depending on real TTY behavior.

❌ Actual Behavior

The test blocks for almost the entire package timeout and then fails:

panic: test timed out after 10m0s
running tests:
    TestRunArgsNoCommandLaunchesTUI (9m59s)
...
github.com/charmbracelet/bubbletea.(*Program).Run(...)
github.com/gentleman-programming/gentle-ai/internal/app.RunArgs(...)
./gentle-ai/internal/app/app.go:114
github.com/gentleman-programming/gentle-ai/internal/app.TestRunArgsNoCommandLaunchesTUI(...)
./gentle-ai/internal/app/parity_test.go:165
FAIL    github.com/gentleman-programming/gentle-ai/internal/app    600.008s

🖥️ Environment

  • Gentle AI Version: v1.18.3
  • Operating System: Linux (Arch/Manjaro)
  • AI Agent / Client: Other (local go test run)
  • 📋 Affected Area: TUI (terminal UI)

💡 Logs / Error Output

Relevant section from gotest.log:

panic: test timed out after 10m0s
    running tests:
        TestRunArgsNoCommandLaunchesTUI (9m59s)

goroutine ...:
github.com/charmbracelet/bubbletea.(*Program).eventLoop(...)
github.com/charmbracelet/bubbletea.(*Program).Run(...)
github.com/gentleman-programming/gentle-ai/internal/app.RunArgs(...)
    ./gentle-ai/internal/app/app.go:114
github.com/gentleman-programming/gentle-ai/internal/app.TestRunArgsNoCommandLaunchesTUI(...)
    ./gentle-ai/internal/app/parity_test.go:165
...
FAIL    github.com/gentleman-programming/gentle-ai/internal/app    600.008s

Additional Context

Tests were executed from a local source checkout.

Current test implementation (internal/app/parity_test.go) expects either:

  • nil (TTY available), or
  • immediate TTY-related error in headless mode.

However, in this environment Bubbletea can block in input/event loops instead of returning quickly, making the test non-deterministic.

Suggested direction:

  • avoid running real Program.Run() in unit tests (inject/mock TUI launcher),
  • keep optional integration test with PTY if needed,
  • add short fail-fast timeout guard for this path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstatus:approvedApproved for implementation — PRs can now be opened

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions