ammachado commented on code in PR #24284:
URL: https://github.com/apache/camel/pull/24284#discussion_r3488523566
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java:
##########
@@ -1733,9 +1810,34 @@ private void renderFooter(Frame frame, Rect area) {
}
}
+ int hintsWidth = spans.stream().mapToInt(Span::width).sum();
+ int rightWidth = rightSpans.stream().mapToInt(Span::width).sum();
+ int minGap = rightSpans.isEmpty() ? 0 : 1;
+
+ if (hintsWidth + rightWidth + minGap > area.width()) {
+ // Drop decorative right-side content first
+ rightSpans.clear();
+ rightWidth = 0;
+ minGap = 0;
+ // Drop secondary F-key hints (F2/F3/F6) before tab-specific
action hints.
+ // They are inserted at position 2 (after the first tab hint), so
the last
+ // secondary F-key pair sits at index (2 + secondaryFKey - 2).
+ while (secondaryFKey > 0 && hintsWidth > area.width()) {
+ int dropIdx = 2 + secondaryFKey - 2;
Review Comment:
Good catch, you're exactly right. I traced it: with help text present,
`insertFKeyHints` returned the secondary-only count (`size - 2 = 6`), and
`dropIdx = 2 + 6 - 2 = 6` pointed at the F3 pair, so the loop removed F3, F2,
then **F1** while keeping F6, the opposite of the intent.
Applied your suggested fix in `40b4c8b`:
- `insertFKeyHints` now returns the total F-key span count
(`fKeySpans.size()`).
- Extracted the drop logic into a testable static `dropFKeyHints(spans,
fKeyTotal, hintsWidth, available)` that removes pairs from the tail (F6, then
F3, F2) and stops at 2, so the first pair (F1 help when present) is always
preserved. Renamed `secondaryFKey` to `fKeyTotal` for accuracy.
Added 4 unit tests in `CamelMonitorTest` covering the help, no-help,
no-overflow, and heavy-overflow cases. I verified they fail against the
original index formula and pass with the fix.
_Claude Code on behalf of Adriano Machado_
--
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]