실시간 UI 갱신: 세션 완료/명령어 변경 시 렌더러 자동 리로드

- bootstrap: notifyRenderer('app:dataChanged') 이벤트 발행
  - session-completed: Dashboard 통계 + History 갱신
  - command:selected: CMD 페이지 활성 명령어 갱신
- preload: app.onDataChanged 이벤트 리스너 추가
- DashboardPage/CommandsPage/HistoryPage: onDataChanged 구독하여 자동 loadData()
This commit is contained in:
Yun Chan 2026-04-05 13:31:57 +09:00
parent 1361b95a4d
commit ea48168b1e
5 changed files with 39 additions and 3 deletions

View file

@ -15,6 +15,7 @@ import { getAutoLaunchService } from './services/AutoLaunchService'
import { initDatabase } from './db'
import {
createMainWindow,
getMainWindow,
preloadPopupWindows,
showHistoryPopup,
hideHistoryPopup,
@ -213,6 +214,9 @@ async function initVoiceMode(): Promise<void> {
} catch (error) {
logger.warn(`Failed to save history: ${error instanceof Error ? error.message : String(error)}`)
}
// 렌더러 UI 갱신 알림 (Dashboard 통계 + History 목록)
notifyRenderer('app:dataChanged', { type: 'session-completed' })
})
voiceMode.on('session-cancelled', ({ reason }) => {
@ -229,6 +233,14 @@ async function initVoiceMode(): Promise<void> {
})
}
/** 메인 윈도우 렌더러에 UI 갱신 이벤트 전송 */
function notifyRenderer(channel: string, data?: Record<string, unknown>): void {
const win = getMainWindow()
if (win && !win.isDestroyed()) {
win.webContents.send(channel, data ?? {})
}
}
async function initLLMPolling(): Promise<void> {
const llm = getLocalLLMService()
llm.startPolling()
@ -275,6 +287,9 @@ function setupCommandPopupIPC(): void {
configSet('activeInstructionId' as keyof import('@shared/types').AppConfig, data.id as never)
configSet('defaultLLMAction', 'custom')
logger.info(`Active command set: ${data.name} (${data.id})`)
// CMD 페이지 UI 갱신 알림
notifyRenderer('app:dataChanged', { type: 'command-changed', activeId: data.id })
})
// 팝업 닫기