Skip to content

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

Draft
gnodet wants to merge 6 commits into
apache:mainfrom
gnodet:CAMEL-23635-tui-shell-tab
Draft

CAMEL-23635: camel-jbang - Add shell panel to TUI#23605
gnodet wants to merge 6 commits into
apache:mainfrom
gnodet:CAMEL-23635-tui-shell-tab

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 28, 2026

CAMEL-23635

Summary

Embeds a real JLine shell inside the TUI using JLine's virtual terminal infrastructure:

  • ShellPanel: new overlay panel accessible from F2 → Shell

    • Uses LineDisciplineTerminal + ScreenTerminal (VT100 emulator) + ScreenTerminalOutputStream — the same wiring pattern as JLine's own WebTerminal
    • Shell runs in a background thread via ShellBuilder with PicocliCommandRegistry — full tab completion, history, aliases, fish-style autosuggestions
    • Screen buffer dumped each frame and converted to TamboUI Span/Line widgets with proper color/attribute mapping
    • Full resize handling: size toggle + real terminal resize propagated via setSize() → SIGWINCH
    • Key events encoded as ANSI escape sequences and forwarded to the virtual terminal
  • Layout: three sizes — 25%, 50%, or 100% of the content area

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

Test plan

  • camel top → F2 → Shell → verify shell prompt appears
  • Type catalog component --filter=kafka → verify output with colors
  • Test tab completion on commands
  • F11 → verify 50% → 100% grow
  • Escape → verify 100% → 50% → 25% → close cycle
  • Resize terminal window → verify shell reflows
  • Reopen shell → verify previous session state

Claude Code on behalf of Guillaume Nodet

Embed a real JLine shell inside the TUI using JLine's virtual terminal
infrastructure (LineDisciplineTerminal + ScreenTerminal):

- ShellPanel: new overlay panel with embedded camel shell
  - Uses ScreenTerminal as VT100 emulator with readable screen buffer
  - LineDisciplineTerminal provides master/slave pipes
  - Shell runs in background thread via ShellBuilder
  - Screen buffer dumped and converted to TamboUI widgets each frame
  - Full resize handling (half/full toggle, terminal resize)
  - Key events forwarded as ANSI escape sequences

- ActionsPopup: add "Shell" action to F2 menu (always visible)

- CamelMonitor: integrate shell panel
  - Event routing: shell panel intercepts keys when open
  - Split-screen rendering: 50/50 with monitoring tabs
  - Full-screen mode: shell takes entire content area
  - Footer hints: Esc to close/shrink, F11 to toggle

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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 ?

Replace the binary half/full toggle with three sizes:
- F11 grows: 25% → 50% → 100%
- Escape shrinks: 100% → 50% → 25% → close

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented May 28, 2026

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

…-tab

# Conflicts:
#	dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActionsPopup.java
@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented May 28, 2026

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

- Use Text.from(lines) wrapper for Paragraph.builder()
- Use MonitorContext.hint() instead of TuiHelper.hint()
- Replace ScreenTerminalOutputStream.DelegateOutputStream with local
  DelegateOutputStream (the JLine class has package-private field)
- Adapt action IDs for new ACTION_RUN_INFRA from main

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-plugin-tui
All tested modules (2 modules)
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: Launcher :: Container

⚙️ View full build and test results

- Add Shell item to renderActionsMenu() (was in labels but not rendered)
- Add F3 as direct shortcut to toggle shell panel
- Fix attribute bit extraction (shifts were 8/12 instead of 24/28)
- Wrap shell panel in Block with rounded border and size title
- Account for border in virtual terminal sizing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet marked this pull request as draft May 28, 2026 20:53
- F3 simple toggle (open/close, no size cycling)
- Enable mouse capture to prevent scroll artifacts
- Set active terminal for subcommands (ask, etc.)
- Separator line instead of Block border
- Overflow.CLIP for proper line rendering
- Shell item in F2 actions menu render list

Still WIP: display rendering issues with shell output positioning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@davsclaus davsclaus left a comment

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.

}
virtualTerminal = null;
}
screenTerminal = null;
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.

FQCN: org.jline.shell.Shell should be imported rather than used inline (per project convention in CLAUDE.md). The OpenRewrite build plugin will auto-fix this on mvn clean install, so just make sure to rebuild before pushing.

Suggested change
screenTerminal = null;
try (Shell shell = Shell.builder()

(with import org.jline.shell.Shell; added to the imports block)

startShell(innerWidth, innerHeight);
}

// Handle resize
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.

Minor: close() calls stopShell() which destroys the virtual terminal and shell thread. The PR test plan mentions "Reopen shell → verify previous session state", but reopening creates a fresh shell with no prior state. Consider updating the test plan description, or alternatively only setting visible = false without destroying the shell (and deferring stopShell() to TUI exit).

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