ammachado opened a new pull request, #24608:
URL: https://github.com/apache/camel/pull/24608

   Follow-up fixes for the TUI AI panel introduced in #24594 (CAMEL-23978, now 
merged). Four independent defects surfaced in a post-merge review of that 
changeset.
   
   ### 1. Overlapping cancellation corrupts request state
   A background CLI command (`/send`) and an LLM request can run at the same 
time. Pressing `Esc` in that state cancelled only the CLI while clearing the 
LLM `thinking` flag, leaving the agent thread running as an orphan that could 
still mutate the conversation. `interruptBusyOperation` now cancels the CLI 
command and stops the LLM agent **independently**, and no longer touches 
thinking state on the CLI path. This extends the same CLI/LLM state separation 
that was applied to `handleCliCompletion` in the merged PR.
   
   ### 2. Provider switch left the client without a model
   Only the Anthropic detection paths assigned a default model, so switching to 
OpenAI or Ollama left `LlmClient.model` null and subsequent chat requests 
failed. Model defaulting is now centralized in `applyDefaultModel()` after a 
successful `detectEndpoint()` for all providers:
   - OpenAI → `gpt-4o-mini`
   - Ollama → `llama3.2`, upgraded to an installed model with better 
tool-calling support when available
   - Anthropic → unchanged (`claude-sonnet-4-6`)
   
   This also closes the same gap on the explicit-URL path.
   
   ### 3. `/model` blocked the TUI event thread
   `/model` (no argument) called `listModels()` synchronously from key-event 
handling, reaching a blocking HTTP call that could freeze rendering and input 
if the provider became slow or unreachable. Discovery now runs on a daemon 
worker thread and posts the result to the conversation, matching the existing 
async CLI pattern.
   
   ### 4. Model listing broke for full OpenAI chat endpoint URLs
   `normalizeOpenAiModelsUrl` transformed a configured 
`.../v1/chat/completions` into `.../v1/chat/completions/v1/models`. It now 
strips the chat suffix before deriving `/v1/models`.
   
   ### Tests
   - `camel-jbang-core` `LlmClientListModelsTest`: 12 pass (8 existing + 4 new 
covering findings 2 and 4).
   - `camel-jbang-plugin-tui`: 82 pass across the AI panel/registry/provider 
suites; new `escapeDuringOverlapCancelsBothCliAndLlm` and 
`modelListingRunsOffTheEventThread`, plus three existing `/model` tests updated 
to await the async result.
   
   ### Notes
   - No upgrade-guide entry: the AI TUI panel is unreleased (shipped on `main` 
via CAMEL-23978, not yet in a release), so these are fixes within an unreleased 
feature.
   - `gpt-4o-mini` is the chosen OpenAI default (cheap, supports tool-calling, 
overridable via `/model`).
   
   ---
   _Claude Code on behalf of @ammachado_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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