Skip to content

Conversation

@sushen123
Copy link
Contributor

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
Screenshot 2025-04-05 19:54:18

Modal
Screenshot 2025-04-05 19:55:44

Video

Screencast.2025-04-05.19.58.12.mp4

Issue(s) Addressed

Closes #35

Steps to Test or Reproduce

  1. Go to any room or channel.
  2. Click on plus button which is in the message box.
  3. Modal will show up.
  4. Select any option
  5. Click on Summarize Button
  6. Messages will be summarize

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.

public async handleActions(context: UIKitViewSubmitInteractionContext): Promise<IUIKitResponse> {
    const { view, user } = context.getInteractionData(); 
    // When I try to extract the roomId and threadId from the context, they return null.
    
    const { roomId } = await getData(
        this.read.getPersistenceReader(),
        user.id,
        ROOM_ID_KEY,
    );
}


        
        
        
        
        

@sushen123
Copy link
Contributor Author

hey @JeffreytheCoder , can you check this PR?

@JeffreytheCoder
Copy link
Contributor

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?

@sushen123
Copy link
Contributor Author

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

Comment on lines 112 to 133
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;
});
}
Copy link
Contributor

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

Copy link
Contributor Author

@sushen123 sushen123 Apr 13, 2025

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

Comment on lines 66 to 219
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);
}
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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

@JeffreytheCoder
Copy link
Contributor

@sushen123 Thanks for adding the demo video! The UI code is very structured 👍 Left some minor comments

@sushen123
Copy link
Contributor Author

sushen123 commented Apr 10, 2025 via email

@JeffreytheCoder
Copy link
Contributor

LGTM! Thanks for the changes

Feel free to merge this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add action button to summarize the thread

2 participants