Skip to content

chore: Reuse shell terminal for TUI subcommands#23484

Open
gnodet wants to merge 2 commits into
apache:mainfrom
gnodet:fix/tui-reuse-shell-terminal
Open

chore: Reuse shell terminal for TUI subcommands#23484
gnodet wants to merge 2 commits into
apache:mainfrom
gnodet:fix/tui-reuse-shell-terminal

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 23, 2026

Summary

Running tui or tui catalog inside camel shell crashes with Stream Closed because TamboUI's JLineBackend tries to create a second system terminal while the shell already owns stdin.

This PR adds a TuiBackendHelper that:

  1. Checks EnvironmentHelper.getActiveTerminal() for an active shell terminal
  2. Creates a JLineBackend(terminal) via reflection and passes it through TuiConfig.builder().backend(backend)
  3. Falls back to TuiRunner.create() when the JLineBackend(Terminal) constructor is not available

Depends on:

Changes:

  • New TuiBackendHelper.createTuiRunner() in the TUI plugin
  • CamelMonitor and CamelCatalogTui use the helper instead of TuiRunner.create()

Test plan

  • Verified: camel shelltui works without "Stream Closed" crash (with tamboui SNAPSHOT containing the new constructor)
  • Verified: camel tui outside shell continues to work (creates its own terminal as before)

Claude Code on behalf of Guillaume Nodet

gnodet and others added 2 commits May 23, 2026 10:34
Inside the JLine shell, System.console() returns null, causing
subcommands that read interactive input to silently fail. This moves
the active terminal reference to EnvironmentHelper so all commands
can detect and use the shell's terminal for input/output.

Commands fixed:
- debug: user input (step, quit) now works inside shell
- infra run: "press ENTER to stop" now works inside shell
- init: interactive template picker now works inside shell
- watch commands: "press enter" to stop now works inside shell
- confirmOperation: interactive confirmation now works inside shell

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When running TUI commands (tui, tui catalog) inside camel shell,
the TUI crashes with "Stream Closed" because TamboUI tries to
create a second system terminal while the shell already owns stdin.

Add TuiBackendHelper that checks for an active shell terminal via
EnvironmentHelper.getActiveTerminal() and passes it to JLineBackend
via TuiConfig, so the TUI reuses the shell's terminal instead of
creating a new one.

Falls back to TuiRunner.create() when JLineBackend(Terminal) is not
available (requires tamboui/tamboui#351).
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions Bot added the dsl label May 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-core
  • dsl/camel-jbang/camel-jbang-plugin-tui

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 1 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (6 modules)
  • Camel :: JBang :: Core
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container

⚙️ View full build and test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants