Skip to content
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

fix: hide edit prompts on the web #6815

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

taiyab
Copy link
Contributor

@taiyab taiyab commented Jan 27, 2025

This PR completely hides edit prompts from the web client (where edits aren't possible).

Web

Before After
CleanShot 2025-01-27 at 12 41 57@2x CleanShot 2025-01-27 at 12 40 29@2x

Client

No change.

Test plan

Manually tested, locally.

@taiyab taiyab requested a review from fkling January 27, 2025 13:54
Comment on lines +164 to +166
function isEditActionLike(action: Action): boolean {
return action.actionType === 'prompt' ? action.mode !== 'CHAT' : action.mode !== 'ask'
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This function should either be defined outside the component or it should replace shouldShowAction which you don't need anymore.

Comment on lines +169 to +171
const filteredActions = isEditEnabled
? actions
: actions.filter(action => !isEditActionLike(action))
Copy link
Contributor

@fkling fkling Jan 27, 2025

Choose a reason for hiding this comment

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

I really would suggest to implement this as

if (!isEditEnabled) {
    actions = actions.filter(action => !isEditActionLike(action))
}

Otherwise we have two variables in scope that represent actions (actions and filteredActions) and it seems too easy to make a mistake and reference actions instead of filteredActions below.
In the worst case you could accidentally do return actions and throw away the whole filtering.

Of course we can also build just a single filter condition to avoid this, but that seems more tricky.

)

// Don't show builtin commands to insert in the prompt editor.
) // Don't show builtin commands to insert in the prompt editor.
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep the empty line and the comment above the following line.

}
const shouldExcludeBuiltinCommands =

const hasCustomFilters =
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming seems to imply that promptFilters.core is not a custom filter. It's not clear to me what a 'custom filter' is in this case. I'd leave the name as before.

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.

2 participants