fix(onboarding): 무진행 구간 UX + 중복 실행 가드
- verifying/manifest 상태(바이트 진행률 없음)에서 인디터미넌트 바 + 친화적 문구 — 9.6GB 검증 ~2분간 멈춘 것처럼 보이던 문제 해소 - OnboardingModal 중복 실행 가드 (runningRef) - LocalLLMService.pullModel: 동일 모델 동시 pull은 기존 promise 합류 - LocalSTTService.downloadModel: /download 409는 실패가 아닌 기존 진행 합류
This commit is contained in:
parent
64c1d3709b
commit
0b9e67afe9
6 changed files with 86 additions and 35 deletions
|
|
@ -98,6 +98,8 @@ function stripReasoningBlocks(text: string): string {
|
|||
|
||||
class LocalLLMService extends EventEmitter {
|
||||
private _state = LLMState.Unavailable
|
||||
/** 모델별 진행 중 pull — 중복 요청은 기존 promise에 합류 */
|
||||
private _pullInFlight = new Map<string, Promise<void>>()
|
||||
private _pollInterval: ReturnType<typeof setInterval> | null = null
|
||||
private _available = false
|
||||
private _abortController: AbortController | null = null
|
||||
|
|
@ -497,6 +499,20 @@ class LocalLLMService extends EventEmitter {
|
|||
* @param modelId 예: 'gemma4:e4b'
|
||||
*/
|
||||
async pullModel(modelId: string): Promise<void> {
|
||||
// 동일 모델 동시 pull 방지 — 진행 중이면 같은 promise에 합류
|
||||
const inFlight = this._pullInFlight.get(modelId)
|
||||
if (inFlight) {
|
||||
logger.info(`Pull 진행 중 재요청 — 기존 작업에 합류: ${modelId}`)
|
||||
return inFlight
|
||||
}
|
||||
const task = this._doPullModel(modelId).finally(() => {
|
||||
this._pullInFlight.delete(modelId)
|
||||
})
|
||||
this._pullInFlight.set(modelId, task)
|
||||
return task
|
||||
}
|
||||
|
||||
private async _doPullModel(modelId: string): Promise<void> {
|
||||
const serverUrl = configGet('ollamaServerUrl')
|
||||
logger.info(`Pull 시작: ${modelId}`)
|
||||
|
||||
|
|
|
|||
|
|
@ -327,7 +327,8 @@ class LocalSTTService extends EventEmitter {
|
|||
signal: AbortSignal.timeout(10000),
|
||||
})
|
||||
|
||||
if (!startRes.ok) {
|
||||
// 409 = 이미 다운로드 진행 중 — 실패가 아니라 기존 진행에 합류해 폴링
|
||||
if (!startRes.ok && startRes.status !== 409) {
|
||||
const text = await startRes.text()
|
||||
throw new D3ROError(
|
||||
ErrorCode.STTModelDownloadFailed,
|
||||
|
|
@ -335,10 +336,14 @@ class LocalSTTService extends EventEmitter {
|
|||
)
|
||||
}
|
||||
|
||||
const started = (await startRes.json()) as { status: string }
|
||||
if (started.status === 'done') {
|
||||
this._emitDownloadProgress(modelId, 100, 0, 0, 0)
|
||||
return
|
||||
if (startRes.ok) {
|
||||
const started = (await startRes.json()) as { status: string }
|
||||
if (started.status === 'done') {
|
||||
this._emitDownloadProgress(modelId, 100, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
logger.info(`모델 다운로드 이미 진행 중 — 폴링에 합류: ${modelId}`)
|
||||
}
|
||||
|
||||
// 진행률 폴링 — sidecar 통신 실패가 연속되면 중단
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue