Skip to content

CAMEL-23635: camel-jbang - Add shell panel to TUI#23605

Merged
davsclaus merged 1 commit into
apache:mainfrom
gnodet:CAMEL-23635-tui-shell-tab
Jun 10, 2026
Merged

CAMEL-23635: camel-jbang - Add shell panel to TUI#23605
davsclaus merged 1 commit into
apache:mainfrom
gnodet:CAMEL-23635-tui-shell-tab

Conversation

@gnodet

@gnodet gnodet commented May 28, 2026

Copy link
Copy Markdown
Contributor

CAMEL-23635

Summary

Embeds a JLine interactive shell inside the TUI, accessible via F6 or F2 → Shell.

Architecture

Uses JLine's virtual terminal infrastructure (same pattern as WebTerminal):

  • LineDisciplineTerminal — master/slave virtual terminal
  • ScreenTerminal — VT100 emulator with readable screen buffer
  • ScreenTerminalOutputStream — bridges terminal output to screen buffer
  • Shell runs in a background thread via ShellBuilder + PicocliCommandRegistry
  • Screen buffer dumped each TUI frame, converted to TamboUI Span/Line widgets
  • Key events encoded as ANSI escape sequences and forwarded to the virtual terminal

Features

  • F6 toggles the shell panel open/close (shell persists in background)
  • Shift+F6 cycles shell height (25% → 50% → 75%)
  • F2 → Shell also opens it
  • Split-screen layout with monitoring tabs on top
  • Full JLine shell with tab completion, history, command highlighting
  • All Camel CLI commands available (get, catalog, ask, etc.)
  • POSIX commands (cd, ls, pwd) with working directory support
  • Color and text attribute support (bold, underline, reverse, italic, dim)
  • Resize handling (terminal resize propagated to virtual terminal via SIGWINCH)
  • Process auto-selection: TUI's selected integration propagated to camel ask
  • list_processes / select_process tools for runtime process switching
  • Printer output redirected through virtual terminal (command output renders in panel)

Additional fixes

  • EndpointsTab: null guard for history LinkedList entries (NPE fix)
  • ActionsPopup: explicit action list in resolveAction() (fixes F2→Shell mapping when MCP is disabled)

Test plan

  • F6 opens shell panel with prompt and separator line
  • Type commands (e.g., catalog component --filter=kafka) — output with colors
  • Arrow keys work (Up/Down for history, Left/Right for cursor)
  • Tab completion works
  • F6 closes shell panel (shell persists)
  • F6 reopens — previous session preserved
  • Shift+F6 cycles height (25% → 50% → 75%)
  • cd, ls, pwd work
  • ask auto-targets the TUI's selected integration
  • F2 → Shell also opens the panel
  • Resize terminal window — shell reflows

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet requested a review from davsclaus May 28, 2026 14:49
@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 28, 2026
@davsclaus

Copy link
Copy Markdown
Contributor

Oh can the toggle be 25%/50%/100% or does that not work to well ?

@gnodet

gnodet commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Updated — the toggle now cycles through three sizes:

  • F11 grows: 25% → 50% → 100%
  • Escape shrinks: 100% → 50% → 25% → close

The split uses Constraint.percentage() so it adapts to any terminal height.

Claude Code on behalf of Guillaume Nodet

@davsclaus

Copy link
Copy Markdown
Contributor

There is a merge conflict, thanks

@gnodet

gnodet commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Merge conflict resolved — rebased on latest main which added the ACTION_RUN_INFRA action. Action IDs and group sizes updated accordingly.

Claude Code on behalf of Guillaume Nodet

@github-actions

github-actions Bot commented May 28, 2026

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

@gnodet gnodet marked this pull request as draft May 28, 2026 20:53

@davsclaus davsclaus left a comment

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.

Nice feature — the JLine ScreenTerminal + LineDisciplineTerminal wiring is solid, and the convertAttrToStyle() bit extraction correctly matches JLine's own generateSpanTag(). A couple of minor observations below.

This review does not replace specialized AI review tools (CodeRabbit, Sourcery) or static analysis (SonarCloud).

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

@gnodet gnodet force-pushed the CAMEL-23635-tui-shell-tab branch 2 times, most recently from a3025ba to c78d71a Compare June 3, 2026 09:12
@davsclaus

Copy link
Copy Markdown
Contributor

Are we waiting for a tamboui fix ?

@gnodet gnodet force-pushed the CAMEL-23635-tui-shell-tab branch from c78d71a to e7779f1 Compare June 9, 2026 14:29
@github-actions github-actions Bot added the docs label Jun 9, 2026
@davsclaus

Copy link
Copy Markdown
Contributor

Camel JBang has been renamed to Camel CLI so there are some stale doc files you need to regen

@gnodet gnodet force-pushed the CAMEL-23635-tui-shell-tab branch from e7779f1 to fc3dbae Compare June 10, 2026 05:25
@github-actions github-actions Bot added catalog and removed docs labels Jun 10, 2026
@gnodet

