stephen-bunn/prompt-toolkit-action-completer

Include the name of the Action's parent trigger in the Action class

Opened this issue · 1 comments

Summary

It would be useful for the user to be able to understand what the action's trigger name is directly off of the action in custom callable completers and validators. When building a custom callable completer, I currently have no text name of the action to use for generating the completion. Including the name will help users to generate better completion messages and such.

Potential Implementations

On registration of a new action, we will need to mark the name it was registered under on the action itself. This should be done in the types.ActionGroup.action decorator as well as validated in the Action.__attrs_post_init__ call.

Risks or Caveats

  • It's not necessarily sustainable for external users to use the action's trigger name on the action itself. This trigger name lacks context into its sibling actions or groups included in the action's current group.
  • We are duplicating data somewhat by storing the trigger name in both the group containing the action and the action itself.
  • This will also affect the current context extraction utility. We will no longer need to include the parent name in the context tuple.
  • When building the Action manually, we will need to include the trigger name multiple times (once in the group and once in the action)

Issue Checklist

  • I checked for duplicate issues 👍
  • I made sure to fill out the potential implementations 😉
  • I made sure to document the risks and caveats of my request ✌️
  • I made sure to drink a glass of water 🥛

Thanks! ❤️

Another interesting idea for a v2 is to swap out the children dictionary in the action group with a list where the action's name will actually be valuable.

Allows for proper action completion ordering when defined by the user.
This has it's own caveats as we will no longer be sure of non-duplicate names for actions.