@glodon-aiot/chat-app-sdk 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/es/index.esm.js +161 -1361
  2. package/libs/cn/index.js +19 -206
  3. package/package.json +1 -1
package/es/index.esm.js CHANGED
@@ -10547,250 +10547,6 @@ ___CSS_LOADER_EXPORT___.locals = {
10547
10547
  /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
10548
10548
 
10549
10549
 
10550
- }),
10551
- 94148: (function (module, __webpack_exports__, __webpack_require__) {
10552
- __webpack_require__.d(__webpack_exports__, {
10553
- A: () => (__WEBPACK_DEFAULT_EXPORT__)
10554
- });
10555
- /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(58623);
10556
- /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
10557
- /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(34688);
10558
- /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
10559
- // Imports
10560
-
10561
-
10562
- var ___CSS_LOADER_EXPORT___ = _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
10563
- // Module
10564
- ___CSS_LOADER_EXPORT___.push([module.id, `/* Comment Message Container */
10565
- .ffe867e2c235a0c5 {
10566
- display: flex;
10567
- align-items: center;
10568
- gap: 4px;
10569
- }
10570
- /* Icon selected state */
10571
- .d07fb38c947809f8 {
10572
- color: #b752ea !important;
10573
- }
10574
- /* IconButton selected state - ensure background doesn't highlight */
10575
- .d9418402ebdc6c0f {
10576
- background-color: transparent !important;
10577
- }
10578
- .d9418402ebdc6c0f:hover {
10579
- background-color: transparent !important;
10580
- }
10581
- /* Feedback Dialog Styles */
10582
- .b29fb4268fffc847 {
10583
- position: absolute;
10584
- top: 0;
10585
- left: 0;
10586
- right: 0;
10587
- bottom: 0;
10588
- background-color: rgba(0, 0, 0, 0.5);
10589
- display: flex;
10590
- align-items: center;
10591
- justify-content: center;
10592
- z-index: 10000;
10593
- }
10594
- /* 当容器是 document.body 时,使用 fixed 定位 */
10595
- .b29fb4268fffc847[data-container-is-body="true"] {
10596
- position: fixed;
10597
- top: 0;
10598
- left: 0;
10599
- right: 0;
10600
- bottom: 0;
10601
- }
10602
- .a82c68467fbd9ba4 {
10603
- background: #fff;
10604
- border-radius: 8px;
10605
- width: 90%;
10606
- max-width: 480px;
10607
- min-width: 320px;
10608
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
10609
- display: flex;
10610
- flex-direction: column;
10611
- max-height: 90vh;
10612
- }
10613
- .a82c68467fbd9ba4 .fe9b5896dd607d27 {
10614
- display: flex;
10615
- align-items: center;
10616
- justify-content: space-between;
10617
- padding: 16px 20px;
10618
- border-bottom: 1px solid #e8e8e8;
10619
- }
10620
- .a82c68467fbd9ba4 .f15e6e77acfff31a {
10621
- margin: 0;
10622
- font-size: 16px;
10623
- font-weight: 600;
10624
- color: #333;
10625
- }
10626
- .a82c68467fbd9ba4 .ec213d35312b7d7e {
10627
- background: none;
10628
- border: none;
10629
- font-size: 24px;
10630
- line-height: 1;
10631
- color: #999;
10632
- cursor: pointer;
10633
- padding: 0;
10634
- width: 24px;
10635
- height: 24px;
10636
- display: flex;
10637
- align-items: center;
10638
- justify-content: center;
10639
- transition: color 0.2s;
10640
- }
10641
- .a82c68467fbd9ba4 .ec213d35312b7d7e:hover {
10642
- color: #333;
10643
- }
10644
- .a82c68467fbd9ba4 .dc3fb716e09637a3 {
10645
- padding: 20px;
10646
- flex: 1;
10647
- overflow-y: auto;
10648
- }
10649
- .a82c68467fbd9ba4 .dab8560c96fa0283 {
10650
- display: flex;
10651
- flex-wrap: wrap;
10652
- gap: 12px;
10653
- margin-bottom: 20px;
10654
- }
10655
- .a82c68467fbd9ba4 .d36e84632eb09d08 {
10656
- padding: 8px 16px;
10657
- border: 1px solid #d9d9d9;
10658
- border-radius: 4px;
10659
- background: #fff;
10660
- color: #333;
10661
- font-size: 14px;
10662
- cursor: pointer;
10663
- transition: all 0.2s;
10664
- }
10665
- .a82c68467fbd9ba4 .d36e84632eb09d08:hover {
10666
- border-color: #999;
10667
- color: #666;
10668
- }
10669
- .a82c68467fbd9ba4 .b8dbe31e00feb69b {
10670
- border-color: #b752ea;
10671
- background: #fff;
10672
- color: #b752ea;
10673
- }
10674
- .a82c68467fbd9ba4 .b8dbe31e00feb69b:hover {
10675
- border-color: #999;
10676
- color: #666;
10677
- }
10678
- .a82c68467fbd9ba4 .df277aeb58f67270 {
10679
- margin-top: 16px;
10680
- }
10681
- .a82c68467fbd9ba4 .d79bf5aef0816574 {
10682
- padding: 5px 8px;
10683
- width: 100%;
10684
- border: 1px solid #d9d9d9;
10685
- border-radius: 4px;
10686
- font-size: 14px;
10687
- font-family: inherit;
10688
- resize: vertical;
10689
- min-height: 80px;
10690
- box-sizing: border-box;
10691
- resize: none;
10692
- }
10693
- .a82c68467fbd9ba4 .d79bf5aef0816574:focus {
10694
- outline: none;
10695
- border: 1px solid #b752ea;
10696
- box-shadow: 0 0 0 2px rgba(183, 82, 234, 0.1);
10697
- }
10698
- .a82c68467fbd9ba4 .d79bf5aef0816574::-moz-placeholder {
10699
- color: #999;
10700
- }
10701
- .a82c68467fbd9ba4 .d79bf5aef0816574::placeholder {
10702
- color: #999;
10703
- }
10704
- .a82c68467fbd9ba4 .ddce66c2730266a9 {
10705
- display: flex;
10706
- justify-content: flex-end;
10707
- gap: 12px;
10708
- padding: 16px 20px;
10709
- border-top: 1px solid #e8e8e8;
10710
- }
10711
- .a82c68467fbd9ba4 .cbb043ea2499271a,
10712
- .a82c68467fbd9ba4 .c55955936e93afa3 {
10713
- padding: 8px 20px;
10714
- border-radius: 4px;
10715
- font-size: 14px;
10716
- cursor: pointer;
10717
- transition: all 0.2s;
10718
- border: none;
10719
- }
10720
- .a82c68467fbd9ba4 .cbb043ea2499271a {
10721
- background: #fff;
10722
- color: #333;
10723
- border: 1px solid #d9d9d9;
10724
- }
10725
- .a82c68467fbd9ba4 .cbb043ea2499271a:hover {
10726
- border-color: #999;
10727
- color: #666;
10728
- }
10729
- .a82c68467fbd9ba4 .c55955936e93afa3 {
10730
- background: #b752ea;
10731
- color: #fff;
10732
- }
10733
- .a82c68467fbd9ba4 .c55955936e93afa3:hover:not(:disabled) {
10734
- background: #9d3ac2;
10735
- }
10736
- .a82c68467fbd9ba4 .c55955936e93afa3:disabled {
10737
- background: #d9d9d9;
10738
- color: #999;
10739
- cursor: not-allowed;
10740
- }
10741
- /* Responsive styles */
10742
- @media (max-width: 768px) {
10743
- .a82c68467fbd9ba4 {
10744
- width: 95%;
10745
- max-width: 95%;
10746
- }
10747
- .dab8560c96fa0283 {
10748
- flex-direction: column;
10749
- }
10750
- .d36e84632eb09d08 {
10751
- width: 100%;
10752
- }
10753
- }
10754
- `, ""]);
10755
- // Exports
10756
- ___CSS_LOADER_EXPORT___.locals = {
10757
- "container": `ffe867e2c235a0c5`,
10758
- "icon-selected": `d07fb38c947809f8`,
10759
- "iconSelected": `d07fb38c947809f8`,
10760
- "icon-button-selected": `d9418402ebdc6c0f`,
10761
- "iconButtonSelected": `d9418402ebdc6c0f`,
10762
- "feedback-overlay": `b29fb4268fffc847`,
10763
- "feedbackOverlay": `b29fb4268fffc847`,
10764
- "feedback-dialog": `a82c68467fbd9ba4`,
10765
- "feedbackDialog": `a82c68467fbd9ba4`,
10766
- "feedback-header": `fe9b5896dd607d27`,
10767
- "feedbackHeader": `fe9b5896dd607d27`,
10768
- "feedback-title": `f15e6e77acfff31a`,
10769
- "feedbackTitle": `f15e6e77acfff31a`,
10770
- "feedback-close": `ec213d35312b7d7e`,
10771
- "feedbackClose": `ec213d35312b7d7e`,
10772
- "feedback-content": `dc3fb716e09637a3`,
10773
- "feedbackContent": `dc3fb716e09637a3`,
10774
- "feedback-types": `dab8560c96fa0283`,
10775
- "feedbackTypes": `dab8560c96fa0283`,
10776
- "feedback-type-btn": `d36e84632eb09d08`,
10777
- "feedbackTypeBtn": `d36e84632eb09d08`,
10778
- "feedback-type-btn-selected": `b8dbe31e00feb69b`,
10779
- "feedbackTypeBtnSelected": `b8dbe31e00feb69b`,
10780
- "feedback-comment": `df277aeb58f67270`,
10781
- "feedbackComment": `df277aeb58f67270`,
10782
- "feedback-textarea": `d79bf5aef0816574`,
10783
- "feedbackTextarea": `d79bf5aef0816574`,
10784
- "feedback-footer": `ddce66c2730266a9`,
10785
- "feedbackFooter": `ddce66c2730266a9`,
10786
- "feedback-btn-cancel": `cbb043ea2499271a`,
10787
- "feedbackBtnCancel": `cbb043ea2499271a`,
10788
- "feedback-btn-confirm": `c55955936e93afa3`,
10789
- "feedbackBtnConfirm": `c55955936e93afa3`
10790
- };
10791
- /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
10792
-
10793
-
10794
10550
  }),
10795
10551
  58678: (function (module, __webpack_exports__, __webpack_require__) {
10796
10552
  __webpack_require__.d(__webpack_exports__, {
@@ -14719,6 +14475,9 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.coze-chat-sdk * {
14719
14475
  -webkit-font-smoothing: antialiased;
14720
14476
  -moz-osx-font-smoothing: grayscale;
14721
14477
  }
14478
+ .coze-chat-sdk textarea {
14479
+ padding: 0;
14480
+ }
14722
14481
  .coze-chat-sdk a:focus,
14723
14482
  .coze-chat-sdk input:focus,
14724
14483
  .coze-chat-sdk p:focus,
@@ -266088,9 +265847,6 @@ axios_axiosInstance.interceptors.response.use((response)=>{
266088
265847
  axios_axiosInstance.interceptors.request.use(async (config)=>{
266089
265848
  var _config_method, _config_headers;
266090
265849
  const setHeader = (key, value)=>{
266091
- if (!config.headers) {
266092
- return;
266093
- }
266094
265850
  if (typeof config.headers.set === 'function') {
266095
265851
  config.headers.set(key, value);
266096
265852
  } else {
@@ -266098,9 +265854,6 @@ axios_axiosInstance.interceptors.request.use(async (config)=>{
266098
265854
  }
266099
265855
  };
266100
265856
  const getHeader = (key)=>{
266101
- if (!config.headers) {
266102
- return undefined;
266103
- }
266104
265857
  if (typeof config.headers.get === 'function') {
266105
265858
  return config.headers.get(key);
266106
265859
  }
@@ -266558,9 +266311,6 @@ const useApiErrorResponseHook = (response)=>{
266558
266311
  };
266559
266312
  const useCsrfRequestHook = (config)=>{
266560
266313
  var _config_method;
266561
- if (!config.headers) {
266562
- return config;
266563
- }
266564
266314
  config.headers.set('x-requested-with', 'XMLHttpRequest');
266565
266315
  if (((_config_method = config.method) === null || _config_method === void 0 ? void 0 : _config_method.toLowerCase()) === 'post' && !config.headers.get('content-type')) {
266566
266316
  // The new CSRF protection requires all post requests to have this header.
@@ -269825,7 +269575,7 @@ class HttpChunk extends CustomEventEmitter {
269825
269575
  dataClump: fetchDataHelper,
269826
269576
  body: channelFetchInfo.body,
269827
269577
  // 将 headers 数组转换为 Headers 对象,因为 fetch API 需要 Headers 对象或普通对象
269828
- headers: new Headers(Array.isArray(channelFetchInfo.headers) ? channelFetchInfo.headers : []),
269578
+ headers: new Headers(channelFetchInfo.headers),
269829
269579
  method: channelFetchInfo.method,
269830
269580
  signal: fetchDataHelper.abortSignal.signal,
269831
269581
  totalFetchTimeout: fetchDataHelper.totalFetchTimeout,
@@ -406875,6 +406625,48 @@ const useHasMessageList = ()=>{
406875
406625
  */ const webSdkDefaultConnectorId = '999';
406876
406626
  const chatflowDraftConnectorId = '10000010';
406877
406627
 
406628
+ ;// CONCATENATED MODULE: ../open-chat/src/util/conversation-display-name.ts
406629
+ /*
406630
+ * Copyright 2025 coze-dev Authors
406631
+ *
406632
+ * Licensed under the Apache License, Version 2.0 (the "License");
406633
+ * you may not use this file except in compliance with the License.
406634
+ * You may obtain a copy of the License at
406635
+ *
406636
+ * http://www.apache.org/licenses/LICENSE-2.0
406637
+ *
406638
+ * Unless required by applicable law or agreed to in writing, software
406639
+ * distributed under the License is distributed on an "AS IS" BASIS,
406640
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
406641
+ * See the License for the specific language governing permissions and
406642
+ * limitations under the License.
406643
+ */
406644
+ // UUID格式判断:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
406645
+ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
406646
+ const isUUID = (str)=>{
406647
+ if (!str) {
406648
+ return false;
406649
+ }
406650
+ return UUID_REGEX.test(str);
406651
+ };
406652
+ /**
406653
+ * 获取会话显示名称
406654
+ * 优先级:title(如果不是UUID)> name(如果不是UUID)> 新创建的会话
406655
+ * @param item 会话项
406656
+ * @returns 显示名称
406657
+ */ const getConversationDisplayName = (item)=>{
406658
+ // 优先使用title,但需要检查是否是UUID
406659
+ if (item.title && !isUUID(item.title)) {
406660
+ return item.title;
406661
+ }
406662
+ // 如果name存在且不是UUID格式,使用name
406663
+ if (item.name && !isUUID(item.name)) {
406664
+ return item.name;
406665
+ }
406666
+ // 否则显示"新创建的会话"
406667
+ return intl_i18n.t('web_sdk_conversation_default_name', {}, '新创建的会话');
406668
+ };
406669
+
406878
406670
  ;// CONCATENATED MODULE: ../open-chat/src/types/conversations.ts
406879
406671
  /*
406880
406672
  * Copyright 2025 coze-dev Authors
@@ -408554,48 +408346,6 @@ const useGroupedConversations = (conversations)=>{
408554
408346
  return groupedConversations;
408555
408347
  };
408556
408348
 
408557
- ;// CONCATENATED MODULE: ../open-chat/src/util/conversation-display-name.ts
408558
- /*
408559
- * Copyright 2025 coze-dev Authors
408560
- *
408561
- * Licensed under the Apache License, Version 2.0 (the "License");
408562
- * you may not use this file except in compliance with the License.
408563
- * You may obtain a copy of the License at
408564
- *
408565
- * http://www.apache.org/licenses/LICENSE-2.0
408566
- *
408567
- * Unless required by applicable law or agreed to in writing, software
408568
- * distributed under the License is distributed on an "AS IS" BASIS,
408569
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
408570
- * See the License for the specific language governing permissions and
408571
- * limitations under the License.
408572
- */
408573
- // UUID格式判断:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
408574
- const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
408575
- const isUUID = (str)=>{
408576
- if (!str) {
408577
- return false;
408578
- }
408579
- return UUID_REGEX.test(str);
408580
- };
408581
- /**
408582
- * 获取会话显示名称
408583
- * 优先级:title(如果不是UUID)> name(如果不是UUID)> 新创建的会话
408584
- * @param item 会话项
408585
- * @returns 显示名称
408586
- */ const getConversationDisplayName = (item)=>{
408587
- // 优先使用title,但需要检查是否是UUID
408588
- if (item.title && !isUUID(item.title)) {
408589
- return item.title;
408590
- }
408591
- // 如果name存在且不是UUID格式,使用name
408592
- if (item.name && !isUUID(item.name)) {
408593
- return item.name;
408594
- }
408595
- // 否则显示"新创建的会话"
408596
- return intl_i18n.t('web_sdk_conversation_default_name', {}, '新创建的会话');
408597
- };
408598
-
408599
408349
  ;// CONCATENATED MODULE: ../open-chat/src/components/conversation-list-sider/conversation-item/mobile/operate/index.tsx
408600
408350
  /*
408601
408351
  * Copyright 2025 coze-dev Authors
@@ -409139,6 +408889,7 @@ const ConversationList = /*#__PURE__*/ (0,react.forwardRef)(// eslint-disable-ne
409139
408889
  // 如果当前会话信息不存在,允许更新
409140
408890
  if (!currentConversationInfo) {
409141
408891
  const sectionId = conversation.last_section_id || '';
408892
+ const conversationWithTitle = conversation;
409142
408893
  console.log('handleConversationChange conversation1', conversation);
409143
408894
  const c = {
409144
408895
  ...conversation,
@@ -409146,7 +408897,10 @@ const ConversationList = /*#__PURE__*/ (0,react.forwardRef)(// eslint-disable-ne
409146
408897
  last_section_id: sectionId,
409147
408898
  sectionId,
409148
408899
  conversationListVisible: false,
409149
- isLargeWidth: false
408900
+ isLargeWidth: false,
408901
+ // 明确设置 name 和 title,确保切换会话时能正确更新
408902
+ name: conversation.name,
408903
+ title: conversationWithTitle.title
409150
408904
  };
409151
408905
  conversationRef.current = c;
409152
408906
  updateCurrentConversationInfo(c);
@@ -409162,12 +408916,16 @@ const ConversationList = /*#__PURE__*/ (0,react.forwardRef)(// eslint-disable-ne
409162
408916
  return;
409163
408917
  }
409164
408918
  // 只有当 sectionId 真的发生变化时才更新
408919
+ const conversationWithTitle = conversation;
409165
408920
  const c = {
409166
408921
  ...currentConversationInfo,
409167
408922
  ...conversation,
409168
408923
  id: conversation.id,
409169
408924
  last_section_id: sectionId,
409170
- sectionId
408925
+ sectionId,
408926
+ // 明确设置 name 和 title,确保切换会话时能正确更新
408927
+ name: conversation.name,
408928
+ title: conversationWithTitle.title
409171
408929
  };
409172
408930
  console.log('handleConversationChange conversation2', c);
409173
408931
  conversationRef.current = c;
@@ -409177,12 +408935,16 @@ const ConversationList = /*#__PURE__*/ (0,react.forwardRef)(// eslint-disable-ne
409177
408935
  // 会话ID不同,正常更新
409178
408936
  // 确保使用正确的 last_section_id
409179
408937
  const sectionId = conversation.last_section_id || '';
408938
+ const conversationWithTitle = conversation;
409180
408939
  const c = {
409181
408940
  ...currentConversationInfo,
409182
408941
  ...conversation,
409183
408942
  id: conversation.id,
409184
408943
  last_section_id: sectionId,
409185
- sectionId
408944
+ sectionId,
408945
+ // 明确设置 name 和 title,确保切换会话时能正确更新
408946
+ name: conversation.name,
408947
+ title: conversationWithTitle.title
409186
408948
  };
409187
408949
  // 先更新 conversationRef,确保 getConversationInfo 能返回正确的值
409188
408950
  console.log('handleConversationChange conversation3', c);
@@ -409415,6 +409177,7 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
409415
409177
 
409416
409178
 
409417
409179
 
409180
+
409418
409181
  /* eslint-disable @coze-arch/max-line-per-function -- This component handles complex conversation list sidebar logic */ const ConversationListSider = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
409419
409182
  let { children } = param;
409420
409183
  const conversationListRef = (0,react.useRef)(null);
@@ -409437,15 +409200,20 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
409437
409200
  const isAppType = chatType === client_ChatType.APP;
409438
409201
  // App 模式优先使用 title 字段,Bot 模式使用 name 字段
409439
409202
  const conversationWithTitle = conversation;
409440
- const displayName = isAppType ? conversationWithTitle.title || conversation.name || '' : conversation.name || conversationWithTitle.title || '';
409203
+ // 使用 getConversationDisplayName 处理 UUID 情况,如果是 UUID 则显示"新创建的会话"
409204
+ const displayName = getConversationDisplayName(conversationWithTitle);
409441
409205
  setModalInfo({
409442
409206
  visible: true,
409443
409207
  type: 'rename',
409444
409208
  conversation: {
409445
409209
  ...conversation,
409446
409210
  name: displayName,
409447
- // 保留 title 字段(如果有)
409448
- ...conversationWithTitle.title && {
409211
+ // App 模式下,如果 title 是 UUID,也使用 displayName
409212
+ ...isAppType && {
409213
+ title: displayName
409214
+ },
409215
+ // Bot 模式下,保留原来的 title(如果有)
409216
+ ...!isAppType && conversationWithTitle.title && {
409449
409217
  title: conversationWithTitle.title
409450
409218
  }
409451
409219
  }
@@ -409618,7 +409386,7 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
409618
409386
  },
409619
409387
  children: (modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.type) === 'rename' ? /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Input, {
409620
409388
  placeholder: intl_i18n.t('web_sdk_conversation_placeholder', {}, '请输入会话名称'),
409621
- value: chatType === client_ChatType.APP ? modalInfo.conversation.title || modalInfo.conversation.name || '' : modalInfo.conversation.name || modalInfo.conversation.title || '',
409389
+ value: modalInfo.conversation.name || '',
409622
409390
  maxLength: 100,
409623
409391
  onChange: (value)=>{
409624
409392
  if (!modalInfo) {
@@ -409907,9 +409675,13 @@ const createChatStore = (chatConfig, userInfo)=>{
409907
409675
  if (!currentConversationInfo) {
409908
409676
  s.currentConversationInfo = currentConversationInfo;
409909
409677
  } else {
409678
+ // 使用 Object.assign 确保 undefined 值也能正确更新
409910
409679
  s.currentConversationInfo = {
409911
409680
  ...s.currentConversationInfo,
409912
- ...currentConversationInfo
409681
+ ...currentConversationInfo,
409682
+ // 明确设置 name 和 title,确保 undefined 值也能正确更新
409683
+ name: currentConversationInfo.name,
409684
+ title: currentConversationInfo.title
409913
409685
  };
409914
409686
  }
409915
409687
  }));
@@ -421380,22 +421152,6 @@ class MessageParser {
421380
421152
  console.error('onBeforeSendMessage: conversationId is empty after creation');
421381
421153
  throw new Error('conversationId is required for sending message');
421382
421154
  }
421383
- // 更新会话列表中的 updated_at,确保每次发送消息时都会更新会话的更新时间
421384
- // 这样会话列表可以正确排序,显示最近活跃的会话
421385
- const existingConversation = refConversations.current.find((c)=>c.id === conversationId);
421386
- if (existingConversation && refUpdateConversations.current) {
421387
- const updatedConversation = {
421388
- id: conversationId,
421389
- updated_at: Math.floor(Date.now() / 1000)
421390
- };
421391
- refUpdateConversations.current([
421392
- updatedConversation
421393
- ], 'update');
421394
- console.log('onBeforeSendMessage: Updated conversation updated_at in list', {
421395
- conversationId,
421396
- updated_at: updatedConversation.updated_at
421397
- });
421398
- }
421399
421155
  // 使用计算后的 API URL
421400
421156
  const url = `${finalApiUrl}/v1/workflows/chat?conversation_id=${conversationId}`;
421401
421157
  // 根据 chatType 选择正确的 parameters 来源
@@ -421419,18 +421175,14 @@ class MessageParser {
421419
421175
  hasBody: !!body,
421420
421176
  bodyLength: body === null || body === void 0 ? void 0 : body.length
421421
421177
  });
421422
- // 确保 headers 是一个数组
421423
- const headers = Array.isArray(requestConfig.headers) ? [
421424
- ...requestConfig.headers
421425
- ] : [];
421426
421178
  Object.keys((debug === null || debug === void 0 ? void 0 : debug.cozeApiRequestHeader) || {}).forEach((key)=>{
421427
421179
  var _debug_cozeApiRequestHeader;
421428
- headers.push([
421180
+ requestConfig.headers.push([
421429
421181
  key,
421430
421182
  (debug === null || debug === void 0 ? void 0 : (_debug_cozeApiRequestHeader = debug.cozeApiRequestHeader) === null || _debug_cozeApiRequestHeader === void 0 ? void 0 : _debug_cozeApiRequestHeader[key]) || ''
421431
421183
  ]);
421432
421184
  });
421433
- headers.push([
421185
+ requestConfig.headers.push([
421434
421186
  'Accept-Language',
421435
421187
  intl.language === 'zh-CN' ? 'zh' : 'en'
421436
421188
  ]);
@@ -421439,7 +421191,7 @@ class MessageParser {
421439
421191
  body,
421440
421192
  url,
421441
421193
  method: requestConfig.method || 'POST',
421442
- headers
421194
+ headers: requestConfig.headers || []
421443
421195
  };
421444
421196
  console.log('onBeforeSendMessage: Returning config', {
421445
421197
  url: finalConfig.url,
@@ -423235,651 +422987,6 @@ const QuoteMessage = (props)=>{
423235
422987
  };
423236
422988
  QuoteMessage.displayName = 'QuoteMessage';
423237
422989
 
423238
- ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/context/comment/context.tsx
423239
- /*
423240
- * Copyright 2025 coze-dev Authors
423241
- *
423242
- * Licensed under the Apache License, Version 2.0 (the "License");
423243
- * you may not use this file except in compliance with the License.
423244
- * You may obtain a copy of the License at
423245
- *
423246
- * http://www.apache.org/licenses/LICENSE-2.0
423247
- *
423248
- * Unless required by applicable law or agreed to in writing, software
423249
- * distributed under the License is distributed on an "AS IS" BASIS,
423250
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423251
- * See the License for the specific language governing permissions and
423252
- * limitations under the License.
423253
- */
423254
- const CommentContext = /*#__PURE__*/ (0,react.createContext)({});
423255
- const CommentProvider = CommentContext.Provider;
423256
-
423257
- ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/context/comment/index.ts
423258
- /*
423259
- * Copyright 2025 coze-dev Authors
423260
- *
423261
- * Licensed under the Apache License, Version 2.0 (the "License");
423262
- * you may not use this file except in compliance with the License.
423263
- * You may obtain a copy of the License at
423264
- *
423265
- * http://www.apache.org/licenses/LICENSE-2.0
423266
- *
423267
- * Unless required by applicable law or agreed to in writing, software
423268
- * distributed under the License is distributed on an "AS IS" BASIS,
423269
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423270
- * See the License for the specific language governing permissions and
423271
- * limitations under the License.
423272
- */
423273
-
423274
- // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].use[2]!../../../../../common/temp/default/node_modules/.pnpm/less-loader@11.1.4_less@4.4.2_webpack@5.91.0/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[7].use[3]!../../../common/chat-area/chat-answer-action/src/components/comment-message/index.module.less
423275
- var comment_message_index_module = __webpack_require__(94148);
423276
- ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/components/comment-message/index.module.less
423277
-
423278
-
423279
-
423280
-
423281
-
423282
-
423283
-
423284
-
423285
-
423286
-
423287
-
423288
- var comment_message_index_module_options = {};
423289
-
423290
- comment_message_index_module_options.styleTagTransform = (styleTagTransform_default());
423291
- comment_message_index_module_options.setAttributes = (setAttributesWithoutAttributes_default());
423292
-
423293
- comment_message_index_module_options.insert = insertBySelector_default().bind(null, "head");
423294
-
423295
- comment_message_index_module_options.domAPI = (styleDomAPI_default());
423296
- comment_message_index_module_options.insertStyleElement = (insertStyleElement_default());
423297
-
423298
- var comment_message_index_module_update = injectStylesIntoStyleTag_default()(comment_message_index_module/* ["default"] */.A, comment_message_index_module_options);
423299
-
423300
-
423301
-
423302
-
423303
- /* ESM default export */ const components_comment_message_index_module = (comment_message_index_module/* ["default"] */.A && comment_message_index_module/* ["default"].locals */.A.locals ? comment_message_index_module/* ["default"].locals */.A.locals : undefined);
423304
-
423305
- ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/components/comment-message/feedback-dialog.tsx
423306
- /*
423307
- * Copyright 2025 coze-dev Authors
423308
- *
423309
- * Licensed under the Apache License, Version 2.0 (the "License");
423310
- * you may not use this file except in compliance with the License.
423311
- * You may obtain a copy of the License at
423312
- *
423313
- * http://www.apache.org/licenses/LICENSE-2.0
423314
- *
423315
- * Unless required by applicable law or agreed to in writing, software
423316
- * distributed under the License is distributed on an "AS IS" BASIS,
423317
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423318
- * See the License for the specific language governing permissions and
423319
- * limitations under the License.
423320
- */
423321
-
423322
-
423323
-
423324
-
423325
-
423326
- const DEFAULT_FEEDBACK_OPTIONS = [
423327
- {
423328
- value: 'HARMFUL',
423329
- label: '有害/不安全'
423330
- },
423331
- {
423332
- value: 'FALSE_INFO',
423333
- label: '虚假信息'
423334
- },
423335
- {
423336
- value: 'NOT_HELPFUL',
423337
- label: '没有帮助'
423338
- },
423339
- {
423340
- value: 'OTHER',
423341
- label: '其他'
423342
- }
423343
- ];
423344
- function findChatAreaContainer() {
423345
- // 方式1: 尝试通过类名查找 coze-chat-sdk 容器
423346
- let cozeChatSdk = document.querySelector('.coze-chat-sdk');
423347
- // 方式2: 如果找不到,尝试查找包含 "coze-chat-sdk" 的类名(部分匹配)
423348
- if (!cozeChatSdk) {
423349
- const allElements = document.querySelectorAll('*');
423350
- for (const el of allElements){
423351
- const classList = Array.from(el.classList);
423352
- if (classList.some((cls)=>cls.includes('coze-chat-sdk'))) {
423353
- cozeChatSdk = el;
423354
- break;
423355
- }
423356
- }
423357
- }
423358
- // 方式3: 如果还是找不到,使用 document.body 作为容器(使用 fixed 定位)
423359
- return cozeChatSdk || document.body;
423360
- }
423361
- const FeedbackDialog = (param)=>{
423362
- let { visible, onConfirm, onCancel, feedbackTypes } = param;
423363
- const [selectedFeedbackType, setSelectedFeedbackType] = (0,react.useState)(null);
423364
- const [comment, setComment] = (0,react.useState)('');
423365
- const [container, setContainer] = (0,react.useState)(null);
423366
- (0,react.useEffect)(()=>{
423367
- setContainer(visible ? findChatAreaContainer() : null);
423368
- }, [
423369
- visible
423370
- ]);
423371
- if (!visible) {
423372
- return null;
423373
- }
423374
- // 使用接口返回的反馈类型,如果没有则使用默认值
423375
- const feedbackOptions = feedbackTypes && feedbackTypes.length > 0 ? feedbackTypes.map((item)=>({
423376
- value: item.value,
423377
- label: item.label
423378
- })) : DEFAULT_FEEDBACK_OPTIONS;
423379
- const handleConfirm = ()=>{
423380
- onConfirm(selectedFeedbackType, comment);
423381
- // 重置状态
423382
- setSelectedFeedbackType(null);
423383
- setComment('');
423384
- };
423385
- const handleCancel = ()=>{
423386
- setSelectedFeedbackType(null);
423387
- setComment('');
423388
- onCancel();
423389
- };
423390
- const isBodyContainer = container === document.body;
423391
- const modalContent = /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423392
- className: components_comment_message_index_module["feedback-overlay"],
423393
- "data-container-is-body": isBodyContainer,
423394
- onClick: handleCancel,
423395
- children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423396
- className: components_comment_message_index_module["feedback-dialog"],
423397
- onClick: (e)=>{
423398
- e.stopPropagation();
423399
- },
423400
- children: [
423401
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423402
- className: components_comment_message_index_module["feedback-header"],
423403
- children: [
423404
- /*#__PURE__*/ (0,jsx_runtime.jsx)("h3", {
423405
- className: components_comment_message_index_module["feedback-title"],
423406
- children: "反馈意见"
423407
- }),
423408
- /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423409
- type: "button",
423410
- className: components_comment_message_index_module["feedback-close"],
423411
- onClick: handleCancel,
423412
- "aria-label": "关闭",
423413
- children: "\xd7"
423414
- })
423415
- ]
423416
- }),
423417
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423418
- className: components_comment_message_index_module["feedback-content"],
423419
- children: [
423420
- /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423421
- className: components_comment_message_index_module["feedback-types"],
423422
- children: feedbackOptions.map((option)=>/*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423423
- type: "button",
423424
- className: classnames_default()(components_comment_message_index_module["feedback-type-btn"], {
423425
- [components_comment_message_index_module["feedback-type-btn-selected"]]: selectedFeedbackType === option.value
423426
- }),
423427
- onClick: ()=>{
423428
- setSelectedFeedbackType(option.value);
423429
- },
423430
- children: option.label
423431
- }, option.value))
423432
- }),
423433
- /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423434
- className: components_comment_message_index_module["feedback-comment"],
423435
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)("textarea", {
423436
- className: components_comment_message_index_module["feedback-textarea"],
423437
- placeholder: "请告诉我们改进意见。",
423438
- value: comment,
423439
- onChange: (e)=>{
423440
- setComment(e.target.value);
423441
- },
423442
- rows: 4
423443
- })
423444
- })
423445
- ]
423446
- }),
423447
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423448
- className: components_comment_message_index_module["feedback-footer"],
423449
- children: [
423450
- /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423451
- type: "button",
423452
- className: components_comment_message_index_module["feedback-btn-cancel"],
423453
- onClick: handleCancel,
423454
- children: "取消"
423455
- }),
423456
- /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423457
- type: "button",
423458
- className: components_comment_message_index_module["feedback-btn-confirm"],
423459
- onClick: handleConfirm,
423460
- children: "确认"
423461
- })
423462
- ]
423463
- })
423464
- ]
423465
- })
423466
- });
423467
- // 如果找到了容器,使用 Portal 渲染;否则直接渲染
423468
- if (container) {
423469
- return /*#__PURE__*/ (0,react_dom.createPortal)(modalContent, container);
423470
- }
423471
- return modalContent;
423472
- };
423473
-
423474
- ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/components/comment-message/index.tsx
423475
- /*
423476
- * Copyright 2025 coze-dev Authors
423477
- *
423478
- * Licensed under the Apache License, Version 2.0 (the "License");
423479
- * you may not use this file except in compliance with the License.
423480
- * You may obtain a copy of the License at
423481
- *
423482
- * http://www.apache.org/licenses/LICENSE-2.0
423483
- *
423484
- * Unless required by applicable law or agreed to in writing, software
423485
- * distributed under the License is distributed on an "AS IS" BASIS,
423486
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423487
- * See the License for the specific language governing permissions and
423488
- * limitations under the License.
423489
- */ /* eslint-disable @coze-arch/max-line-per-function -- 评论组件功能完整,拆分会影响可读性 */
423490
-
423491
-
423492
-
423493
-
423494
-
423495
-
423496
-
423497
-
423498
-
423499
-
423500
- /**
423501
- * 评论数据缓存
423502
- * 使用 chatId 作为 key 来缓存每个消息的评论状态
423503
- */ const commentCache = new Map();
423504
- /**
423505
- * 枚举数据缓存
423506
- * 枚举数据通常不会变化,可以全局共享
423507
- */ let enumsCache = null;
423508
- /**
423509
- * 缓存过期时间(毫秒)
423510
- * 评论状态缓存 5 分钟,枚举数据缓存 30 分钟
423511
- */ const COMMENT_CACHE_TTL = 5 * 60 * 1000; // 5 分钟
423512
- const ENUMS_CACHE_TTL = 30 * 60 * 1000; // 30 分钟
423513
- /**
423514
- * 生成缓存 key
423515
- */ function getCacheKey(chatId, appId, conversationId) {
423516
- return `${appId}:${conversationId}:${chatId}`;
423517
- }
423518
- /**
423519
- * 从枚举数据中获取点赞按钮文字
423520
- */ function getLikeLabel(enumsData, currentComment) {
423521
- if (!(enumsData === null || enumsData === void 0 ? void 0 : enumsData.comment_names)) {
423522
- return currentComment === 'LIKE' ? '取消点赞' : '点赞';
423523
- }
423524
- const likeOption = enumsData.comment_names.find((item)=>item.value === 'LIKE');
423525
- if (likeOption) {
423526
- return currentComment === 'LIKE' ? `取消${likeOption.label}` : likeOption.label;
423527
- }
423528
- return currentComment === 'LIKE' ? '取消点赞' : '点赞';
423529
- }
423530
- /**
423531
- * 从枚举数据中获取点踩按钮文字
423532
- */ function getDislikeLabel(enumsData, currentComment) {
423533
- if (!(enumsData === null || enumsData === void 0 ? void 0 : enumsData.comment_names)) {
423534
- return currentComment === 'DISLIKE' ? '取消点踩' : '点踩';
423535
- }
423536
- const dislikeOption = enumsData.comment_names.find((item)=>item.value === 'DISLIKE');
423537
- if (dislikeOption) {
423538
- return currentComment === 'DISLIKE' ? `取消${dislikeOption.label}` : dislikeOption.label;
423539
- }
423540
- return currentComment === 'DISLIKE' ? '取消点踩' : '点踩';
423541
- }
423542
- /**
423543
- * 查找 coze-chat-sdk 容器
423544
- */ function findCozeChatSdkContainer() {
423545
- // 方式1: 尝试通过类名查找
423546
- let container = document.querySelector('.coze-chat-sdk');
423547
- // 方式2: 如果找不到,尝试查找包含 "coze-chat-sdk" 的类名(部分匹配)
423548
- if (!container) {
423549
- const allElements = document.querySelectorAll('*');
423550
- for (const el of allElements){
423551
- const classList = Array.from(el.classList);
423552
- if (classList.some((cls)=>cls.includes('coze-chat-sdk'))) {
423553
- container = el;
423554
- break;
423555
- }
423556
- }
423557
- }
423558
- // 方式3: 如果还是找不到,使用 document.body 作为容器
423559
- return container || document.body;
423560
- }
423561
- const CommentMessage = (param)=>{
423562
- let { className, isMustGroupLastAnswerMessage = true, ...props } = param;
423563
- var _enumsData_feedback_types;
423564
- const { message, meta } = message_box_useMessageBoxContext();
423565
- const { commentApiService, extractMessageParams } = (0,react.useContext)(CommentContext);
423566
- const { useGlobalInitStore } = use_chat_area_context_useChatAreaStoreSet();
423567
- const conversationIdFromStore = useGlobalInitStore((state)=>state.conversationId);
423568
- const [currentComment, setCurrentComment] = (0,react.useState)(null);
423569
- const [showFeedbackDialog, setShowFeedbackDialog] = (0,react.useState)(false);
423570
- const [loading, setLoading] = (0,react.useState)(false);
423571
- const [enumsData, setEnumsData] = (0,react.useState)(null);
423572
- const trigger = use_tooltip_trigger_useTooltipTrigger('hover');
423573
- // 提取消息参数,优先使用 store 中的 conversationId
423574
- const messageParams = extractMessageParams ? extractMessageParams(message, conversationIdFromStore || undefined) : null;
423575
- // 在组件加载时获取枚举数据和查询当前消息的评论状态
423576
- (0,react.useEffect)(()=>{
423577
- if (!commentApiService || !messageParams) {
423578
- return;
423579
- }
423580
- const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
423581
- const fetchEnums = async ()=>{
423582
- if (!(commentApiService === null || commentApiService === void 0 ? void 0 : commentApiService.getCommentEnums)) {
423583
- return;
423584
- }
423585
- // 检查缓存
423586
- const now = Date.now();
423587
- if (enumsCache && enumsCache.data && now - enumsCache.timestamp < ENUMS_CACHE_TTL) {
423588
- setEnumsData(enumsCache.data);
423589
- return;
423590
- }
423591
- try {
423592
- const response = await commentApiService.getCommentEnums();
423593
- enumsCache = {
423594
- data: response.data,
423595
- timestamp: now
423596
- };
423597
- setEnumsData(response.data);
423598
- } catch (error) {
423599
- console.error('[Comment Message] Failed to fetch enums:', error);
423600
- // 如果请求失败,尝试使用缓存数据
423601
- if (enumsCache === null || enumsCache === void 0 ? void 0 : enumsCache.data) {
423602
- setEnumsData(enumsCache.data);
423603
- }
423604
- }
423605
- };
423606
- const fetchCommentStatus = async ()=>{
423607
- if (!(commentApiService === null || commentApiService === void 0 ? void 0 : commentApiService.getCommentsByChatID)) {
423608
- return;
423609
- }
423610
- // 检查缓存
423611
- const cached = commentCache.get(cacheKey);
423612
- const now = Date.now();
423613
- if (cached && now - cached.timestamp < COMMENT_CACHE_TTL) {
423614
- setCurrentComment(cached.comment);
423615
- return;
423616
- }
423617
- try {
423618
- var _response_data_results, _response_data;
423619
- const requestParams = {
423620
- app_id: messageParams.appId,
423621
- conversation_id: messageParams.conversationId,
423622
- chat_ids: [
423623
- messageParams.chatId
423624
- ]
423625
- };
423626
- const response = await commentApiService.getCommentsByChatID(requestParams);
423627
- const chatComments = (_response_data = response.data) === null || _response_data === void 0 ? void 0 : (_response_data_results = _response_data.results) === null || _response_data_results === void 0 ? void 0 : _response_data_results.find((item)=>item.chat_id === messageParams.chatId);
423628
- let comment = null;
423629
- if (chatComments === null || chatComments === void 0 ? void 0 : chatComments.comments.length) {
423630
- const sortedComments = [
423631
- ...chatComments.comments
423632
- ].sort((a, b)=>b.created_at - a.created_at);
423633
- const latestComment = sortedComments[0];
423634
- if (latestComment) {
423635
- comment = latestComment.name;
423636
- }
423637
- }
423638
- // 更新缓存
423639
- commentCache.set(cacheKey, {
423640
- comment,
423641
- timestamp: now
423642
- });
423643
- setCurrentComment(comment);
423644
- } catch (error) {
423645
- console.error('[Comment Message] Failed to fetch comment status:', error);
423646
- // 如果请求失败,尝试使用缓存数据
423647
- if (cached) {
423648
- setCurrentComment(cached.comment);
423649
- }
423650
- }
423651
- };
423652
- fetchEnums();
423653
- fetchCommentStatus();
423654
- // eslint-disable-next-line react-hooks/exhaustive-deps -- messageParams 是对象,使用其属性作为依赖
423655
- }, [
423656
- commentApiService,
423657
- messageParams === null || messageParams === void 0 ? void 0 : messageParams.chatId,
423658
- messageParams === null || messageParams === void 0 ? void 0 : messageParams.appId,
423659
- messageParams === null || messageParams === void 0 ? void 0 : messageParams.conversationId
423660
- ]);
423661
- const handleLike = (0,react.useCallback)(async ()=>{
423662
- if (loading || !commentApiService || !messageParams) {
423663
- return;
423664
- }
423665
- setLoading(true);
423666
- try {
423667
- const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
423668
- // 如果已经点赞,则取消点赞(再次点击)
423669
- if (currentComment === 'LIKE') {
423670
- if (commentApiService.cancelComment) {
423671
- await commentApiService.cancelComment({
423672
- chat_id: messageParams.chatId,
423673
- app_id: messageParams.appId,
423674
- conversation_id: messageParams.conversationId
423675
- });
423676
- }
423677
- const newComment = null;
423678
- setCurrentComment(newComment);
423679
- // 更新缓存
423680
- commentCache.set(cacheKey, {
423681
- comment: newComment,
423682
- timestamp: Date.now()
423683
- });
423684
- } else {
423685
- await commentApiService.createComment({
423686
- chat_id: messageParams.chatId,
423687
- app_id: messageParams.appId,
423688
- conversation_id: messageParams.conversationId,
423689
- name: 'LIKE'
423690
- });
423691
- const newComment = 'LIKE';
423692
- setCurrentComment(newComment);
423693
- // 更新缓存
423694
- commentCache.set(cacheKey, {
423695
- comment: newComment,
423696
- timestamp: Date.now()
423697
- });
423698
- // 显示成功提示
423699
- const container = findCozeChatSdkContainer();
423700
- esm_webpack_exports_Toast.success({
423701
- content: '感谢您的反馈',
423702
- getContainer: ()=>container,
423703
- showClose: false
423704
- });
423705
- }
423706
- } catch (error) {
423707
- console.error('[Comment Message] Failed to handle like comment:', error);
423708
- // 发生错误时保持当前状态
423709
- } finally{
423710
- setLoading(false);
423711
- }
423712
- }, [
423713
- commentApiService,
423714
- messageParams,
423715
- currentComment,
423716
- loading
423717
- ]);
423718
- const handleCancelDislike = (0,react.useCallback)(async ()=>{
423719
- if (!commentApiService || !messageParams) {
423720
- return;
423721
- }
423722
- setLoading(true);
423723
- try {
423724
- const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
423725
- if (commentApiService.cancelComment) {
423726
- await commentApiService.cancelComment({
423727
- chat_id: messageParams.chatId,
423728
- app_id: messageParams.appId,
423729
- conversation_id: messageParams.conversationId
423730
- });
423731
- }
423732
- const newComment = null;
423733
- setCurrentComment(newComment);
423734
- // 更新缓存
423735
- commentCache.set(cacheKey, {
423736
- comment: newComment,
423737
- timestamp: Date.now()
423738
- });
423739
- } catch (error) {
423740
- console.error('[Comment Message] Failed to cancel dislike comment:', error);
423741
- // 发生错误时保持当前状态
423742
- } finally{
423743
- setLoading(false);
423744
- }
423745
- }, [
423746
- commentApiService,
423747
- messageParams
423748
- ]);
423749
- const handleDislike = (0,react.useCallback)(async ()=>{
423750
- if (loading || !commentApiService || !messageParams) {
423751
- return;
423752
- }
423753
- // 如果已经点踩,则取消点踩(再次点击)
423754
- if (currentComment === 'DISLIKE') {
423755
- await handleCancelDislike();
423756
- return;
423757
- }
423758
- // 显示反馈对话框
423759
- setShowFeedbackDialog(true);
423760
- }, [
423761
- commentApiService,
423762
- messageParams,
423763
- currentComment,
423764
- loading,
423765
- handleCancelDislike
423766
- ]);
423767
- const handleFeedbackConfirm = (0,react.useCallback)(async (feedbackType, comment)=>{
423768
- if (loading || !commentApiService || !messageParams) {
423769
- return;
423770
- }
423771
- setLoading(true);
423772
- setShowFeedbackDialog(false);
423773
- try {
423774
- const cacheKey = getCacheKey(messageParams.chatId, messageParams.appId, messageParams.conversationId);
423775
- await commentApiService.createComment({
423776
- chat_id: messageParams.chatId,
423777
- app_id: messageParams.appId,
423778
- conversation_id: messageParams.conversationId,
423779
- name: 'DISLIKE',
423780
- feedback_type: feedbackType || undefined,
423781
- comment: comment || undefined
423782
- });
423783
- const newComment = 'DISLIKE';
423784
- setCurrentComment(newComment);
423785
- // 更新缓存
423786
- commentCache.set(cacheKey, {
423787
- comment: newComment,
423788
- timestamp: Date.now()
423789
- });
423790
- // 显示成功提示
423791
- const container = findCozeChatSdkContainer();
423792
- esm_webpack_exports_Toast.success({
423793
- content: '感谢您的反馈',
423794
- getContainer: ()=>container,
423795
- showClose: false
423796
- });
423797
- } catch (error) {
423798
- console.error('[Comment Message] Failed to create dislike comment:', error);
423799
- setCurrentComment(null);
423800
- } finally{
423801
- setLoading(false);
423802
- }
423803
- }, [
423804
- commentApiService,
423805
- messageParams,
423806
- loading
423807
- ]);
423808
- const handleFeedbackCancel = (0,react.useCallback)(()=>{
423809
- setShowFeedbackDialog(false);
423810
- }, []);
423811
- const iconClassNames = classnames_default()(className, 'w-[14px] h-[14px]');
423812
- const likeIconClassNames = classnames_default()(iconClassNames, {
423813
- [components_comment_message_index_module["icon-selected"]]: currentComment === 'LIKE'
423814
- });
423815
- const dislikeIconClassNames = classnames_default()(iconClassNames, {
423816
- [components_comment_message_index_module["icon-selected"]]: currentComment === 'DISLIKE'
423817
- });
423818
- // 如果没有提供 API 服务,则不显示评论按钮
423819
- if (!commentApiService || !extractMessageParams) {
423820
- return null;
423821
- }
423822
- // 只在最终答案消息时显示
423823
- if (!meta.isGroupLastAnswerMessage && isMustGroupLastAnswerMessage) {
423824
- return null;
423825
- }
423826
- // 如果无法提取消息参数,则不显示
423827
- if (!messageParams) {
423828
- return null;
423829
- }
423830
- return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
423831
- children: [
423832
- /*#__PURE__*/ (0,jsx_runtime.jsx)(FeedbackDialog, {
423833
- visible: showFeedbackDialog,
423834
- onConfirm: handleFeedbackConfirm,
423835
- onCancel: handleFeedbackCancel,
423836
- feedbackTypes: (enumsData === null || enumsData === void 0 ? void 0 : (_enumsData_feedback_types = enumsData.feedback_types) === null || _enumsData_feedback_types === void 0 ? void 0 : _enumsData_feedback_types.DISLIKE) || undefined
423837
- }),
423838
- /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423839
- className: components_comment_message_index_module.container,
423840
- children: [
423841
- /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Tooltip, {
423842
- content: getLikeLabel(enumsData, currentComment),
423843
- trigger: trigger,
423844
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_IconButton, {
423845
- "data-testid": "chat-area.answer-action.comment-like-button",
423846
- size: "small",
423847
- icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(__webpack_exports__IconCozThumbsup, {
423848
- className: likeIconClassNames
423849
- }),
423850
- color: "secondary",
423851
- className: classnames_default()({
423852
- [components_comment_message_index_module["icon-button-selected"]]: currentComment === 'LIKE'
423853
- }),
423854
- onClick: handleLike,
423855
- disabled: loading,
423856
- ...props
423857
- })
423858
- }),
423859
- /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Tooltip, {
423860
- content: getDislikeLabel(enumsData, currentComment),
423861
- trigger: trigger,
423862
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_IconButton, {
423863
- "data-testid": "chat-area.answer-action.comment-dislike-button",
423864
- size: "small",
423865
- icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(__webpack_exports__IconCozThumbdown, {
423866
- className: dislikeIconClassNames
423867
- }),
423868
- color: "secondary",
423869
- className: classnames_default()({
423870
- [components_comment_message_index_module["icon-button-selected"]]: currentComment === 'DISLIKE'
423871
- }),
423872
- onClick: handleDislike,
423873
- disabled: loading,
423874
- ...props
423875
- })
423876
- })
423877
- ]
423878
- })
423879
- ]
423880
- });
423881
- };
423882
-
423883
422990
  ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/context/store/context.tsx
423884
422991
  /*
423885
422992
  * Copyright 2025 coze-dev Authors
@@ -424310,8 +423417,6 @@ const BotTriggerConfigButtonGroup = (param)=>{
424310
423417
 
424311
423418
 
424312
423419
 
424313
-
424314
-
424315
423420
 
424316
423421
 
424317
423422
  ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/plugin/hooks/use-cur-message-info.ts
@@ -424562,7 +423667,6 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
424562
423667
  const { isShowDelete, isNeedQuote } = useCurMessageInfo();
424563
423668
  const isShowHoverContainer = isShowDelete || !!showHoverText;
424564
423669
  const isShowQuote = message.type === 'answer' && !!showHoverText && isNeedQuote;
424565
- const isShowComment = message.type === 'answer' && !!showHoverText;
424566
423670
  const { width: actionBarSize } = es_useSize(actionBarRef) || {};
424567
423671
  const actionBarLeft = (0,react.useMemo)(()=>{
424568
423672
  var _actionBarRef_current_closest, _actionBarRef_current;
@@ -424587,7 +423691,7 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
424587
423691
  return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
424588
423692
  children: [
424589
423693
  /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
424590
- className: classnames_default()('w-full flex', 'justify-start'),
423694
+ className: classnames_default()('w-full flex', isMultiMessage ? 'justify-start' : 'justify-end'),
424591
423695
  style: {},
424592
423696
  children: /*#__PURE__*/ (0,jsx_runtime.jsxs)(ActionBarHoverContainer, {
424593
423697
  style: {
@@ -424604,9 +423708,6 @@ const UIKitMessageBoxHoverSlotContent = ()=>{
424604
423708
  externalContent: showHoverText,
424605
423709
  isMustGroupLastAnswerMessage: false
424606
423710
  }) : null,
424607
- isShowComment ? /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentMessage, {
424608
- isMustGroupLastAnswerMessage: false
424609
- }) : null,
424610
423711
  isShowDelete ? /*#__PURE__*/ (0,jsx_runtime.jsx)(delete_message_DeleteMessage, {}) : null,
424611
423712
  isShowQuote ? /*#__PURE__*/ (0,jsx_runtime.jsx)(QuoteMessage, {}) : null
424612
423713
  ]
@@ -424709,9 +423810,6 @@ const ChatMessageFooterContent = ()=>{
424709
423810
  isUseExternalContent: true,
424710
423811
  externalContent: lastMessageText
424711
423812
  }, "copy"),
424712
- !!lastMessageText && /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentMessage, {
424713
- className: buttonClass
424714
- }, "comment"),
424715
423813
  isShowDelete && /*#__PURE__*/ (0,jsx_runtime.jsx)(delete_message_DeleteMessage, {
424716
423814
  className: classnames_default()(buttonClass)
424717
423815
  }, "delete"),
@@ -425235,154 +424333,6 @@ const useBgBackgroundPlugin = ()=>{
425235
424333
  };
425236
424334
  };
425237
424335
 
425238
- ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/comment-provider.tsx
425239
- /*
425240
- * Copyright 2025 coze-dev Authors
425241
- *
425242
- * Licensed under the Apache License, Version 2.0 (the "License");
425243
- * you may not use this file except in compliance with the License.
425244
- * You may obtain a copy of the License at
425245
- *
425246
- * http://www.apache.org/licenses/LICENSE-2.0
425247
- *
425248
- * Unless required by applicable law or agreed to in writing, software
425249
- * distributed under the License is distributed on an "AS IS" BASIS,
425250
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
425251
- * See the License for the specific language governing permissions and
425252
- * limitations under the License.
425253
- */
425254
-
425255
-
425256
-
425257
-
425258
-
425259
-
425260
- /**
425261
- * 从消息对象中提取评论所需的参数
425262
- */ function extractMessageParamsForBuilderChat(message, chatConfig, conversationIdFromContext) {
425263
- var _msg_extra_info, _msg_extra_info1, _msg_extra_info2, _msg_extra_info3, _msg_extra_info4, _chatConfig_appInfo;
425264
- if (!message || typeof message !== 'object') {
425265
- return null;
425266
- }
425267
- const msg = message;
425268
- // 从 extra_info 中提取
425269
- const chatId = ((_msg_extra_info = msg.extra_info) === null || _msg_extra_info === void 0 ? void 0 : _msg_extra_info.chat_id) || ((_msg_extra_info1 = msg.extra_info) === null || _msg_extra_info1 === void 0 ? void 0 : _msg_extra_info1.coze_api_chat_id) || ((_msg_extra_info2 = msg.extra_info) === null || _msg_extra_info2 === void 0 ? void 0 : _msg_extra_info2.conversation_id) || msg.message_id || msg.reply_id;
425270
- // conversationId 可以从多个地方获取(按优先级):
425271
- // 1. conversationIdFromContext (从 chat area context 获取,最优先)
425272
- // 2. extra_info.conversation_id
425273
- // 3. section_id (作为 fallback,但通常 section_id 不等于 conversation_id)
425274
- // 4. reply_id (最后的 fallback)
425275
- const conversationId = conversationIdFromContext || ((_msg_extra_info3 = msg.extra_info) === null || _msg_extra_info3 === void 0 ? void 0 : _msg_extra_info3.conversation_id) || msg.section_id || msg.reply_id;
425276
- // 从 chatConfig 中获取 app_id
425277
- const appId = ((_msg_extra_info4 = msg.extra_info) === null || _msg_extra_info4 === void 0 ? void 0 : _msg_extra_info4.app_id) || (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo = chatConfig.appInfo) === null || _chatConfig_appInfo === void 0 ? void 0 : _chatConfig_appInfo.appId) || (chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.bot_id) || '';
425278
- if (!chatId || !conversationId || !appId) {
425279
- return null;
425280
- }
425281
- return {
425282
- chatId: String(chatId),
425283
- conversationId: String(conversationId),
425284
- appId: String(appId)
425285
- };
425286
- }
425287
- /**
425288
- * 使用 fetch 直接调用评论 API(绕过 CozeAPI 的响应拦截器)
425289
- */ async function requestCommentApi(config, endpoint) {
425290
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
425291
- const url = `${config.apiUrl}${endpoint}`;
425292
- const response = await fetch(url, {
425293
- ...options,
425294
- headers: {
425295
- 'Content-Type': 'application/json',
425296
- Authorization: `Bearer ${config.token}`,
425297
- ...options.headers
425298
- }
425299
- });
425300
- const data = await response.json();
425301
- if (!response.ok) {
425302
- const error = data;
425303
- throw new Error(error.message || `HTTP error! status: ${response.status}`);
425304
- }
425305
- return data;
425306
- }
425307
- /**
425308
- * 创建评论
425309
- */ async function createCommentWithFetch(apiUrl, token, params) {
425310
- return requestCommentApi({
425311
- apiUrl,
425312
- token
425313
- }, '/api/workflow_api/comment/create', {
425314
- method: 'POST',
425315
- body: JSON.stringify(params)
425316
- });
425317
- }
425318
- /**
425319
- * 查询评论列表
425320
- */ async function getCommentsByChatIDWithFetch(apiUrl, token, params) {
425321
- return requestCommentApi({
425322
- apiUrl,
425323
- token
425324
- }, '/api/workflow_api/comment/list', {
425325
- method: 'POST',
425326
- body: JSON.stringify(params)
425327
- });
425328
- }
425329
- /**
425330
- * 获取评论枚举值
425331
- */ async function getCommentEnumsWithFetch(apiUrl, token) {
425332
- return requestCommentApi({
425333
- apiUrl,
425334
- token
425335
- }, '/api/workflow_api/comment/enums', {
425336
- method: 'GET'
425337
- });
425338
- }
425339
- /**
425340
- * 取消评论
425341
- */ async function cancelCommentWithFetch(apiUrl, token, params) {
425342
- return requestCommentApi({
425343
- apiUrl,
425344
- token
425345
- }, '/api/workflow_api/comment/cancel', {
425346
- method: 'POST',
425347
- body: JSON.stringify(params)
425348
- });
425349
- }
425350
- /**
425351
- * 为 BuilderChat 提供评论功能的 Provider
425352
- */ const BuilderChatCommentProvider = (param)=>{
425353
- let { children } = param;
425354
- const { chatConfig } = context_useChatAppProps();
425355
- const { token, apiUrl } = context_useChatAppStore(shallow_useShallow((s)=>({
425356
- token: s.token,
425357
- apiUrl: s.apiUrl
425358
- })));
425359
- const { useGlobalInitStore } = use_chat_area_context_useChatAreaStoreSet();
425360
- const conversationIdFromStore = useGlobalInitStore((state)=>state.conversationId);
425361
- const commentContextValue = (0,react.useMemo)(()=>{
425362
- if (!token || !apiUrl) {
425363
- return {};
425364
- }
425365
- return {
425366
- commentApiService: {
425367
- createComment: async (params)=>createCommentWithFetch(apiUrl, token, params),
425368
- getCommentsByChatID: async (params)=>getCommentsByChatIDWithFetch(apiUrl, token, params),
425369
- getCommentEnums: async ()=>getCommentEnumsWithFetch(apiUrl, token),
425370
- cancelComment: async (params)=>cancelCommentWithFetch(apiUrl, token, params)
425371
- },
425372
- extractMessageParams: (message, conversationIdFromContext)=>extractMessageParamsForBuilderChat(message, chatConfig, conversationIdFromContext || conversationIdFromStore || undefined)
425373
- };
425374
- }, [
425375
- token,
425376
- apiUrl,
425377
- chatConfig,
425378
- conversationIdFromStore
425379
- ]);
425380
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentProvider, {
425381
- value: commentContextValue,
425382
- children: children
425383
- });
425384
- };
425385
-
425386
424336
  ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/chat-provider.tsx
425387
424337
  /*
425388
424338
  * Copyright 2025 coze-dev Authors
@@ -425422,7 +424372,6 @@ const useBgBackgroundPlugin = ()=>{
425422
424372
 
425423
424373
 
425424
424374
 
425425
-
425426
424375
 
425427
424376
 
425428
424377
  const ChatProviderFuncComp = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
@@ -425730,11 +424679,9 @@ const ChatProviderImpl = (param)=>{
425730
424679
  ],
425731
424680
  showBackground: isShowBackground,
425732
424681
  enableDragUpload: false,
425733
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(BuilderChatCommentProvider, {
425734
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ChatProviderFuncComp, {
425735
- ref: refChatFunc,
425736
- children: children
425737
- })
424682
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ChatProviderFuncComp, {
424683
+ ref: refChatFunc,
424684
+ children: children
425738
424685
  })
425739
424686
  });
425740
424687
  };
@@ -437875,6 +436822,31 @@ var header_pc_index_module_update = injectStylesIntoStyleTag_default()(header_pc
437875
436822
 
437876
436823
 
437877
436824
 
436825
+ const convertAppResponseToConversation = (param)=>{
436826
+ let { res, isAppType, currentConversationInfo, renameInputValue } = param;
436827
+ if (isAppType && 'conversation_id' in res.data) {
436828
+ const responseData = res.data;
436829
+ return {
436830
+ id: responseData.conversation_id || responseData.id || currentConversationInfo.id,
436831
+ name: responseData.conversation_name || responseData.name || renameInputValue.trim(),
436832
+ title: responseData.title || renameInputValue.trim(),
436833
+ created_at: responseData.created_at ? Math.floor(responseData.created_at / 1000) : currentConversationInfo.created_at || Math.floor(Date.now() / 1000),
436834
+ updated_at: responseData.updated_at ? Math.floor(responseData.updated_at / 1000) : Math.floor(Date.now() / 1000),
436835
+ last_section_id: responseData.last_section_id || currentConversationInfo.last_section_id || '',
436836
+ meta_data: responseData.meta_data || currentConversationInfo.meta_data || {},
436837
+ sort: conversations_ConversationSort.Today
436838
+ };
436839
+ }
436840
+ const data = res.data;
436841
+ const result = {
436842
+ ...data,
436843
+ created_at: data.created_at || currentConversationInfo.created_at || Math.floor(Date.now() / 1000),
436844
+ updated_at: data.updated_at || Math.floor(Date.now() / 1000),
436845
+ meta_data: data.meta_data || currentConversationInfo.meta_data || {},
436846
+ sort: conversations_ConversationSort.Today
436847
+ };
436848
+ return result;
436849
+ };
437878
436850
  const ChatHeader = (param)=>{
437879
436851
  let { iconUrl = coze_logo_namespaceObject, title = 'Coze Bot', extra, theme, isShowConversations, isNeedLogo = true } = param;
437880
436852
  const { headerTopLeftOps } = useChatOpInfo();
@@ -437891,6 +436863,8 @@ const ChatHeader = (param)=>{
437891
436863
  const [isRenameLoading, setIsRenameLoading] = (0,react.useState)(false);
437892
436864
  // 使用 useMemo 计算显示文本,确保 title 变化时能及时更新
437893
436865
  const conversationId = currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.id;
436866
+ const conversationName = currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.name;
436867
+ const conversationTitle = currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.title;
437894
436868
  const displayTitle = (0,react.useMemo)(()=>{
437895
436869
  if (conversationId === '') {
437896
436870
  return title;
@@ -437903,6 +436877,8 @@ const ChatHeader = (param)=>{
437903
436877
  return getConversationDisplayName(conversationItem) || title;
437904
436878
  }, [
437905
436879
  conversationId,
436880
+ conversationName,
436881
+ conversationTitle,
437906
436882
  currentConversationInfo,
437907
436883
  title
437908
436884
  ]);
@@ -437911,9 +436887,9 @@ const ChatHeader = (param)=>{
437911
436887
  if (!(currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.id) || currentConversationInfo.id === '') {
437912
436888
  return; // 空会话不能重命名
437913
436889
  }
437914
- const isAppType = chatType === client_ChatType.APP;
437915
436890
  const conversationWithTitle = currentConversationInfo;
437916
- const displayName = isAppType ? conversationWithTitle.title || currentConversationInfo.name || '' : currentConversationInfo.name || conversationWithTitle.title || '';
436891
+ // 使用 getConversationDisplayName 处理 UUID 情况,如果是 UUID 则显示"新创建的会话"
436892
+ const displayName = getConversationDisplayName(conversationWithTitle);
437917
436893
  setRenameInputValue(displayName);
437918
436894
  setIsRenameModalVisible(true);
437919
436895
  };
@@ -437939,25 +436915,12 @@ const ChatHeader = (param)=>{
437939
436915
  return;
437940
436916
  }
437941
436917
  // 转换 App 模式返回的数据结构为标准 Conversation 格式
437942
- let updatedConversation;
437943
- if (isAppType && 'conversation_id' in res.data) {
437944
- const responseData = res.data;
437945
- updatedConversation = {
437946
- id: responseData.conversation_id || responseData.id || currentConversationInfo.id,
437947
- name: responseData.conversation_name || responseData.name || renameInputValue.trim(),
437948
- title: responseData.title || renameInputValue.trim(),
437949
- created_at: responseData.created_at ? Math.floor(responseData.created_at / 1000) : currentConversationInfo.created_at || Math.floor(Date.now() / 1000),
437950
- updated_at: responseData.updated_at ? Math.floor(responseData.updated_at / 1000) : Math.floor(Date.now() / 1000),
437951
- last_section_id: responseData.last_section_id || currentConversationInfo.last_section_id || '',
437952
- meta_data: responseData.meta_data || currentConversationInfo.meta_data || {},
437953
- sort: conversations_ConversationSort.Today
437954
- };
437955
- } else {
437956
- updatedConversation = {
437957
- ...res.data,
437958
- sort: conversations_ConversationSort.Today
437959
- };
437960
- }
436918
+ const updatedConversation = convertAppResponseToConversation({
436919
+ res,
436920
+ isAppType,
436921
+ currentConversationInfo,
436922
+ renameInputValue
436923
+ });
437961
436924
  await updateConversations([
437962
436925
  updatedConversation
437963
436926
  ], 'update');
@@ -438146,6 +437109,8 @@ const ChatHeaderMobile = (param)=>{
438146
437109
  const [isRenameLoading, setIsRenameLoading] = (0,react.useState)(false);
438147
437110
  // 使用 useMemo 计算显示文本,确保 title 变化时能及时更新
438148
437111
  const conversationId = currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.id;
437112
+ const conversationName = currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.name;
437113
+ const conversationTitle = currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.title;
438149
437114
  const displayTitle = (0,react.useMemo)(()=>{
438150
437115
  if (conversationId === '') {
438151
437116
  return title;
@@ -438158,6 +437123,8 @@ const ChatHeaderMobile = (param)=>{
438158
437123
  return getConversationDisplayName(conversationItem) || title;
438159
437124
  }, [
438160
437125
  conversationId,
437126
+ conversationName,
437127
+ conversationTitle,
438161
437128
  currentConversationInfo,
438162
437129
  title
438163
437130
  ]);
@@ -438166,9 +437133,9 @@ const ChatHeaderMobile = (param)=>{
438166
437133
  if (!(currentConversationInfo === null || currentConversationInfo === void 0 ? void 0 : currentConversationInfo.id) || currentConversationInfo.id === '') {
438167
437134
  return; // 空会话不能重命名
438168
437135
  }
438169
- const isAppType = chatType === client_ChatType.APP;
438170
437136
  const conversationWithTitle = currentConversationInfo;
438171
- const displayName = isAppType ? conversationWithTitle.title || currentConversationInfo.name || '' : currentConversationInfo.name || conversationWithTitle.title || '';
437137
+ // 使用 getConversationDisplayName 处理 UUID 情况,如果是 UUID 则显示"新创建的会话"
437138
+ const displayName = getConversationDisplayName(conversationWithTitle);
438172
437139
  setRenameInputValue(displayName);
438173
437140
  setIsRenameModalVisible(true);
438174
437141
  };
@@ -440283,169 +439250,6 @@ const BuilderChatWeb = /*#__PURE__*/ (0,react.forwardRef)((props, ref)=>{
440283
439250
 
440284
439251
  const BuilderChat = BuilderChatWeb;
440285
439252
 
440286
- ;// CONCATENATED MODULE: ./src/util/extract-message-params.ts
440287
- /*
440288
- * Copyright 2025 coze-dev Authors
440289
- *
440290
- * Licensed under the Apache License, Version 2.0 (the "License");
440291
- * you may not use this file except in compliance with the License.
440292
- * You may obtain a copy of the License at
440293
- *
440294
- * http://www.apache.org/licenses/LICENSE-2.0
440295
- *
440296
- * Unless required by applicable law or agreed to in writing, software
440297
- * distributed under the License is distributed on an "AS IS" BASIS,
440298
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440299
- * See the License for the specific language governing permissions and
440300
- * limitations under the License.
440301
- */ /**
440302
- * 从消息对象中提取评论所需的参数
440303
- */ /* eslint-disable complexity -- 需要处理多个可选字段的提取逻辑 */ function extract_message_params_extractMessageParams(message, client, conversationIdFromContext) {
440304
- var _msg_extra_info, _msg_extra_info1, _msg_extra_info2, _msg_extra_info3, _msg_extra_info4, _client_options_config_appInfo, _client_options_config, _client_options, _client_options_config1, _client_options1;
440305
- if (!message || typeof message !== 'object') {
440306
- return null;
440307
- }
440308
- const msg = message;
440309
- // 从 extra_info 中提取
440310
- const chatId = ((_msg_extra_info = msg.extra_info) === null || _msg_extra_info === void 0 ? void 0 : _msg_extra_info.chat_id) || ((_msg_extra_info1 = msg.extra_info) === null || _msg_extra_info1 === void 0 ? void 0 : _msg_extra_info1.coze_api_chat_id) || ((_msg_extra_info2 = msg.extra_info) === null || _msg_extra_info2 === void 0 ? void 0 : _msg_extra_info2.conversation_id) || msg.message_id || msg.reply_id;
440311
- // conversationId 可以从多个地方获取(按优先级):
440312
- // 1. conversationIdFromContext (从 chat area context 获取,最优先)
440313
- // 2. extra_info.conversation_id
440314
- // 3. section_id (作为 fallback,但通常 section_id 不等于 conversation_id)
440315
- // 4. reply_id (最后的 fallback)
440316
- const conversationId = conversationIdFromContext || ((_msg_extra_info3 = msg.extra_info) === null || _msg_extra_info3 === void 0 ? void 0 : _msg_extra_info3.conversation_id) || msg.section_id || msg.reply_id;
440317
- // 从 client options 中获取 app_id
440318
- const appId = ((_msg_extra_info4 = msg.extra_info) === null || _msg_extra_info4 === void 0 ? void 0 : _msg_extra_info4.app_id) || ((_client_options = client.options) === null || _client_options === void 0 ? void 0 : (_client_options_config = _client_options.config) === null || _client_options_config === void 0 ? void 0 : (_client_options_config_appInfo = _client_options_config.appInfo) === null || _client_options_config_appInfo === void 0 ? void 0 : _client_options_config_appInfo.appId) || ((_client_options1 = client.options) === null || _client_options1 === void 0 ? void 0 : (_client_options_config1 = _client_options1.config) === null || _client_options_config1 === void 0 ? void 0 : _client_options_config1.botId) || '';
440319
- if (!chatId || !conversationId || !appId) {
440320
- return null;
440321
- }
440322
- return {
440323
- chatId: String(chatId),
440324
- conversationId: String(conversationId),
440325
- appId: String(appId)
440326
- };
440327
- }
440328
-
440329
- ;// CONCATENATED MODULE: ./src/services/comment-api.ts
440330
- /*
440331
- * Copyright 2025 coze-dev Authors
440332
- *
440333
- * Licensed under the Apache License, Version 2.0 (the "License");
440334
- * you may not use this file except in compliance with the License.
440335
- * You may obtain a copy of the License at
440336
- *
440337
- * http://www.apache.org/licenses/LICENSE-2.0
440338
- *
440339
- * Unless required by applicable law or agreed to in writing, software
440340
- * distributed under the License is distributed on an "AS IS" BASIS,
440341
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440342
- * See the License for the specific language governing permissions and
440343
- * limitations under the License.
440344
- */
440345
- /**
440346
- * 获取认证 token
440347
- */ async function comment_api_getAuthToken(client) {
440348
- try {
440349
- var _client_authClient_options_auth_onRefreshToken, _client_authClient_options_auth;
440350
- const token = await ((_client_authClient_options_auth = client.authClient.options.auth) === null || _client_authClient_options_auth === void 0 ? void 0 : (_client_authClient_options_auth_onRefreshToken = _client_authClient_options_auth.onRefreshToken) === null || _client_authClient_options_auth_onRefreshToken === void 0 ? void 0 : _client_authClient_options_auth_onRefreshToken.call(_client_authClient_options_auth, ''));
440351
- return token || null;
440352
- } catch (error) {
440353
- console.error('[Comment API] Failed to get auth token:', error);
440354
- return null;
440355
- }
440356
- }
440357
- /**
440358
- * 发起 API 请求
440359
- */ async function comment_api_request(client, endpoint) {
440360
- let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
440361
- const token = await comment_api_getAuthToken(client);
440362
- if (!token) {
440363
- throw new Error('Authentication token is required');
440364
- }
440365
- const url = `${client.apiUrl}${endpoint}`;
440366
- const response = await fetch(url, {
440367
- ...options,
440368
- headers: {
440369
- 'Content-Type': 'application/json',
440370
- Authorization: `Bearer ${token}`,
440371
- ...options.headers
440372
- }
440373
- });
440374
- const data = await response.json();
440375
- if (!response.ok) {
440376
- const error = data;
440377
- throw new Error(error.message || `HTTP error! status: ${response.status}`);
440378
- }
440379
- return data;
440380
- }
440381
- /**
440382
- * 创建评论(点赞/点踩)
440383
- */ async function createComment(client, params) {
440384
- return comment_api_request(client, '/api/workflow_api/comment/create', {
440385
- method: 'POST',
440386
- body: JSON.stringify(params)
440387
- });
440388
- }
440389
- /**
440390
- * 查询评论列表(支持单个或批量chat_id)
440391
- */ async function getCommentsByChatID(client, params) {
440392
- return comment_api_request(client, '/api/workflow_api/comment/list', {
440393
- method: 'POST',
440394
- body: JSON.stringify(params)
440395
- });
440396
- }
440397
- /**
440398
- * 获取评论相关枚举值
440399
- */ async function getCommentEnums(client) {
440400
- return comment_api_request(client, '/api/workflow_api/comment/enums', {
440401
- method: 'GET'
440402
- });
440403
- }
440404
- /**
440405
- * 取消评论(取消点赞/点踩)
440406
- */ async function cancelComment(client, params) {
440407
- return comment_api_request(client, '/api/workflow_api/comment/cancel', {
440408
- method: 'POST',
440409
- body: JSON.stringify(params)
440410
- });
440411
- }
440412
-
440413
- ;// CONCATENATED MODULE: ./src/components/comment/comment-provider.tsx
440414
- /*
440415
- * Copyright 2025 coze-dev Authors
440416
- *
440417
- * Licensed under the Apache License, Version 2.0 (the "License");
440418
- * you may not use this file except in compliance with the License.
440419
- * You may obtain a copy of the License at
440420
- *
440421
- * http://www.apache.org/licenses/LICENSE-2.0
440422
- *
440423
- * Unless required by applicable law or agreed to in writing, software
440424
- * distributed under the License is distributed on an "AS IS" BASIS,
440425
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440426
- * See the License for the specific language governing permissions and
440427
- * limitations under the License.
440428
- */
440429
-
440430
-
440431
-
440432
- const CommentProviderWrapper = (param)=>{
440433
- let { client, children } = param;
440434
- const commentContextValue = {
440435
- commentApiService: {
440436
- createComment: async (params)=>createComment(client, params),
440437
- getCommentsByChatID: async (params)=>getCommentsByChatID(client, params),
440438
- getCommentEnums: async ()=>getCommentEnums(client),
440439
- cancelComment: async (params)=>cancelComment(client, params)
440440
- },
440441
- extractMessageParams: (message, conversationIdFromContext)=>extract_message_params_extractMessageParams(message, client, conversationIdFromContext)
440442
- };
440443
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentProvider, {
440444
- value: commentContextValue,
440445
- children: children
440446
- });
440447
- };
440448
-
440449
439253
  // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].use[2]!../../../../../common/temp/default/node_modules/.pnpm/less-loader@11.1.4_less@4.4.2_webpack@5.91.0/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[7].use[3]!./src/components/widget/non-iframe-app/index.module.less
440450
439254
  var non_iframe_app_index_module = __webpack_require__(81562);
440451
439255
  ;// CONCATENATED MODULE: ./src/components/widget/non-iframe-app/index.module.less
@@ -440496,7 +439300,6 @@ var non_iframe_app_index_module_update = injectStylesIntoStyleTag_default()(non_
440496
439300
 
440497
439301
 
440498
439302
 
440499
-
440500
439303
  const NonIframeApp = (param)=>{
440501
439304
  let { client, onImageClick, uiKitCustomComponents, contentBox } = param;
440502
439305
  var _options_ui_header, _options_ui, _options_ui_chatBot, _options_ui1, _options_ui_chatBot1, _options_ui2, _options_ui_chatBot2, _options_ui3, _options_ui_chatBot3, _options_ui4, _options_ui_chatBot4, _options_ui5, _options_ui_chatBot5, _options_ui6, _options_ui_chatBot6, _options_ui7, _options_ui_header1, _options_ui8, _options_ui_base, _options_ui9, _options_ui10, _options_ui11, _options_ui_chatBot7, _options_ui12, _options_ui_input, _options_ui13, _options_ui_input1, _options_ui14, _options_ui_input2, _options_ui15, _options_ui_input3, _options_ui16, _options_ui_input4, _options_ui17, _options_ui_input5, _options_ui18, _options_ui19, _options_ui20, _options_ui21, _options_config_appInfo, _options_config, _options_config_appInfo1, _options_config1, _options_config_appInfo2, _options_config2, _options_config_appInfo3, _options_config3, _options_config_appInfo4, _options_config4, _options_ui_base1, _options_ui22, _options_config_appInfo5, _options_userInfo, _options_userInfo1, _options_userInfo2, _options_auth, _options_auth1;
@@ -440538,44 +439341,41 @@ const NonIframeApp = (param)=>{
440538
439341
  onboarding: options === null || options === void 0 ? void 0 : (_options_ui20 = options.ui) === null || _options_ui20 === void 0 ? void 0 : _options_ui20.onboarding,
440539
439342
  getMessageRenderIndex: options === null || options === void 0 ? void 0 : (_options_ui21 = options.ui) === null || _options_ui21 === void 0 ? void 0 : _options_ui21.getMessageRenderIndex
440540
439343
  };
440541
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentProviderWrapper, {
440542
- client: client,
440543
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(BuilderChat, {
440544
- // 传递 apiUrl(需要在 BuilderChat props 中支持)
440545
- apiUrl: apiUrl,
440546
- workflow: {
440547
- id: options === null || options === void 0 ? void 0 : (_options_config = options.config) === null || _options_config === void 0 ? void 0 : (_options_config_appInfo = _options_config.appInfo) === null || _options_config_appInfo === void 0 ? void 0 : _options_config_appInfo.workflowId,
440548
- // 直接传递引用,不创建副本,这样参数更新会立即生效
440549
- parameters: (options === null || options === void 0 ? void 0 : (_options_config1 = options.config) === null || _options_config1 === void 0 ? void 0 : (_options_config_appInfo1 = _options_config1.appInfo) === null || _options_config_appInfo1 === void 0 ? void 0 : _options_config_appInfo1.parameters) || {}
440550
- },
440551
- project: {
440552
- type: 'app',
440553
- // 根据 appInfo.draft_mode 设置 mode:draft_mode: true -> 'draft', draft_mode: false -> 'websdk'
440554
- // 如果没有设置 draft_mode,则根据环境判断
440555
- mode: (options === null || options === void 0 ? void 0 : (_options_config2 = options.config) === null || _options_config2 === void 0 ? void 0 : (_options_config_appInfo2 = _options_config2.appInfo) === null || _options_config_appInfo2 === void 0 ? void 0 : _options_config_appInfo2.draft_mode) !== undefined ? options.config.appInfo.draft_mode ? 'draft' : 'websdk' : false ? 0 : 'websdk',
440556
- id: (options === null || options === void 0 ? void 0 : (_options_config3 = options.config) === null || _options_config3 === void 0 ? void 0 : (_options_config_appInfo3 = _options_config3.appInfo) === null || _options_config_appInfo3 === void 0 ? void 0 : _options_config_appInfo3.appId) || '',
440557
- conversationName: options === null || options === void 0 ? void 0 : (_options_config4 = options.config) === null || _options_config4 === void 0 ? void 0 : (_options_config_appInfo4 = _options_config4.appInfo) === null || _options_config_appInfo4 === void 0 ? void 0 : _options_config_appInfo4.conversationName,
440558
- layout: options === null || options === void 0 ? void 0 : (_options_ui22 = options.ui) === null || _options_ui22 === void 0 ? void 0 : (_options_ui_base1 = _options_ui22.base) === null || _options_ui_base1 === void 0 ? void 0 : _options_ui_base1.layout,
440559
- version: options === null || options === void 0 ? void 0 : (_options_config_appInfo5 = options.config.appInfo) === null || _options_config_appInfo5 === void 0 ? void 0 : _options_config_appInfo5.version
440560
- },
440561
- userInfo: {
440562
- url: (options === null || options === void 0 ? void 0 : (_options_userInfo = options.userInfo) === null || _options_userInfo === void 0 ? void 0 : _options_userInfo.url) || '',
440563
- nickname: (options === null || options === void 0 ? void 0 : (_options_userInfo1 = options.userInfo) === null || _options_userInfo1 === void 0 ? void 0 : _options_userInfo1.nickname) || '',
440564
- id: (options === null || options === void 0 ? void 0 : (_options_userInfo2 = options.userInfo) === null || _options_userInfo2 === void 0 ? void 0 : _options_userInfo2.id) || ''
440565
- },
440566
- areaUi: areaUi,
440567
- auth: {
440568
- type: 'external',
440569
- token: options === null || options === void 0 ? void 0 : (_options_auth = options.auth) === null || _options_auth === void 0 ? void 0 : _options_auth.token,
440570
- refreshToken: options === null || options === void 0 ? void 0 : (_options_auth1 = options.auth) === null || _options_auth1 === void 0 ? void 0 : _options_auth1.onRefreshToken
440571
- },
440572
- eventCallbacks: {
440573
- onImageClick,
440574
- onThemeChange: setThemeType
440575
- },
440576
- uiKitCustomComponents: uiKitCustomComponents,
440577
- contentBox: contentBox
440578
- })
439344
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(BuilderChat, {
439345
+ // 传递 apiUrl(需要在 BuilderChat props 中支持)
439346
+ apiUrl: apiUrl,
439347
+ workflow: {
439348
+ id: options === null || options === void 0 ? void 0 : (_options_config = options.config) === null || _options_config === void 0 ? void 0 : (_options_config_appInfo = _options_config.appInfo) === null || _options_config_appInfo === void 0 ? void 0 : _options_config_appInfo.workflowId,
439349
+ // 直接传递引用,不创建副本,这样参数更新会立即生效
439350
+ parameters: (options === null || options === void 0 ? void 0 : (_options_config1 = options.config) === null || _options_config1 === void 0 ? void 0 : (_options_config_appInfo1 = _options_config1.appInfo) === null || _options_config_appInfo1 === void 0 ? void 0 : _options_config_appInfo1.parameters) || {}
439351
+ },
439352
+ project: {
439353
+ type: 'app',
439354
+ // 根据 appInfo.draft_mode 设置 mode:draft_mode: true -> 'draft', draft_mode: false -> 'websdk'
439355
+ // 如果没有设置 draft_mode,则根据环境判断
439356
+ mode: (options === null || options === void 0 ? void 0 : (_options_config2 = options.config) === null || _options_config2 === void 0 ? void 0 : (_options_config_appInfo2 = _options_config2.appInfo) === null || _options_config_appInfo2 === void 0 ? void 0 : _options_config_appInfo2.draft_mode) !== undefined ? options.config.appInfo.draft_mode ? 'draft' : 'websdk' : false ? 0 : 'websdk',
439357
+ id: (options === null || options === void 0 ? void 0 : (_options_config3 = options.config) === null || _options_config3 === void 0 ? void 0 : (_options_config_appInfo3 = _options_config3.appInfo) === null || _options_config_appInfo3 === void 0 ? void 0 : _options_config_appInfo3.appId) || '',
439358
+ conversationName: options === null || options === void 0 ? void 0 : (_options_config4 = options.config) === null || _options_config4 === void 0 ? void 0 : (_options_config_appInfo4 = _options_config4.appInfo) === null || _options_config_appInfo4 === void 0 ? void 0 : _options_config_appInfo4.conversationName,
439359
+ layout: options === null || options === void 0 ? void 0 : (_options_ui22 = options.ui) === null || _options_ui22 === void 0 ? void 0 : (_options_ui_base1 = _options_ui22.base) === null || _options_ui_base1 === void 0 ? void 0 : _options_ui_base1.layout,
439360
+ version: options === null || options === void 0 ? void 0 : (_options_config_appInfo5 = options.config.appInfo) === null || _options_config_appInfo5 === void 0 ? void 0 : _options_config_appInfo5.version
439361
+ },
439362
+ userInfo: {
439363
+ url: (options === null || options === void 0 ? void 0 : (_options_userInfo = options.userInfo) === null || _options_userInfo === void 0 ? void 0 : _options_userInfo.url) || '',
439364
+ nickname: (options === null || options === void 0 ? void 0 : (_options_userInfo1 = options.userInfo) === null || _options_userInfo1 === void 0 ? void 0 : _options_userInfo1.nickname) || '',
439365
+ id: (options === null || options === void 0 ? void 0 : (_options_userInfo2 = options.userInfo) === null || _options_userInfo2 === void 0 ? void 0 : _options_userInfo2.id) || ''
439366
+ },
439367
+ areaUi: areaUi,
439368
+ auth: {
439369
+ type: 'external',
439370
+ token: options === null || options === void 0 ? void 0 : (_options_auth = options.auth) === null || _options_auth === void 0 ? void 0 : _options_auth.token,
439371
+ refreshToken: options === null || options === void 0 ? void 0 : (_options_auth1 = options.auth) === null || _options_auth1 === void 0 ? void 0 : _options_auth1.onRefreshToken
439372
+ },
439373
+ eventCallbacks: {
439374
+ onImageClick,
439375
+ onThemeChange: setThemeType
439376
+ },
439377
+ uiKitCustomComponents: uiKitCustomComponents,
439378
+ contentBox: contentBox
440579
439379
  });
440580
439380
  };
440581
439381