-
Notifications
You must be signed in to change notification settings - Fork 19
feat: Add UI for summarzing messages #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add UI for summarzing messages #36
Conversation
|
hey @JeffreytheCoder , can you check this PR? |
|
Hi @sushen123 , thanks for implementing this! The demo video is not playable on my side - could you double check it or provide an alternative link please? |
hey @JeffreytheCoder you can check here https://vimeo.com/1073130710/683a3f2e83?share=copy#t=0 |
| if(filterValue === "users") { | ||
| const participantOptions: MultiStaticSelectOptionsParam = []; | ||
| try { | ||
| if (user.id && roomId) { | ||
| const members = await read.getRoomReader().getMembers(roomId); | ||
| for (const member of members) { | ||
| if (member.id) { | ||
| participantOptions.push({ | ||
| text: { | ||
| type: TextObjectType.MRKDWN, | ||
| text: `${member.name} - @${member.username}`, | ||
| }, | ||
| value: `${member.username}`, | ||
| }); | ||
| } | ||
| } | ||
| participantOptions.sort((a, b) => { | ||
| return a.text.text.toUpperCase() < b.text.text.toUpperCase() | ||
| ? -1 | ||
| : 1; | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the room has hundreds of users? It may create a big load on UI. It's worth testing out and adding some safety strategies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think sorting a large list could add extra load, and it’s probably not that necessary. So I’m thinking of skipping the sort altogether.
Is there anything else that might slow things down? would love to hear your thoughts
| switch (filter) { | ||
| case 'today': | ||
| startDate = new Date( | ||
| now.getFullYear(), | ||
| now.getMonth(), | ||
| now.getDate(), | ||
| 0, | ||
| 0, | ||
| 0, | ||
| 0 | ||
| ); | ||
| break; | ||
| case 'week': | ||
| startDate = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000); | ||
| break; | ||
| case 'unread': | ||
| unreadCount = await this.read | ||
| .getUserReader() | ||
| .getUserUnreadMessageCount(user.id); | ||
| break; | ||
| default: | ||
| usernames = view.state?.[SummarizeModalEnum.USER_LISTS_BLOCK_ID]?.[ | ||
| SummarizeModalEnum.USER_LISTS_ACTION_ID | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| const addOns = await this.app | ||
| .getAccessors() | ||
| .environmentReader.getSettings() | ||
| .getValueById('add-ons'); | ||
| const xAuthToken = await this.app | ||
| .getAccessors() | ||
| .environmentReader.getSettings() | ||
| .getValueById('x-auth-token'); | ||
| const xUserId = await this.app | ||
| .getAccessors() | ||
| .environmentReader.getSettings() | ||
| .getValueById('x-user-id'); | ||
|
|
||
|
|
||
| let messages: string; | ||
| if (!threadId) { | ||
| messages = await this.getRoomMessages( | ||
| room, | ||
| this.read, | ||
| user, | ||
| this.http, | ||
| addOns, | ||
| xAuthToken, | ||
| xUserId, | ||
| startDate, | ||
| unreadCount, | ||
| usernames, | ||
| anyMatchedUsername | ||
| ); | ||
| } else { | ||
| messages = await this.getThreadMessages( | ||
| room, | ||
| this.read, | ||
| user, | ||
| this.http, | ||
| threadId, | ||
| addOns, | ||
| xAuthToken, | ||
| xUserId, | ||
| startDate, | ||
| unreadCount, | ||
| usernames, | ||
| anyMatchedUsername | ||
| ); | ||
| } | ||
|
|
||
| if (!messages || messages.trim().length === 0) { | ||
| await notifyMessage( | ||
| room, | ||
| this.read, | ||
| user, | ||
| 'There are no messages to summarize in this channel.', | ||
| threadId | ||
| ); | ||
| return this.context.getInteractionResponder().successResponse();; | ||
| } | ||
|
|
||
| await notifyMessage(room, this.read, user, messages, threadId); | ||
|
|
||
| let summary: string; | ||
| if (!threadId) { | ||
| const prompt = createSummaryPromptByTopics(messages); | ||
| summary = await createTextCompletion( | ||
| this.app, | ||
| room, | ||
| this.read, | ||
| user, | ||
| this.http, | ||
| prompt, | ||
| threadId | ||
| ); | ||
| } else { | ||
| const prompt = createSummaryPrompt(messages); | ||
| summary = await createTextCompletion( | ||
| this.app, | ||
| room, | ||
| this.read, | ||
| user, | ||
| this.http, | ||
| prompt, | ||
| threadId | ||
| ); | ||
| } | ||
| await notifyMessage(room, this.read, user, summary, threadId); | ||
|
|
||
| if (addOns.includes('assigned-tasks')) { | ||
| const assignedTasksPrompt = createAssignedTasksPrompt(messages); | ||
| const assignedTasks = await createTextCompletion( | ||
| this.app, | ||
| room, | ||
| this.read, | ||
| user, | ||
| this.http, | ||
| assignedTasksPrompt, | ||
| threadId | ||
| ); | ||
| await notifyMessage(room, this.read, user, assignedTasks, threadId); | ||
| } | ||
|
|
||
| if (addOns.includes('follow-up-questions')) { | ||
| const followUpQuestionsPrompt = createFollowUpQuestionsPrompt(messages); | ||
| const followUpQuestions = await createTextCompletion( | ||
| this.app, | ||
| room, | ||
| this.read, | ||
| user, | ||
| this.http, | ||
| followUpQuestionsPrompt, | ||
| threadId | ||
| ); | ||
| await notifyMessage(room, this.read, user, followUpQuestions, threadId); | ||
| } | ||
|
|
||
| if (addOns.includes('participants-summary')) { | ||
| const participantsSummaryPrompt = | ||
| createParticipantsSummaryPrompt(messages); | ||
| const participantsSummary = await createTextCompletion( | ||
| this.app, | ||
| room, | ||
| this.read, | ||
| user, | ||
| this.http, | ||
| participantsSummaryPrompt, | ||
| threadId | ||
| ); | ||
| await notifyMessage(room, this.read, user, participantsSummary, threadId); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is duplicated from the slash command handling. It's better to unify these to reduce code duplication and ensure future changes on any subcommand works across slash command & UI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*Not only this part, but the entire submit handler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey i have made the changes can you look into it
|
@sushen123 Thanks for adding the demo video! The UI code is very structured 👍 Left some minor comments |
|
Sorry, I’ve been working on my lab report for the last 2-3 days. I’ll check
this tomorrow.
…On Tue, 8 Apr 2025, 9:31 am Jeffrey Yu, ***@***.***> wrote:
@sushen123 <https://github.com/sushen123> Thanks for adding the demo
video! The UI code is very structured 👍 Left some minor comments
—
Reply to this email directly, view it on GitHub
<#36 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVHF2TN346657IQEUS234LL2YNBCFAVCNFSM6AAAAAB2QRYTRCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBVGE2DONZTHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: JeffreytheCoder]*JeffreytheCoder* left a comment
(RocketChat/Apps.Chat.Summarize#36)
<#36 (comment)>
@sushen123 <https://github.com/sushen123> Thanks for adding the demo
video! The UI code is very structured 👍 Left some minor comments
—
Reply to this email directly, view it on GitHub
<#36 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVHF2TN346657IQEUS234LL2YNBCFAVCNFSM6AAAAAB2QRYTRCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBVGE2DONZTHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
LGTM! Thanks for the changes Feel free to merge this PR |
Proposed Changes
I have added a new action button to the UI that triggers a modal for summarizing messages. In modal there is filter to summarize message like (Messages from today, week, unread and specific users).
Action Button

Modal

Video
Screencast.2025-04-05.19.58.12.mp4
Issue(s) Addressed
Closes #35
Steps to Test or Reproduce
Further Comments
I have to use app persistence to store the roomId and threadId because the UIKitViewSubmitInteractionContext returns null when attempting to extract these values directly.