The tree carried uncommitted work from several areas (web push, mobile screens, admin charts, test-hygiene cleanup, CI and map docs). It is landed as one commit so the release pipeline can start from a clean tree; the desktop transcript-correction behaviour shipped in the previous commit and is unchanged here.
267 lines
9.1 KiB
TypeScript
267 lines
9.1 KiB
TypeScript
// src/renderer/components/shell/AppSidebar.tsx
|
|
// 메인 창 사이드바 — 2026-09-28 정보 구조 개편.
|
|
//
|
|
// 위: 1급(홈·기록·회의) — Ctrl+1..3. 가운데: "도구"(AI 대화·명령어·사전·지식). 아래: 지원·설정·상태 한 줄.
|
|
// 모든 항목은 <button> 이고 현재 화면은 aria-current="page". (이전: Box onClick — 키보드로 닿지 않았다)
|
|
// 사이드바는 본문보다 한 단 어둡고, 강조색은 현재 위치의 아이콘 하나에만 쓴다(Linear 관찰: 크롬의 파랑 최소화).
|
|
|
|
import React, { useEffect, useState } from 'react'
|
|
import { Box, ButtonBase, Tooltip, Typography } from '@mui/material'
|
|
import {
|
|
BookOpen,
|
|
Headphones,
|
|
History as HistoryIcon,
|
|
Home,
|
|
Library,
|
|
MessagesSquare,
|
|
Search,
|
|
Settings,
|
|
SquareTerminal,
|
|
Users,
|
|
} from 'lucide-react'
|
|
import { Led, TactileBadge } from '@d3ro/ui/components/ds'
|
|
import { d3roPalette, d3roRadius, d3roFocusRing, d3roTransition, typoSx } from '@d3ro/ui/theme'
|
|
import { useI18n } from '@d3ro/i18n'
|
|
import type { TranslationKey } from '@d3ro/i18n'
|
|
import type { LicenseTier, LLMStatus } from '@d3ro/core/types'
|
|
import { PRIMARY_ROUTES, TOOL_ROUTES, useAppNavigation } from '../../navigation/app-navigation'
|
|
import type { AppRoute } from '../../navigation/app-navigation'
|
|
import { tierLabelKey } from '../../utils/display-labels'
|
|
|
|
const ICON = 18
|
|
|
|
const ROUTE_META: Record<AppRoute, { labelKey: TranslationKey; icon: React.ReactElement }> = {
|
|
home: { labelKey: 'nav.home', icon: <Home size={ICON} /> },
|
|
search: { labelKey: 'unifiedSearch.title', icon: <Search size={ICON} /> },
|
|
records: { labelKey: 'nav.records', icon: <HistoryIcon size={ICON} /> },
|
|
meetings: { labelKey: 'nav.meeting', icon: <Users size={ICON} /> },
|
|
conversation: { labelKey: 'nav.aiChat', icon: <MessagesSquare size={ICON} /> },
|
|
commands: { labelKey: 'nav.commands', icon: <SquareTerminal size={ICON} /> },
|
|
dictionary: { labelKey: 'nav.dictionary', icon: <BookOpen size={ICON} /> },
|
|
knowledge: { labelKey: 'nav.knowledge', icon: <Library size={ICON} /> },
|
|
settings: { labelKey: 'nav.settings', icon: <Settings size={ICON} /> },
|
|
}
|
|
|
|
function NavButton({
|
|
active,
|
|
icon,
|
|
label,
|
|
trailing,
|
|
onClick,
|
|
shortcut,
|
|
testId,
|
|
}: {
|
|
active: boolean
|
|
icon: React.ReactElement
|
|
label: string
|
|
trailing?: React.ReactNode
|
|
onClick: () => void
|
|
shortcut?: string
|
|
testId: string
|
|
}): React.ReactElement {
|
|
const button = (
|
|
<ButtonBase
|
|
onClick={onClick}
|
|
data-testid={testId}
|
|
aria-current={active ? 'page' : undefined}
|
|
sx={{
|
|
width: '100%',
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
justifyContent: 'flex-start',
|
|
gap: 1.25,
|
|
height: 34,
|
|
px: 1.25,
|
|
borderRadius: d3roRadius.button,
|
|
color: active ? d3roPalette.text.primary : d3roPalette.text.secondary,
|
|
bgcolor: active ? d3roPalette.surface.overlayStrong : 'transparent',
|
|
transition: d3roTransition('background-color', 'color'),
|
|
'&:hover': { color: d3roPalette.text.primary, bgcolor: active ? d3roPalette.surface.overlayStrong : d3roPalette.surface.overlaySoft },
|
|
'&:focus-visible': d3roFocusRing,
|
|
'& svg': { flexShrink: 0, color: active ? d3roPalette.accent.light : 'inherit' },
|
|
}}
|
|
>
|
|
{icon}
|
|
<Typography
|
|
component="span"
|
|
sx={{ ...typoSx('compact'), fontWeight: active ? 500 : 400, color: 'inherit', flex: 1, textAlign: 'left', lineHeight: 1 }}
|
|
>
|
|
{label}
|
|
</Typography>
|
|
{trailing}
|
|
</ButtonBase>
|
|
)
|
|
return shortcut ? (
|
|
<Tooltip title={shortcut} placement="right" enterDelay={600} describeChild>
|
|
{button}
|
|
</Tooltip>
|
|
) : (
|
|
button
|
|
)
|
|
}
|
|
|
|
function GroupLabel({ children }: { children: React.ReactNode }): React.ReactElement {
|
|
return (
|
|
<Typography
|
|
component="h2"
|
|
sx={{ ...typoSx('label'), color: d3roPalette.text.tertiary, px: 1.25, pt: 2.5, pb: 0.75 }}
|
|
>
|
|
{children}
|
|
</Typography>
|
|
)
|
|
}
|
|
|
|
/** 사이드바 맨 아래 한 줄 — 조회한 상태만. 조회 전에는 '확인 중'. */
|
|
function StatusLine({ onOpenGuide }: { onOpenGuide: () => void }): React.ReactElement {
|
|
const { t } = useI18n()
|
|
const [llm, setLlm] = useState<LLMStatus | null>(null)
|
|
|
|
useEffect(() => {
|
|
window.electronAPI.llm.getStatus().then((r) => {
|
|
if (r.success) setLlm(r.data)
|
|
})
|
|
return window.electronAPI.llm.onStatusChanged((e) => setLlm(e.status))
|
|
}, [])
|
|
|
|
const connected = llm?.connectionState === 'connected'
|
|
const label = llm === null ? t('shell.localAi.checking') : connected ? t('shell.localAi.connected') : t('shell.localAi.offline')
|
|
|
|
return (
|
|
<Box
|
|
role="status"
|
|
sx={{ display: 'flex', alignItems: 'center', gap: 1, px: 1.25, pt: 1.5, minHeight: 28, color: d3roPalette.text.tertiary }}
|
|
>
|
|
<Led color={llm === null ? 'off' : connected ? 'green' : 'orange'} size={6} />
|
|
<Typography component="span" sx={{ ...typoSx('small'), color: 'inherit', flex: 1, minWidth: 0, whiteSpace: 'nowrap' }}>
|
|
{label}
|
|
</Typography>
|
|
{llm !== null && !connected && (
|
|
<ButtonBase
|
|
onClick={onOpenGuide}
|
|
sx={{
|
|
...typoSx('small'),
|
|
color: d3roPalette.accent.light,
|
|
borderRadius: d3roRadius.xs,
|
|
px: 0.5,
|
|
'&:hover': { textDecoration: 'underline' },
|
|
'&:focus-visible': d3roFocusRing,
|
|
}}
|
|
>
|
|
{t('shell.localAi.setup')}
|
|
</ButtonBase>
|
|
)}
|
|
</Box>
|
|
)
|
|
}
|
|
|
|
export function AppSidebar({
|
|
tier,
|
|
onOpenSupport,
|
|
onOpenOllamaGuide,
|
|
}: {
|
|
tier: LicenseTier
|
|
onOpenSupport: () => void
|
|
onOpenOllamaGuide: () => void
|
|
}): React.ReactElement {
|
|
const { t } = useI18n()
|
|
const { route, navigate } = useAppNavigation()
|
|
const [captionActive, setCaptionActive] = useState(false)
|
|
const [meetingRecording, setMeetingRecording] = useState(false)
|
|
|
|
useEffect(() => {
|
|
window.electronAPI.caption.getState().then((r) => {
|
|
if (r.success) setCaptionActive(r.data === 'active')
|
|
})
|
|
window.electronAPI.meetingMode.getState().then((r) => {
|
|
if (r.success) setMeetingRecording(r.data.state === 'recording')
|
|
})
|
|
const unsubCaption = window.electronAPI.caption.onStateChanged((e) => setCaptionActive(e.state === 'active'))
|
|
const unsubMeeting = window.electronAPI.meetingMode.onStateChanged((e) => setMeetingRecording(e.state === 'recording'))
|
|
return () => {
|
|
unsubCaption()
|
|
unsubMeeting()
|
|
}
|
|
}, [])
|
|
|
|
const item = (r: AppRoute, index?: number, trailing?: React.ReactNode): React.ReactElement => (
|
|
<NavButton
|
|
key={r}
|
|
active={route === r}
|
|
icon={ROUTE_META[r].icon}
|
|
label={t(ROUTE_META[r].labelKey)}
|
|
trailing={trailing}
|
|
shortcut={index !== undefined ? t('nav.shortcutHint', { n: index + 1 }) : undefined}
|
|
onClick={() => navigate(r)}
|
|
testId={`nav-${r}`}
|
|
/>
|
|
)
|
|
|
|
return (
|
|
<Box
|
|
component="nav"
|
|
aria-label={t('nav.mainLabel')}
|
|
sx={{
|
|
width: 216,
|
|
flexShrink: 0,
|
|
bgcolor: d3roPalette.bg.sidebar,
|
|
borderRight: `1px solid ${d3roPalette.border.subtle}`,
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
px: 1.5,
|
|
pt: 2,
|
|
pb: 1.5,
|
|
gap: 0.25,
|
|
}}
|
|
>
|
|
{/* 브랜드 — 그라디언트·LED 없이 글자로 */}
|
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, px: 1.25, pb: 2 }}>
|
|
<Typography sx={{ ...typoSx('heading'), color: d3roPalette.text.primary, flex: 1 }}>D3RO Voice</Typography>
|
|
{tier !== 'free' && <TactileBadge tone="accent">{t(tierLabelKey(tier))}</TactileBadge>}
|
|
</Box>
|
|
|
|
{PRIMARY_ROUTES.map((r, i) =>
|
|
item(
|
|
r,
|
|
i,
|
|
r === 'meetings' && meetingRecording ? <Led color="red" pulse size={6} /> : undefined,
|
|
),
|
|
)}
|
|
|
|
<GroupLabel>{t('nav.tools')}</GroupLabel>
|
|
{TOOL_ROUTES.map((r) => item(r))}
|
|
|
|
<Box sx={{ flex: 1 }} />
|
|
|
|
{/* 진행 중인 것 — 어디서든 보여야 한다 */}
|
|
{(captionActive || meetingRecording) && (
|
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.5, px: 1.25, pb: 1 }}>
|
|
{meetingRecording && (
|
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, color: d3roPalette.status.danger }}>
|
|
<Led color="red" pulse size={6} />
|
|
<Typography sx={{ ...typoSx('small'), color: 'inherit' }}>{t('shell.live.meeting')}</Typography>
|
|
</Box>
|
|
)}
|
|
{captionActive && !meetingRecording && (
|
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, color: d3roPalette.text.secondary }}>
|
|
<Led color="blue" pulse size={6} />
|
|
<Typography sx={{ ...typoSx('small'), color: 'inherit' }}>{t('shell.live.caption')}</Typography>
|
|
</Box>
|
|
)}
|
|
</Box>
|
|
)}
|
|
|
|
<NavButton
|
|
active={false}
|
|
icon={<Headphones size={ICON} />}
|
|
label={t('nav.support')}
|
|
onClick={onOpenSupport}
|
|
testId="nav-support"
|
|
/>
|
|
{item('settings')}
|
|
|
|
<Box sx={{ borderTop: `1px solid ${d3roPalette.border.subtle}`, mt: 1 }}>
|
|
<StatusLine onOpenGuide={onOpenOllamaGuide} />
|
|
</Box>
|
|
</Box>
|
|
)
|
|
}
|