@lvce-editor/chat-view 1.10.0 → 1.12.0

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.
@@ -1200,7 +1200,7 @@ i18nString('You');
1200
1200
  i18nString('Assistant');
1201
1201
  const composePlaceholder = i18nString('Type your message. Enter to send, Shift+Enter for newline.');
1202
1202
  const sendMessage = i18nString('Send message');
1203
- const send = i18nString('Send');
1203
+ i18nString('Send');
1204
1204
  const deleteChatSession$1 = i18nString('Delete chat session');
1205
1205
  const defaultSessionTitle = i18nString('Chat 1');
1206
1206
  const dummyChatA = i18nString('Dummy Chat A');
@@ -1309,8 +1309,8 @@ const diffValue = (oldState, newState) => {
1309
1309
  return newState.inputSource !== 'script';
1310
1310
  };
1311
1311
 
1312
- const modules = [isEqual, diffValue, diffFocus, isEqual$1];
1313
- const numbers = [RenderIncremental, RenderValue, RenderFocus, RenderCss];
1312
+ const modules = [isEqual, diffValue, diffFocus, isEqual$1, diffFocus];
1313
+ const numbers = [RenderIncremental, RenderValue, RenderFocus, RenderCss, RenderFocusContext];
1314
1314
 
1315
1315
  const diff = (oldState, newState) => {
1316
1316
  const diffResult = [];
@@ -2115,21 +2115,22 @@ const getListIndex = (state, eventX, eventY) => {
2115
2115
  return Math.floor(listY / itemHeight);
2116
2116
  };
2117
2117
 
2118
- const handleClickList = async (state, eventX, eventY) => {
2118
+ const selectListIndex = async (state, index) => {
2119
2119
  const {
2120
2120
  sessions
2121
2121
  } = state;
2122
- const index = getListIndex(state, eventX, eventY);
2123
- if (index < 0) {
2122
+ if (index < 0 || index >= sessions.length) {
2124
2123
  return state;
2125
2124
  }
2126
2125
  const session = sessions[index];
2127
- if (!session) {
2128
- return state;
2129
- }
2130
2126
  return selectSession(state, session.id);
2131
2127
  };
2132
2128
 
2129
+ const handleClickList = async (state, eventX, eventY) => {
2130
+ const index = getListIndex(state, eventX, eventY);
2131
+ return selectListIndex(state, index);
2132
+ };
2133
+
2133
2134
  const CREATE_SESSION = 'create-session';
2134
2135
  const SESSION_PREFIX = 'session:';
2135
2136
  const RENAME_PREFIX = 'session-rename:';
@@ -2520,8 +2521,7 @@ const renderFocus = (oldState, newState) => {
2520
2521
  };
2521
2522
 
2522
2523
  const renderFocusContext = (oldState, newState) => {
2523
- const when = 2344;
2524
- return [SetFocusContext, newState.uid, when];
2524
+ return [SetFocusContext, newState.uid, FocusChatInput];
2525
2525
  };
2526
2526
 
2527
2527
  const ChatActions = 'ChatActions';
@@ -2555,7 +2555,7 @@ const Select = 'Select';
2555
2555
  const Viewlet = 'Viewlet';
2556
2556
  const ChatWelcomeMessage = 'ChatWelcomeMessage';
2557
2557
 
2558
- const HandleContextMenu = 2;
2558
+ const HandleListContextMenu = 2;
2559
2559
  const HandleFocus = 3;
2560
2560
  const HandleInput = 4;
2561
2561
  const HandleClick = 11;
@@ -2579,8 +2579,12 @@ const getModelOptionDOm = (model, selectedModelId) => {
2579
2579
  }, text(model.name)];
2580
2580
  };
2581
2581
 
2582
+ const getSendButtonClassName = isSendDisabled => {
2583
+ return isSendDisabled ? `${Button} ${ButtonPrimary} ${ButtonDisabled}` : `${Button} ${ButtonPrimary}`;
2584
+ };
2585
+
2582
2586
  const getSendButtonDom = isSendDisabled => {
2583
- const sendButtonClassName = isSendDisabled ? `${Button} ${ButtonPrimary} ${ButtonDisabled}` : `${Button} ${ButtonPrimary}`;
2587
+ const sendButtonClassName = getSendButtonClassName(isSendDisabled);
2584
2588
  return [{
2585
2589
  childCount: 1,
2586
2590
  className: sendButtonClassName,
@@ -2590,7 +2594,11 @@ const getSendButtonDom = isSendDisabled => {
2590
2594
  role: Button$2,
2591
2595
  title: sendMessage,
2592
2596
  type: Button$1
2593
- }, text(send)];
2597
+ }, {
2598
+ childCount: 0,
2599
+ class: 'MaskIcon MaskIconSend',
2600
+ type: Div
2601
+ }];
2594
2602
  };
2595
2603
 
