feat(input): expand Araso Han/Eng contractions, acronyms, typo recovery, and fast cursor-tail replacement
This commit is contained in:
parent
51bf664302
commit
f403111256
80 changed files with 1449 additions and 458 deletions
|
|
@ -571,9 +571,23 @@ export class SuggestionService extends EventEmitter {
|
|||
this.emit('state-changed', this.getState())
|
||||
}
|
||||
|
||||
/** 설정에서 명시적으로 제안을 켤 때만 모델을 짧게 준비한다. */
|
||||
warmUp(options: { silent?: boolean } = {}): Promise<void> {
|
||||
if (!this.isEnabled()) return Promise.resolve()
|
||||
private _isModelWarmNeeded(allowForTypo = false): boolean {
|
||||
if (this.isEnabled()) return true
|
||||
return (
|
||||
allowForTypo &&
|
||||
configGet('typoAutoCorrectEnabled') !== false &&
|
||||
configGet('typoAutoCorrectUseModel') !== false
|
||||
)
|
||||
}
|
||||
|
||||
/** 타이핑 중 오타·한영 교정 모델(Gemma)과 제안 모델을 백그라운드에서 미리 데운다. */
|
||||
ensureWarmForTyping(context: TypingContext): void {
|
||||
this._keepWarm(context, Date.now())
|
||||
}
|
||||
|
||||
/** 설정에서 명시적으로 제안을 켤 때 또는 백그라운드 오타 교정 워밍업 시 모델을 짧게 준비한다. */
|
||||
warmUp(options: { silent?: boolean; allowForTypo?: boolean } = {}): Promise<void> {
|
||||
if (!this._isModelWarmNeeded(options.allowForTypo === true)) return Promise.resolve()
|
||||
if (this._warmUpPromise) return this._warmUpPromise
|
||||
|
||||
const abort = new AbortController()
|
||||
|
|
@ -582,7 +596,7 @@ export class SuggestionService extends EventEmitter {
|
|||
// 열려 실제로 제안을 기다릴 때(_showWarming)만 한다.
|
||||
if (!options.silent) this._warmingUp = true
|
||||
this.emit('state-changed', this.getState())
|
||||
const warmUp = this._warmUpUntilReady(abort)
|
||||
const warmUp = this._warmUpUntilReady(abort, options.allowForTypo === true)
|
||||
this._warmUpPromise = warmUp
|
||||
void warmUp.finally(() => {
|
||||
if (this._warmUpPromise === warmUp) this._warmUpPromise = null
|
||||
|
|
@ -591,10 +605,10 @@ export class SuggestionService extends EventEmitter {
|
|||
return warmUp
|
||||
}
|
||||
|
||||
private async _warmUpUntilReady(abort: AbortController): Promise<void> {
|
||||
private async _warmUpUntilReady(abort: AbortController, allowForTypo = false): Promise<void> {
|
||||
try {
|
||||
for (let attempt = 0; attempt <= 15; attempt += 1) {
|
||||
if (abort.signal.aborted || !this.isEnabled()) return
|
||||
if (abort.signal.aborted || !this._isModelWarmNeeded(allowForTypo)) return
|
||||
if (!getLocalLLMService().isAvailable()) {
|
||||
if (attempt === 15) return
|
||||
await this._waitForWarmUpRetry(abort.signal)
|
||||
|
|
@ -861,14 +875,14 @@ export class SuggestionService extends EventEmitter {
|
|||
* - 따뜻하지만 유지 시간이 얼마 안 남았으면 1토큰 요청으로 연장한다.
|
||||
*/
|
||||
private _keepWarm(context: TypingContext, now: number): void {
|
||||
if (!this.isEnabled() || !context.typedRecently || !context.isEditable || context.isPassword) return
|
||||
if (!this._isModelWarmNeeded(true) || !context.typedRecently || !context.isEditable || context.isPassword) return
|
||||
if (this._warmUpPromise || this._inFlight || this._filling) return
|
||||
const model = this.resolveModel()
|
||||
if (!model || !getLocalLLMService().isAvailable()) return
|
||||
if (!this._warmth.isWarm(model, now)) {
|
||||
if (this._warmth.isBackingOff(model, now, WARM_UP_FAILURE_BACKOFF_MS)) return
|
||||
logger.info(`타이핑 감지 — 식은 제안 모델을 미리 올린다 (model=${model})`)
|
||||
void this.warmUp({ silent: true })
|
||||
void this.warmUp({ silent: true, allowForTypo: true })
|
||||
return
|
||||
}
|
||||
if (this._warmth.warmUntil - now > KEEP_WARM_REFRESH_MS) return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue