fix(ai): wait for llama-server readiness - #202
Merged
Merged
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe PR adds cancellable sidecar startup tracking, exposes startup status, and replaces direct port lookup with abort-aware health polling. AI requests now use separate readiness and completion timeouts, with expanded lifecycle, retry, cancellation, concurrency, and cleanup tests. ChangesSidecar lifecycle and readiness flow
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Chat
participant AiAgent
participant SidecarStatus
participant SidecarHealth
participant CompletionEndpoint
Chat->>AiAgent: Submit chat request
AiAgent->>SidecarStatus: Get sidecar status
SidecarStatus-->>AiAgent: Starting or running status
AiAgent->>SidecarHealth: Poll /health
SidecarHealth-->>AiAgent: Healthy response
AiAgent->>CompletionEndpoint: Submit completion
CompletionEndpoint-->>AiAgent: Headers and response body
AiAgent-->>Chat: Parsed reply or classified error
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
scotej
force-pushed
the
agent/fix-ai-dialog-timeout-197
branch
from
August 8, 2026 06:21
056bd13 to
2050ff6
Compare
scotej
marked this pull request as ready for review
August 8, 2026 06:39
scotej
force-pushed
the
agent/fix-ai-dialog-timeout-197
branch
from
August 8, 2026 09:09
2050ff6 to
c0216de
Compare
scotej
marked this pull request as draft
August 8, 2026 09:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
All user-triggered text inference now waits for llama-server to become ready before submitting a completion:
sidecar_statusplus/health, waits through initial install/spawn and model loading, follows automatic respawns to a replacement port, and fails promptly on a terminal error or explicit stop.startinglifecycle bit and uses a start-epoch token so an explicit stop during a slow install cannot later resurrect llama-server. Matching JS generation guards prevent stale start continuations from overwriting newer state.AbortSignal; session-chat caller cancellation remains independent.ai.agent.readiness.readyandai.agent.request.succeededtelemetry records elapsed time, attempt count, and intent without prompt or response text.This fixes a concrete startup-readiness race: Rust can report a spawned child and port before model/projector loading completes, while pinned llama-server b9095 returns 503 from
/healthduring that window. The reporter's logs show the Ctrl+] dialog opening during model load and one pre-load completion 503, which strongly supports this cause. The old StudyVis logs lack request outcome telemetry, so they still do not demonstrate that the request was Ctrl+] or prove a fixed run on the affected Windows 11 CPU-only setup.Pinned llama.cpp b9095 automatically selects four slots with unified KV caching and enables continuous batching by default. This PR leaves those server defaults intact and does not add CLI flags that would override inherited
LLAMA_ARG_*settings.The focus-detection failures reported against v1.10.0 are already addressed by #172, released in v1.10.1. This PR does not duplicate that fix.
Related to #197. Keep #197 open until the reporter's Ctrl+] failure has been reproduced and verified on the affected Windows CPU-only configuration.
Regression coverage
Manual Windows test
This PR remains a draft until the affected Windows 11 x64 CPU-only smoke test is completed.
1195989after its checks finish.llama-server.exe, reboot to make model loading cold, and do not rerun the benchmark first.studyvis.logandllama-server.log; confirmai.agent.readiness.readyprecedesai.agent.request.succeeded.Compatibility surfaces
No SQLite, peer wire format, identity derivation, persisted setting, updater manifest, release artifact, or benchmark fingerprint changes.
SidecarStatus.startingis an internal lockstep Tauri IPC addition. Sidecar spawn arguments remain unchanged frommain, including support for inheritedLLAMA_ARG_*configuration; no throughput-sensitive runtime flag changed.Local gates on current head
npm run buildnpm run lintnpm run format:checknpm test— 94 files / 1,189 testscheck-tokens,check-strings,check-contrast,check-migrations, andcheck-storiescargo fmt --check,cargo check, correctness clippy, andcargo test --locked— 103 unit + 4 crypto-vector + 13 round-trip testscargo deny checkgit diff --check1195989The non-blocking live relay probe previously passed 10/11 endpoints twice;
relay.nostr.placerejected the test event because it requires proof of work. That external relay policy is unrelated to this AI change.Merge style
Summary by CodeRabbit
New Features
Bug Fixes
Tests