refactor(desktop): session-scoped voice runtime, STT/LLM ports, caption ownership and meeting export fixes

This commit is contained in:
Yun Chan 2026-09-28 00:53:43 +09:00
parent 0adedf5e7b
commit 83cf9133ac
39 changed files with 4787 additions and 1061 deletions

View file

@ -259,3 +259,84 @@ export function parseUpdatePolicy(raw: unknown): UpdatePolicy {
return policy
}
// ============================================================
// 업데이트 제안 평가 (게이팅 순서의 단일 정본)
// ============================================================
export interface UpdateOfferInput {
policy: UpdatePolicy
channel: UpdateChannel
currentVersion: string
targetVersion: string
/** 사용자가 건너뛴 버전 (없으면 null) */
skippedVersion: string | null
deviceId: string
}
export type UpdateOfferIgnoreReason = 'kill-switch' | 'channel' | 'skipped' | 'rollout'
export type UpdateOffer =
| { action: 'ignore'; reason: UpdateOfferIgnoreReason; decision: UpdateDecision }
| { action: 'prompt' | 'force-download'; decision: UpdateDecision; isMajorUpgrade: boolean }
/**
* 발견된 업데이트를 어떻게 다룰지 결정한다. 순서:
* 킬 스위치 → 채널(prerelease) → 사용자 건너뛰기(필수면 무시) → staged rollout(필수면 무시)
* → 강제 설치 하한 미만이면 대화상자 없이 다운로드, 아니면 사용자에게 묻는다.
*/
export function evaluateUpdateOffer(input: UpdateOfferInput): UpdateOffer {
const { policy, channel, currentVersion, targetVersion } = input
const decision = decideUpdate(policy, currentVersion, targetVersion)
if (policy.killSwitch) return { action: 'ignore', reason: 'kill-switch', decision }
const channelPolicy = policy.channels[channel] ?? { allowPrerelease: false }
if (!isChannelAcceptable(channelPolicy.allowPrerelease, currentVersion, targetVersion)) {
return { action: 'ignore', reason: 'channel', decision }
}
if (!decision.mandatory && input.skippedVersion === targetVersion) {
return { action: 'ignore', reason: 'skipped', decision }
}
if (!isWithinRollout(policy, input.deviceId, targetVersion, decision)) {
return { action: 'ignore', reason: 'rollout', decision }
}
const currentMajor = majorOf(currentVersion)
const targetMajor = majorOf(targetVersion)
const isMajorUpgrade = currentMajor !== null && targetMajor !== null && currentMajor !== targetMajor
if (decision.mandatory && decision.reason === 'below-force-install') {
return { action: 'force-download', decision, isMajorUpgrade }
}
return { action: 'prompt', decision, isMajorUpgrade }
}
/** 마지막으로 사용자에게 업데이트를 물어본 기록 */
export interface UpdatePromptRecord {
version: string
mandatory: boolean
at: number
}
/** '나중에' 이후 같은 버전을 다시 묻기까지의 간격 (24시간) */
export const UPDATE_REPROMPT_INTERVAL_MS = 24 * 60 * 60 * 1000
/**
* 이번 제안을 사용자에게 다시 물을지 결정한다.
* 예전엔 프로세스당 한 번만 물어 '나중에'나 다운로드 실패 뒤로는 새 버전·필수 업데이트도
* 앱을 다시 켤 때까지 조용히 묻혔다. 이제 새 버전, 필수로 격상, 또는 간격이 지나면 다시 묻는다.
*/
export function shouldPromptForUpdate(
last: UpdatePromptRecord | null,
offer: { version: string; mandatory: boolean },
now: number,
intervalMs: number = UPDATE_REPROMPT_INTERVAL_MS,
): boolean {
if (!last) return true
if (last.version !== offer.version) return true
if (offer.mandatory && !last.mandatory) return true
return now - last.at >= intervalMs
}