Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/recording/RightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ type Tab = 'summary' | 'memo';

interface RightPanelProps {
memos: MemoEntry[];
summaries: string[];
defaultTab?: Tab;
}

export default function RightPanel({
memos,
summaries,
defaultTab = 'summary',
}: RightPanelProps) {
const [activeTab, setActiveTab] = useState<Tab>(defaultTab);
Expand Down Expand Up @@ -52,7 +54,7 @@ export default function RightPanel({

{/* 탭 콘텐츠 */}
<div className="flex-1 overflow-y-auto">
{activeTab === 'summary' ? <SummaryTab /> : <MemoTab memos={memos} />}
{activeTab === 'summary' ? <SummaryTab summaries={summaries} /> : <MemoTab memos={memos} />}
</div>
</div>
);
Expand Down
31 changes: 24 additions & 7 deletions src/components/recording/SummaryTab.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
export default function SummaryTab() {
interface SummaryTabProps {
summaries: string[];
}

export default function SummaryTab({ summaries }: SummaryTabProps) {
if (summaries.length === 0) {
return (
<div className="px-[32px] pt-[35px]">
<p className="text-[16px] leading-normal font-medium text-black">
중요한 내용만
<br />
실시간으로 정리해드릴게요! 📝
</p>
</div>
);
}

return (
<div className="px-[32px] pt-[35px]">
<p className="text-[16px] leading-normal font-medium text-black">
중요한 내용만
<br />
실시간으로 정리해드릴게요! 📝
</p>
<div className="flex flex-col gap-[24px] px-[32px] pt-[35px] pb-[32px]">
{summaries.map((summary, index) => (
<div key={index} className="flex flex-col gap-[8px]">
<p className="text-[12px] font-medium text-[#959595]">{index + 1}분</p>
<p className="text-[14px] leading-normal font-medium text-black whitespace-pre-wrap">{summary}</p>
</div>
))}
</div>
);
}
11 changes: 10 additions & 1 deletion src/hooks/useSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ interface UseSocketReturn {

export function useSocket(
onSubtitleFinal: (text: string) => void,
onSummary: (text: string) => void,
): UseSocketReturn {
const socketRef = useRef<SocketIOClient.Socket | null>(null);
const [isConnected, setIsConnected] = useState(false);

const onSubtitleFinalRef = useRef(onSubtitleFinal);
const onSummaryRef = useRef(onSummary);

useEffect(() => {
onSubtitleFinalRef.current = onSubtitleFinal;
}, [onSubtitleFinal]);
onSummaryRef.current = onSummary;
}, [onSubtitleFinal, onSummary]);

const connect = useCallback(() => {
if (socketRef.current?.connected) return;
Expand All @@ -47,6 +50,12 @@ export function useSocket(
onSubtitleFinalRef.current(text);
});

socket.on('stt:summary', (...args: unknown[]) => {
const text = args[0] as string;
console.log('[Socket] summary:', text);
onSummaryRef.current(text);
});

socketRef.current = socket;
}, []);

Expand Down
6 changes: 5 additions & 1 deletion src/pages/RecordingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function formatElapsed(ms: number): string {

export default function RecordingPage() {
const [entries, setEntries] = useState<TranscriptEntry[]>([]);
const [summaries, setSummaries] = useState<string[]>([]);
const [isRecording, setIsRecording] = useState(false);
const [isPaused, setIsPaused] = useState(false);

Expand Down Expand Up @@ -60,6 +61,9 @@ export default function RecordingPage() {
},
]);
},
(text) => {
setSummaries((prev) => [...prev, text]);
},
);

const handleStart = useCallback(async () => {
Expand Down Expand Up @@ -127,7 +131,7 @@ export default function RecordingPage() {
<div className="flex-1 overflow-y-auto">
<TranscriptArea entries={entries} />
</div>
<RightPanel memos={[]} defaultTab="summary" />
<RightPanel memos={[]} summaries={summaries} defaultTab="summary" />
</div>
</div>

Expand Down
Loading