fix(lmstudio): 모델 전환 시 다른 모델 전부 자동 언로드 (v2.2.210)

VRAM 부족으로 12b 등 다른 모델 로드 실패하던 문제 강화.
- lifecycleManager.doSwitch: 추적 중인 currentModel 만이 아니라 listLoaded()
  기반으로 *로드된 모든 LLM* 을 타깃 전 언로드(VRAM 회수). draft 모델·임베딩
  모델은 보호. listLoaded 실패 시 기존 동작(tracked unload)으로 폴백.
- extension.ts: defaultModel 설정 변경(설정 패널/settings.json 포함) 시
  lifecycle.onModelSelected 호출 → 설정 패널 전환도 unload→load 발동.
- 테스트 FakeLMStudioClient 가 실제 로드 상태를 추적하도록 갱신.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 11:27:43 +09:00
parent b4ddd4f79a
commit 6d06311d60
5 changed files with 46 additions and 22 deletions
+7 -3
View File
@@ -33,6 +33,8 @@ class FakeLMStudioClient implements ILMStudioClient {
public failNextUnload: Error | null = null;
public loadDelayMs = 0;
public lastLoadSignal: AbortSignal | undefined;
/** 실제 로드 상태 추적 — listLoaded()가 이를 반영해야 lifecycle 의 '전체 언로드'를 검증할 수 있다. */
public loaded = new Set<string>();
setBaseUrl(_: string): void { /* noop */ }
@@ -54,6 +56,7 @@ class FakeLMStudioClient implements ILMStudioClient {
this.failNextLoad = null;
throw err;
}
this.loaded.add(modelKey); // 성공 시에만 로드 상태로
}
async unload(modelKey: string): Promise<void> {
@@ -61,13 +64,14 @@ class FakeLMStudioClient implements ILMStudioClient {
if (this.failNextUnload) {
const err = this.failNextUnload;
this.failNextUnload = null;
throw err;
throw err; // 실패 시 로드 상태 유지
}
this.loaded.delete(modelKey);
}
async listLoaded(): Promise<string[]> {
this.listLoadedCalls++;
return [];
return [...this.loaded];
}
async isReachable(): Promise<boolean> {
@@ -75,7 +79,7 @@ class FakeLMStudioClient implements ILMStudioClient {
}
async listLoadedCached(): Promise<string[]> {
return [];
return [...this.loaded];
}
async listDownloaded(): Promise<string[]> {