@opensumi/ide-ai-native 3.9.1-next-1749022986.0 → 3.9.1-next-1749023860.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.
Files changed (39) hide show
  1. package/lib/browser/components/ChatMentionInput.d.ts.map +1 -1
  2. package/lib/browser/components/ChatMentionInput.js +3 -18
  3. package/lib/browser/components/ChatMentionInput.js.map +1 -1
  4. package/lib/browser/components/ChatReply.js +2 -2
  5. package/lib/browser/components/ChatReply.js.map +1 -1
  6. package/lib/browser/components/components.module.less +8 -30
  7. package/lib/browser/components/mention-input/mention-input.d.ts.map +1 -1
  8. package/lib/browser/components/mention-input/mention-input.js +36 -30
  9. package/lib/browser/components/mention-input/mention-input.js.map +1 -1
  10. package/lib/browser/components/mention-input/mention-input.module.less +1 -0
  11. package/lib/browser/components/mention-input/types.d.ts +0 -13
  12. package/lib/browser/components/mention-input/types.d.ts.map +1 -1
  13. package/lib/browser/components/mention-input/types.js.map +1 -1
  14. package/lib/browser/rules/rules.module.less +0 -1
  15. package/lib/browser/rules/rules.view.js +1 -1
  16. package/lib/browser/rules/rules.view.js.map +1 -1
  17. package/lib/common/model.d.ts +0 -1
  18. package/lib/common/model.d.ts.map +1 -1
  19. package/lib/common/model.js.map +1 -1
  20. package/lib/node/base-language-model.js +1 -2
  21. package/lib/node/base-language-model.js.map +1 -1
  22. package/package.json +25 -25
  23. package/src/browser/components/ChatMentionInput.tsx +4 -26
  24. package/src/browser/components/ChatReply.tsx +4 -4
  25. package/src/browser/components/components.module.less +8 -30
  26. package/src/browser/components/mention-input/mention-input.module.less +1 -0
  27. package/src/browser/components/mention-input/mention-input.tsx +52 -38
  28. package/src/browser/components/mention-input/types.ts +0 -14
  29. package/src/browser/rules/rules.module.less +0 -1
  30. package/src/browser/rules/rules.view.tsx +1 -1
  31. package/src/common/model.ts +0 -1
  32. package/src/node/base-language-model.ts +1 -1
  33. package/lib/browser/components/mention-input/mention-select.d.ts +0 -28
  34. package/lib/browser/components/mention-input/mention-select.d.ts.map +0 -1
  35. package/lib/browser/components/mention-input/mention-select.js +0 -136
  36. package/lib/browser/components/mention-input/mention-select.js.map +0 -1
  37. package/lib/browser/components/mention-input/mention-select.module.less +0 -297
  38. package/src/browser/components/mention-input/mention-select.module.less +0 -297
  39. package/src/browser/components/mention-input/mention-select.tsx +0 -256
