Claus Ibsen created CAMEL-25892:
-----------------------------------

             Summary: camel-jbang - show the body types each step has been 
reached with in the Routes, Diagram and Source views
                 Key: CAMEL-25892
                 URL: https://issues.apache.org/jira/browse/CAMEL-25892
             Project: Camel
          Issue Type: Improvement
          Components: camel-jbang
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Camel now keeps the body types each step of a route has been reached with, 
across the messages, with their kinds: null, payload, data and collection 
(CAMEL-25750, PR [#28178|https://github.com/apache/camel/pull/28178]). The 
route-structure console, {{camel cmd route-structure}} (with {{--varied}}) and 
the MCP tools show them. A step reached with bodies of more than one kind needs 
attention: a step that writes the body fails for the data, and one that reads 
fields fails for the payload.

This brings them to the views of {{camel tui}}. The sketches use one route: 
{{unmarshal: json}}, then a choice where only one branch marshals, then {{to: 
file:outbox}}. Three views, built in this order:

*1. Routes (6): a column, and the varied steps of the selected route.* The 
counts are already in the status file (the route console's {{variedBodyTypes}} 
and {{mixedBodyKinds}}). The list below the table is the route-structure 
console's, as {{camel cmd route-structure --varied}} shows it.
{noformat}
 6 Routes
  ID        FROM                    STATUS   TOTAL  FAIL  BODY TYPES
> orders    platform-http:/orders   Started     15     3  ⚠ 1 mixed · 2 varied
  stock     timer:stock             Started     40     0
  invoices  file:inbox              Started      8     0  1 varied
 -- orders: steps reached with more than one body type ----------------------
  18  to file:outbox   byte[] | LinkedHashMap               payload and data  ⚠
   7  unmarshal        String | ByteArrayInputStreamCache   payload
{noformat}

*2. Diagram (5): the body types on the arrows*, switched on with a key such as 
{{b}}. Each arrow into a step is labelled with the types the step was reached 
with, so the arrows show how the body changes along the route. A step reached 
with more than one kind gets a ⚠ and the kinds. Shift+F8 asks the AI with these 
facts. The route-structure console's steps map to the diagram's nodes by id.
{noformat}
                 ┌─────────────────────────┐
                 │ from platform-http      │
                 │ /orders                 │
                 └────────────┬────────────┘
                              │ ByteArrayInputStreamCache
                 ┌────────────▼────────────┐
                 │ unmarshal json          │
                 └────────────┬────────────┘
                              │ LinkedHashMap
                 ┌────────────▼────────────┐
                 │ choice                  │
                 └─────┬─────────────┬─────┘
              high     │             │     otherwise
     LinkedHashMap     │             │     LinkedHashMap
           ┌───────────▼───┐     ┌───▼───────────┐
           │ marshal json  │     │ log           │
           └───────────┬───┘     └───┬───────────┘
                       └──────┬──────┘
                              │ byte[] | LinkedHashMap  (payload and data)
                 ┌────────────▼────────────┐
                 │ ⚠ to file:outbox        │
                 └─────────────────────────┘
 ⚠ to file:outbox: some messages bring data, others a payload   Shift+F8 ask AI
{noformat}

*3. Source (2): dimmed hints at the end of each step*, with a ⚠ in the gutter 
for a step reached with more than one kind.
{noformat}
 2 Source  orders.camel.yaml                       ● running this version  [b]
   5        uri: platform-http:/orders
   6        steps:
   7          - unmarshal:                       ByteArrayInputStreamCache
   8              json: {}
   9          - choice:                          LinkedHashMap
  10              when:
  11                - simple: ${body[priority]} == 'high'
  12                  steps:
  13                    - marshal:               LinkedHashMap
  14                        json: {}
  15              otherwise:
  16                steps:
  17                  - log: ${body[id]}         LinkedHashMap
⚠ 18          - to: file:outbox                  byte[] | LinkedHashMap  
(payload and data)
{noformat}
Facts per line only hold while the editor has the version of the file that 
runs. Once it is edited, the routes that did not change keep their hints. 
Knowing which routes did not change needs the route checksum of CAMEL-25771, so 
this view comes after it.

*Also:* the Errors view (9) gets the hint of CAMEL-25750 with no change: "other 
messages reached this step with data (LinkedHashMap), so the body here depends 
on the path a message takes" (PR 
[#28180|https://github.com/apache/camel/pull/28180]). Its diagram of a failed 
message could mark the ⚠ step.

*Depends on:* PR #28178 for the body types in the consoles, and CAMEL-25771 for 
view 3.

_Filed by Claude Code on behalf of davsclaus_




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

Reply via email to