[06-Reviewer] #218 sticky cache 수정 + reference doc nit 3건
코드 결함 1건 + 문서 정확성 nit 3건. 사용자 동작에 영향 있는 건 (1)
번만, 나머지는 문서 정정.
(1) _LazyLlmService._delegate sticky cache 수정 (main.dart)
- 기존: 첫 호출 시점에 잡힌 delegate (Mock vs Gemma) 가 앱 재시작까지
유지 — 옵트인 OFF 상태에서 첫 suggestFrame 호출 → Mock 잡힘 → 사용자
옵트인 ON + 다운로드 완료 후에도 같은 Mock 만 반환 (사용자는 AI 가
켜진 줄 알고 mock 응답 받음).
- 수정: 매 _resolve() 호출마다 checkAvailability 재평가. 캐시는
(Gemma↔Mock 종류) + (Gemma 의 modelPath) 모두 일치할 때만 재사용 →
state 변화 시 자동 교체. flutter_gemma installModel 자체가
idempotent 라 반복 resolve 비용 무시 가능.
(2) reference doc nit 3건 — 04-QA round 2 가 08-Documenter 로 인계한
nit 를 Reviewer 가 직접 정정:
- L184: "device_info_plus 로 systemFeatures / totalMem 조회" → 실
구현은 MethodChannel `life_helper/device_caps`. device_info_plus
는 deps 에 있지만 4GB 임계 측정엔 미사용 (isLowRamDevice 는 ~1GB).
- L186: F1 후속 이슈 번호 "#222 등" → "#219 별도 이슈".
- L191: follow-up 매핑 — 임의 "#219 ProGuard rules 정제" 항목 제거.
Planner OOS 기준 #219=F1 unload, #220=F2 purge, #221=AC10 corpus,
#222=production keystore 로 정정.
검증: flutter analyze 무이슈, flutter test 88/88 통과.
Refs #218
This commit is contained in:
@@ -40,13 +40,21 @@ class _LazyLlmService implements LlmService {
|
||||
LlmService? _delegate;
|
||||
|
||||
Future<LlmService> _resolve() async {
|
||||
if (_delegate != null) return _delegate!;
|
||||
final avail = await lifecycle.checkAvailability();
|
||||
final path = await meta.find(AiMetaKeys.modelPath);
|
||||
if (avail == ModelAvailability.ready && path != null) {
|
||||
_delegate = GemmaLlmService(modelPath: path);
|
||||
} else {
|
||||
_delegate = MockLlmService();
|
||||
final wantGemma = avail == ModelAvailability.ready && path != null;
|
||||
// Re-resolve every call so opt-in / opt-out state changes are reflected
|
||||
// without an app restart. Repeat-resolve of the same kind reuses the
|
||||
// cached instance (Gemma's flutter_gemma installModel is idempotent;
|
||||
// Mock has no setup), but the kind itself flips when availability does.
|
||||
final keep = _delegate != null &&
|
||||
(wantGemma == (_delegate is GemmaLlmService)) &&
|
||||
(!wantGemma ||
|
||||
(_delegate as GemmaLlmService).modelPath == path);
|
||||
if (!keep) {
|
||||
_delegate = wantGemma
|
||||
? GemmaLlmService(modelPath: path)
|
||||
: MockLlmService();
|
||||
}
|
||||
return _delegate!;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user