Skip to content

Add "Apply to Editor" button for AI code suggestions in chat panelΒ #853

@Divyansh2992

Description

@Divyansh2992

Feature Request πŸ›οΈ

One-Click "Apply to Editor" for AI Code Suggestions

Use Case

When the AI Assistant suggests updated TemplateMark, Concerto Model, or JSON Data code in the chat panel, users must manually copy the code, switch to the correct editor, select all existing content, and paste. This multi-step process is tedious and error-prone, especially when the AI suggests changes across multiple editors.

Possible Solution

The AI system prompt already instructs the model to use special language tags β€”concertoApply, templatemarkApply, and jsonApply β€” to mark code blocks that are complete and ready to replace the corresponding editor content.

The chat panel (AIChatPanel.tsx) should detect these tags when rendering code blocks and display an "Apply to Editor" button beneath them. Clicking it would call the appropriate store action:

  • concertoApply β†’ setEditorModelCto(code)
  • templatemarkApply β†’ setEditorValue(code)
  • jsonApply β†’ setEditorAgreementData(code)

Context

The AI prompt design already anticipates this feature (the Apply suffix convention is documented in the system prompt), but the UI counterpart was never implemented. Users currently lose the primary benefit of having an AI assistant β€” seamless integration with the editor β€” and must manually copy-paste every suggestion.

Detailed Description

Changes needed in AIChatPanel.tsx:

  • In renderMessageContent, extract the language identifier from each code block's
    first line
  • If the identifier ends with Apply (e.g. concertoApply), render an
    "Apply to Editor" button below the code block
  • On click, call the matching Zustand store setter with the code content
  • Optionally show a success toast and trigger a rebuild automatically

Changes needed in chatRelay.ts / prompts.ts:

  • Reinforce the Apply suffix instruction in the system prompt to make the AI more consistently use the correct tags

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