feat(desktop): built-in Han/Eng layout auto-switching, terminal/Vim support, and Unicode input

This commit is contained in:
Yun Chan 2026-10-27 10:48:07 +09:00
parent 1da04b9e46
commit a3ac44da2b
109 changed files with 8234 additions and 242 deletions

View file

@ -28,6 +28,7 @@ import { InputConsentPanel } from './input-insights/InputConsentPanel'
import { KeyBindingField } from './keybinding/KeyBindingField'
import { asTranslationKey } from './keybinding/translation-key'
import { SettingNote, SettingRow, SettingsSection, SETTING_CONTROL_WIDTH } from './settings/SettingsRows'
import { UpdateSection } from './settings/UpdateSection'
import { useI18n, LOCALE_META } from '@d3ro/i18n'
import type { Locale } from '@d3ro/i18n'
import type { KeyBindingActionGroup } from '@d3ro/core/keybinding'
@ -872,6 +873,8 @@ export function SettingsModal({ open, initialTab = DEFAULT_SETTINGS_TAB, onClose
{/* ── 정보 탭 ──────────────────────────────── */}
<TabPanel value={activeTab} tab="about">
<UpdateSection />
<SettingsSection title={t('settings.about.appName')} description={t('settings.about.summary')}>
<SettingRow
label={t('settings.about.version')}

View file

@ -8,6 +8,7 @@ import { useState, useEffect, useCallback } from 'react'
import { Box } from '@mui/material'
import { Minus, Square, Copy, X } from 'lucide-react'
import { d3roPalette, d3roRadius } from '@d3ro/ui/theme'
import { UpdateChip } from './shell/UpdateChip'
const BAR_HEIGHT = 40
const isDarwin = window.electronAPI?.platform === 'darwin'
@ -50,6 +51,9 @@ export function TitleBar(): React.ReactElement {
{/* Drag Region Placeholder */}
<Box sx={{ flex: 1, height: '100%', WebkitAppRegion: 'drag' }} />
{/* 업데이트 알림 — 새 버전·받는 중·설치 대기일 때만 보인다 */}
<UpdateChip />
{/* Window Controls — macOS는 네이티브 교통신호 사용 */}
{!isDarwin && (
<Box

View file

@ -532,9 +532,9 @@ export function InputConsentPanel(): React.ReactElement {
}
/>
{/* 오타 교정은 입력 맥락(수집 동의)만 있으면 제안과 따로 동작한다. */}
{/* 자동 한영 변환 및 오타 교정은 통계 수집 동의와 무관하게 기본 기능으로 동작한다. */}
<FormControlLabel
disabled={!enabled}
disabled={paused}
control={
<Switch
size="small"

View file

@ -0,0 +1,89 @@
// src/renderer/components/settings/UpdateSection.tsx
// 설정 → 정보 탭 맨 위의 업데이트 구획: 상태 · 진행률 · 마지막 확인 · 확인/다운로드/설치 버튼.
// 현재 버전은 바로 아래 앱 정보 구획에 있다.
// 예전에는 업데이트가 네이티브 대화상자로만 보여, 직접 확인하거나 받는 중인지 알 방법이 없었다.
import { Box, Button, LinearProgress, Typography } from '@mui/material'
import { Download, RefreshCw, RotateCcw } from 'lucide-react'
import { d3roPalette, typoSx } from '@d3ro/ui/theme'
import { useI18n } from '@d3ro/i18n'
import { SettingRow, SettingsSection } from './SettingsRows'
import { useAppUpdateStatus } from '../../hooks/useAppUpdateStatus'
import { describeUpdateStatus, primaryUpdateAction, progressPercent } from './update-status-model'
const TONE_COLOR = {
normal: d3roPalette.text.secondary,
accent: d3roPalette.accent.light,
danger: d3roPalette.status.danger,
} as const
export function UpdateSection(): React.ReactElement {
const { t, formatDate } = useI18n()
const { status, busy, check, download, install } = useAppUpdateStatus()
const message = status ? describeUpdateStatus(status) : null
const action = status ? primaryUpdateAction(status) : null
const actionButton = (() => {
if (action === 'download') {
return (
<Button variant="contained" size="small" disabled={busy} onClick={download} startIcon={<Download size={14} />}>
{t('update.action.download')}
</Button>
)
}
if (action === 'install') {
return (
<Button variant="contained" size="small" disabled={busy} onClick={install} startIcon={<RotateCcw size={14} />}>
{t('update.action.install')}
</Button>
)
}
return (
<Button
variant="outlined"
size="small"
disabled={busy || action === null}
onClick={check}
startIcon={<RefreshCw size={14} />}
>
{t('update.action.check')}
</Button>
)
})()
return (
<SettingsSection title={t('update.section')} description={t('update.section.desc')}>
<SettingRow
label={t('update.status.label')}
description={
status?.lastCheckedAt
? t('update.lastChecked', {
time: formatDate(status.lastCheckedAt, { dateStyle: 'medium', timeStyle: 'short' }),
})
: undefined
}
control={actionButton}
>
{message && (
<Typography
role="status"
aria-live="polite"
sx={{ ...typoSx('compact'), color: TONE_COLOR[message.tone], fontVariantNumeric: 'tabular-nums' }}
>
{t(message.key, message.params)}
</Typography>
)}
{status?.phase === 'downloading' && (
<Box sx={{ mt: 1 }}>
<LinearProgress
variant="determinate"
value={progressPercent(status)}
aria-label={t(message?.key ?? 'update.status.checking', message?.params)}
/>
</Box>
)}
</SettingRow>
</SettingsSection>
)
}

View file

@ -0,0 +1,75 @@
// src/renderer/components/settings/update-status-model.ts
// 업데이트 상태 → 화면 문구·버튼·칩 결정 (순수 로직 — 컴포넌트 테스트 환경 없이 검증한다).
import type { AppUpdateStatus } from '@d3ro/core/types'
import type { TranslationKey } from '@d3ro/i18n'
export interface UpdateMessage {
key: TranslationKey
params?: Record<string, string | number>
tone: 'normal' | 'accent' | 'danger'
}
export type UpdateAction = 'check' | 'download' | 'install'
export function describeUpdateStatus(status: AppUpdateStatus): UpdateMessage {
const version = status.version ?? ''
switch (status.phase) {
case 'disabled':
return { key: 'update.status.disabled', tone: 'normal' }
case 'idle':
return { key: 'update.status.idle', tone: 'normal' }
case 'checking':
return { key: 'update.status.checking', tone: 'normal' }
case 'up-to-date':
return { key: 'update.status.upToDate', tone: 'normal' }
case 'available':
if (status.skipped) return { key: 'update.status.skipped', params: { version }, tone: 'accent' }
return status.isMandatory
? { key: 'update.status.availableMandatory', params: { version }, tone: 'accent' }
: { key: 'update.status.available', params: { version }, tone: 'accent' }
case 'downloading':
return { key: 'update.status.downloading', params: { version, percent: progressPercent(status) }, tone: 'accent' }
case 'downloaded':
return { key: 'update.status.downloaded', params: { version }, tone: 'accent' }
case 'error':
return { key: 'update.status.error', params: { message: status.error ?? '' }, tone: 'danger' }
}
}
/** 지금 누를 수 있는 주 동작. 받는 중·비활성 빌드는 없다. */
export function primaryUpdateAction(status: AppUpdateStatus): UpdateAction | null {
switch (status.phase) {
case 'disabled':
case 'downloading':
case 'checking':
return null
case 'available':
return 'download'
case 'downloaded':
return 'install'
default:
return 'check'
}
}
/** 타이틀바 칩 — 사용자가 알아야 할 때(새 버전·받는 중·설치 대기)만 보인다. */
export function updateChipMessage(status: AppUpdateStatus | null): UpdateMessage | null {
if (!status) return null
const version = status.version ?? ''
switch (status.phase) {
case 'available':
return { key: 'update.chip.available', params: { version }, tone: 'accent' }
case 'downloading':
return { key: 'update.chip.downloading', params: { percent: progressPercent(status) }, tone: 'normal' }
case 'downloaded':
return { key: 'update.chip.downloaded', tone: 'accent' }
default:
return null
}
}
export function progressPercent(status: AppUpdateStatus): number {
const percent = status.progress?.percent ?? 0
return Math.max(0, Math.min(100, Math.round(percent)))
}

View file

@ -0,0 +1,54 @@
// src/renderer/components/shell/UpdateChip.tsx
// 타이틀바 오른쪽 업데이트 알림 — 새 버전·받는 중·설치 대기일 때만 보인다. 누르면 설정 → 정보 탭.
// 업데이트가 네이티브 대화상자로만 알려져 놓치기 쉬웠다(2026-10-24 사용자 지적).
import { Box, Tooltip } from '@mui/material'
import { ArrowDownCircle, RotateCcw } from 'lucide-react'
import { d3roPalette, d3roRadius, typoSx } from '@d3ro/ui/theme'
import { useI18n } from '@d3ro/i18n'
import { useAppUpdateStatus } from '../../hooks/useAppUpdateStatus'
import { updateChipMessage } from '../settings/update-status-model'
import { openSettings } from '../../navigation/settingsTabs'
export function UpdateChip(): React.ReactElement | null {
const { t } = useI18n()
const { status } = useAppUpdateStatus()
const message = updateChipMessage(status)
if (!message) return null
const accent = message.tone === 'accent'
const label = t(message.key, message.params)
return (
<Tooltip title={t('update.chip.tooltip')}>
<Box
component="button"
type="button"
onClick={() => openSettings('about')}
aria-label={`${label} — ${t('update.chip.tooltip')}`}
sx={{
...typoSx('small'),
display: 'flex',
alignItems: 'center',
gap: 0.75,
height: 26,
px: 1.25,
mr: 1,
border: `1px solid ${accent ? d3roPalette.accent.main : d3roPalette.glass.hairlineStrong}`,
borderRadius: d3roRadius.small,
bgcolor: accent ? d3roPalette.accent.solid : 'transparent',
color: accent ? d3roPalette.accent.ink : d3roPalette.text.secondary,
cursor: 'pointer',
fontVariantNumeric: 'tabular-nums',
whiteSpace: 'nowrap',
WebkitAppRegion: 'no-drag',
transition: 'background-color 0.12s ease',
'&:hover': { bgcolor: accent ? d3roPalette.accent.solidHover : d3roPalette.glass.raised },
'&:focus-visible': { outline: `2px solid ${d3roPalette.accent.main}`, outlineOffset: 2 },
}}
>
{status?.phase === 'downloaded' ? <RotateCcw size={13} /> : <ArrowDownCircle size={13} />}
{label}
</Box>
</Tooltip>
)
}

View file

@ -0,0 +1,48 @@
// src/renderer/hooks/useAppUpdateStatus.ts
// 앱 업데이트 상태 구독 — 설정 정보 탭(UpdateSection)과 타이틀바 칩(UpdateChip)이 같이 쓴다.
import { useCallback, useEffect, useState } from 'react'
import type { AppUpdateStatus } from '@d3ro/core/types'
export interface AppUpdateControls {
status: AppUpdateStatus | null
/** 확인·다운로드·설치 요청이 진행 중이다 (버튼 중복 클릭 방지) */
busy: boolean
check: () => void
download: () => void
install: () => void
}
export function useAppUpdateStatus(): AppUpdateControls {
const [status, setStatus] = useState<AppUpdateStatus | null>(null)
const [busy, setBusy] = useState(false)
useEffect(() => {
let alive = true
void window.electronAPI.appUpdate.getStatus().then((result) => {
if (alive && result.success) setStatus(result.data)
})
const unsubscribe = window.electronAPI.appUpdate.onStatusChanged((next) => setStatus(next))
return () => {
alive = false
unsubscribe()
}
}, [])
const run = useCallback((request: () => ReturnType<typeof window.electronAPI.appUpdate.check>) => {
setBusy(true)
void request()
.then((result) => {
if (result.success) setStatus(result.data)
})
.finally(() => setBusy(false))
}, [])
return {
status,
busy,
check: useCallback(() => run(() => window.electronAPI.appUpdate.check()), [run]),
download: useCallback(() => run(() => window.electronAPI.appUpdate.download()), [run]),
install: useCallback(() => run(() => window.electronAPI.appUpdate.install()), [run]),
}
}

View file

@ -39,6 +39,8 @@
var correction = null
var generatingSince = 0
var tickTimer = null
// 후보 없이 끝났을 때 잠깐 보이는 알림 ('no-suggestion') — 메인이 1초 뒤 창을 닫는다
var notice = null
function render() {
candidatesContainer.textContent = ''
@ -46,9 +48,13 @@
// 후보가 이미 있으면(채우기 루프가 배경에서 더 만드는 중이어도) 헤더 스피너는
// 끈다 — 진행률 줄의 작은 표시가 그 역할을 대신한다(중복 표시 방지).
var busy = warmingUp || (generating && candidates.length === 0)
if (statusRow) statusRow.hidden = !busy
var showNotice = !busy && notice === 'no-suggestion' && candidates.length === 0
if (statusRow) statusRow.hidden = !busy && !showNotice
if (statusRow) statusRow.classList.toggle('notice', showNotice)
if (statusText) {
if (warmingUp) {
if (showNotice) {
statusText.textContent = i18nStrings.suggestionNone || ''
} else if (warmingUp) {
statusText.textContent = i18nStrings.suggestionWarming || '...'
} else if (busy) {
// 경과 시간을 보여준다 — 모델이 바쁘면 몇 초 걸리는지 보이는 편이 덜 답답하다.
@ -197,6 +203,7 @@
var entries = [
[keyHints.move, i18nStrings.suggestionHintMoveLabel, ''],
[keyHints.accept, i18nStrings.suggestionHintAcceptLabel, ''],
[keyHints.word, i18nStrings.suggestionHintWordLabel, ''],
[keyHints.close, i18nStrings.suggestionHintCloseLabel, ' close-hint']
]
for (var i = 0; i < entries.length; i++) {
@ -252,6 +259,7 @@
if (payload.partialText !== undefined) partialText = payload.partialText || null
if (payload.provenance !== undefined) provenance = payload.provenance || null
if (payload.correction !== undefined) correction = payload.correction || null
if (payload.notice !== undefined) notice = payload.notice || null
}
function startTick() {
@ -296,6 +304,7 @@
partialText = null
provenance = null
correction = null
notice = null
candidates = []
activeIndex = 0
targetTotal = 0

View file

@ -129,6 +129,15 @@ body {
font-size: 12px;
}
/* 후보 없이 끝났을 때의 "제안 사항 없음" — 같은 자리에 스피너 없이 1초 */
.status.notice .spinner {
display: none;
}
.status.notice .status-text {
color: var(--d3-text-tertiary);
}
/* ── 후보 (한 페이지 = 3개, 각 최대 2줄, 고정 높이라 채워져도 창이 흔들리지 않는다) ── */
.candidates {
display: flex;