From 999a3e05a41430ae5ec8c3df2d57d5ebd83179f8 Mon Sep 17 00:00:00 2001 From: Koper Date: Mon, 4 Dec 2023 20:54:54 +0700 Subject: [PATCH] Temp commit to merge main into this branch --- README.md | 8 + .../transcripts/[transcriptId]/page.tsx | 54 ++++++- .../transcripts/[transcriptId]/shareModal.tsx | 145 ++++++++++++------ www/app/[domain]/transcripts/finalSummary.tsx | 25 ++- www/app/lib/utils.ts | 10 ++ www/app/lib/zulip.ts | 80 ++++++++++ www/pages/api/send-to-zulip.ts | 62 -------- www/pages/api/send-zulip-message.ts | 44 ++++++ 8 files changed, 310 insertions(+), 118 deletions(-) create mode 100644 www/app/lib/zulip.ts delete mode 100644 www/pages/api/send-to-zulip.ts create mode 100644 www/pages/api/send-zulip-message.ts diff --git a/README.md b/README.md index cb75c76b..627de235 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,15 @@ poetry run python3 -m reflector.app And start the background worker +```bash celery -A reflector.worker.app worker --loglevel=info +``` + +Redis: + +```bash +TODO +``` #### Using docker diff --git a/www/app/[domain]/transcripts/[transcriptId]/page.tsx b/www/app/[domain]/transcripts/[transcriptId]/page.tsx index 98027af0..50d3002c 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/page.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/page.tsx @@ -49,6 +49,49 @@ export default function TranscriptDetails(details: TranscriptDetails) { .replace(/ +/g, " ") .trim() || ""; + if ( + (transcript?.response?.longSummary === null || true) && + transcript && + transcript.response + ) { + transcript.response.longSummary = ` +**Meeting Summary:** + +**Date:** November 21, 2023 +**Attendees:** Alice Johnson, Bob Smith, Carlos Gomez, Dana Lee +**Agenda Items:** + +1. **Project Alpha Update:** + - Discussed current progress and minor setbacks. + - Agreed on extending the deadline by two weeks. + - Assigned new tasks to team members. + +2. **Budget Review for Quarter 4:** + - Reviewed financial performance. + - Identified areas of overspending and discussed cost-cutting measures. + - Decided to allocate additional funds to marketing. + +3. **New Product Launch Strategy:** + - Brainstormed ideas for the upcoming product launch. + - Agreed on a digital-first marketing approach. + - Set a tentative launch date for January 15, 2024. + +**Key Decisions:** +- Extend Project Alpha's deadline to allow for quality enhancement. +- Implement cost-saving strategies in non-essential departments. +- Proceed with the digital marketing plan for the new product launch. + +**Action Items:** +- Alice to coordinate with the marketing team for the new campaign. +- Bob to oversee the budget adjustments and report back in one week. +- Carlos to lead the task force for Project Alpha's final phase. +- Dana to prepare a detailed report on competitor analysis for the next meeting. + +**Next Meeting:** +Scheduled for December 5, 2023, to review progress and finalize the new product launch details. +`; + } + return ( <> {!transcriptId || transcript?.loading || topics?.loading ? ( @@ -56,10 +99,13 @@ export default function TranscriptDetails(details: TranscriptDetails) { ) : ( <> setShowModal(v)} title={transcript?.response?.title} summary={transcript?.response?.longSummary} + date={transcript?.response?.createdAt} url={window.location.href} />
@@ -90,19 +136,13 @@ export default function TranscriptDetails(details: TranscriptDetails) { />
- - {transcript?.response?.longSummary && ( setShowModal(true)} /> )}
diff --git a/www/app/[domain]/transcripts/[transcriptId]/shareModal.tsx b/www/app/[domain]/transcripts/[transcriptId]/shareModal.tsx index 0c38f81f..debd60d4 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/shareModal.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/shareModal.tsx @@ -1,5 +1,17 @@ import React, { useState, useEffect } from "react"; import SelectSearch from "react-select-search"; +import { + getZulipMessage, + sendZulipMessage, + ZULIP_MSG_MAX_LENGTH, +} from "../../../lib/zulip"; +import { Transcript } from "../webSocketTypes"; +import { + GetTranscript, + GetTranscriptSegmentTopic, + GetTranscriptTopic, +} from "../../../api"; +import "react-select-search/style.css"; type ShareModal = { show: boolean; @@ -7,16 +19,28 @@ type ShareModal = { title: string; url: string; summary: string; + date: string; + transcript: GetTranscript | null; + topics: GetTranscriptTopic[] | null; }; +interface Stream { + id: number; + name: string; + topics: string[]; +} + +interface SelectSearchOption { + name: string; + value: string; +} + const ShareModal = (props: ShareModal) => { - const [stream, setStream] = useState(null); - const [topic, setTopic] = useState(null); - const [includeTranscript, setIncludeTranscript] = useState(false); - const [includeSummary, setIncludeSummary] = useState(false); + const [stream, setStream] = useState(undefined); + const [topic, setTopic] = useState(undefined); const [includeTopics, setIncludeTopics] = useState(false); const [isLoading, setIsLoading] = useState(true); - const [streams, setStreams] = useState({}); + const [streams, setStreams] = useState([]); useEffect(() => { fetch("/streams.json") @@ -27,6 +51,9 @@ const ShareModal = (props: ShareModal) => { return response.json(); }) .then((data) => { + data = data.sort((a: Stream, b: Stream) => + a.name.localeCompare(b.name), + ); console.log("Stream data:", data); setStreams(data); setIsLoading(false); @@ -38,67 +65,99 @@ const ShareModal = (props: ShareModal) => { }, []); const handleSendToZulip = () => { - const message = `### Reflector Recording\n\n**[${props.title}](${props.url})**\n\n${props.summary}`; + if (!props.transcript) return; - alert("Send to zulip"); + const msg = getZulipMessage(props.transcript, props.topics, includeTopics); + + if (stream && topic) sendZulipMessage(stream, topic, msg); }; if (props.show && isLoading) { return
Loading...
; } + console.log(stream); + + let streamOptions: SelectSearchOption[] = []; + if (streams) { + streams.forEach((stream) => { + const value = stream.name; + streamOptions.push({ name: value, value: value }); + }); + } + return (
{props.show && ( -
-
+
+
- {/* - */} -
- - -