Claus Ibsen created CAMEL-25581:
-----------------------------------

             Summary: camel-jbang - run the web session on JLine instead of Aesh
                 Key: CAMEL-25581
                 URL: https://issues.apache.org/jira/browse/CAMEL-25581
             Project: Camel
          Issue Type: Improvement
          Components: camel-jbang
            Reporter: Claus Ibsen


{{camel tui --web}} serves the TUI to a browser (xterm.js) over a WebSocket. 
Today that one path runs on Aesh: Camel's own netty pipeline (Origin check, 
headers, bounded executor) hands the socket to Aesh's 
{{TtyWebSocketFrameHandler}}, which gives an Aesh {{Connection}}, and TamboUI's 
{{AeshBackend}} draws on it. Everything else is JLine: the local session 
(TamboUI's {{JLineBackend}}, built explicitly because backend auto-discovery 
could pick Aesh, whose native terminal does not shut down cleanly), the shell 
panel (JLine {{ScreenTerminal}}, {{LineReader}}, picocli commands and history) 
and {{camel shell}}.

*Why move the web session to JLine*
* One terminal stack: local and web would parse keys, paste and mouse the same 
way, through the same backend.
* Aesh's issues hit only the web path:
** a closed browser tab is not noticed, so the session runs on and then fails 
with a {{NullPointerException}} (fixed in TamboUI by 
https://github.com/tamboui/tamboui/pull/543, still caught in {{TuiWebServer}} 
today);
** Aesh never signals end of input;
** its input thread dies on the first byte that is not UTF-8 (a bug in Aesh 
itself);
** it split escape sequences and pastes (fixed in TamboUI by 
https://github.com/tamboui/tamboui/pull/474).
* JLine stays in Camel anyway (shell panel, {{camel shell}}). Aesh is used only 
by {{TuiWebServer}}, so the {{tamboui-aesh-backend}} and Aesh terminal 
dependencies, and the {{aesh-terminal-version}} property in the parent pom, can 
be removed.

*How*
* Keep Camel's netty WebSocket pipeline, and handle the page's messages in 
Camel instead of Aesh's {{TtyWebSocketFrameHandler}}. The page sends JSON: 
{{init}} with {{cols}}/{{rows}}, {{read}} with the typed data, {{resize}} with 
{{cols}}/{{rows}}. The server writes plain terminal output back.
* Feed the input into a JLine terminal built from streams (for example 
{{TerminalBuilder.builder().system(false).streams(in, 
out).type("xterm-256color").encoding(UTF_8)}}). Apply {{resize}} with 
{{terminal.setSize(...)}}, and close the terminal when the socket closes, so 
the runner sees end of input.
* Create the session's runner with TamboUI's {{JLineBackend}} on that terminal, 
as {{TuiBackendHelper}} already does for the local terminal.
* Test with a fake WebSocket client: typing, paste, resize, emoji and CJK 
input, and a closed socket ending the session.

Best done after the TamboUI 0.6 upgrade, CAMEL-25580. TamboUI's JLine backend 
is built against JLine 3.25.1 while Camel uses JLine 4.4.7; check that first.

_Claude Code on behalf of davsclaus_




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to