Skip to content

Attaching Actions to Buttons #99

@rabisg

Description

@rabisg

Hey - so I was able to successfully create a button and an action. I can see the LLM attaching the action to the button in the form of ... on: { press: { action }}
However I'm unable to understand what should I send in the emit fn call?

catalog:

  actions: {
    openLink: z.object({
      url: z.string().describe("The URL to open"),
    }), 
  }

registry:

Button: ({ props, emit }) => (
      <button onClick={() => emit?.("??")}>
        {props.label}
      </button>
    ),

component:

const handlers = {
    openLink: (params: any) => {
      const { url } = params as { url: string };
      window.open(url, "_blank", "noopener,noreferrer");
    },
<ActionProvider handlers={handlers}>
  <Renderer spec={spec} registry={registry} loading={isStreaming} />
</ActionProvider>

At a high level what Im trying to do is generate a button that can be clicked to open a website

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions