refactor(core): delete dead IPC/TTS contract and rewire live payload types (WS-G2)

Wave 5 G2 — 채널·타입 SSOT 정리 (docs/REFACTOR_WAVE5_AUDIT.md W5-02/W5-03).

삭제한 죽은 채널 (값 문자열·`IPC_CHANNELS.X` 참조 모두 0, 빌드 산출물 제외 검증):
- TTS 블록 전체 (tts:speak/stop/getVoices/getActiveVoice/setVoice/getStatus/
  downloadVoice/statusChanged/speakingStateChanged) — preload·handler·렌더러 어디에도 없음
- WINDOW: showRecordingTip, showResultPopup, tipMeasured, tipPrepare, tipShow
- SYSTEM: requestMicPermission, showNotification, getActiveApp, insertText
- HISTORY: export · STATS: getDaily, getWeekly · RAG: queryResult
- SUPPORT: getTickets · POPUP_SUGGESTION: accepted

삭제한 죽은 타입 (참조 0): TTS 9종, ShowRecordingTipParams, ShowResultPopupParams,
TipMeasuredParams, TipPrepareEvent, TipShowEvent, ActiveAppInfo, ShowNotificationParams,
InsertTextParams, InsertTextResult, HistoryExportParams, StatsQueryParams, DailyStats,
WeeklyStats, RAGChunk, CreateSupportTicketParams, DiarizationResult,
MeetingGenerateDocResult (preload는 이미 MeetingDocument를 반환 — 낡은 래퍼).

재배선한 살아있는 계약 (드리프트 수정):
- PullModelParams: 실제 payload는 { modelId } 인데 SSOT는 { modelName } 이었다 →
  타입을 실제에 맞추고 llm-handlers + preload가 코어 타입을 쓰도록 복구
- OpenExternalParams: preload·window-handler 인라인 { url } → 코어 타입
- RecordingTipState/TipStateChangedEvent: WindowManager가 string을 받고 있었다 →
  유니온으로 좁히고 'done'(팝업 렌더러가 실제 사용)을 유니온에 포함

검증:
- npm run typecheck (desktop/web/admin/packages) GREEN
- npm run typecheck:mobile GREEN · lint --max-warnings=0 GREEN
- npm test GREEN (desktop 2800, core 605, web 24, api-client 31)
- npm run test:mobile 599 GREEN · test:hygiene 400 files GREEN
- contract:check GREEN · check:design 0 violations
This commit is contained in:
Yun Chan 2026-11-08 21:06:24 +09:00
parent b8b91901eb
commit f95bc9cdeb
6 changed files with 21 additions and 193 deletions

View file

@ -11,7 +11,12 @@ import { configGet, configSet } from '../services/ConfigService'
import { buildInstructionInvocation, resolveTargetLanguage } from '../services/llm-prompts'
import { normalizeLoopbackUrl } from '../utils/loopback'
import { getMainWindow } from '../windows/WindowManager'
import type { SetLLMModelParams, SetServerUrlParams, LLMProcessParams } from '@d3ro/core/types'
import type {
SetLLMModelParams,
SetServerUrlParams,
LLMProcessParams,
PullModelParams
} from '@d3ro/core/types'
function safeSendToRenderer(channel: string, data: unknown): void {
const win = getMainWindow()
@ -29,7 +34,7 @@ export function registerLLMHandlers(): void {
safeSendToRenderer(IPC_CHANNELS.LLM.PULL_PROGRESS, payload)
})
ipcMain.handle(IPC_CHANNELS.LLM.PULL_MODEL, async (_event, params: { modelId: string }) => {
ipcMain.handle(IPC_CHANNELS.LLM.PULL_MODEL, async (_event, params: PullModelParams) => {
try {
await getLocalLLMService().pullModel(params.modelId)
return ipcSuccess(undefined)

View file

@ -2,6 +2,7 @@
import { ipcMain } from 'electron'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import type { OpenExternalParams } from '@d3ro/core/types'
import { ErrorCode, ipcError, ipcSuccess } from '@d3ro/core/errors'
import { getMainWindow, hideResultPopup, hideRecordingTip } from '../windows/WindowManager'
import { isTrustedIpcSender, openExternalSafe } from '../windows/web-contents-hardening'
@ -40,7 +41,7 @@ export function registerWindowHandlers(): void {
})
// 외부 URL 열기 — 앱 페이지가 보낸 요청만, 허용 scheme(https/mailto)만 연다.
ipcMain.handle(IPC_CHANNELS.SYSTEM.OPEN_EXTERNAL, async (event, params: { url: string }) => {
ipcMain.handle(IPC_CHANNELS.SYSTEM.OPEN_EXTERNAL, async (event, params: OpenExternalParams) => {
if (!isTrustedIpcSender(event)) {
return ipcError(ErrorCode.ConfigInvalidValue, 'openExternal: untrusted sender')
}

View file

@ -6,6 +6,7 @@ import { join } from 'path'
import { is } from '@electron-toolkit/utils'
import { WINDOW_SIZE } from '@d3ro/core/constants'
import type { AnchorKind, PhysicalRect, SuggestionCorrection } from '@d3ro/core/input-intelligence'
import type { RecordingTipState, TipStateChangedEvent } from '@d3ro/core/types'
import {
fitAnchoredPanel,
placeAnchoredPanel,
@ -389,8 +390,8 @@ const TIP_WIDTH = 320
const TIP_HEIGHT = 110
export function showRecordingTip(
state: string,
params?: { text?: string; errorMessage?: string }
state: RecordingTipState,
params?: Omit<TipStateChangedEvent, 'state'>
): void {
const win = getRecordingTipWindow()
@ -424,8 +425,8 @@ export function hideRecordingTip(): void {
}
export function updateRecordingTipState(
state: string,
params?: { text?: string; errorMessage?: string }
state: RecordingTipState,
params?: Omit<TipStateChangedEvent, 'state'>
): void {
if (recordingTipWindow && !recordingTipWindow.isDestroyed()) {
sendToPopupWindow(recordingTipWindow, IPC_CHANNELS.WINDOW.TIP_STATE_CHANGED, { state, _i18n: getPopupI18nStrings(), ...params })

View file

@ -58,6 +58,8 @@ import type {
LLMProcessResult,
SetLLMModelParams,
SetServerUrlParams,
OpenExternalParams,
PullModelParams,
LLMStatusChangedEvent,
LLMProcessProgressEvent,
HistoryQueryParams,
@ -367,7 +369,7 @@ const electronAPI = {
on(IPC_CHANNELS.LLM.STATUS_CHANGED, cb),
onProcessProgress: (cb: (e: LLMProcessProgressEvent) => void): Unsubscribe =>
on(IPC_CHANNELS.LLM.PROCESS_PROGRESS, cb),
pullModel: (params: { modelId: string }) =>
pullModel: (params: PullModelParams) =>
invoke<void>(IPC_CHANNELS.LLM.PULL_MODEL, params),
startServer: () =>
invoke<'running' | 'starting' | 'not-installed' | 'failed'>(
@ -487,7 +489,7 @@ const electronAPI = {
getVersion: () => invoke<string>(IPC_CHANNELS.SYSTEM.GET_VERSION),
checkMicPermission: () =>
invoke<PermissionStatus>(IPC_CHANNELS.SYSTEM.CHECK_MIC_PERMISSION),
openExternal: (params: { url: string }) =>
openExternal: (params: OpenExternalParams) =>
invoke<void>(IPC_CHANNELS.SYSTEM.OPEN_EXTERNAL, params),
},

View file

@ -57,19 +57,6 @@ export const IPC_CHANNELS = {
DOWNLOAD_PROGRESS: 'stt:downloadProgress'
},
TTS: {
SPEAK: 'tts:speak',
STOP: 'tts:stop',
GET_VOICES: 'tts:getVoices',
GET_ACTIVE_VOICE: 'tts:getActiveVoice',
SET_VOICE: 'tts:setVoice',
GET_STATUS: 'tts:getStatus',
DOWNLOAD_VOICE: 'tts:downloadVoice',
// Main → Renderer events
STATUS_CHANGED: 'tts:statusChanged',
SPEAKING_STATE_CHANGED: 'tts:speakingStateChanged'
},
LLM: {
GET_STATUS: 'llm:getStatus',
GET_MODELS: 'llm:getModels',
@ -149,7 +136,6 @@ export const IPC_CHANNELS = {
/** 녹음 재생 소스: 로컬 파일 바이트 또는 다른 기기 녹음의 서명 URL */
GET_AUDIO: 'history:getAudio',
SEARCH: 'history:search',
EXPORT: 'history:export',
// Main → Renderer events
ADDED: 'history:added'
},
@ -173,26 +159,17 @@ export const IPC_CHANNELS = {
MAXIMIZE: 'window:maximize',
CLOSE: 'window:close',
IS_MAXIMIZED: 'window:isMaximized',
SHOW_RECORDING_TIP: 'window:showRecordingTip',
HIDE_RECORDING_TIP: 'window:hideRecordingTip',
SHOW_RESULT_POPUP: 'window:showResultPopup',
HIDE_RESULT_POPUP: 'window:hideResultPopup',
TIP_MEASURED: 'window:tipMeasured',
// Main → Renderer events
TIP_STATE_CHANGED: 'window:tipStateChanged',
TIP_PREPARE: 'window:tipPrepare',
TIP_SHOW: 'window:tipShow'
TIP_STATE_CHANGED: 'window:tipStateChanged'
},
SYSTEM: {
GET_PLATFORM: 'system:getPlatform',
GET_VERSION: 'system:getVersion',
CHECK_MIC_PERMISSION: 'system:checkMicPermission',
REQUEST_MIC_PERMISSION: 'system:requestMicPermission',
SHOW_NOTIFICATION: 'system:showNotification',
OPEN_EXTERNAL: 'system:openExternal',
GET_ACTIVE_APP: 'system:getActiveApp',
INSERT_TEXT: 'system:insertText',
PLAY_SOUND: 'system:playSound',
SET_SOUND_ENABLED: 'system:setSoundEnabled',
IS_SOUND_ENABLED: 'system:isSoundEnabled'
@ -200,8 +177,6 @@ export const IPC_CHANNELS = {
STATS: {
GET_SUMMARY: 'stats:getSummary',
GET_DAILY: 'stats:getDaily',
GET_WEEKLY: 'stats:getWeekly',
// Main → Renderer events
UPDATED: 'stats:updated'
},
@ -340,7 +315,6 @@ export const IPC_CHANNELS = {
INDEX_COMPLETE: 'rag:indexComplete',
/** 색인 실패 { documentId, fileName, code, message } (임베딩 모델 없음·서버 없음 등) */
INDEX_FAILED: 'rag:indexFailed',
QUERY_RESULT: 'rag:queryResult',
},
// ── Phase 13: Voice Action / OS Automation (13.3) ──
@ -535,7 +509,6 @@ export const IPC_CHANNELS = {
GET_DIAGNOSTICS: 'support:getDiagnostics',
QUERY_AI: 'support:queryAI',
CREATE_TICKET: 'support:createTicket',
GET_TICKETS: 'support:getTickets',
CHECK_REFUND: 'support:checkRefund',
},
@ -579,7 +552,6 @@ export const IPC_CHANNELS = {
HIDE: 'suggestionPopup:hide',
ACCEPT: 'suggestionPopup:accept',
DISMISS: 'suggestionPopup:dismiss',
ACCEPTED: 'suggestionPopup:accepted',
DISMISSED: 'suggestionPopup:dismissed',
},

View file

@ -240,60 +240,6 @@ export interface DownloadProgressEvent {
bytesPerSecond: number
}
// ============================================================
// TTS (로컬 TTS)
// ============================================================
export enum TTSEngineState {
NOT_INSTALLED = 'not-installed',
LOADING = 'loading',
READY = 'ready',
SPEAKING = 'speaking',
ERROR = 'error'
}
export interface TTSStatus {
engineState: TTSEngineState
activeVoice: string | null
engineVersion: string | null
}
export interface TTSVoice {
id: string
name: string
language: string
gender: 'male' | 'female' | 'neutral'
downloaded: boolean
sizeBytes: number
}
export interface TTSSpeakParams {
text: string
voiceId?: string
speed?: number
}
export interface TTSSpeakResult {
durationMs: number
}
export interface SetTTSVoiceParams {
voiceId: string
}
export interface DownloadVoiceParams {
voiceId: string
}
export interface TTSStatusChangedEvent {
status: TTSStatus
}
export interface SpeakingStateChangedEvent {
isSpeaking: boolean
text: string
}
// ============================================================
// LLM (Ollama)
// ============================================================
@ -354,7 +300,7 @@ export interface SetServerUrlParams {
}
export interface PullModelParams {
modelName: string
modelId: string
}
export interface LLMStatusChangedEvent {
@ -741,12 +687,6 @@ export interface UnifiedSearchResponse {
total: number
}
export interface HistoryExportParams {
format: 'json' | 'csv'
from?: string
to?: string
}
// ============================================================
// Dictionary (사전)
// ============================================================
@ -820,23 +760,7 @@ export interface DictionarySearchParams {
// Window (윈도우 제어)
// ============================================================
export type RecordingTipState = 'opening' | 'recording' | 'thinking' | 'result' | 'error'
export interface ShowRecordingTipParams {
state: RecordingTipState
text?: string
errorMessage?: string
}
export interface ShowResultPopupParams {
text: string
autoHideMs?: number
}
export interface TipMeasuredParams {
width: number
height: number
}
export type RecordingTipState = 'opening' | 'recording' | 'thinking' | 'done' | 'result' | 'error'
export interface TipStateChangedEvent {
state: RecordingTipState
@ -844,45 +768,14 @@ export interface TipStateChangedEvent {
errorMessage?: string
}
export interface TipPrepareEvent {
state: RecordingTipState
text?: string
}
export interface TipShowEvent {
state: RecordingTipState
}
// ============================================================
// System (시스템)
// ============================================================
export interface ActiveAppInfo {
name: string
title: string
pid: number
}
export interface ShowNotificationParams {
title: string
body: string
type?: 'info' | 'warning' | 'error'
}
export interface OpenExternalParams {
url: string
}
export interface InsertTextParams {
text: string
method?: 'clipboard' | 'keyboard'
}
export interface InsertTextResult {
success: boolean
insertedLength: number
}
export type SoundEffect =
| 'recording-start'
| 'recording-stop'
@ -912,25 +805,6 @@ export interface StatsSummary {
streakDays: number
}
export interface StatsQueryParams {
from: string
to: string
}
export interface DailyStats {
date: string
recordingTimeMs: number
wordCount: number
sessionCount: number
}
export interface WeeklyStats {
weekStart: string
recordingTimeMs: number
wordCount: number
sessionCount: number
}
// ============================================================
// Phase 10: Memo Tags (10.3)
// ============================================================
@ -1487,14 +1361,6 @@ export interface RAGDocument {
addedAt: number
}
export interface RAGChunk {
id: string
documentId: string
content: string
embedding: number[]
chunkIndex: number
}
export interface RAGQueryParams {
query: string
topK?: number
@ -1722,10 +1588,6 @@ export interface MeetingGenerateDocParams {
customTitle?: string
}
export interface MeetingGenerateDocResult {
document: MeetingDocument
}
export interface MeetingUpdateDocParams {
documentId: string
content: string
@ -1806,12 +1668,6 @@ export interface DiarizationSegment {
end: number
}
export interface DiarizationResult {
segments: DiarizationSegment[]
numSpeakers: number
processingTime: number
}
export interface DiarizeSessionParams {
sessionId: string
numSpeakers?: number
@ -2011,15 +1867,6 @@ export interface SupportTicket {
assignedTo?: string
}
export interface CreateSupportTicketParams {
category: TicketCategory
priority: TicketPriority
subject: string
description: string
customerEmail: string
includeDiagnostics?: boolean
}
export interface AIAssistQuery {
question: string
diagnostics?: SystemDiagnosticsPayload