Skip to content

fix(agent-chat): add safe local runtime preflight#419

Merged
ucguy4u merged 1 commit into
mainfrom
codex/issue-310-model-init-diagnostics
Jun 28, 2026
Merged

fix(agent-chat): add safe local runtime preflight#419
ucguy4u merged 1 commit into
mainfrom
codex/issue-310-model-init-diagnostics

Conversation

@ucguy4u

@ucguy4u ucguy4u commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces changes to local model launch preflight in Brain project setup.
Goal: block unsupported or crash-prone local runtime launches before chat opens.

Core outcome:

  • local model launch now runs a phased preflight instead of falling straight into first-prompt initialization
  • unsupported or memory-unsafe runtimes surface copyable diagnostics and repair actions
  • slow setup shows progress and supports cancellation from the project picker

Changes

Code

  • Added:
    • phased runtime preparation and diagnostic envelope types in assistant_runtime_service.dart
    • widget coverage for unsupported local runtime launch in model_library_screen_test.dart
  • Updated:
    • model_library_screen.dart to run local runtime preflight before selecting a project runtime
    • litert_lm_service.dart with explicit per-model warmup support
    • assistant_runtime_service_test.dart with unsupported, cancelled, and compatibility-blocked preflight coverage

Logic

  • Gemini Nano preflight validates support, initializes, and warms before chat launch
  • LiteRT local packages validate compatibility and warm before selection completes
  • failures no longer trap the user in launch ambiguity; they stay in the picker with diagnostics they can copy into a GitHub issue

API Changes (if any)

  • None.

Database Changes (if any)

  • None.

Observability / Logging

  • Added a user-copyable diagnostic envelope for runtime launch failures.

Performance Impact

  • Latency: initial local runtime launch is now explicit and phased
  • Throughput: no meaningful change
  • Memory/CPU: unchanged runtime cost, but launch failures are blocked earlier

Risks

  • cancellation is cooperative between phases, not a hard native abort
  • preflight only covers the runtime paths wired through the Brain project picker
  • Rollback plan:
    • revert this PR

Testing

  • Unit tests:
    • assistant runtime preparation blocked/cancelled paths
  • Integration tests:
    • widget coverage for unsupported runtime diagnostics in the project picker
  • Manual testing:
    • not run

Deployment Notes

  • Config changes:
    • none
  • Order of deployment:
    • standard

Related Commits

  • fix(agent-chat): add safe local runtime preflight

Notes

  • Focus review on preflight gating, diagnostic copy behavior, and local runtime preparation before selection.

Closes #310

- add phased local runtime preparation with cancellation and diagnostics
- block unsupported or memory-unsafe model launches before chat opens
- surface copyable repair guidance in the project picker

Prevents crash-prone local model launches from falling through to first-prompt initialization.
@github-actions

Copy link
Copy Markdown

Plugin Module Size Gate

Policy: modules over 3 MB must be delivered as plugins; plugin modules over 5 MB must document cache management.

Module Size Type Status
No changed Dart/Flutter modules detected n/a n/a OK

@ucguy4u ucguy4u merged commit e20bd53 into main Jun 28, 2026
8 of 13 checks passed
@ucguy4u ucguy4u deleted the codex/issue-310-model-init-diagnostics branch June 28, 2026 05:36
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🚀 PR Quick Check Summary

Check Status Description
PR Validation ❌ failure Title format, docs, bundled model guardrail
Code Quality ❌ failure Analyze, formatting
Core Tests ✅ success Core package unit tests

💡 Note: Full app tests, coverage reports, and security scans run on merge to main.

View Details

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add device compatibility diagnostics and crash-safe model initialization

1 participant