Skip to content

fix(local-ai,clawkeep): robust ollama pull/delete, ClawKeep status mapping - #346

Merged
KrasimirKralev merged 2 commits into
betafrom
fix/local-ai-clawkeep
Aug 9, 2026
Merged

KrasimirKralev merged 2 commits into
betafrom
fix/local-ai-clawkeep

Conversation

@KrasimirKralev

@KrasimirKralev KrasimirKralev commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Local-AI and ClawKeep robustness.

  • ollama/pull: idempotent stream close (no double-close), model-ref validation mirrors the delete route (namespaced refs allowed) while still rejecting .. segments.
  • ollama/delete + useOllamaModels: surface delete errors to the UI and always reconcile the list against the daemon.
  • clawkeep: classify daemon failures into sensible HTTP statuses (unpaired β†’ 409, auth β†’ 401, network β†’ 504, portal β†’ 502) instead of collapsing to 502; fail-fast friendly on the unpaired case; ENOENT β†’ 503; backup timeout guard so a hung daemon can't hold a worker open.
  • clawkeep/pair/poll: JSON parse guard.

Build green, 1710 tests pass on-device.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Ollama model deletion validation and support for namespaced model names.
    • Deletion failures now display clear error messages and refresh model status reliably.
    • Pairing polls remain pending when upstream responses contain invalid data.
    • Improved backup error handling, timeouts, and unavailable-service responses.
    • Prevented backup actions for unpaired devices.
    • Fixed local AI services so idle shutdown remains properly scheduled after startup.

@KrasimirKralev
KrasimirKralev requested a review from a team as a code owner August 9, 2026 22:05
@KrasimirKralev
KrasimirKralev merged commit 182eaf3 into beta Aug 9, 2026
4 of 5 checks passed
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 980e5b81-689b-43bd-9ff6-9f73718ba793

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between e63c40e and 4252659.

πŸ“’ Files selected for processing (8)
  • src/app/setup-api/clawkeep/pair/poll/route.ts
  • src/app/setup-api/ollama/delete/route.ts
  • src/app/setup-api/ollama/pull/route.ts
  • src/components/AIModelsStep.tsx
  • src/components/DoneStep.tsx
  • src/hooks/useOllamaModels.ts
  • src/lib/clawkeep.ts
  • src/lib/local-ai-runtime.ts

πŸ“ Walkthrough

Walkthrough

The changes improve error handling across ClawKeep, Ollama setup routes, model deletion, pair polling, and local AI lifecycle management. They add validation, timeout handling, error propagation, and reliable status or timer updates.

Changes

Runtime and setup error handling

Layer / File(s) Summary
ClawKeep error mapping and backup execution
src/lib/clawkeep.ts
ClawKeep maps daemon and spawn failures to classified errors, rejects unpaired snapshot requests, and bounds backup process execution with timeout and single-settlement handling.
Ollama model validation and stream handling
src/app/setup-api/ollama/delete/route.ts, src/app/setup-api/ollama/pull/route.ts
Ollama routes accept namespaced model references, reject names containing .., and defer stream closure to the existing finalization path.
Ollama deletion error reporting
src/hooks/useOllamaModels.ts, src/components/AIModelsStep.tsx, src/components/DoneStep.tsx
Model deletion reports HTTP and request failures, refreshes status after every attempt, and displays errors in both model panels.
Pair polling response handling
src/app/setup-api/clawkeep/pair/poll/route.ts
Invalid or absent upstream JSON bodies now produce a pending response instead of an exception.
Local AI idle-stop scheduling
src/lib/local-ai-runtime.ts
Local AI startup schedules the idle-stop timer when no requests are active.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: area: ui, area: gateway

Suggested reviewers: georgik77, yalexx

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/local-ai-clawkeep

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

πŸ¦€ ClawReview

Fresh PR washed in with the tide β€” here's the gist.

A robustness pass across Ollama model management and the ClawKeep backup service. Fixes a stream double-close during model pulls, surfaces delete errors to the UI rather than swallowing them silently, and maps ClawKeep daemon failures to meaningful HTTP statuses (409 unpaired / 401 auth / 504 network / 502 portal) instead of collapsing everything to 502. Also adds a timeout guard so a hung clawkeepd can't hold a Next.js worker open indefinitely, and re-arms the idle-stop timer after pull/delete so large models don't stay resident on the 8 GB Jetson.

At a glance

  • πŸ”§ Fix Β· touches Ollama model management, ClawKeep backup service, local AI runtime idle-stop logic
  • Base branch: beta Β· +112 source / +0 tests across 8 files
  • βœ… base beta matches the beta-first convention
  • βœ… conventional PR title
  • 🟑 src/ changes without test changes β€” add or update tests if behavior changed

Good to know

  • 🟑 onDeleteError is now a required field on OllamaCallbacks β€” any caller of useOllamaModels beyond AIModelsStep and DoneStep will need to add it.
  • 🟑 No test changes included; the policy check flagged this and several code paths (delete error surfacing, ClawKeep status mapping) changed behavior.
  • ℹ️ The 1-hour backup timeout and idle-stop timer re-arm both affect long-running daemon interactions that run on customer devices under systemd.

β€” ClawReview πŸ¦€. I set the scene; CodeRabbit reviews the code; you decide. Conventions: docs.

@github-actions github-actions Bot added the area: ui Auto-triage area label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

CI Summary

βœ… Tests

  • Result: passed
  • View run
  • Coverage: statements 69.32%, branches 59.84%, functions 65.36%, lines 71.13%

βœ… E2E

❌ E2E Install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui Auto-triage area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant