feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -380,24 +380,16 @@ class InputTelemetryService extends EventEmitter {
|
|||
this._onKeyUp = (e: UiohookKeyboardEvent) => this._handleKeyUp(e)
|
||||
this._onMouseDown = (e: UiohookMouseEvent) => this._handleMouseDown(e)
|
||||
this._onMouseUp = (e: UiohookMouseEvent) => this._handleMouseUp(e)
|
||||
this._onMouseMove = (e: UiohookMouseEvent) => this._handleMouseMove(e)
|
||||
this._onWheel = (e: UiohookWheelEvent) => this._handleWheel(e)
|
||||
|
||||
uIOhook.on('keydown', this._onKeyDown)
|
||||
uIOhook.on('keyup', this._onKeyUp)
|
||||
uIOhook.on('mousedown', this._onMouseDown)
|
||||
uIOhook.on('mouseup', this._onMouseUp)
|
||||
uIOhook.on('mousemove', this._onMouseMove)
|
||||
uIOhook.on('wheel', this._onWheel)
|
||||
|
||||
this._releaseHook = acquireGlobalInputHook()
|
||||
this._running = true
|
||||
this._inputRevision += 1
|
||||
this._flushTimer = setInterval(
|
||||
() => this._flush(),
|
||||
INPUT_TELEMETRY_DEFAULTS.flushIntervalMs
|
||||
)
|
||||
this._flushTimer.unref?.()
|
||||
this._syncCollectionMode()
|
||||
|
||||
// 주기 샘플러.
|
||||
//
|
||||
|
|
@ -411,9 +403,6 @@ class InputTelemetryService extends EventEmitter {
|
|||
)
|
||||
this._sampleTimer.unref?.()
|
||||
|
||||
if (this._isTelemetryCollectionEnabled()) {
|
||||
this._pruneOldData()
|
||||
}
|
||||
logger.info(
|
||||
this._isTelemetryCollectionEnabled()
|
||||
? '입력 텔레메트리 시작 (키/마우스 집계)'
|
||||
|
|
@ -476,9 +465,52 @@ class InputTelemetryService extends EventEmitter {
|
|||
const shouldRun = this._isEnabledByConfig()
|
||||
if (shouldRun && !this._running) this.start()
|
||||
else if (!shouldRun && this._running) this.stop()
|
||||
else if (this._running) this._syncCollectionMode()
|
||||
this._emitState()
|
||||
}
|
||||
|
||||
/**
|
||||
* 입력 텔레메트리 수집 동의가 켜진 동안에만 고빈도 마우스(mousemove 1,000Hz / wheel) 훅과
|
||||
* 5초 DB 플러시 타이머를 가동한다. 기본 모드(오타 교정·제안만 활성)에서는 N-API 호출 폭풍을 원천 차단한다.
|
||||
*/
|
||||
private _syncCollectionMode(): void {
|
||||
if (this._running && this._isTelemetryCollectionEnabled()) {
|
||||
if (!this._onMouseMove) {
|
||||
this._onMouseMove = (e: UiohookMouseEvent) => this._handleMouseMove(e)
|
||||
uIOhook.on('mousemove', this._onMouseMove)
|
||||
}
|
||||
if (!this._onWheel) {
|
||||
this._onWheel = (e: UiohookWheelEvent) => this._handleWheel(e)
|
||||
uIOhook.on('wheel', this._onWheel)
|
||||
}
|
||||
if (!this._flushTimer) {
|
||||
this._flushTimer = setInterval(
|
||||
() => this._flush(),
|
||||
INPUT_TELEMETRY_DEFAULTS.flushIntervalMs
|
||||
)
|
||||
this._flushTimer.unref?.()
|
||||
}
|
||||
if (this._prunedAt === 0) {
|
||||
this._pruneOldData()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (this._onMouseMove) {
|
||||
uIOhook.removeListener('mousemove', this._onMouseMove)
|
||||
this._onMouseMove = null
|
||||
}
|
||||
if (this._onWheel) {
|
||||
uIOhook.removeListener('wheel', this._onWheel)
|
||||
this._onWheel = null
|
||||
}
|
||||
if (this._flushTimer) {
|
||||
clearInterval(this._flushTimer)
|
||||
this._flushTimer = null
|
||||
}
|
||||
this._pending.clear()
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.stop()
|
||||
this._recentWrites.clear()
|
||||
|
|
@ -579,11 +611,6 @@ class InputTelemetryService extends EventEmitter {
|
|||
// 실제 키 입력은 화면을 바꾼다 — 이전 UIA 응답은 무효다.
|
||||
this._inputRevision += 1
|
||||
this._registerInput(true)
|
||||
const bucket = this._bucket()
|
||||
// 한글·일본어 IME 가 켜져 있으면 Windows 는 글자 키를 VK_PROCESSKEY 로 넘기고, uiohook 은 그것을
|
||||
// 변환표에 없는 키코드로 보낸다 — 그대로 'other' 로 두면 한글 타이핑 전체가 "타이핑 아님" 이 되어
|
||||
// 제안이 영영 뜨지 않았다(2026-10-03 실측: 글자 키가 전부 key=other). 수정자 없이 눌린 미지의
|
||||
// 키는 IME 조합 키로 본다. 실제 텍스트 변화(editedSinceFocus)가 함께 있어야 제안이 열린다.
|
||||
const keyClass =
|
||||
vk === null
|
||||
? this._modifiers.ctrl || this._modifiers.alt || this._modifiers.meta
|
||||
|
|
@ -591,9 +618,12 @@ class InputTelemetryService extends EventEmitter {
|
|||
: 'ime'
|
||||
: classifyKeyStroke(vk, this._modifiers)
|
||||
|
||||
if (keyClass === 'shortcut') bucket.shortcuts += 1
|
||||
else bucket.keystrokes += 1
|
||||
if (keyClass === 'backspace') bucket.backspaces += 1
|
||||
if (this._isTelemetryCollectionEnabled()) {
|
||||
const bucket = this._bucket()
|
||||
if (keyClass === 'shortcut') bucket.shortcuts += 1
|
||||
else bucket.keystrokes += 1
|
||||
if (keyClass === 'backspace') bucket.backspaces += 1
|
||||
}
|
||||
|
||||
this._lastKeyAt = Date.now()
|
||||
this._lastKeyClass = keyClass
|
||||
|
|
@ -650,9 +680,11 @@ class InputTelemetryService extends EventEmitter {
|
|||
this._lastClickPos !== null &&
|
||||
manhattanDistance(this._lastClickPos, position) < 6
|
||||
|
||||
const bucket = this._bucket()
|
||||
if (isDoubleClick) bucket.doubleClicks += 1
|
||||
else bucket.clicks += 1
|
||||
if (this._isTelemetryCollectionEnabled()) {
|
||||
const bucket = this._bucket()
|
||||
if (isDoubleClick) bucket.doubleClicks += 1
|
||||
else bucket.clicks += 1
|
||||
}
|
||||
|
||||
this._lastClickAt = now
|
||||
this._lastClickButton = button
|
||||
|
|
@ -706,10 +738,12 @@ class InputTelemetryService extends EventEmitter {
|
|||
const now = Date.now()
|
||||
const gap = this._lastEventAt === 0 ? 0 : now - this._lastEventAt
|
||||
|
||||
if (gap > 0 && gap <= INPUT_TELEMETRY_DEFAULTS.activeIdleTimeoutMs) {
|
||||
this._bucket().activeMs += gap
|
||||
} else if (isKeyboard && this._lastActiveTickAt > 0) {
|
||||
this._bucket().activeMs += 250
|
||||
if (this._isTelemetryCollectionEnabled()) {
|
||||
if (gap > 0 && gap <= INPUT_TELEMETRY_DEFAULTS.activeIdleTimeoutMs) {
|
||||
this._bucket().activeMs += gap
|
||||
} else if (isKeyboard && this._lastActiveTickAt > 0) {
|
||||
this._bucket().activeMs += 250
|
||||
}
|
||||
}
|
||||
|
||||
if (isKeyboard) this._lastActiveTickAt = now
|
||||
|
|
@ -1240,10 +1274,12 @@ class InputTelemetryService extends EventEmitter {
|
|||
return
|
||||
}
|
||||
|
||||
const bucket = this._bucket()
|
||||
bucket.chars += delta.insertedChars
|
||||
bucket.words += delta.insertedWords
|
||||
bucket.sentences += delta.insertedSentences
|
||||
if (this._isTelemetryCollectionEnabled()) {
|
||||
const bucket = this._bucket()
|
||||
bucket.chars += delta.insertedChars
|
||||
bucket.words += delta.insertedWords
|
||||
bucket.sentences += delta.insertedSentences
|
||||
}
|
||||
|
||||
if (!delta.insertedText) return
|
||||
const typedText = this._withoutExpectedInsert(delta.insertedText)
|
||||
|
|
@ -1493,41 +1529,43 @@ class InputTelemetryService extends EventEmitter {
|
|||
|
||||
try {
|
||||
const db = getDatabase()
|
||||
for (const [key, bucket] of entries) {
|
||||
const [date, hourRaw, appName] = key.split('|')
|
||||
const hour = Number(hourRaw)
|
||||
if (!date || Number.isNaN(hour)) continue
|
||||
db.transaction((tx) => {
|
||||
for (const [key, bucket] of entries) {
|
||||
const [date, hourRaw, appName] = key.split('|')
|
||||
const hour = Number(hourRaw)
|
||||
if (!date || Number.isNaN(hour)) continue
|
||||
|
||||
mergeActivityBucket(this._sessionTotals, bucket)
|
||||
mergeActivityBucket(this._sessionTotals, bucket)
|
||||
|
||||
db.insert(inputActivity)
|
||||
.values({
|
||||
id: crypto.randomUUID(),
|
||||
date,
|
||||
hour,
|
||||
appName: appName ?? '',
|
||||
...bucket,
|
||||
updatedAt: now
|
||||
})
|
||||
.onConflictDoUpdate({
|
||||
target: [inputActivity.date, inputActivity.hour, inputActivity.appName],
|
||||
set: {
|
||||
keystrokes: sql`${inputActivity.keystrokes} + ${bucket.keystrokes}`,
|
||||
shortcuts: sql`${inputActivity.shortcuts} + ${bucket.shortcuts}`,
|
||||
backspaces: sql`${inputActivity.backspaces} + ${bucket.backspaces}`,
|
||||
clicks: sql`${inputActivity.clicks} + ${bucket.clicks}`,
|
||||
doubleClicks: sql`${inputActivity.doubleClicks} + ${bucket.doubleClicks}`,
|
||||
scrollTicks: sql`${inputActivity.scrollTicks} + ${bucket.scrollTicks}`,
|
||||
mouseDistancePx: sql`${inputActivity.mouseDistancePx} + ${bucket.mouseDistancePx}`,
|
||||
chars: sql`${inputActivity.chars} + ${bucket.chars}`,
|
||||
words: sql`${inputActivity.words} + ${bucket.words}`,
|
||||
sentences: sql`${inputActivity.sentences} + ${bucket.sentences}`,
|
||||
activeMs: sql`${inputActivity.activeMs} + ${bucket.activeMs}`,
|
||||
tx.insert(inputActivity)
|
||||
.values({
|
||||
id: crypto.randomUUID(),
|
||||
date,
|
||||
hour,
|
||||
appName: appName ?? '',
|
||||
...bucket,
|
||||
updatedAt: now
|
||||
}
|
||||
})
|
||||
.run()
|
||||
}
|
||||
})
|
||||
.onConflictDoUpdate({
|
||||
target: [inputActivity.date, inputActivity.hour, inputActivity.appName],
|
||||
set: {
|
||||
keystrokes: sql`${inputActivity.keystrokes} + ${bucket.keystrokes}`,
|
||||
shortcuts: sql`${inputActivity.shortcuts} + ${bucket.shortcuts}`,
|
||||
backspaces: sql`${inputActivity.backspaces} + ${bucket.backspaces}`,
|
||||
clicks: sql`${inputActivity.clicks} + ${bucket.clicks}`,
|
||||
doubleClicks: sql`${inputActivity.doubleClicks} + ${bucket.doubleClicks}`,
|
||||
scrollTicks: sql`${inputActivity.scrollTicks} + ${bucket.scrollTicks}`,
|
||||
mouseDistancePx: sql`${inputActivity.mouseDistancePx} + ${bucket.mouseDistancePx}`,
|
||||
chars: sql`${inputActivity.chars} + ${bucket.chars}`,
|
||||
words: sql`${inputActivity.words} + ${bucket.words}`,
|
||||
sentences: sql`${inputActivity.sentences} + ${bucket.sentences}`,
|
||||
activeMs: sql`${inputActivity.activeMs} + ${bucket.activeMs}`,
|
||||
updatedAt: now
|
||||
}
|
||||
})
|
||||
.run()
|
||||
}
|
||||
})
|
||||
this.emit('activity', {
|
||||
totals: { ...this._sessionTotals },
|
||||
appName: this._foreground.appName
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue