in common/src/main/java/org/mvndaemon/mvnd/common/logging/TerminalInputHandler.java [92:127]
public TerminalInputHandler(Terminal terminal, boolean dumb) {
this.terminal = terminal;
this.inputRequests = new LinkedBlockingQueue<>();
this.dumb = dumb;
// Always create input thread as we always need to handle prompts and project input
this.inputThread = new Thread(() -> {
try {
while (!closing) {
InputRequest request = inputRequests.poll(10, TimeUnit.MILLISECONDS);
if (request == null) {
// No active request
if (!dumb) {
// Only listen for control keys in non-dumb mode
handleControlKeys();
}
} else if (request.prompt != null) {
// Always handle prompts
handlePrompt(request.prompt);
} else if (request.projectId != null) {
// Always handle project input
handleProjectInput(request.projectId, request.bytesToRead);
} else if (!dumb && request.isControlKey) {
// Only handle control keys in non-dumb mode
handleControlKeys();
}
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (IOException e) {
// Handle terminal IO exception
}
});
inputThread.setDaemon(true);
inputThread.start();
}