diff --git a/.codeclimate.yml b/.codeclimate.yml index 5e16262da..213f7d172 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -57,3 +57,5 @@ exclude_patterns: - 'app/javascript/shared/constants/locales.js' - 'app/javascript/dashboard/helper/specs/macrosFixtures.js' - 'app/javascript/dashboard/routes/dashboard/settings/macros/constants.js' + - '**/fixtures/**' + - '**/*/fixtures.js' diff --git a/Gemfile b/Gemfile index f18305970..439b0f63e 100644 --- a/Gemfile +++ b/Gemfile @@ -49,7 +49,7 @@ gem 'aws-sdk-s3', require: false # original gem isn't maintained actively # we wanted updated version of faraday which is a dependency for slack-ruby-client gem 'azure-storage-blob', git: 'https://github.com/chatwoot/azure-storage-ruby', branch: 'chatwoot', require: false -gem 'google-cloud-storage', require: false +gem 'google-cloud-storage', '>= 1.48.0', require: false gem 'image_processing' ##-- gems for database --# diff --git a/Gemfile.lock b/Gemfile.lock index e2f5c91be..74cdbeea8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,70 +33,70 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.5) - actionpack (= 7.0.8.5) - activesupport (= 7.0.8.5) + actioncable (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.5) - actionpack (= 7.0.8.5) - activejob (= 7.0.8.5) - activerecord (= 7.0.8.5) - activestorage (= 7.0.8.5) - activesupport (= 7.0.8.5) + actionmailbox (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.5) - actionpack (= 7.0.8.5) - actionview (= 7.0.8.5) - activejob (= 7.0.8.5) - activesupport (= 7.0.8.5) + actionmailer (7.0.8.7) + actionpack (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8.5) - actionview (= 7.0.8.5) - activesupport (= 7.0.8.5) + actionpack (7.0.8.7) + actionview (= 7.0.8.7) + activesupport (= 7.0.8.7) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.5) - actionpack (= 7.0.8.5) - activerecord (= 7.0.8.5) - activestorage (= 7.0.8.5) - activesupport (= 7.0.8.5) + actiontext (7.0.8.7) + actionpack (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.5) - activesupport (= 7.0.8.5) + actionview (7.0.8.7) + activesupport (= 7.0.8.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) active_record_query_trace (1.8) - activejob (7.0.8.5) - activesupport (= 7.0.8.5) + activejob (7.0.8.7) + activesupport (= 7.0.8.7) globalid (>= 0.3.6) - activemodel (7.0.8.5) - activesupport (= 7.0.8.5) - activerecord (7.0.8.5) - activemodel (= 7.0.8.5) - activesupport (= 7.0.8.5) + activemodel (7.0.8.7) + activesupport (= 7.0.8.7) + activerecord (7.0.8.7) + activemodel (= 7.0.8.7) + activesupport (= 7.0.8.7) activerecord-import (1.4.1) activerecord (>= 4.2) - activestorage (7.0.8.5) - actionpack (= 7.0.8.5) - activejob (= 7.0.8.5) - activerecord (= 7.0.8.5) - activesupport (= 7.0.8.5) + activestorage (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activesupport (= 7.0.8.7) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8.5) + activesupport (7.0.8.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -209,7 +209,7 @@ GEM devise (> 3.5.2, < 5) rails (>= 4.2.0, < 7.2) diff-lcs (1.5.1) - digest-crc (0.6.4) + digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) docile (1.4.0) domain_name (0.5.20190701) @@ -284,39 +284,39 @@ GEM activesupport (>= 6.1) gmail_xoauth (0.4.3) oauth (>= 0.3.6) - google-apis-core (0.11.0) + google-apis-core (0.15.1) addressable (~> 2.5, >= 2.5.1) - googleauth (>= 0.16.2, < 2.a) - httpclient (>= 2.8.1, < 3.a) + googleauth (~> 1.9) + httpclient (>= 2.8.3, < 3.a) mini_mime (~> 1.0) + mutex_m representable (~> 3.0) retriable (>= 2.0, < 4.a) - rexml - webrick - google-apis-iamcredentials_v1 (0.17.0) - google-apis-core (>= 0.11.0, < 2.a) - google-apis-storage_v1 (0.19.0) - google-apis-core (>= 0.9.0, < 2.a) - google-cloud-core (1.6.0) - google-cloud-env (~> 1.0) + google-apis-iamcredentials_v1 (0.22.0) + google-apis-core (>= 0.15.0, < 2.a) + google-apis-storage_v1 (0.47.0) + google-apis-core (>= 0.15.0, < 2.a) + google-cloud-core (1.7.1) + google-cloud-env (>= 1.0, < 3.a) google-cloud-errors (~> 1.0) google-cloud-dialogflow-v2 (0.31.0) gapic-common (>= 0.20.0, < 2.a) google-cloud-errors (~> 1.0) google-cloud-location (>= 0.4, < 2.a) - google-cloud-env (1.6.0) - faraday (>= 0.17.3, < 3.0) + google-cloud-env (2.2.1) + faraday (>= 1.0, < 3.a) google-cloud-errors (1.3.1) google-cloud-location (0.6.0) gapic-common (>= 0.20.0, < 2.a) google-cloud-errors (~> 1.0) - google-cloud-storage (1.44.0) + google-cloud-storage (1.52.0) addressable (~> 2.8) digest-crc (~> 0.4) - google-apis-iamcredentials_v1 (~> 0.1) - google-apis-storage_v1 (~> 0.19.0) + google-apis-core (~> 0.13) + google-apis-iamcredentials_v1 (~> 0.18) + google-apis-storage_v1 (~> 0.38) google-cloud-core (~> 1.6) - googleauth (>= 0.16.2, < 2.a) + googleauth (~> 1.9) mini_mime (~> 1.0) google-cloud-translate-v3 (0.10.0) gapic-common (>= 0.20.0, < 2.a) @@ -331,10 +331,10 @@ GEM grpc (~> 1.41) googleapis-common-protos-types (1.14.0) google-protobuf (~> 3.18) - googleauth (1.5.2) - faraday (>= 0.17.3, < 3.a) + googleauth (1.11.2) + faraday (>= 1.0, < 3.a) + google-cloud-env (~> 2.1) jwt (>= 1.4, < 3.0) - memoist (~> 0.16) multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) @@ -452,7 +452,7 @@ GEM activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.22.0) + loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -462,7 +462,6 @@ GEM net-smtp marcel (1.0.4) maxminddb (0.1.22) - memoist (0.16.2) meta_request (0.8.3) rack-contrib (>= 1.1, < 3) railties (>= 3.0.0, < 8) @@ -472,14 +471,15 @@ GEM mime-types-data (3.2023.0218.1) mini_magick (4.12.0) mini_mime (1.1.5) - mini_portile2 (2.8.7) - minitest (5.25.1) + mini_portile2 (2.8.8) + minitest (5.25.4) mock_redis (0.36.0) ruby2_keywords msgpack (1.7.0) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.3.0) + mutex_m (0.3.0) neighbor (0.2.3) activerecord (>= 5.2) net-http (0.4.1) @@ -502,14 +502,14 @@ GEM newrelic_rpm (9.6.0) base64 nio4r (2.7.3) - nokogiri (1.16.7) + nokogiri (1.17.1) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.7-arm64-darwin) + nokogiri (1.17.1-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.7-x86_64-darwin) + nokogiri (1.17.1-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) + nokogiri (1.17.1-x86_64-linux) racc (~> 1.4) oauth (1.1.0) oauth-tty (~> 1.0, >= 1.0.1) @@ -581,30 +581,30 @@ GEM rack-test (2.1.0) rack (>= 1.3) rack-timeout (0.6.3) - rails (7.0.8.5) - actioncable (= 7.0.8.5) - actionmailbox (= 7.0.8.5) - actionmailer (= 7.0.8.5) - actionpack (= 7.0.8.5) - actiontext (= 7.0.8.5) - actionview (= 7.0.8.5) - activejob (= 7.0.8.5) - activemodel (= 7.0.8.5) - activerecord (= 7.0.8.5) - activestorage (= 7.0.8.5) - activesupport (= 7.0.8.5) + rails (7.0.8.7) + actioncable (= 7.0.8.7) + actionmailbox (= 7.0.8.7) + actionmailer (= 7.0.8.7) + actionpack (= 7.0.8.7) + actiontext (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activemodel (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) bundler (>= 1.15.0) - railties (= 7.0.8.5) + railties (= 7.0.8.7) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.1) loofah (~> 2.21) - nokogiri (~> 1.14) - railties (7.0.8.5) - actionpack (= 7.0.8.5) - activesupport (= 7.0.8.5) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) method_source rake (>= 12.2) thor (~> 1.0) @@ -824,7 +824,6 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webrick (1.8.2) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -886,7 +885,7 @@ DEPENDENCIES geocoder gmail_xoauth google-cloud-dialogflow-v2 (>= 0.24.0) - google-cloud-storage + google-cloud-storage (>= 1.48.0) google-cloud-translate-v3 (>= 0.7.0) groupdate grpc diff --git a/app.json b/app.json index d50040814..08e725c8e 100644 --- a/app.json +++ b/app.json @@ -48,7 +48,7 @@ "size": "basic" } }, - "stack": "heroku-20", + "stack": "heroku-24", "image": "heroku/ruby", "addons": [ { @@ -58,7 +58,7 @@ "plan": "heroku-postgresql:essential-0" } ], - "stack": "heroku-20", + "stack": "heroku-24", "buildpacks": [ { "url": "heroku/nodejs" diff --git a/app/controllers/api/v1/accounts/contacts_controller.rb b/app/controllers/api/v1/accounts/contacts_controller.rb index 250c64a86..0d8e0ed93 100644 --- a/app/controllers/api/v1/accounts/contacts_controller.rb +++ b/app/controllers/api/v1/accounts/contacts_controller.rb @@ -14,7 +14,7 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController before_action :check_authorization before_action :set_current_page, only: [:index, :active, :search, :filter] before_action :fetch_contact, only: [:show, :update, :destroy, :avatar, :contactable_inboxes, :destroy_custom_attributes] - before_action :set_include_contact_inboxes, only: [:index, :search, :filter] + before_action :set_include_contact_inboxes, only: [:index, :search, :filter, :show, :update] def index @contacts_count = resolved_contacts.count diff --git a/app/controllers/api/v1/accounts/integrations/captain_controller.rb b/app/controllers/api/v1/accounts/integrations/captain_controller.rb index 15e81b726..6813d14b5 100644 --- a/app/controllers/api/v1/accounts/integrations/captain_controller.rb +++ b/app/controllers/api/v1/accounts/integrations/captain_controller.rb @@ -2,10 +2,22 @@ class Api::V1::Accounts::Integrations::CaptainController < Api::V1::Accounts::Ba before_action :hook def proxy + request_url = build_request_url(request_path) response = HTTParty.send(request_method, request_url, body: permitted_params[:body].to_json, headers: headers) render plain: response.body, status: response.code end + def copilot + request_url = build_request_url(build_request_path("/assistants/#{hook.settings['assistant_id']}/copilot")) + params = { + previous_messages: copilot_params[:previous_messages], + conversation_history: conversation_history, + message: copilot_params[:message] + } + response = HTTParty.send(:post, request_url, body: params.to_json, headers: headers) + render plain: response.body, status: response.code + end + private def headers @@ -17,15 +29,19 @@ class Api::V1::Accounts::Integrations::CaptainController < Api::V1::Accounts::Ba } end + def build_request_path(route) + "api/accounts/#{hook.settings['account_id']}#{route}" + end + def request_path request_route = with_leading_hash_on_route(params[:route]) return 'api/sessions/profile' if request_route == '/sessions/profile' - "api/accounts/#{hook.settings['account_id']}#{request_route}" + build_request_path(request_route) end - def request_url + def build_request_url(request_path) base_url = InstallationConfig.find_by(name: 'CAPTAIN_API_URL').value URI.join(base_url, request_path).to_s end @@ -47,6 +63,15 @@ class Api::V1::Accounts::Integrations::CaptainController < Api::V1::Accounts::Ba request_route.start_with?('/') ? request_route : "/#{request_route}" end + def conversation_history + conversation = Current.account.conversations.find_by!(display_id: copilot_params[:conversation_id]) + conversation.to_llm_text + end + + def copilot_params + params.permit(:previous_messages, :conversation_id, :message) + end + def permitted_params params.permit(:method, :route, body: {}) end diff --git a/app/controllers/api/v1/profiles_controller.rb b/app/controllers/api/v1/profiles_controller.rb index bd3c2673c..ae1a1fe30 100644 --- a/app/controllers/api/v1/profiles_controller.rb +++ b/app/controllers/api/v1/profiles_controller.rb @@ -17,7 +17,7 @@ class Api::V1::ProfilesController < Api::BaseController def avatar @user.avatar.attachment.destroy! if @user.avatar.attached? - head :ok + @user.reload end def auto_offline diff --git a/app/javascript/dashboard/api/contacts.js b/app/javascript/dashboard/api/contacts.js index 85c4bba1d..2eee3f484 100644 --- a/app/javascript/dashboard/api/contacts.js +++ b/app/javascript/dashboard/api/contacts.js @@ -27,6 +27,14 @@ class ContactAPI extends ApiClient { return axios.get(requestURL); } + show(id) { + return axios.get(`${this.url}/${id}?include_contact_inboxes=false`); + } + + update(id, data) { + return axios.patch(`${this.url}/${id}?include_contact_inboxes=false`, data); + } + getConversations(contactId) { return axios.get(`${this.url}/${contactId}/conversations`); } diff --git a/app/javascript/dashboard/api/integrations.js b/app/javascript/dashboard/api/integrations.js index 59a3e244a..b78a2ea7e 100644 --- a/app/javascript/dashboard/api/integrations.js +++ b/app/javascript/dashboard/api/integrations.js @@ -36,6 +36,10 @@ class IntegrationsAPI extends ApiClient { requestCaptain(body) { return axios.post(`${this.baseUrl()}/integrations/captain/proxy`, body); } + + requestCaptainCopilot(body) { + return axios.post(`${this.baseUrl()}/integrations/captain/copilot`, body); + } } export default new IntegrationsAPI(); diff --git a/app/javascript/dashboard/assets/scss/_date-picker.scss b/app/javascript/dashboard/assets/scss/_date-picker.scss index 92deab095..2fa577673 100644 --- a/app/javascript/dashboard/assets/scss/_date-picker.scss +++ b/app/javascript/dashboard/assets/scss/_date-picker.scss @@ -25,7 +25,7 @@ } .mx-input { - @apply h-[2.5rem] flex border border-solid border-slate-200 dark:border-slate-600 rounded-md shadow-none; + @apply h-[2.5rem] flex border border-solid border-n-weak rounded-md shadow-none; } .mx-input:disabled, @@ -39,7 +39,7 @@ } .mx-datepicker-main { - @apply border-0 bg-white dark:bg-slate-800; + @apply border-0 bg-n-solid-2 rounded-xl; .cell { &.disabled { @@ -53,6 +53,14 @@ } } + .mx-calendar+.mx-calendar { + @apply border-l border-n-weak; + } + + .mx-datepicker-footer { + @apply border border-n-weak; + } + .mx-time { @apply border-0 bg-white dark:bg-slate-800; diff --git a/app/javascript/dashboard/assets/scss/_woot.scss b/app/javascript/dashboard/assets/scss/_woot.scss index e3474e616..c6304cf19 100644 --- a/app/javascript/dashboard/assets/scss/_woot.scss +++ b/app/javascript/dashboard/assets/scss/_woot.scss @@ -72,6 +72,19 @@ --slate-11: 96 100 108; --slate-12: 28 32 36; + --iris-1: 253 253 255; + --iris-2: 248 248 255; + --iris-3: 240 241 254; + --iris-4: 230 231 255; + --iris-5: 218 220 255; + --iris-6: 203 205 255; + --iris-7: 184 186 248; + --iris-8: 155 158 240; + --iris-9: 91 91 214; + --iris-10: 81 81 205; + --iris-11: 87 83 198; + --iris-12: 39 41 98; + --ruby-1: 255 252 253; --ruby-2: 255 247 248; --ruby-3: 254 234 237; @@ -122,6 +135,7 @@ --solid-active: 255 255 255; --solid-amber: 252 232 193; --solid-blue: 218 236 255; + --solid-iris: 230 231 255; --alpha-1: 67, 67, 67, 0.06; --alpha-2: 201, 202, 207, 0.15; @@ -129,10 +143,10 @@ --black-alpha-1: 0, 0, 0, 0.12; --black-alpha-2: 0, 0, 0, 0.04; --border-blue: 39, 129, 246, 0.5; - --white-alpha: 255, 255, 255, 0.1; + --white-alpha: 255, 255, 255, 0.8; } - body.dark { + .dark { /* slate */ --slate-1: 17 17 19; --slate-2: 24 25 27; @@ -147,6 +161,19 @@ --slate-11: 176 180 186; --slate-12: 237 238 240; + --iris-1: 19 19 30; + --iris-2: 23 22 37; + --iris-3: 32 34 72; + --iris-4: 38 42 101; + --iris-5: 48 51 116; + --iris-6: 61 62 130; + --iris-7: 74 74 149; + --iris-8: 89 88 177; + --iris-9: 91 91 214; + --iris-10: 84 114 228; + --iris-11: 158 177 255; + --iris-12: 224 223 254; + --ruby-1: 25 17 19; --ruby-2: 30 21 23; --ruby-3: 58 20 30; @@ -195,6 +222,7 @@ --solid-active: 53 57 66; --solid-amber: 42 37 30; --solid-blue: 16 49 91; + --solid-iris: 38 42 101; --text-blue: 126 182 255; --alpha-1: 36, 36, 36, 0.8; @@ -204,7 +232,7 @@ --black-alpha-2: 0, 0, 0, 0.2; --border-blue: 39, 129, 246, 0.5; --border-container: 236, 236, 236, 0; - --white-alpha: 255, 255, 255, 0.1; + --white-alpha: 255, 255, 255, 0.8; } /* NEXT COLORS END */ diff --git a/app/javascript/dashboard/assets/scss/widgets/_tabs.scss b/app/javascript/dashboard/assets/scss/widgets/_tabs.scss index b9999fac9..01ccaf671 100644 --- a/app/javascript/dashboard/assets/scss/widgets/_tabs.scss +++ b/app/javascript/dashboard/assets/scss/widgets/_tabs.scss @@ -6,6 +6,14 @@ @apply border-b border-slate-50 dark:border-slate-800/50; } +.tabs--container--compact.tab--chat-type { + .tabs-title { + a { + @apply py-2 text-sm; + } + } +} + .tabs { @apply border-r-0 border-l-0 border-t-0 flex min-w-[6.25rem] py-0 px-4 list-none mb-0; } diff --git a/app/javascript/dashboard/components-next/Campaigns/CampaignLayout.vue b/app/javascript/dashboard/components-next/Campaigns/CampaignLayout.vue index 11006bfe3..3169dbc3e 100644 --- a/app/javascript/dashboard/components-next/Campaigns/CampaignLayout.vue +++ b/app/javascript/dashboard/components-next/Campaigns/CampaignLayout.vue @@ -22,7 +22,7 @@ const handleButtonClick = () => {