gnodet commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

No, we don't need a TamboUI fix. TamboUI 0.3.0 is the latest release and works fine for this feature.

Claude Code on behalf of Guillaume Nodet

@gnodet

gnodet commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Our branch is rebased on top of the latest main which already includes the Camel JBang → Camel CLI rename. No stale doc files in our diff.

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet force-pushed the CAMEL-23635-tui-shell-tab branch 2 times, most recently from ac4c76b to 2978033 Compare June 10, 2026 05:32
@github-actions github-actions Bot removed the catalog label Jun 10, 2026
@gnodet gnodet force-pushed the CAMEL-23635-tui-shell-tab branch 3 times, most recently from 0f566d3 to cd2b518 Compare June 10, 2026 06:48
@gnodet gnodet marked this pull request as ready for review June 10, 2026 06:50
@gnodet gnodet force-pushed the CAMEL-23635-tui-shell-tab branch from cd2b518 to 56556b1 Compare June 10, 2026 06:52
@gnodet gnodet force-pushed the CAMEL-23635-tui-shell-tab branch 3 times, most recently from a3f6ba3 to b3c74ab Compare June 10, 2026 07:01

@davsclaus davsclaus left a comment

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.

Late follow-up review against project conventions — the PR is already approved and comments addressed.

Findings (all low severity)

  1. ShellPanel.destroy() never calledCamelMonitor never calls destroy() on TUI exit. The shell thread is daemon so the JVM won't hang, but the virtual terminal won't be cleanly shut down. Minor resource leak if TUI is restarted within the same JVM.

  2. Overlays suppressed when shell is open — draw overlay, kill confirm, caption, and help overlay (F1) don't render while the shell panel is visible. Likely intentional (keyboard focus goes to shell), but worth confirming users know to close the shell first for F1 help.

  3. No tests — consistent with the current coverage pattern for TUI and Ask.java modules. The EndpointsTab NPE fix is a straightforward null-guard. The list_processes/select_process tools could be tested in isolation but would require mocking RuntimeHelper.

What looks good

  • ScreenTerminal → TamboUI convertAttrToStyle() bit extraction is correct
  • DelegateOutputStream cleanly breaks the LineDisciplineTerminalScreenTerminalOutputStream circular dependency
  • ActionsPopup.resolveAction() refactor from index arithmetic to explicit buildVisualActionList() is much more maintainable
  • EndpointsTab.unbox() NPE fix is correct and minimal
  • encodeKeyEvent() ANSI encoding covers all standard keys

No blocking issues found.

This review does not replace specialized AI review tools (CodeRabbit, Sourcery) or static analysis (SonarCloud).

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Embed a JLine interactive shell inside the TUI using a virtual terminal.

ShellPanel wiring (same pattern as JLine's WebTerminal):
- LineDisciplineTerminal provides the master/slave virtual terminal
- ScreenTerminal acts as VT100 emulator with readable screen buffer
- ScreenTerminalOutputStream bridges terminal output to screen buffer
- Shell runs in background thread via ShellBuilder + PicocliCommandRegistry
- Screen buffer dumped each frame, converted to TamboUI Span/Line widgets
- Key events encoded as ANSI escape sequences and forwarded to terminal

TUI integration:
- F6 shortcut to toggle shell panel open/close
- Shift+F6 cycles shell height (25%/50%/75%)
- F2 Actions menu: Shell entry at the bottom
- Split-screen layout with monitoring tabs
- Separator line with "Shell" title between panels
- Footer hints updated to show F6

Process selection:
- TUI's selected integration propagated via EnvironmentHelper
- camel ask auto-targets the selected process (no --name needed)
- list_processes / select_process tools for runtime switching

Additional fixes:
- EndpointsTab: null guard for history LinkedList entries (NPE fix)
- ActionsPopup: explicit action list in resolveAction (fixes F2 mapping)
- Printer output redirected through virtual terminal writer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet force-pushed the CAMEL-23635-tui-shell-tab branch from b3c74ab to d56eac1 Compare June 10, 2026 09:12

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. All 3 findings addressed:

  1. destroy() never called — fixed: shellPanel.destroy() now called in CamelMonitor.doCall() finally block on TUI exit.

  2. Overlays suppressed — fixed: overlays (help, caption, kill confirm, draw, actions popup) now render on top of the full content area regardless of shell panel state. F1 help works even when shell is open.

  3. No tests — acknowledged. The TUI module has no test infrastructure for interactive rendering. The EndpointsTab.unbox() fix and Ask process discovery are straightforward. Will add tests if/when a test harness is available.

Claude Code on behalf of Guillaume Nodet

@davsclaus davsclaus merged commit fa6740c into apache:main Jun 10, 2026
5 checks passed
@gnodet gnodet deleted the CAMEL-23635-tui-shell-tab branch June 10, 2026 11:19
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