From 6b42305f59ff2b8e576c80a968ebc7d78a207d73 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 6 May 2025 04:56:30 +0530 Subject: [PATCH 1/3] fix: Show agent bot name and avatar correctly in messages (#11394) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes an issue where messages from the agent bot were incorrectly displayed as "BOT" with a missing avatar. It now correctly shows the agent bot’s name and avatar URL in the message list. --- .../components-next/message/Message.vue | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/javascript/dashboard/components-next/message/Message.vue b/app/javascript/dashboard/components-next/message/Message.vue index 9d6b30f81..a3d5df015 100644 --- a/app/javascript/dashboard/components-next/message/Message.vue +++ b/app/javascript/dashboard/components-next/message/Message.vue @@ -394,23 +394,29 @@ function handleReplyTo() { } const avatarInfo = computed(() => { - if (!props.sender || props.sender.type === SENDER_TYPES.AGENT_BOT) { + // If no sender, return bot info + if (!props.sender) { return { name: t('CONVERSATION.BOT'), src: '', }; } - if (props.sender) { + const { sender } = props; + const { name, type, avatarUrl, thumbnail } = sender || {}; + + // If sender type is agent bot, use avatarUrl + if (type === SENDER_TYPES.AGENT_BOT) { return { - name: props.sender.name, - src: props.sender?.thumbnail, + name: name ?? '', + src: avatarUrl ?? '', }; } + // For all other senders, use thumbnail return { - name: '', - src: '', + name: name ?? '', + src: thumbnail ?? '', }; }); From 7cf051aba09451eaa35e749cd5af9802c264e848 Mon Sep 17 00:00:00 2001 From: Pranav Date: Mon, 5 May 2025 19:41:28 -0700 Subject: [PATCH 2/3] fix: Show campaigns only if the feature is enabled (#11420) If the feature is disabled (manually or due to plan changes), the customer cannot disable the existing campaigns. This PR would fix that. Fixes https://linear.app/chatwoot/issue/CW-3691/fix-disable-campaigns-on-plan-downgrade --- .../api/v1/widget/campaigns_controller.rb | 15 ++++++++----- .../v1/widget/campaigns_controller_spec.rb | 22 +++++++++++++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/v1/widget/campaigns_controller.rb b/app/controllers/api/v1/widget/campaigns_controller.rb index 10a73aa62..9cf8dcb6e 100644 --- a/app/controllers/api/v1/widget/campaigns_controller.rb +++ b/app/controllers/api/v1/widget/campaigns_controller.rb @@ -2,10 +2,15 @@ class Api::V1::Widget::CampaignsController < Api::V1::Widget::BaseController skip_before_action :set_contact def index - @campaigns = @web_widget - .inbox - .campaigns - .where(enabled: true, account_id: @web_widget.inbox.account_id) - .includes(:sender) + account = @web_widget.inbox.account + @campaigns = if account.feature_enabled?('campaigns') + @web_widget + .inbox + .campaigns + .where(enabled: true, account_id: account.id) + .includes(:sender) + else + [] + end end end diff --git a/spec/controllers/api/v1/widget/campaigns_controller_spec.rb b/spec/controllers/api/v1/widget/campaigns_controller_spec.rb index 602fa96b7..91e5e40ba 100644 --- a/spec/controllers/api/v1/widget/campaigns_controller_spec.rb +++ b/spec/controllers/api/v1/widget/campaigns_controller_spec.rb @@ -9,7 +9,11 @@ RSpec.describe '/api/v1/widget/campaigns', type: :request do describe 'GET /api/v1/widget/campaigns' do let(:params) { { website_token: web_widget.website_token } } - context 'with correct website token' do + context 'when campaigns feature is enabled' do + before do + account.enable_features!('campaigns') + end + it 'returns the list of enabled campaigns' do get '/api/v1/widget/campaigns', params: params @@ -21,8 +25,22 @@ RSpec.describe '/api/v1/widget/campaigns', type: :request do end end + context 'when campaigns feature is disabled' do + before do + account.disable_features!('campaigns') + end + + it 'returns empty array' do + get '/api/v1/widget/campaigns', params: params + + expect(response).to have_http_status(:success) + json_response = response.parsed_body + expect(json_response).to eq [] + end + end + context 'with invalid website token' do - it 'returns the list of agents' do + it 'returns not found status' do get '/api/v1/widget/campaigns', params: { website_token: '' } expect(response).to have_http_status(:not_found) end From cbdbf7900e30894fd050f643f9305c582923438d Mon Sep 17 00:00:00 2001 From: Pranav Date: Mon, 5 May 2025 19:41:38 -0700 Subject: [PATCH 3/3] fix: Update the character count for instructions (#11419) - Increase the Captain instruction size to 20k instead of 2k - Fix a display issue in the Captain playground and i18n issue in Captain form. --- .../components-next/captain/assistant/MessageList.vue | 2 +- .../pageComponents/assistant/EditAssistantForm.vue | 2 +- .../dashboard/i18n/locale/en/integrations.json | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/javascript/dashboard/components-next/captain/assistant/MessageList.vue b/app/javascript/dashboard/components-next/captain/assistant/MessageList.vue index 1d6529a45..3eca35744 100644 --- a/app/javascript/dashboard/components-next/captain/assistant/MessageList.vue +++ b/app/javascript/dashboard/components-next/captain/assistant/MessageList.vue @@ -65,7 +65,7 @@ watch(() => props.messages.length, scrollToBottom); class="max-w-[80%] rounded-lg p-3 text-sm" :class="getMessageStyle(message.sender)" > -
+
diff --git a/app/javascript/dashboard/components-next/captain/pageComponents/assistant/EditAssistantForm.vue b/app/javascript/dashboard/components-next/captain/pageComponents/assistant/EditAssistantForm.vue index 3a668a757..249051878 100644 --- a/app/javascript/dashboard/components-next/captain/pageComponents/assistant/EditAssistantForm.vue +++ b/app/javascript/dashboard/components-next/captain/pageComponents/assistant/EditAssistantForm.vue @@ -214,7 +214,7 @@ watch( v-model="state.instructions" :placeholder="t('CAPTAIN.ASSISTANTS.FORM.INSTRUCTIONS.PLACEHOLDER')" :message="formErrors.instructions" - :max-length="2000" + :max-length="20000" :message-type="formErrors.instructions ? 'error' : 'info'" /> diff --git a/app/javascript/dashboard/i18n/locale/en/integrations.json b/app/javascript/dashboard/i18n/locale/en/integrations.json index 14e1506b4..76dd56e49 100644 --- a/app/javascript/dashboard/i18n/locale/en/integrations.json +++ b/app/javascript/dashboard/i18n/locale/en/integrations.json @@ -403,15 +403,18 @@ }, "NAME": { "LABEL": "Name", - "PLACEHOLDER": "Enter assistant name" + "PLACEHOLDER": "Enter assistant name", + "ERROR": "The name is required" }, "DESCRIPTION": { "LABEL": "Description", - "PLACEHOLDER": "Enter assistant description" + "PLACEHOLDER": "Enter assistant description", + "ERROR": "The description is required" }, "PRODUCT_NAME": { "LABEL": "Product Name", - "PLACEHOLDER": "Enter product name" + "PLACEHOLDER": "Enter product name", + "ERROR": "The product name is required" }, "WELCOME_MESSAGE": { "LABEL": "Welcome Message",