2596
2604
  const clampToPercentage = (tokensUsed, tokensMax) => {
@@ -2643,6 +2651,7 @@ const getChatSendAreaDom = (composerValue, models, selectedModelId, usageOvervie
2643
2651
  childCount: 0,
2644
2652
  className: MultilineInputBox,
2645
2653
  name: 'composer',
2654
+ onFocus: HandleFocus,
2646
2655
  onInput: HandleInput,
2647
2656
  placeholder: composePlaceholder,
2648
2657
  rows: 4,
@@ -2662,6 +2671,22 @@ const getChatSendAreaDom = (composerValue, models, selectedModelId, usageOvervie
2662
2671
  }, ...modelOptions, ...(usageOverviewEnabled ? getUsageOverviewDom(tokensUsed, tokensMax) : []), ...getSendButtonDom(isSendDisabled)];
2663
2672
  };
2664
2673
 
2674
+ const getBackButtonVirtualDom = () => {
2675
+ return [{
2676
+ childCount: 1,
2677
+ className: IconButton,
2678
+ name: 'back',
2679
+ onClick: HandleClickBack,
2680
+ role: Button$2,
2681
+ title: backToChats,
2682
+ type: Button$1
2683
+ }, {
2684
+ childCount: 0,
2685
+ className: 'MaskIcon MaskIconArrowLeft',
2686
+ type: Div
2687
+ }];
2688
+ };
2689
+
2665
2690
  const getHeaderActionVirtualDom = item => {
2666
2691
  return [{
2667
2692
  childCount: 1,
@@ -2671,22 +2696,26 @@ const getHeaderActionVirtualDom = item => {
2671
2696
  role: Button$2,
2672
2697
  title: item.title,
2673
2698
  type: Button$1
2674
- }, text(item.icon)];
2699
+ }, {
2700
+ childCount: 0,
2701
+ className: item.icon,
2702
+ type: Div
2703
+ }];
2675
2704
  };
2676
2705
 
2677
2706
  const getChatHeaderActionsDom = () => {
2678
2707
  const items = [{
2679
- icon: '+',
2708
+ icon: 'MaskIcon MaskIconAdd',
2680
2709
  name: 'create-session',
2681
2710
  onClick: HandleClickNew,
2682
2711
  title: newChat
2683
2712
  }, {
2684
- icon: '',
2713
+ icon: 'MaskIcon MaskIconSettingsGear',
2685
2714
  name: 'settings',
2686
2715
  onClick: HandleClickSettings,
2687
2716
  title: settings
2688
2717
  }, {
2689
- icon: '×',
2718
+ icon: 'MaskIcon MaskIconClose',
2690
2719
  name: 'close-chat',
2691
2720
  onClick: HandleClickClose,
2692
2721
  title: closeChat
@@ -2698,22 +2727,6 @@ const getChatHeaderActionsDom = () => {
2698
2727
  }, ...items.flatMap(getHeaderActionVirtualDom)];
2699
2728
  };
2700
2729
 
2701
- const getChatHeaderBackButtonVirtualDom = () => {
2702
- return [{
2703
- childCount: 1,
2704
- className: IconButton,
2705
- name: 'back',
2706
- onClick: HandleClickBack,
2707
- role: Button$2,
2708
- title: backToChats,
2709
- type: Button$1
2710
- }, {
2711
- childCount: 0,
2712
- className: 'MaskIcon MaskIconArrowLeft',
2713
- type: Div
2714
- }];
2715
- };
2716
-
2717
2730
  const getChatHeaderDomDetailMode = selectedSessionTitle => {
2718
2731
  return [{
2719
2732
  childCount: 2,
@@ -2723,7 +2736,7 @@ const getChatHeaderDomDetailMode = selectedSessionTitle => {
2723
2736
  childCount: 2,
2724
2737
  className: ChatName,
2725
2738
  type: Div
2726
- }, ...getChatHeaderBackButtonVirtualDom(), {
2739
+ }, ...getBackButtonVirtualDom(), {
2727
2740
  childCount: 1,
2728
2741
  className: Label,
2729
2742
  type: Span
@@ -2807,7 +2820,7 @@ const getSessionDom = session => {
2807
2820
  childCount: 1,
2808
2821
  className: ChatListItemLabel,
2809
2822
  name: `session:${session.id}`,
2810
- onContextMenu: HandleContextMenu,
2823
+ onContextMenu: HandleListContextMenu,
2811
2824
  tabIndex: 0,
2812
2825
  type: Div
2813
2826
  }, text(session.title), {
@@ -2943,8 +2956,8 @@ const render2 = (uid, diffResult) => {
2943
2956
 
2944
2957
  const renderEventListeners = () => {
2945
2958
  return [{
2946
- name: HandleContextMenu,
2947
- params: ['handleChatListContextMenu', TargetName, ClientX, ClientY],
2959
+ name: HandleListContextMenu,
2960
+ params: ['handleChatListContextMenu', ClientX, ClientY],
2948
2961
  preventDefault: true
2949
2962
  }, {
2950
2963
  name: HandleClick,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-view",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Chat View Worker",
5
5
  "repository": {
6
6
  "type": "git",