gnodet commented on code in PR #22197:
URL: https://github.com/apache/camel/pull/22197#discussion_r2975710216


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelCatalogTui.java:
##########
@@ -0,0 +1,697 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.tui;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import dev.tamboui.layout.Constraint;
+import dev.tamboui.layout.Layout;
+import dev.tamboui.layout.Rect;
+import dev.tamboui.style.Color;
+import dev.tamboui.style.Overflow;
+import dev.tamboui.style.Style;
+import dev.tamboui.terminal.Frame;
+import dev.tamboui.text.Line;
+import dev.tamboui.text.Span;
+import dev.tamboui.text.Text;
+import dev.tamboui.tui.TuiRunner;
+import dev.tamboui.tui.event.Event;
+import dev.tamboui.tui.event.KeyCode;
+import dev.tamboui.tui.event.KeyEvent;
+import dev.tamboui.widgets.block.Block;
+import dev.tamboui.widgets.block.BorderType;
+import dev.tamboui.widgets.paragraph.Paragraph;
+import dev.tamboui.widgets.table.Cell;
+import dev.tamboui.widgets.table.Row;
+import dev.tamboui.widgets.table.Table;
+import dev.tamboui.widgets.table.TableState;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.apache.camel.util.json.Jsoner;
+import picocli.CommandLine.Command;
+
+@Command(name = "catalog-tui",
+         description = "Interactive TUI catalog browser",
+         sortOptions = false)
+public class CamelCatalogTui extends CamelCommand {
+
+    private static final int FOCUS_LIST = 0;
+    private static final int FOCUS_DETAILS = 1;
+
+    // Catalog data
+    private List<ComponentInfo> allComponents = Collections.emptyList();
+    private List<ComponentInfo> filteredComponents = Collections.emptyList();
+
+    // UI state
+    private final TableState listTableState = new TableState();
+    private final TableState optionsTableState = new TableState();
+    private int focus = FOCUS_LIST;
+    private boolean searching;
+    private final StringBuilder searchText = new StringBuilder();
+    private int detailScroll;
+
+    // Selected component details
+    private ComponentDetail selectedDetail;
+
+    public CamelCatalogTui(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        try {
+            Class.forName("dev.tamboui.tui.event.KeyModifiers");
+            Class.forName("dev.tamboui.tui.event.KeyEvent");
+            Class.forName("dev.tamboui.tui.event.KeyCode");
+            Class.forName("picocli.CommandLine$IExitCodeGenerator");
+        } catch (ClassNotFoundException e) {
+            // ignore
+        }

Review Comment:
   _Claude Code on behalf of Guillaume Nodet_
   
   Good question! This eagerly pre-loads classes that the TUI input reader 
daemon thread needs. Without this, during JVM shutdown the classloader may 
already be closing (especially with JBang's custom classloader) while the input 
reader thread is still trying to load `KeyModifiers`, `KeyEvent`, etc. lazily — 
causing `ClassNotFoundException` stack traces on exit.
   
   The comment was missing on this file (the others already had it). Added it 
now, and will also extract this into a shared utility to avoid the duplication.



-- 
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]

Reply via email to