gnodet-bot commented on code in PR #27515:
URL: https://github.com/apache/camel/pull/27515#discussion_r4211461510
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/McpFacade.java:
##########
@@ -1474,13 +1531,36 @@ JsonObject updateRow(String table, String datasource,
String pkValuesJson, Strin
}
String controlIntegration(String action) {
+ return controlIntegration(action, null);
+ }
+
+ /**
+ * Controls the integration with the given name or pid, which becomes the
selected one, so the screen shows what the
+ * agent acts on (CAMEL-25424). Without a name: the selected integration,
or the only one running.
+ */
+ String controlIntegration(String action, String nameOrPid) {
if (action == null || action.isBlank()) {
return "Error: action is required";
}
if ("stop-all".equals(action)) {
bridge.stopAll();
return "Stopping all processes";
}
+ if (nameOrPid != null && !nameOrPid.isBlank()) {
+ String pid = findPidByNameOrPid(nameOrPid.trim());
+ if (pid == null) {
+ String names = data.get().stream().filter(i -> !i.vanishing)
+ .map(i -> i.name + " (pid " + i.pid +
")").collect(Collectors.joining(", "));
+ return "Error: no integration with name or pid " + nameOrPid
+ + (names.isEmpty() ? "; none is running" : ". Known: "
+ names);
Review Comment:
💡 **Incomplete listing in error message**
`findPidByNameOrPid` searches both `data.get()` (integrations) and
`ctx.infraData.get()` (infra services), but the error hint here only streams
`data.get()` to build the `"Known:"` list. If the user misspells an infra
service name, the error message silently omits all infra services from the
suggestion, which can make it look like no matching service exists at all.
Consider including infra service names in the listing:
```suggestion
String names = Stream.concat(
data.get().stream().filter(i -> !i.vanishing).map(i
-> i.name + " (pid " + i.pid + ")"),
ctx.infraData.get().stream().map(i -> i.name + "
(pid " + i.pid + ")")
).collect(Collectors.joining(", "));
return "Error: no integration with name or pid " + nameOrPid
+ (names.isEmpty() ? "; none is running" : ". Known:
" + names);
```
(The exact `InfraServiceInfo` field names may need adjustment to match the
actual type.)
--
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]