feat: add mobile shell and unified search
Some checks failed
ci / 정본·보안·린트·타입·테스트 (push) Failing after 50s
ci / 워크스페이스 빌드 검증 (push) Has been skipped
ci / Supabase Edge Functions + Cloudflare Worker (push) Successful in 20s
ci / .NET API 서버 테스트 (push) Successful in 12s
deploy-site / deploy (push) Successful in 39s
ci / 모바일 린트·타입·Jest (push) Failing after 3h10m31s
Some checks failed
ci / 정본·보안·린트·타입·테스트 (push) Failing after 50s
ci / 워크스페이스 빌드 검증 (push) Has been skipped
ci / Supabase Edge Functions + Cloudflare Worker (push) Successful in 20s
ci / .NET API 서버 테스트 (push) Successful in 12s
deploy-site / deploy (push) Successful in 39s
ci / 모바일 린트·타입·Jest (push) Failing after 3h10m31s
This commit is contained in:
parent
f505a03d34
commit
5ca3709b32
98 changed files with 5168 additions and 2093 deletions
|
|
@ -19,6 +19,7 @@ import { CommandsPage } from '../pages/CommandsPage'
|
|||
import { VoiceConversationPage } from '../pages/VoiceConversationPage'
|
||||
import { KnowledgeBasePage } from '../pages/KnowledgeBasePage'
|
||||
import { MeetingModePage } from '../pages/MeetingModePage'
|
||||
import { UnifiedSearchPage } from '../pages/UnifiedSearchPage'
|
||||
import { SettingsModal } from './SettingsModal'
|
||||
import { OPEN_SETTINGS_EVENT, readOpenSettingsTab, DEFAULT_SETTINGS_TAB } from '../navigation/settingsTabs'
|
||||
import type { SettingsTabId } from '../navigation/settingsTabs'
|
||||
|
|
@ -132,10 +133,16 @@ function Shell(): React.ReactElement {
|
|||
}
|
||||
}, [t, navigate])
|
||||
|
||||
// 키보드: Ctrl+1..3 = 1급 화면, Ctrl+, = 설정. 입력 중에는 무시.
|
||||
// 키보드: Ctrl+K = 통합 검색, Ctrl+1..3 = 1급 화면, Ctrl+, = 설정.
|
||||
useEffect(() => {
|
||||
const onKeyDown = (e: KeyboardEvent): void => {
|
||||
if (!(e.ctrlKey || e.metaKey) || e.altKey || e.shiftKey || isTypingTarget(e.target)) return
|
||||
if (!(e.ctrlKey || e.metaKey) || e.altKey || e.shiftKey) return
|
||||
if (e.key.toLocaleLowerCase() === 'k') {
|
||||
e.preventDefault()
|
||||
if (route !== 'search') navigate('search')
|
||||
return
|
||||
}
|
||||
if (isTypingTarget(e.target)) return
|
||||
const index = ['1', '2', '3'].indexOf(e.key)
|
||||
if (index >= 0) {
|
||||
e.preventDefault()
|
||||
|
|
@ -147,7 +154,7 @@ function Shell(): React.ReactElement {
|
|||
}
|
||||
window.addEventListener('keydown', onKeyDown)
|
||||
return () => window.removeEventListener('keydown', onKeyDown)
|
||||
}, [navigate])
|
||||
}, [navigate, route])
|
||||
|
||||
const openSettingsTab = useCallback(
|
||||
(tab: SettingsTabId) => {
|
||||
|
|
@ -186,6 +193,7 @@ function Shell(): React.ReactElement {
|
|||
style={{ height: '100%', width: '100%' }}
|
||||
>
|
||||
{route === 'home' && <HomePage />}
|
||||
{route === 'search' && <UnifiedSearchPage />}
|
||||
{route === 'records' && <HistoryPage />}
|
||||
{route === 'meetings' && <MeetingModePage />}
|
||||
{route === 'conversation' && <VoiceConversationPage />}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ export interface SearchInputProps {
|
|||
value: string
|
||||
onChange: (value: string) => void
|
||||
placeholder: string
|
||||
/** 포커스 단축키. '/' 만 지원. 빈 문자열이면 끈다 */
|
||||
/** 포커스 단축키. '/' 또는 'Ctrl K'. 빈 문자열이면 끈다 */
|
||||
shortcut?: string
|
||||
autoFocus?: boolean
|
||||
}
|
||||
|
||||
function isTypingTarget(target: EventTarget | null): boolean {
|
||||
|
|
@ -21,17 +22,34 @@ function isTypingTarget(target: EventTarget | null): boolean {
|
|||
return target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName)
|
||||
}
|
||||
|
||||
export function SearchInput({ value, onChange, placeholder, shortcut = '/' }: SearchInputProps): React.ReactElement {
|
||||
export function SearchInput({
|
||||
value,
|
||||
onChange,
|
||||
placeholder,
|
||||
shortcut = '/',
|
||||
autoFocus = false,
|
||||
}: SearchInputProps): React.ReactElement {
|
||||
const { t } = useI18n()
|
||||
const inputRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (shortcut !== '/') return undefined
|
||||
const onKeyDown = (e: KeyboardEvent): void => {
|
||||
if (e.key !== '/' || e.ctrlKey || e.metaKey || e.altKey || isTypingTarget(e.target)) return
|
||||
const slash = shortcut === '/'
|
||||
&& e.key === '/'
|
||||
&& !e.ctrlKey
|
||||
&& !e.metaKey
|
||||
&& !e.altKey
|
||||
&& !isTypingTarget(e.target)
|
||||
const commandK = shortcut === 'Ctrl K'
|
||||
&& (e.ctrlKey || e.metaKey)
|
||||
&& !e.altKey
|
||||
&& !e.shiftKey
|
||||
&& e.key.toLocaleLowerCase() === 'k'
|
||||
if (!slash && !commandK) return
|
||||
e.preventDefault()
|
||||
inputRef.current?.focus()
|
||||
}
|
||||
if (shortcut !== '/' && shortcut !== 'Ctrl K') return undefined
|
||||
window.addEventListener('keydown', onKeyDown)
|
||||
return () => window.removeEventListener('keydown', onKeyDown)
|
||||
}, [shortcut])
|
||||
|
|
@ -39,6 +57,7 @@ export function SearchInput({ value, onChange, placeholder, shortcut = '/' }: Se
|
|||
return (
|
||||
<TextField
|
||||
inputRef={inputRef}
|
||||
autoFocus={autoFocus}
|
||||
placeholder={placeholder}
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import {
|
|||
Home,
|
||||
Library,
|
||||
MessagesSquare,
|
||||
Search,
|
||||
Settings,
|
||||
SquareTerminal,
|
||||
Users,
|
||||
|
|
@ -31,6 +32,7 @@ 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} /> },
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import type { SettingsTabId } from './settingsTabs'
|
|||
|
||||
export type AppRoute =
|
||||
| 'home'
|
||||
| 'search'
|
||||
| 'records'
|
||||
| 'meetings'
|
||||
| 'conversation'
|
||||
|
|
|
|||
251
apps/desktop/src/renderer/pages/UnifiedSearchPage.tsx
Normal file
251
apps/desktop/src/renderer/pages/UnifiedSearchPage.tsx
Normal file
|
|
@ -0,0 +1,251 @@
|
|||
// 기록과 회의 제목·전사를 함께 찾고, 원본 상세로 돌려보내는 읽기 전용 검색 화면.
|
||||
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { Box, ButtonBase, IconButton, Skeleton, Typography } from '@mui/material'
|
||||
import { AlertTriangle, ArrowLeft, FileText, Search as SearchIcon, SearchX, Users } from 'lucide-react'
|
||||
import type { UnifiedSearchMatchedField, UnifiedSearchResponse, UnifiedSearchResult } from '@d3ro/core/types'
|
||||
import { PhysicalButton } from '@d3ro/ui/components/ds'
|
||||
import {
|
||||
d3roFocusRing,
|
||||
d3roPalette,
|
||||
d3roRadius,
|
||||
d3roTransition,
|
||||
typoSx,
|
||||
} from '@d3ro/ui/theme'
|
||||
import { useI18n } from '@d3ro/i18n'
|
||||
import { EmptyStateCard, PageHeader, SearchInput } from '../components/shared'
|
||||
import { useAppNavigation, useRouteRequest } from '../navigation/app-navigation'
|
||||
|
||||
const SEARCH_DEBOUNCE_MS = 180
|
||||
|
||||
type SearchState =
|
||||
| { status: 'idle' }
|
||||
| { status: 'loading' }
|
||||
| { status: 'ready'; response: UnifiedSearchResponse }
|
||||
| { status: 'error' }
|
||||
|
||||
function resultIcon(source: UnifiedSearchResult['source']): React.ReactElement {
|
||||
return source === 'record' ? <FileText size={18} aria-hidden /> : <Users size={18} aria-hidden />
|
||||
}
|
||||
|
||||
export function UnifiedSearchPage(): React.ReactElement {
|
||||
const { t, locale } = useI18n()
|
||||
const { navigate, back } = useAppNavigation()
|
||||
const [query, setQuery] = useState('')
|
||||
const [state, setState] = useState<SearchState>({ status: 'idle' })
|
||||
const [retryNonce, setRetryNonce] = useState(0)
|
||||
const requestSequence = useRef(0)
|
||||
|
||||
useRouteRequest('search', (params) => {
|
||||
setQuery(params.query ?? '')
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const normalized = query.trim()
|
||||
if (!normalized) {
|
||||
requestSequence.current += 1
|
||||
setState({ status: 'idle' })
|
||||
return undefined
|
||||
}
|
||||
|
||||
const sequence = ++requestSequence.current
|
||||
const timer = window.setTimeout(() => {
|
||||
setState({ status: 'loading' })
|
||||
void window.electronAPI.unifiedSearch
|
||||
.query({ query: normalized })
|
||||
.then((result) => {
|
||||
if (requestSequence.current !== sequence) return
|
||||
setState(result.success ? { status: 'ready', response: result.data } : { status: 'error' })
|
||||
})
|
||||
.catch(() => {
|
||||
if (requestSequence.current === sequence) setState({ status: 'error' })
|
||||
})
|
||||
}, SEARCH_DEBOUNCE_MS)
|
||||
|
||||
return () => {
|
||||
window.clearTimeout(timer)
|
||||
if (requestSequence.current === sequence) requestSequence.current += 1
|
||||
}
|
||||
}, [query, retryNonce])
|
||||
|
||||
const openResult = useCallback(
|
||||
(result: UnifiedSearchResult) => {
|
||||
if (result.source === 'record') navigate('records', { recordId: result.id })
|
||||
else navigate('meetings', { meetingSessionId: result.id })
|
||||
},
|
||||
[navigate],
|
||||
)
|
||||
|
||||
const matchLabel = useCallback(
|
||||
(field: UnifiedSearchMatchedField): string => {
|
||||
switch (field) {
|
||||
case 'title':
|
||||
return t('unifiedSearch.matchedTitle')
|
||||
case 'content':
|
||||
return t('unifiedSearch.matchedContent')
|
||||
case 'transcript':
|
||||
return t('unifiedSearch.matchedTranscript')
|
||||
}
|
||||
},
|
||||
[t],
|
||||
)
|
||||
|
||||
const resultCount = state.status === 'ready'
|
||||
? t('unifiedSearch.resultCount', { count: state.response.total })
|
||||
: undefined
|
||||
|
||||
let body: React.ReactNode
|
||||
if (state.status === 'idle') {
|
||||
body = (
|
||||
<EmptyStateCard
|
||||
icon={<SearchIcon />}
|
||||
message={t('unifiedSearch.promptTitle')}
|
||||
description={t('unifiedSearch.promptDescription')}
|
||||
/>
|
||||
)
|
||||
} else if (state.status === 'loading') {
|
||||
body = (
|
||||
<Box aria-busy="true" aria-label={t('unifiedSearch.loading')} sx={{ pt: 1 }}>
|
||||
{Array.from({ length: 5 }, (_, index) => (
|
||||
<Box key={index} sx={{ display: 'flex', gap: 2, px: 1.5, py: 1.75, borderBottom: `1px solid ${d3roPalette.border.subtle}` }}>
|
||||
<Skeleton variant="circular" width={18} height={18} />
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<Skeleton variant="text" width={`${52 + index * 7}%`} />
|
||||
<Skeleton variant="text" width={`${78 - index * 5}%`} />
|
||||
</Box>
|
||||
</Box>
|
||||
))}
|
||||
</Box>
|
||||
)
|
||||
} else if (state.status === 'error') {
|
||||
body = (
|
||||
<EmptyStateCard
|
||||
icon={<AlertTriangle />}
|
||||
message={t('unifiedSearch.loadErrorTitle')}
|
||||
description={t('unifiedSearch.loadErrorDescription')}
|
||||
action={
|
||||
<PhysicalButton tone="glass" size="small" onClick={() => setRetryNonce((value) => value + 1)}>
|
||||
{t('unifiedSearch.retry')}
|
||||
</PhysicalButton>
|
||||
}
|
||||
/>
|
||||
)
|
||||
} else if (state.response.results.length === 0) {
|
||||
body = (
|
||||
<EmptyStateCard
|
||||
icon={<SearchX />}
|
||||
message={t('unifiedSearch.noResultsTitle')}
|
||||
description={t('unifiedSearch.noResultsDescription', { query: state.response.query })}
|
||||
/>
|
||||
)
|
||||
} else {
|
||||
body = (
|
||||
<Box component="ul" aria-label={t('unifiedSearch.resultsLabel')} sx={{ m: 0, p: 0, listStyle: 'none' }}>
|
||||
{state.response.results.map((result) => {
|
||||
const sourceLabel = result.source === 'record'
|
||||
? t('unifiedSearch.sourceRecord')
|
||||
: t('unifiedSearch.sourceMeeting')
|
||||
const title = result.title?.trim() || (result.source === 'record'
|
||||
? t('unifiedSearch.untitledRecord')
|
||||
: t('unifiedSearch.untitledMeeting'))
|
||||
|
||||
return (
|
||||
<Box component="li" key={`${result.source}:${result.id}`}>
|
||||
<ButtonBase
|
||||
onClick={() => openResult(result)}
|
||||
aria-label={t('unifiedSearch.openResult', { source: sourceLabel, title })}
|
||||
sx={{
|
||||
width: '100%',
|
||||
minHeight: 72,
|
||||
display: 'grid',
|
||||
gridTemplateColumns: '24px minmax(0, 1fr) auto',
|
||||
alignItems: 'start',
|
||||
gap: 1.5,
|
||||
px: 1.5,
|
||||
py: 1.5,
|
||||
textAlign: 'left',
|
||||
color: d3roPalette.text.secondary,
|
||||
borderBottom: `1px solid ${d3roPalette.border.subtle}`,
|
||||
borderRadius: d3roRadius.button,
|
||||
transition: d3roTransition('background-color', 'color'),
|
||||
'&:hover': { bgcolor: d3roPalette.surface.overlaySoft },
|
||||
'&:focus-visible': d3roFocusRing,
|
||||
}}
|
||||
>
|
||||
<Box aria-hidden sx={{ color: d3roPalette.text.tertiary, pt: 0.25 }}>
|
||||
{resultIcon(result.source)}
|
||||
</Box>
|
||||
<Box sx={{ minWidth: 0 }}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'baseline', gap: 1, flexWrap: 'wrap' }}>
|
||||
<Typography component="h2" sx={{ ...typoSx('compact'), fontWeight: 500, color: d3roPalette.text.primary }}>
|
||||
{title}
|
||||
</Typography>
|
||||
<Typography component="span" sx={{ ...typoSx('small'), color: d3roPalette.text.tertiary }}>
|
||||
{sourceLabel} · {matchLabel(result.matchedField)}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Typography
|
||||
sx={{
|
||||
...typoSx('compact'),
|
||||
color: d3roPalette.text.secondary,
|
||||
mt: 0.5,
|
||||
overflowWrap: 'anywhere',
|
||||
display: '-webkit-box',
|
||||
WebkitLineClamp: 2,
|
||||
WebkitBoxOrient: 'vertical',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
{result.excerpt || t('unifiedSearch.noPreview')}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Typography
|
||||
component="time"
|
||||
dateTime={new Date(result.occurredAt).toISOString()}
|
||||
sx={{ ...typoSx('small'), color: d3roPalette.text.tertiary, whiteSpace: 'nowrap', pt: 0.25 }}
|
||||
>
|
||||
{new Date(result.occurredAt).toLocaleDateString(locale, { year: 'numeric', month: 'short', day: 'numeric' })}
|
||||
</Typography>
|
||||
</ButtonBase>
|
||||
</Box>
|
||||
)
|
||||
})}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Box
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Escape' && query.trim().length === 0) back()
|
||||
}}
|
||||
sx={{ maxWidth: 1000, mx: 'auto', px: 5, py: 4, pb: 10 }}
|
||||
>
|
||||
<PageHeader
|
||||
title={t('unifiedSearch.title')}
|
||||
count={resultCount}
|
||||
description={t('unifiedSearch.description')}
|
||||
action={
|
||||
<IconButton aria-label={t('unifiedSearch.back')} onClick={back} sx={{ color: d3roPalette.text.secondary }}>
|
||||
<ArrowLeft size={18} aria-hidden />
|
||||
</IconButton>
|
||||
}
|
||||
/>
|
||||
<SearchInput
|
||||
value={query}
|
||||
onChange={setQuery}
|
||||
placeholder={t('unifiedSearch.placeholder')}
|
||||
shortcut="Ctrl K"
|
||||
autoFocus
|
||||
/>
|
||||
<Box role="status" aria-live="polite" sx={{ minHeight: 18, mb: 1 }}>
|
||||
{resultCount && (
|
||||
<Typography sx={{ ...typoSx('small'), color: d3roPalette.text.tertiary }}>
|
||||
{resultCount}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
{body}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue