davsclaus opened a new pull request, #23254: URL: https://github.com/apache/camel/pull/23254
## Summary Applies TamboUI best-practice improvements to `CamelMonitor.java` in `camel-jbang-plugin-tui`. Changes are split into 7 focused commits, each addressing one improvement category. - **Fix scrollbar not showing in word-wrap mode** — `ScrollbarState` was comparing raw `lines.size()` instead of computed `contentHeight` (the wrapped line count), causing the scrollbar to be suppressed when wrapping expanded content beyond the visible area. - **Fix O(n²) `getTraceExchangeIds`** — replaced `List.contains()` inside a loop with `LinkedHashSet` for O(1) deduplication while preserving insertion order. Also removed a no-op empty `runOnRenderThread` lambda. - **Consolidate sort label/style helpers and `formatSinceLast`** — three pairs of nearly-identical `*SortLabel`/`*SortStyle` methods replaced by two generic static helpers; three `formatSinceLast` overloads collapsed to one; log-level coloring inlined switch replaced by existing `colorStyleForLevel` helper. - **Promote `ScrollbarState` to class-level fields** — TamboUI stateful widgets require external state objects maintained across frames. `traceDetailScrollState` and `historyDetailScrollState` were being allocated `new ScrollbarState()` every render frame; promoted to class-level `final` fields alongside the existing diagram scroll states. - **Extract `parseMessage()`** — duplicate JSON parsing logic (headers, body, exchange properties/variables) was copy-pasted between `parseTraceEntry` and `parseHistoryEntry`; extracted to a single `parseMessage(JsonObject)` returning a record. - **Extract shared step table builder** — `buildStepRow()` and `buildStepTable()` static helpers eliminate identical row/table construction duplicated across the Trace and History tabs. - **Extract `addExchangeInfoLines`, `addKvLines`, `addBodyLines`, `renderDetailPanel`** — duplicate exchange-info header lines, typed key-value section rendering, body section rendering, and the scroll/paragraph/scrollbar detail-panel logic were copy-pasted between `renderTraceStepDetail` and `renderHistoryDetail`; extracted to shared static/instance helpers. Net removal of ~150 lines. ## Test plan - [ ] Build passes: `mvn compile -pl dsl/camel-jbang/camel-jbang-plugin-tui` - [ ] Trace tab: scrollbar appears correctly in both clip and word-wrap modes - [ ] History tab: scrollbar appears correctly in both clip and word-wrap modes - [ ] Sort labels and styles render correctly in Overview, Route, and Trace tabs - [ ] Exchange properties, variables, headers, and body render correctly in Trace and History detail panels _Claude Code on behalf of Claus Ibsen_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
