Skip to content

Conversation

not-meet
Copy link
Contributor

@not-meet not-meet commented Nov 22, 2024

Issue(s)

Closes #22

##This PR introduces a new feature that allows users to add the name and body of the new quick message from the rc rooms message box itself

Acceptance Criteria fulfillment

  • Add initial values to the create modal.
  • Update the readme file as per the same.

Proposed changes (including videos or screenshots)

  • User can now add the reply name and replybody from the rooms message box itself as
    /quick create "reply name" reply body
    to have the reply value in the modal

Demo

Screencast.from.2025-02-23.02-37-52.webm

here i have shown the demo of all three cases

  1. case where user creates reply from the modal (normally)
  2. case where a user uses the rooms input box to add the name and body
  3. case where a user changes the value he putted in the modal from the input box

up for any changes and learning :)

@CLAassistant
Copy link

CLAassistant commented Nov 22, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is alot of thing's that make no sense, try to make a PR that is clear and not bloated it, Ideally a PR should not have move then 200-300 line of code.

IModify,
IPersistence,
IRead,
IHttp,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these spaces

public persis: IPersistence;
public triggerId?: string;
public threadId?: string;
public app: QuickRepliesApp;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

const subCommand = this.params[0].toLowerCase();

if (
subCommand === CommandParam.CREATE ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we creating team in all the command ? explain me this

await this.handleSingleParam(handler);
break;
}
default: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be in default

}
}
}
private async handleQuickCreate(handler: Handler, args: string[]): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already handled default cases

);

if (args.length < 3) {
await sendUsageMessage(modify, room, sender);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this ?

return;
}
}
public app: QuickRepliesApp;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too much bloated code remove all these spaces

room: IRoom,
user: IUser,
): Promise<void> {
const text = '/quick-create <replyName> "<replyBody>"';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we have this code ?

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make requested changes

@not-meet
Copy link
Contributor Author

not-meet commented Nov 22, 2024

Hi @VipinDevelops so i reflected the changes you asked for and made them as per the requirements

Note
the reason of adding the handlequickcreate function in the default is because of the number of arguments and the authentication of the keyword used as the switch case works on the parameters of length so as there can be a high chances of having uncertainty of inputs ive added quick create function in the default as it gets only called when there is a create keyword in the first index! :)

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still a lot of room for improvement basically you are repeating a lot of code and not following best practice.

}
default: {
await handler.sendDefault();
const subCommand = this.params[0].toLowerCase();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't have to put this in switch case you can handle this in global

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no updates here ?

}
}

private async handleQuickCreate(handler: Handler, args: string[]): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dont use the function we already have for creating new replies ?

return;
}

switch (args[0].toLowerCase()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why switch case in a function that is made to create a reply ?

await handler.CreateQuickReply(args);
break;
}
default: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the third place where you please .sendDefault() is there any other way to achieve check without repeating this

return;
}
}
public async CreateQuickReply(args: string[]): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do have a method already for this

@VipinDevelops
Copy link
Collaborator

Also, update the documentation accordingly.

@not-meet
Copy link
Contributor Author

hey @VipinDevelops made changes as you asked..! now i believe the code looks much cleaner to be merged...
up if there are any other changes to be made : )

@VipinDevelops
Copy link
Collaborator

VipinDevelops commented Dec 16, 2024

Hey @not-meet Can you explain a little about changes you have made and use the code we have already for creating replies I have seen you writing some code again that already exist Either reuse the function we have or make something new that can be use in both old and new code.

@not-meet
Copy link
Contributor Author

not-meet commented Dec 17, 2024

hey!! @VipinDevelops
so I've added conditional logic in the CreateModal to take the reply name and body from CLI arguments as the original modal uses the input from the input boxes in the modal.

I wrote new logic instead of modifying the existing modal to avoid conflicts. While I understand the concern about calling the handler in the default switch case instead of passing it globally, doing so avoids issues where the global call still triggers the switch case unintentionally.

@not-meet
Copy link
Contributor Author

Hey! @VipinDevelops i have made the changes as you asked! now i believe the code is much cleaner.... also added an example in readme to help user to get the context of quick create cli command!

export class QuickRepliesApp extends App {
private elementBuilder: ElementBuilder;
private blockBuilder: BlockBuilder;
public params: Array<string>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this ?

http,
persistence,
modify,
this.params,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

}
default: {
await handler.sendDefault();
const subCommand = this.params[0].toLowerCase();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no updates here ?


export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & {
language: Language;
args : string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ?

room: IRoom,
language: Language,
): Promise<IUIKitSurfaceViewParam | Error> {
args: string[],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why add this logic again we can just use the arguments to pass in the existing function

break;
}
default: {
default: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & {
language: Language;
args? : string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why optional ? it will always be there

this.modify,
this.room,
this.language,
this.args ?? [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

return;
}

if (!modal) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

language: Language,
): Promise<IUIKitSurfaceViewParam | Error> {
args: string[],
): Promise<IUIKitSurfaceViewParam | Error | void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no change here

@VipinDevelops
Copy link
Collaborator

Again fix PR name , please follow the standard for everything you do

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alot of changes required


const commandUtility = new CommandUtility(commandUtilityParams);
await commandUtility.resolveCommand();
await new CommandUtility(commandUtilityParams).resolveCommand();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ?

label: labelReplyBody,
optional: false,
multiline: true,
initialValue: args.length > 2 ? args.slice(2).join(' ') : undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think that's how you should do this

super(info, logger, accessors);
}

public setCommandParams(userId: string, params: string[]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this ?

persistence: IPersistence,
modify: IModify,
) {
const userId = context.getInteractionData().user.id;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again what is this ?

modify: IModify,
) {
const userId = context.getInteractionData().user.id;
const storedParams = this.getCommandParams(userId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you strong params makes no sense to me

protected readonly http: IHttp,
protected readonly persistence: IPersistence,
protected readonly modify: IModify,
protected readonly params: ICommandUtilityParams['params'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

view,
language,
triggerId,
this.params
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

const name = nameStateValue ? nameStateValue.trim() : '';
const body = bodyStateValue ? bodyStateValue.trim() : '';

const argsName = params.length > 1 ? params[1] : undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why undefined that should not be possible


const argsName = params.length > 1 ? params[1] : undefined;
const argsBody = params.length > 2 ? params.slice(2).join(' ') : undefined;
const name = argsName ? argsName : nameStateValue ? nameStateValue.trim() : '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ternary operator is doing simple thing in much complex way

this.triggerId = params.triggerId;
this.threadId = params.threadId;
this.language = params.language;
this.args = params.args;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@not-meet not-meet changed the title added a feature of quick create from the input box itself.. preview of reply in create modal Feb 21, 2025
@not-meet
Copy link
Contributor Author

hi! sorry for the delay for now i have changed the pr name and in the recent commit was just trying this approach, I will
go through the reviews and make a final commit as soon as possible

@not-meet not-meet changed the title preview of reply in create modal pre-filled quick create modal Feb 21, 2025
Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read how I named my intial PR and use similar name I won't allow any PR that is not following good naming and description practice.

README.md Outdated
- **`/quick ai`**: Use AI to generate replies
- **`/quick help`**: Get help with Quick Reply
- **`/qs <reply name>`**: Quickly search and send a reply by name
- **`/quick create <name> <message>`**: Create a quick reply directly from the input box with a name and message
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put create command together , explain how double quotes works to name a reply

break;
}
default: {
default: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

view.state?.[CreateModalEnum.REPLY_BODY_BLOCK_ID]?.[
CreateModalEnum.REPLY_BODY_ACTION_ID
];
const nameStateValue = view.state && Object.values(view.state)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is so bad adding find don't make sense to me here and again you are not using enums , please find why enum are good and how we are using in this case.

}

public async CreateReply(): Promise<void> {
const cliName = this.args?.[1] || '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we give them better naems like initial name or something ? or can we just make one object that have both values

@not-meet not-meet changed the title pre-filled quick create modal [FEAT] : Added dynamic initial values in create modal Feb 23, 2025
Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are close

README.md Outdated
- **`/quick ai`**: Use AI to generate replies
- **`/quick help`**: Get help with Quick Reply
- **`/qs <reply name>`**: Quickly search and send a reply by name
- **`/quick create <name> <message>`**: Create a quick reply directly from the input box with a name and message
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double quotes ("") ? Explain double quote behavior here

triggerId: this.triggerId,
threadId: this.threadId,
language,
args: this.params,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not name it params only then ?


export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & {
language: Language;
args? : string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why optional ? it will always be there

public triggerId?: string;
public threadId?: string;
public language: Language;
public args? : string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

}

public async CreateReply(): Promise<void> {
const initialReplyName = this.args?.[1] || '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial values are optional why OR here ? just don't pass it if its not there

text: label,
element: plainTextInputElement,
optional,
blockId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

modify: IModify,
room: IRoom,
language: Language,
initialReplyName: string,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make it a object but fine for now

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you make requested changes also share about what you changed in comment or reply

README.md Outdated
#### Example:
```sh
/quick create "greeting" Hello! How have you been?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what I ment

How double quotes make the multiple words a single text for body use


export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & {
language: Language;
params?: string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why optinal?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not answered ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again not answered?

@not-meet
Copy link
Contributor Author

hey @VipinDevelops i've added the comments with detailed explanation of what changes i have made

@not-meet
Copy link
Contributor Author

Ive made the required changes in the readme file
Screenshot from 2025-02-27 06-14-51

added the detailed explanation and examples how "quotes" work .

NOTE-i have also added comments in all the changes i have made with detailed reasoning's kindly go through them as well

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requested more changes
don't tag me before you reply to all the old messages

Comment on lines 97 to 120
#### Creating Quick Replies from Message Box
**`/quick create "<name>" <message>`**: Create a quick reply using the message box
When you use this command:
1. A modal window opens automatically
2. The name and replybody field is prefilled with your specified values
3. Simply review and click the Submit button to save your quick reply
The command works as follows:
- The name must be enclosed in quotes `"..."` if it contains multiple words
- Everything after the name is treated as the message body
- Without quotes, only the first word would be taken as the name
#### Examples:
```sh
# Single word name (quotes optional)
/quick create greeting Hello! How have you been?
# Multi-word name (quotes required)
/quick create "welcome message" Welcome to our channel! How can I help you?
```

Both examples will open a modal with the name and message already filled in. Just click Submit to save your quick reply, which can then be used with **`/qs <name>`**.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is just to much for such simple thing

and can't we just do like

/quick create "you can use double quotes to write the name with spaces" you write everything else as a body ??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just looks like AI-generated markdown to me


export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & {
language: Language;
params?: string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not answered ?

public triggerId?: string;
public threadId?: string;
public language: Language;
public params?: string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stilll ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man ?

@not-meet
Copy link
Contributor Author

hey @VipinDevelops
i have made the requested changes in the readme
Screenshot from 2025-02-28 04-45-22

i have added examples as well

@not-meet
Copy link
Contributor Author

not-meet commented Feb 27, 2025

I have also replied to the asked questions in the messages in the review section in each file still to ease it out

why i added params as optional?

  • so the reason to make this optional is because not all the handler implementations such as executeActionbutton or executeBlockAction, they dont need params to run thus i made this optional as it removes unnecesary addition of parameter

@not-meet
Copy link
Contributor Author

@VipinDevelops i was thinking about making a new pr for the same as this pr now has too many conversation messages and commits thus makes it a bit more clutterd and not easy to get through all the messages and conversation

i am thinking if you allow me to make a new pr for this issue with the same commits and solution

@VipinDevelops
Copy link
Collaborator

hey @VipinDevelops i have made the requested changes in the readme Screenshot from 2025-02-28 04-45-22

i have added examples as well

Super bad example Can't understand anything make it simple and short

@VipinDevelops
Copy link
Collaborator

I have also replied to the asked questions in the messages in the review section in each file still to ease it out

why i added params as optional?

  • so the reason to make this optional is because not all the handler implementations such as executeActionbutton or executeBlockAction, they dont need params to run thus i made this optional as it removes unnecesary addition of parameter

Just remove it if not needed why make it optional ?

@VipinDevelops
Copy link
Collaborator

@VipinDevelops i was thinking about making a new pr for the same as this pr now has too many conversation messages and commits thus makes it a bit more clutterd and not easy to get through all the messages and conversation

i am thinking if you allow me to make a new pr for this issue with the same commits and solution

NO we won't make new PR's because of TOO MANY conversations

@not-meet
Copy link
Contributor Author

not-meet commented Feb 28, 2025

I have also replied to the asked questions in the messages in the review section in each file still to ease it out

why i added params as optional?

  • so the reason to make this optional is because not all the handler implementations such as executeActionbutton or executeBlockAction, they dont need params to run thus i made this optional as it removes unnecesary addition of parameter

Just remove it if not needed why make it optional ?

See Handler function is implemented in three files executeBlockActionhandler , executeActionButtonHandler and commandUtilty where only the command utility needs params as the createReply uses params to get the initial values

here are all the places where the handler is used
Notice how only one handler needs params - thus i added params as optional as it can only be passed where it is necessary just like how thriggerID args works

@not-meet
Copy link
Contributor Author

not-meet commented Feb 28, 2025

hey @VipinDevelops i have made the requested changes in the readme Screenshot from 2025-02-28 04-45-22
i have added examples as well

Super bad example Can't understand anything make it simple and short
Screenshot from 2025-02-28 21-08-27

How about this i have changed the examples and made them quite more clear

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still a lot of changes needed for this.

We are just making it longer—try to fix it this time

- **`/quick help`**: Get help with Quick Reply
- **`/qs <reply name>`**: Quickly search and send a reply by name
- **`/quick create <name> <message>`**: Create a quick reply directly from the input box with a name and message
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add SS man why you are not making requested changes before asking for review.

**`/quick create "<name>" <message>`**: "if your name has multiple words with space, use double quotes" and write everything else as a body!
Example: `/quick create "schedule meeting" let's have a quick meet in an hour!`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what I meant.

Can you please avoid writing a lot in the README to explain really simple things?


export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & {
language: Language;
params?: string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again not answered?

public triggerId?: string;
public threadId?: string;
public language: Language;
public params?: string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man ?

text: label,
element: plainTextInputElement,
optional,
blockId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

modify: IModify,
room: IRoom,
language: Language,
initialReplyName?: string,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i said already we can make a new type for this or interface

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] Enable Quick Reply Creation via Message Input in Quick Replies

3 participants