From af1dfc21f6354904413137362b7bf76748e37994 Mon Sep 17 00:00:00 2001 From: Tony Vincent Date: Tue, 9 Jun 2026 08:42:46 +0200 Subject: [PATCH 01/10] fix: include account data in webhook payloads (#12445) Conversation and inbox webhook payloads now include the account object (`{ id, name }`) so integrations can reliably identify the account without depending on nested message data. ## Closes Closes #11753 Closes #12442 ## Why Message, contact, and contact inbox webhook payloads already expose `account`. Conversation and inbox webhook payloads were outliers, which forced webhook consumers to infer account context from nested messages or other fields that may not always be present. ## What changed - Adds `account: { id, name }` to conversation webhook payloads. - Adds webhook-specific inbox payload data with `account: { id, name }` for inbox created/updated events. - Keeps non-webhook conversation and inbox push payload behavior unchanged. ## How to test - Configure an account webhook for `conversation_created`, trigger a new conversation, and confirm the webhook payload includes `account.id` and `account.name`. - Configure an account webhook for `inbox_created`, create a new inbox, and confirm the webhook payload includes `account.id` and `account.name`. - Configure a webhook agent bot and update a conversation status, then confirm the bot webhook payload includes the same account object. --------- Co-authored-by: Muhsin Keloth Co-authored-by: Sojan Jose --- app/listeners/webhook_listener.rb | 4 +-- .../conversations/event_data_presenter.rb | 5 +++- app/presenters/inbox/event_data_presenter.rb | 4 +++ spec/listeners/agent_bot_listener_spec.rb | 20 +++++++++++++- spec/listeners/webhook_listener_spec.rb | 26 +++++++++++++++++-- .../event_data_presenter_spec.rb | 4 +++ 6 files changed, 57 insertions(+), 6 deletions(-) diff --git a/app/listeners/webhook_listener.rb b/app/listeners/webhook_listener.rb index 835d03661..c64b36ca0 100644 --- a/app/listeners/webhook_listener.rb +++ b/app/listeners/webhook_listener.rb @@ -68,7 +68,7 @@ class WebhookListener < BaseListener def inbox_created(event) inbox, account = extract_inbox_and_account(event) - inbox_webhook_data = Inbox::EventDataPresenter.new(inbox).push_data + inbox_webhook_data = Inbox::EventDataPresenter.new(inbox).webhook_data payload = inbox_webhook_data.merge(event: __method__.to_s) deliver_account_webhooks(payload, account) end @@ -78,7 +78,7 @@ class WebhookListener < BaseListener changed_attributes = extract_changed_attributes(event) return if changed_attributes.blank? - inbox_webhook_data = Inbox::EventDataPresenter.new(inbox).push_data + inbox_webhook_data = Inbox::EventDataPresenter.new(inbox).webhook_data payload = inbox_webhook_data.merge(event: __method__.to_s, changed_attributes: changed_attributes) deliver_account_webhooks(payload, account) end diff --git a/app/presenters/conversations/event_data_presenter.rb b/app/presenters/conversations/event_data_presenter.rb index ae0e69608..4dfa10abe 100644 --- a/app/presenters/conversations/event_data_presenter.rb +++ b/app/presenters/conversations/event_data_presenter.rb @@ -23,7 +23,10 @@ class Conversations::EventDataPresenter < SimpleDelegator # Like #push_data but with message text normalized for external integrations (webhooks). def webhook_data - push_data.merge(messages: webhook_push_messages) + push_data.merge( + account: account.webhook_data, + messages: webhook_push_messages + ) end private diff --git a/app/presenters/inbox/event_data_presenter.rb b/app/presenters/inbox/event_data_presenter.rb index a408424ae..7f832bb5a 100644 --- a/app/presenters/inbox/event_data_presenter.rb +++ b/app/presenters/inbox/event_data_presenter.rb @@ -32,4 +32,8 @@ class Inbox::EventDataPresenter < SimpleDelegator channel: channel } end + + def webhook_data + push_data.merge(account: account.webhook_data) + end end diff --git a/spec/listeners/agent_bot_listener_spec.rb b/spec/listeners/agent_bot_listener_spec.rb index 08deeb6c4..e3f9f0402 100644 --- a/spec/listeners/agent_bot_listener_spec.rb +++ b/spec/listeners/agent_bot_listener_spec.rb @@ -82,7 +82,7 @@ describe AgentBotListener do create(:agent_bot_inbox, inbox: inbox, agent_bot: agent_bot) expect(AgentBots::WebhookJob).to receive(:perform_later).with( agent_bot.outgoing_url, - hash_including(event: 'conversation_status_changed', changed_attributes: anything), + hash_including(event: 'conversation_status_changed', account: account.webhook_data, changed_attributes: anything), :agent_bot_webhook, hash_including(secret: agent_bot.secret) ).once @@ -158,6 +158,24 @@ describe AgentBotListener do end end + describe '#conversation_resolved' do + let(:event_name) { 'conversation.resolved' } + let!(:event) { Events::Base.new(event_name, Time.zone.now, conversation: conversation) } + + context 'when agent bot is configured' do + it 'sends account details in the conversation payload' do + create(:agent_bot_inbox, inbox: inbox, agent_bot: agent_bot) + expect(AgentBots::WebhookJob).to receive(:perform_later).with( + agent_bot.outgoing_url, + hash_including(event: 'conversation_resolved', account: account.webhook_data), + :agent_bot_webhook, + hash_including(secret: agent_bot.secret) + ).once + listener.conversation_resolved(event) + end + end + end + describe '#webwidget_triggered' do let(:event_name) { 'webwidget.triggered' } diff --git a/spec/listeners/webhook_listener_spec.rb b/spec/listeners/webhook_listener_spec.rb index a7a64f175..b63f43c2f 100644 --- a/spec/listeners/webhook_listener_spec.rb +++ b/spec/listeners/webhook_listener_spec.rb @@ -101,6 +101,17 @@ describe WebhookListener do ).once listener.conversation_created(conversation_created_event) end + + it 'includes account details in the conversation payload' do + webhook = create(:webhook, inbox: inbox, account: account) + expect(WebhookJob).to receive(:perform_later).with( + webhook.url, + hash_including(account: account.webhook_data), + :account_webhook, + hash_including(secret: webhook.secret) + ).once + listener.conversation_created(conversation_created_event) + end end context 'when inbox is an API Channel' do @@ -250,7 +261,7 @@ describe WebhookListener do context 'when webhook is configured' do it 'triggers webhook' do - inbox_data = Inbox::EventDataPresenter.new(inbox).push_data + inbox_data = Inbox::EventDataPresenter.new(inbox).webhook_data webhook = create(:webhook, account: account, subscriptions: ['inbox_created']) expect(WebhookJob).to receive(:perform_later).with( webhook.url, inbox_data.merge(event: 'inbox_created'), :account_webhook, @@ -258,6 +269,17 @@ describe WebhookListener do ).once listener.inbox_created(inbox_created_event) end + + it 'includes account details in the inbox payload' do + webhook = create(:webhook, account: account, subscriptions: ['inbox_created']) + expect(WebhookJob).to receive(:perform_later).with( + webhook.url, + hash_including(account: account.webhook_data), + :account_webhook, + hash_including(secret: webhook.secret) + ).once + listener.inbox_created(inbox_created_event) + end end end @@ -287,7 +309,7 @@ describe WebhookListener do it 'triggers webhook' do webhook = create(:webhook, account: account, subscriptions: ['inbox_updated']) - inbox_data = Inbox::EventDataPresenter.new(inbox).push_data + inbox_data = Inbox::EventDataPresenter.new(inbox).webhook_data changed_attributes_data = [{ 'name' => { 'previous_value': 'Inbox 1', 'current_value': inbox.name } }] expect(WebhookJob).to receive(:perform_later).with( diff --git a/spec/presenters/conversations/event_data_presenter_spec.rb b/spec/presenters/conversations/event_data_presenter_spec.rb index 76fd8f8a8..21cb26c98 100644 --- a/spec/presenters/conversations/event_data_presenter_spec.rb +++ b/spec/presenters/conversations/event_data_presenter_spec.rb @@ -46,6 +46,10 @@ RSpec.describe Conversations::EventDataPresenter do end describe '#webhook_data' do + it 'includes account details for webhook consumers' do + expect(presenter.webhook_data[:account]).to eq(conversation.account.webhook_data) + end + it 'normalizes hard-break backslashes in message content' do message = create(:message, conversation: conversation, account: conversation.account, message_type: :outgoing, content: "Hello\\\nWorld") From 8a3b1292927b51a5a7b3fd51b03c7da332b911a7 Mon Sep 17 00:00:00 2001 From: Shivam Kumar Date: Tue, 9 Jun 2026 12:42:03 +0530 Subject: [PATCH 02/10] fix: Disable re-oauth flow for manual whatsapp (#13599) Restrict the WhatsApp reauthorization flag to channels whose provider_config source is 'embedded_signup'. Previously the view exposed resource.channel.reauthorization_required? for all WhatsApp channels; now it only returns true when (provider_config || {}).to_h['source'] == 'embedded_signup' && resource.channel.reauthorization_required?. This prevents showing reauthorization prompts for manual/API-key flows (non-OAuth) and safely handles nil provider_config. # Pull Request Template ## Description Please include a summary of the change and issue(s) fixed. Also, mention relevant motivation, context, and any dependencies that this change requires. Fixes #13553 ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected) - [ ] This change requires a documentation update ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Muhsin Keloth Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com> --- app/jobs/webhooks/whatsapp_events_job.rb | 7 ++++- app/views/api/v1/models/_inbox.json.jbuilder | 6 +++- .../v1/accounts/inboxes_controller_spec.rb | 29 +++++++++++++++++++ .../jobs/webhooks/whatsapp_events_job_spec.rb | 8 +++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/app/jobs/webhooks/whatsapp_events_job.rb b/app/jobs/webhooks/whatsapp_events_job.rb index f904b3723..14429e61c 100644 --- a/app/jobs/webhooks/whatsapp_events_job.rb +++ b/app/jobs/webhooks/whatsapp_events_job.rb @@ -126,12 +126,17 @@ class Webhooks::WhatsappEventsJob < MutexApplicationJob def channel_is_inactive?(channel) return true if channel.blank? - return true if channel.reauthorization_required? + # Only skip for embedded signup when reauth is required; manual flow uses API keys and should still receive webhooks + return true if channel.reauthorization_required? && embedded_signup_channel?(channel) return true unless channel.account.active? false end + def embedded_signup_channel?(channel) + (channel.provider_config || {}).to_h['source'] == 'embedded_signup' + end + def find_channel_by_url_param(params) return unless params[:phone_number] diff --git a/app/views/api/v1/models/_inbox.json.jbuilder b/app/views/api/v1/models/_inbox.json.jbuilder index 0ae0745cd..b34bbe95b 100644 --- a/app/views/api/v1/models/_inbox.json.jbuilder +++ b/app/views/api/v1/models/_inbox.json.jbuilder @@ -130,7 +130,11 @@ json.bot_name resource.channel.try(:bot_name) if resource.telegram? if resource.whatsapp? json.message_templates resource.channel.try(:message_templates) json.provider_config resource.channel.try(:provider_config) if Current.account_user&.administrator? - json.reauthorization_required resource.channel.try(:reauthorization_required?) + # Only show reauthorization for embedded signup; manual flow uses API keys, not OAuth + json.reauthorization_required( + (resource.channel.try(:provider_config) || {}).to_h['source'] == 'embedded_signup' && + resource.channel.try(:reauthorization_required?) + ) end ## Voice attributes for TwilioSms diff --git a/spec/controllers/api/v1/accounts/inboxes_controller_spec.rb b/spec/controllers/api/v1/accounts/inboxes_controller_spec.rb index 9e03e2587..0fd6ad7bf 100644 --- a/spec/controllers/api/v1/accounts/inboxes_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/inboxes_controller_spec.rb @@ -100,6 +100,35 @@ RSpec.describe 'Inboxes API', type: :request do expect(JSON.parse(response.body, symbolize_names: true)[:id]).to eq(inbox.id) end + it 'returns reauthorization_required for embedded signup whatsapp channel when reauth required' do + whatsapp_channel = create(:channel_whatsapp, account: account, provider: 'whatsapp_cloud', sync_templates: false, + validate_provider_config: false) + whatsapp_inbox = create(:inbox, channel: whatsapp_channel, account: account) + whatsapp_channel.prompt_reauthorization! + + get "/api/v1/accounts/#{account.id}/inboxes/#{whatsapp_inbox.id}", + headers: admin.create_new_auth_token, + as: :json + + expect(response).to have_http_status(:success) + expect(response.parsed_body['reauthorization_required']).to be(true) + end + + it 'does not flag reauthorization_required for manual whatsapp channel even when reauth required' do + whatsapp_channel = create(:channel_whatsapp, account: account, provider: 'whatsapp_cloud', sync_templates: false, + validate_provider_config: false) + whatsapp_channel.update!(provider_config: whatsapp_channel.provider_config.merge('source' => 'manual')) + whatsapp_inbox = create(:inbox, channel: whatsapp_channel, account: account) + whatsapp_channel.prompt_reauthorization! + + get "/api/v1/accounts/#{account.id}/inboxes/#{whatsapp_inbox.id}", + headers: admin.create_new_auth_token, + as: :json + + expect(response).to have_http_status(:success) + expect(response.parsed_body['reauthorization_required']).to be(false) + end + it 'returns the inbox if assigned inbox is assigned as agent' do create(:inbox_member, user: agent, inbox: inbox) get "/api/v1/accounts/#{account.id}/inboxes/#{inbox.id}", diff --git a/spec/jobs/webhooks/whatsapp_events_job_spec.rb b/spec/jobs/webhooks/whatsapp_events_job_spec.rb index d82658102..8d1b24b52 100644 --- a/spec/jobs/webhooks/whatsapp_events_job_spec.rb +++ b/spec/jobs/webhooks/whatsapp_events_job_spec.rb @@ -62,6 +62,14 @@ RSpec.describe Webhooks::WhatsappEventsJob do job.perform_now(params) end + it 'still enqueues for manual channels even when reauthorization required' do + channel.update!(provider_config: channel.provider_config.merge('source' => 'manual')) + channel.prompt_reauthorization! + allow(Whatsapp::IncomingMessageWhatsappCloudService).to receive(:new).and_return(process_service) + expect(Whatsapp::IncomingMessageWhatsappCloudService).to receive(:new) + job.perform_now(params) + end + it 'will not enqueue if channel is not present' do allow(Whatsapp::IncomingMessageWhatsappCloudService).to receive(:new).and_return(process_service) allow(Whatsapp::IncomingMessageService).to receive(:new).and_return(process_service) From 59d869d1edcbc9b748e3521f7d12ac7f592b6d04 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 9 Jun 2026 18:04:48 +0530 Subject: [PATCH 03/10] feat: Ability to resize table column width (#14611) --- .../shared/helpers/MessageFormatter.js | 9 +- .../helpers/specs/MessageFormatter.spec.js | 10 +++ lib/custom_markdown_renderer.rb | 82 ++++++++++++++++++- package.json | 2 +- pnpm-lock.yaml | 10 +-- spec/lib/custom_markdown_renderer_spec.rb | 53 ++++++++++++ 6 files changed, 157 insertions(+), 9 deletions(-) diff --git a/app/javascript/shared/helpers/MessageFormatter.js b/app/javascript/shared/helpers/MessageFormatter.js index eb8fecf01..85ce67bc6 100644 --- a/app/javascript/shared/helpers/MessageFormatter.js +++ b/app/javascript/shared/helpers/MessageFormatter.js @@ -63,6 +63,13 @@ const createMarkdownInstance = (linkify = true) => { }); }; +// Help center article tables persist column widths as an internal +// `` comment before the table. It exists only for the +// editor's markdown round-trip and must never surface as text — markdown-it runs +// with `html: false`, which would otherwise escape it into a visible comment in +// rendered/plain output (e.g. dashboard search snippets). Strip it on the way in. +const COLWIDTHS_MARKER_REGEX = /\r?\n?/g; + const TWITTER_USERNAME_REGEX = /(^|[^@\w])@(\w{1,15})\b/g; const TWITTER_USERNAME_REPLACEMENT = '$1[@$2](http://twitter.com/$2)'; const TWITTER_HASH_REGEX = /(^|\s)#(\w+)/g; @@ -75,7 +82,7 @@ class MessageFormatter { isAPrivateNote = false, linkify = true ) { - this.message = message || ''; + this.message = (message || '').replace(COLWIDTHS_MARKER_REGEX, ''); this.isAPrivateNote = isAPrivateNote; this.isATweet = isATweet; this.linkify = linkify; diff --git a/app/javascript/shared/helpers/specs/MessageFormatter.spec.js b/app/javascript/shared/helpers/specs/MessageFormatter.spec.js index 12b84085c..3350399eb 100644 --- a/app/javascript/shared/helpers/specs/MessageFormatter.spec.js +++ b/app/javascript/shared/helpers/specs/MessageFormatter.spec.js @@ -126,6 +126,16 @@ describe('#MessageFormatter', () => { }); }); + describe('help center table colwidth marker', () => { + it('strips the internal colwidths marker from rendered output', () => { + const message = + '\n| A | B |\n| --- | --- |\n| 1 | 2 |'; + const formatter = new MessageFormatter(message); + expect(formatter.formattedMessage).not.toContain('cw-colwidths'); + expect(formatter.plainText).not.toContain('cw-colwidths'); + }); + }); + describe('#sanitize', () => { it('sanitizes markup and removes all unnecessary elements', () => { const message = diff --git a/lib/custom_markdown_renderer.rb b/lib/custom_markdown_renderer.rb index 665d4c80c..fa191f5ed 100644 --- a/lib/custom_markdown_renderer.rb +++ b/lib/custom_markdown_renderer.rb @@ -9,9 +9,32 @@ class CustomMarkdownRenderer < CommonMarker::HtmlRenderer @embed_regexes ||= config.transform_values { |embed_config| Regexp.new(embed_config['regex']) } end + # Matches columnResizing({ cellMinWidth: 50 }) in @chatwoot/prosemirror-schema + # so cells without an explicit colwidth render the same minimum here as in the editor. + TABLE_CELL_MIN_WIDTH_PX = 50 + COLWIDTHS_COMMENT = // + + # The article editor serializes column widths as a `` HTML + # comment immediately before each resized table. Capture it (emitting nothing) so the + # next `table` can size itself; any other raw HTML keeps its default rendering. + def html(node) + match = node.string_content.match(COLWIDTHS_COMMENT) + return super unless match + + @pending_colwidths = match[1].split(',').map(&:to_i) + end + def table(node) - out('
') - super + widths = @pending_colwidths + @pending_colwidths = nil + + if sized_widths?(widths) + out(table_wrapper_open(widths)) + out(inject_table_sizing(capture_html { super(node) }, widths)) + else + out('
') + super + end out('
') end @@ -47,6 +70,61 @@ class CustomMarkdownRenderer < CommonMarker::HtmlRenderer private + def sized_widths?(widths) + widths.is_a?(Array) && widths.any? { |w| w.to_i.positive? } + end + + def fully_sized?(widths) + widths.all? { |w| w.to_i.positive? } + end + + # Fully-sized tables hug their exact width so the card doesn't trail empty space; + # partial tables stay a plain full-width card so flexible columns can expand. + def table_wrapper_open(widths) + return '
' unless fully_sized?(widths) + + %(
) + end + + # Let the gem render the whole table, then splice a and sizing style + # into the opening tag. Delegating the row/cell/tbody/alignment markup to + # super keeps this working across commonmarker upgrades. + # `!important` overrides the portal's `[&_table]:!min-w-full` Tailwind rule. + def inject_table_sizing(html, widths) + opening = %(
\n#{colgroup_html(widths)}) + html.sub(/]*>\n?/, opening) + end + + # Capture everything `super` writes by swapping the renderer's output buffer. + def capture_html + original = @stream + @stream = StringIO.new(+'') + yield + @stream.string + ensure + @stream = original + end + + # Total table width: each column's saved width, or the cell min for unsized ones. + def total_width(widths) + widths.sum { |w| w.to_i.positive? ? w.to_i : TABLE_CELL_MIN_WIDTH_PX } + end + + # Fully sized → lock to the exact total (min-width too, so a narrow saved width + # beats the portal's `[&_table]:!min-w-full`). Partial → `max(100%, total)` fills + # the container (flexible columns) yet scrolls when the sized columns exceed it. + def table_sizing_style(widths) + total = total_width(widths) + return "table-layout: fixed; min-width: max(100%, #{total}px) !important;" unless fully_sized?(widths) + + "table-layout: fixed; width: #{total}px !important; min-width: #{total}px !important;" + end + + def colgroup_html(widths) + cols = widths.map { |w| w.to_i.positive? ? %() : '' } + "#{cols.join}\n" + end + def extract_image_width(src) query = URI.parse(src).query raw = query && CGI.parse(query)['cw_image_width']&.first diff --git a/package.json b/package.json index d8527051d..41313c8b3 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@amplitude/analytics-browser": "^2.11.10", "@breezystack/lamejs": "^1.2.7", "@chatwoot/ninja-keys": "1.2.3", - "@chatwoot/prosemirror-schema": "1.3.17", + "@chatwoot/prosemirror-schema": "1.3.19", "@chatwoot/utils": "^0.0.55", "@formkit/core": "^1.7.2", "@formkit/vue": "^1.7.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a4b61061c..68e667953 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,8 +25,8 @@ importers: specifier: 1.2.3 version: 1.2.3 '@chatwoot/prosemirror-schema': - specifier: 1.3.17 - version: 1.3.17 + specifier: 1.3.19 + version: 1.3.19 '@chatwoot/utils': specifier: ^0.0.55 version: 0.0.55 @@ -458,8 +458,8 @@ packages: '@chatwoot/ninja-keys@1.2.3': resolution: {integrity: sha512-xM8d9P5ikDMZm2WbaCTk/TW5HFauylrU3cJ75fq5je6ixKwyhl/0kZbVN/vbbZN4+AUX/OaSIn6IJbtCgIF67g==} - '@chatwoot/prosemirror-schema@1.3.17': - resolution: {integrity: sha512-n78ZfMIzSrylImIN5cjCeEdTJ8ub0JtCybwUlqFyOyLy3ZzAZpOHvCSo+w/KmV4dCgOH2mBmYlxBQ9Rww+e0Rw==} + '@chatwoot/prosemirror-schema@1.3.19': + resolution: {integrity: sha512-LbATIAeTzclvbIK6WjtrGUO37AtMWkzCJi+s/KpUIp81TORhc0fHnclGT3353AbxeH6dF51/4hFTTsmF+ziqGA==} '@chatwoot/utils@0.0.55': resolution: {integrity: sha512-8G6HYQe1ZEYfJEsSYfDVvE+uhf98JDRjtGlpB+bzMko+yltbrk4yACSo/ImC3jSaJ6K8yPTSjJToSRmsQbL2iQ==} @@ -5128,7 +5128,7 @@ snapshots: hotkeys-js: 3.8.7 lit: 2.2.6 - '@chatwoot/prosemirror-schema@1.3.17': + '@chatwoot/prosemirror-schema@1.3.19': dependencies: markdown-it-sup: 2.0.0 prosemirror-commands: 1.7.1 diff --git a/spec/lib/custom_markdown_renderer_spec.rb b/spec/lib/custom_markdown_renderer_spec.rb index 28c5e069c..6484f2e6c 100644 --- a/spec/lib/custom_markdown_renderer_spec.rb +++ b/spec/lib/custom_markdown_renderer_spec.rb @@ -258,6 +258,59 @@ describe CustomMarkdownRenderer do end end + describe '#table' do + def render_table(markdown) + doc = CommonMarker.render_doc(markdown, :DEFAULT, [:table]) + described_class.new.render(doc) + end + + let(:plain_table) { "| A | B |\n| --- | --- |\n| 1 | 2 |\n" } + + it 'renders a table without column widths when no marker is present' do + output = render_table(plain_table) + expect(output).to include('
') + expect(output).not_to include('colgroup') + expect(output).not_to include('cw-colwidths') + end + + context 'when every column has a saved width' do + it 'lays the table out at the total width with a sized colgroup' do + output = render_table("\n#{plain_table}") + # Wrapper hugs the table; min-width is set alongside width so a narrow saved width beats min-w-full. + expect(output).to include('
') + expect(output).to include('
') + expect(output).to include('') + end + end + + context 'when only some columns have a saved width' do + it 'fills the container so unsized columns stay flexible, floored at the sized total' do + output = render_table("\n#{plain_table}") + # max(100%, 200px): fills the container (flexible) but scrolls if the sized columns exceed it. + expect(output).to include('table-layout: fixed; min-width: max(100%, 200px) !important;') + expect(output).to include('') + # No exact-width lock on the wrapper or table — the table must be free to expand. + expect(output).to include('
') + expect(output).to include('width: 400px !important;') + expect(output).to include('') + expect(output.scan('colgroup').length).to eq(2) + end + + it 'does not emit the marker comment into the rendered html' do + expect(render_table("\n#{plain_table}")).not_to include('cw-colwidths') + end + end + describe '#image' do it 'renders width in px with responsive cap and auto height' do markdown = '![Sample](https://example.com/image.jpg?cw_image_width=400px)' From 33f75505259362d1a2e23cdcbb70918ced58470c Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Wed, 10 Jun 2026 08:52:34 +0400 Subject: [PATCH 04/10] fix(whatsapp): restrict OGG voice recording to WhatsApp Cloud inboxes (#14692) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recording and sending an audio message from a **Twilio WhatsApp** inbox failed silently — Twilio rejected the media with delivery error `63019` ("Media failed to download") and the voice note never reached the customer. This restores audio sending for Twilio WhatsApp (and 360dialog) inboxes. Closes Regression from #14606 ## How to reproduce 1. Open a conversation in a **Twilio WhatsApp** inbox. 2. Record a voice message in the reply box and send it. 3. Before this fix: the message fails to deliver and a `Webhooks::TwilioDeliveryStatusJob` is enqueued with `ErrorCode: 63019`, `ErrorMessage: "Media failed to download"`. 4. After this fix: the audio is recorded as MP3 and delivers normally. ## What changed PR #14606 added WhatsApp **Cloud** voice notes, which require OGG/Opus. It changed `audioRecordFormat` in `ReplyBox.vue` to return OGG for `isAWhatsAppChannel` — but that getter is also `true` for Twilio WhatsApp inboxes. The OGG handling (content-type normalization + the `voice: true` flag) lives only in `WhatsappCloudService`, so Twilio could not download/process the remuxed OGG file. This change scopes OGG to `isAWhatsAppCloudChannel`. Twilio WhatsApp, 360dialog, and Telegram fall back to MP3 exactly as they did before the PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) --- .../dashboard/components/widgets/conversation/ReplyBox.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue index 17f5559f1..fc93ff2c7 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue @@ -375,10 +375,10 @@ export default { return `draft-${this.conversationIdByRoute}-${this.replyType}`; }, audioRecordFormat() { - if (this.isAWhatsAppChannel) { + if (this.isAWhatsAppCloudChannel) { return AUDIO_FORMATS.OGG; } - if (this.isATelegramChannel) { + if (this.isAWhatsAppChannel || this.isATelegramChannel) { return AUDIO_FORMATS.MP3; } if (this.isAPIInbox) { From cabe9bc7332e89656cdd1ec8e30f4134d6b993a9 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Wed, 10 Jun 2026 10:56:17 +0530 Subject: [PATCH 05/10] fix: populate general settings form on hard reload (#14685) --- .../routes/dashboard/settings/account/Index.vue | 12 +++++++++++- .../settings/account/components/AccountId.vue | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/settings/account/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/account/Index.vue index 0502ebc1b..55c1e7f03 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/account/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/account/Index.vue @@ -94,8 +94,18 @@ export default { return this.getAccount(this.accountId) || {}; }, }, + watch: { + 'currentAccount.id'(id) { + if (id) { + this.initializeAccount(); + } + }, + }, mounted() { - this.initializeAccount(); + // Account already in the store (navigated in): seed immediately. + if (this.currentAccount.id) { + this.initializeAccount(); + } }, methods: { async initializeAccount() { diff --git a/app/javascript/dashboard/routes/dashboard/settings/account/components/AccountId.vue b/app/javascript/dashboard/routes/dashboard/settings/account/components/AccountId.vue index f02efcdc2..941d79fb1 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/account/components/AccountId.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/account/components/AccountId.vue @@ -8,7 +8,7 @@ import SectionLayout from './SectionLayout.vue'; const { t } = useI18n(); const { currentAccount } = useAccount(); -const getAccountId = computed(() => currentAccount.value.id.toString()); +const getAccountId = computed(() => currentAccount.value?.id?.toString());