export function useWorkbenchAiMessageActions({
  assistantDraft,
  focusAiModeInput,
  persistCurrentConversation,
  toast
}) {
  async function copyInlineMessage(message) {
    try {
      await navigator.clipboard?.writeText(message.content)
      toast('已复制内容。')
    } catch {
      toast('当前浏览器暂不支持自动复制。')
    }
  }

  function quoteInlineMessage(message) {
    const quote = `> ${message.content}\n\n`
    assistantDraft.value = assistantDraft.value ? assistantDraft.value + '\n' + quote : quote
    focusAiModeInput()
  }

  function markInlineMessageFeedback(message, feedback) {
    message.feedback = feedback
    persistCurrentConversation()
    toast(feedback === 'up' ? '已记录有帮助反馈。' : '已记录需要改进反馈。')
  }

  return {
    copyInlineMessage,
    markInlineMessageFeedback,
    quoteInlineMessage
  }
}