@@ -1,297 +0,0 @@
1
- .mention_select {
2
- position: relative;
3
- display: inline-block;
4
-
5
- &.size_small {
6
- .select_trigger {
7
- height: 20px;
8
- padding: 0 6px;
9
- font-size: 12px;
10
- }
11
- }
12
-
13
- &.size_medium {
14
- .select_trigger {
15
- height: 32px;
16
- padding: 0 12px;
17
- font-size: 14px;
18
- }
19
- }
20
-
21
- &.size_large {
22
- .select_trigger {
23
- height: 40px;
24
- padding: 0 16px;
25
- font-size: 16px;
26
- }
27
- }
28
-
29
- &.disabled {
30
- opacity: 0.6;
31
- cursor: not-allowed;
32
-
33
- .select_trigger {
34
- cursor: not-allowed;
35
- background-color: var(--input-background-disabled);
36
- }
37
- }
38
-
39
- .select_trigger {
40
- display: flex;
41
- align-items: center;
42
- justify-content: space-between;
43
- background-color: var(--input-background);
44
- border: 1px solid var(--input-border);
45
- border-radius: 4px;
46
- cursor: pointer;
47
- transition: all 0.2s;
48
- opacity: 0.7;
49
-
50
- &:hover:not(.disabled) {
51
- opacity: 1;
52
- }
53
- }
54
-
55
- .select_content {
56
- flex: 1;
57
- overflow: hidden;
58
- }
59
-
60
- .selected_option {
61
- display: flex;
62
- align-items: center;
63
- gap: 6px;
64
- }
65
-
66
- .option_icon {
67
- flex-shrink: 0;
68
- font-size: 14px;
69
- }
70
-
71
- .option_label {
72
- flex: 1;
73
- white-space: nowrap;
74
- overflow: hidden;
75
- text-overflow: ellipsis;
76
- }
77
-
78
- .option_badge {
79
- display: inline-block;
80
- padding: 2px 6px;
81
- border-radius: 10px;
82
- font-size: 10px;
83
- color: white;
84
- background-color: var(--badge-background);
85
- white-space: nowrap;
86
- }
87
-
88
- .placeholder {
89
- color: var(--input-placeholder-foreground);
90
- }
91
-
92
- .dropdown_arrow {
93
- margin-left: 8px;
94
- transition: transform 0.2s;
95
- color: var(--icon-foreground);
96
-
97
- &.open {
98
- transform: rotate(180deg);
99
- }
100
- }
101
-
102
- .dropdown {
103
- position: absolute;
104
- left: 0;
105
- right: 0;
106
- z-index: 1000;
107
- background-color: var(--editor-background);
108
- border: 1px solid var(--dropdown-border);
109
- border-radius: 6px;
110
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.05);
111
- max-height: 400px;
112
- min-width: 300px;
113
- overflow-y: auto;
114
- padding: 4px;
115
- animation: dropdownFadeIn 0.15s ease-out;
116
-
117
- // 滚动条样式
118
- &::-webkit-scrollbar {
119
- width: 6px;
120
- }
121
-
122
- &::-webkit-scrollbar-track {
123
- background: transparent;
124
- }
125
-
126
- &::-webkit-scrollbar-thumb {
127
- background: var(--scrollbar-thumb);
128
- border-radius: 3px;
129
- transition: background-color 0.2s;
130
- }
131
-
132
- &::-webkit-scrollbar-thumb:hover {
133
- background: var(--scrollbar-thumb-hover);
134
- }
135
- }
136
-
137
- @keyframes dropdownFadeIn {
138
- from {
139
- opacity: 0;
140
- transform: translateY(-4px);
141
- }
142
-
143
- to {
144
- opacity: 1;
145
- transform: translateY(0);
146
- }
147
- }
148
-
149
- .thinking_section {
150
- padding: 8px 12px 4px;
151
- }
152
-
153
- .thinking_toggle {
154
- display: flex;
155
- align-items: center;
156
- gap: 8px;
157
- padding: 6px 0;
158
- cursor: pointer;
159
- border-radius: 4px;
160
-
161
- &:hover {
162
- background-color: var(--list-hover-background);
163
- }
164
- }
165
-
166
- .thinking_icon {
167
- flex-shrink: 0;
168
- color: var(--icon-foreground);
169
-
170
- &.enabled {
171
- color: var(--list-active-selection-foreground);
172
- }
173
- }
174
-
175
- .thinking_label {
176
- font-size: 13px;
177
- color: var(--foreground);
178
- font-weight: 500;
179
- }
180
-
181
- .divider {
182
- height: 1px;
183
- background-color: var(--separator-border);
184
- margin: 8px 0 4px;
185
- }
186
-
187
- // 向上展开(默认)
188
- &.dropdown_up .dropdown {
189
- bottom: 100%;
190
- margin-bottom: 4px;
191
- }
192
-
193
- // 向下展开
194
- &.dropdown_down .dropdown {
195
- top: 100%;
196
- margin-top: 4px;
197
- }
198
-
199
- .option {
200
- padding: 8px 12px;
201
- border-radius: 4px;
202
- cursor: pointer;
203
- transition: all 0.2s;
204
- position: relative;
205
- border: 1px solid transparent;
206
- box-sizing: content-box;
207
- margin-bottom: 4px;
208
- &:last-child {
209
- margin-bottom: 0;
210
- }
211
- &:hover:not(.disabled) {
212
- border-color: var(--dropdown-border);
213
- }
214
-
215
- &.active {
216
- border-color: var(--dropdown-border);
217
- }
218
-
219
- &.selected {
220
- background-color: var(--dropdown-background);
221
-
222
- &::after {
223
- content: '✓';
224
- position: absolute;
225
- top: 50%;
226
- right: 12px;
227
- transform: translateY(-50%);
228
- color: var(--list-active-selection-foreground);
229
- font-weight: bold;
230
- font-size: 14px;
231
- z-index: 1;
232
- }
233
- }
234
-
235
- &.disabled {
236
- opacity: 0.5;
237
- cursor: not-allowed;
238
-
239
- &:hover {
240
- transform: none;
241
- box-shadow: none;
242
- border-color: transparent;
243
- }
244
- }
245
- }
246
-
247
- .option_main {
248
- display: flex;
249
- flex-direction: column;
250
- gap: 6px;
251
- padding-right: 24px;
252
- }
253
-
254
- .option_header {
255
- display: flex;
256
- align-items: center;
257
- justify-content: space-between;
258
- }
259
-
260
- .option_title {
261
- display: flex;
262
- align-items: center;
263
- gap: 8px;
264
- flex: 1;
265
- }
266
-
267
- .option_description {
268
- font-size: 12px;
269
- color: var(--descriptionForeground);
270
- line-height: 1.4;
271
- margin-top: 4px;
272
- }
273
-
274
- .option_tags {
275
- display: flex;
276
- flex-wrap: wrap;
277
- gap: 4px;
278
- margin-top: 6px;
279
- }
280
-
281
- .tag {
282
- display: inline-block;
283
- padding: 2px 6px;
284
- border-radius: 10px;
285
- font-size: 10px;
286
- background-color: var(--badge-background);
287
- color: var(--badge-foreground);
288
- white-space: nowrap;
289
- }
290
-
291
- .status_indicator {
292
- width: 8px;
293
- height: 8px;
294
- border-radius: 50%;
295
- flex-shrink: 0;
296
- }
297
- }
@@ -1,256 +0,0 @@
1
- import cls from 'classnames';
2
- import React, { useEffect, useRef, useState } from 'react';
3
-
4
- import { ClickOutside } from '@opensumi/ide-components/lib/click-outside';
5
- import { Icon, getIcon } from '@opensumi/ide-core-browser/lib/components';
6
-
7
- import styles from './mention-select.module.less';
8
-
9
- export interface ExtendedModelOption {
10
- label: string;
11
- value: string;
12
- icon?: string;
13
- iconClass?: string;
14
- tags?: string[];
15
- features?: string[];
16
- description?: string;
17
- disabled?: boolean;
18
- badge?: string;
19
- badgeColor?: string;
20
- selected?: boolean;
21
- }
22
-
23
- export interface MentionSelectProps {
24
- options: ExtendedModelOption[];
25
- value?: string;
26
- onChange?: (value: string) => void;
27
- placeholder?: string;
28
- disabled?: boolean;
29
- className?: string;
30
- size?: 'small' | 'medium' | 'large';
31
- showThinking?: boolean;
32
- thinkingEnabled?: boolean;
33
- onThinkingChange?: (enabled: boolean) => void;
34
- }
35
-
36
- const ThinkingToggle: React.FC<{
37
- enabled: boolean;
38
- onChange: (enabled: boolean) => void;
39
- }> = ({ enabled, onChange }) => (
40
- <div className={styles.thinking_toggle} onClick={() => onChange(!enabled)}>
41
- <Icon
42
- iconClass={getIcon(enabled ? 'check' : 'circle-outline')}
43
- className={cls(styles.thinking_icon, {
44
- [styles.enabled]: enabled,
45
- })}
46
- />
47
- <span className={styles.thinking_label}>Thinking</span>
48
- </div>
49
- );
50
-
51
- export const MentionSelect: React.FC<MentionSelectProps> = ({
52
- options,
53
- value,
54
- onChange,
55
- placeholder,
56
- disabled = false,
57
- className,
58
- size = 'small',
59
- showThinking = false,
60
- thinkingEnabled = false,
61
- onThinkingChange,
62
- }) => {
63
- const [isOpen, setIsOpen] = useState(false);
64
- const [activeIndex, setActiveIndex] = useState(-1);
65
- const [dropdownDirection, setDropdownDirection] = useState<'up' | 'down'>('up');
66
- const selectRef = useRef<HTMLDivElement>(null);
67
- const dropdownRef = useRef<HTMLDivElement>(null);
68
-
69
- const selectedOption = options.find((option) => option.selected) || options.find((option) => option.value === value);
70
-
71
- const handleToggle = () => {
72
- if (!disabled) {
73
- setIsOpen(!isOpen);
74
- setActiveIndex(-1);
75
- }
76
- };
77
-
78
- const handleSelect = (option: ExtendedModelOption) => {
79
- if (!option.disabled) {
80
- onChange?.(option.value);
81
- setIsOpen(false);
82
- setActiveIndex(-1);
83
- }
84
- };
85
-
86
- const handleKeyDown = (e: React.KeyboardEvent) => {
87
- if (disabled) {
88
- return;
89
- }
90
-
91
- switch (e.key) {
92
- case 'Enter':
93
- case ' ':
94
- e.preventDefault();
95
- if (!isOpen) {
96
- setIsOpen(true);
97
- } else if (activeIndex >= 0) {
98
- handleSelect(options[activeIndex]);
99
- }
100
- break;
101
- case 'Escape':
102
- e.preventDefault();
103
- setIsOpen(false);
104
- setActiveIndex(-1);
105
- break;
106
- case 'ArrowDown':
107
- e.preventDefault();
108
- if (!isOpen) {
109
- setIsOpen(true);
110
- } else {
111
- setActiveIndex((prev) => (prev < options.length - 1 ? prev + 1 : 0));
112
- }
113
- break;
114
- case 'ArrowUp':
115
- e.preventDefault();
116
- if (isOpen) {
117
- setActiveIndex((prev) => (prev > 0 ? prev - 1 : options.length - 1));
118
- }
119
- break;
120
- }
121
- };
122
-
123
- const handleClickOutside = () => {
124
- setIsOpen(false);
125
- setActiveIndex(-1);
126
- };
127
-
128
- useEffect(() => {
129
- if (isOpen && selectRef.current) {
130
- const selectRect = selectRef.current.getBoundingClientRect();
131
- const viewportHeight = window.innerHeight;
132
- const dropdownHeight = Math.min(400, options.length * 60);
133
-
134
- const spaceAbove = selectRect.top;
135
- const spaceBelow = viewportHeight - selectRect.bottom;
136
-
137
- if (spaceAbove < dropdownHeight && spaceBelow > spaceAbove) {
138
- setDropdownDirection('down');
139
- } else {
140
- setDropdownDirection('up');
141
- }
142
- }
143
- }, [isOpen, options.length]);
144
-
145
- useEffect(() => {
146
- if (isOpen && activeIndex >= 0 && dropdownRef.current) {
147
- const activeElement = dropdownRef.current.children[activeIndex] as HTMLElement;
148
- if (activeElement) {
149
- activeElement.scrollIntoView({
150
- behavior: 'smooth',
151
- block: 'nearest',
152
- });
153
- }
154
- }
155
- }, [isOpen, activeIndex]);
156
-
157
- return (
158
- <ClickOutside onOutsideClick={handleClickOutside}>
159
- <div
160
- ref={selectRef}
161
- className={cls(
162
- styles.mention_select,
163
- styles[`size_${size}`],
164
- {
165
- [styles.disabled]: disabled,
166
- [styles.open]: isOpen,
167
- [styles.dropdown_up]: dropdownDirection === 'up',
168
- [styles.dropdown_down]: dropdownDirection === 'down',
169
- },
170
- className,
171
- )}
172
- onClick={handleToggle}
173
- onKeyDown={handleKeyDown}
174
- tabIndex={disabled ? -1 : 0}
175
- role='combobox'
176
- aria-expanded={isOpen}
177
- aria-haspopup='listbox'
178
- >
179
- <div className={styles.select_trigger}>
180
- <div className={styles.select_content}>
181
- {selectedOption ? (
182
- <div className={styles.selected_option}>
183
- <span className={styles.option_label}>{selectedOption.label}</span>
184
- {selectedOption.badge && (
185
- <span className={styles.option_badge} style={{ backgroundColor: selectedOption.badgeColor }}>
186
- {selectedOption.badge}
187
- </span>
188
- )}
189
- </div>
190
- ) : (
191
- <span className={styles.placeholder}>{placeholder}</span>
192
- )}
193
- </div>
194
- <Icon
195
- iconClass={getIcon('down-arrow')}
196
- className={cls(styles.dropdown_arrow, {
197
- [styles.open]: isOpen,
198
- })}
199
- />
200
- </div>
201
-
202
- {isOpen && (
203
- <div ref={dropdownRef} className={styles.dropdown} role='listbox'>
204
- {showThinking && onThinkingChange && (
205
- <div className={styles.thinking_section}>
206
- <ThinkingToggle enabled={thinkingEnabled} onChange={onThinkingChange} />
207
- <div className={styles.divider} />
208
- </div>
209
- )}
210
-
211
- {options.map((option, index) => (
212
- <div
213
- key={option.value}
214
- className={cls(styles.option, {
215
- [styles.active]: index === activeIndex,
216
- [styles.selected]: option.selected || option.value === value,
217
- [styles.disabled]: option.disabled,
218
- })}
219
- onClick={() => handleSelect(option)}
220
- role='option'
221
- aria-selected={option.selected || option.value === value}
222
- >
223
- <div className={styles.option_main}>
224
- <div className={styles.option_header}>
225
- <div className={styles.option_title}>
226
- {option.icon && <Icon icon={option.icon} className={styles.option_icon} />}
227
- {option.iconClass && <Icon iconClass={option.iconClass} className={styles.option_icon} />}
228
- <span className={styles.option_label}>{option.label}</span>
229
- {option.badge && (
230
- <span className={styles.option_badge} style={{ backgroundColor: option.badgeColor }}>
231
- {option.badge}
232
- </span>
233
- )}
234
- </div>
235
- </div>
236
-
237
- {option.description && <div className={styles.option_description}>{option.description}</div>}
238
-
239
- {option.tags && option.tags.length > 0 && (
240
- <div className={styles.option_tags}>
241
- {option.tags.map((tag, idx) => (
242
- <span key={idx} className={styles.tag}>
243
- {tag}
244
- </span>
245
- ))}
246
- </div>
247
- )}
248
- </div>
249
- </div>
250
- ))}
251
- </div>
252
- )}
253
- </div>
254
- </ClickOutside>
255
- );
256
- };