ChatInputArea.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841
  1. <template>
  2. <div class="chat-input-area">
  3. <div v-if="pendingFile" class="pending-file-display">
  4. <div class="pending-file-card">
  5. <div class="file-icon-pending"></div>
  6. <div class="file-info-pending">
  7. <div class="file-name-pending">{{ pendingFile.name }}</div>
  8. <div class="file-size-pending">{{ formatFileSize(pendingFile.size) }}</div>
  9. </div>
  10. <div class="remove-pending" @click="emit('remove-pending-file')">
  11. <CloseOutlined />
  12. </div>
  13. </div>
  14. </div>
  15. <!-- 已选会话引用标签 -->
  16. <div v-if="selectedSessions.length > 0" class="session-chips">
  17. <div v-for="session in selectedSessions" :key="session.id" class="session-chip">
  18. <div class="session-chip-icon"></div>
  19. <span class="session-chip-name">{{ session.name }}</span>
  20. <CloseOutlined class="session-chip-remove" @click.stop="removeSession(session.id)" />
  21. </div>
  22. </div>
  23. <!-- 已选技能引用标签 -->
  24. <div v-if="selectedSkill" class="skill-chips">
  25. <div class="skill-chip">
  26. <div class="skill-chip-icon"></div>
  27. <span class="skill-chip-name">{{ selectedSkill.display_name }}</span>
  28. <CloseOutlined class="skill-chip-remove" @click.stop="removeSkill()" />
  29. </div>
  30. </div>
  31. <a-textarea
  32. ref="textareaRef"
  33. :value="modelValue"
  34. @update:value="handleTextareaInput"
  35. :rows="3"
  36. class="chat-input"
  37. placeholder="请输入你的问题"
  38. :auto-size="{ minRows: 3, maxRows: 6 }"
  39. @keydown="handleSessionKeydown"
  40. @keydown.enter.prevent="handleEnterKey"
  41. @keydown.backspace="handleBackspace"
  42. />
  43. <div class="input-actions">
  44. <div class="action-left">
  45. <div class="btn-upload-wrapper">
  46. <a-tooltip title="添加上下文">
  47. <div class="btn-upload" @click="togglePopup">
  48. <div class="plus-icon"></div>
  49. </div>
  50. </a-tooltip>
  51. <div v-if="showPopup" ref="popupRef" class="upload-popup" @click.stop>
  52. <div class="popup-item" @click="handleAddAttachment">
  53. <div class="popup-item-icon attach-icon"></div>
  54. <span class="popup-item-text">添加附件</span>
  55. </div>
  56. <!-- <div class="popup-item" @click="handleInsertMention">
  57. <div class="popup-item-icon mention-icon"></div>
  58. <span class="popup-item-text">插入 @ 提及</span>
  59. </div> -->
  60. <div class="popup-item" @click="handleInsertSession">
  61. <div class="popup-item-icon session-icon"></div>
  62. <span class="popup-item-text">插入 # 会话</span>
  63. </div>
  64. <div class="popup-item" @click="handleInsertSkill">
  65. <div class="popup-item-icon skill-icon"></div>
  66. <span class="popup-item-text">插入 $ 技能</span>
  67. </div>
  68. <!-- <div class="popup-item" @click="handleInsertCommand">
  69. <div class="popup-item-icon command-icon"></div>
  70. <span class="popup-item-text">插入 / 命令</span>
  71. </div> -->
  72. </div>
  73. </div>
  74. <div class="action-divider"></div>
  75. <div class="btn-edit-mode-wrapper">
  76. <a-tooltip title="切换模式">
  77. <div class="btn-edit-mode" @click="toggleEditModePopup">
  78. <div class="btn-icon" :class="`mode-icon-${selectedEditMode.key}`"></div>
  79. <span class="btn-text">{{ selectedEditMode.label }}</span>
  80. <div class="btn-arrow"></div>
  81. </div>
  82. </a-tooltip>
  83. <div v-if="showEditModePopup" ref="editModePopupRef" class="edit-mode-popup">
  84. <div
  85. v-for="item in editModeOptions"
  86. :key="item.key"
  87. class="edit-mode-item"
  88. :class="{ active: selectedEditMode.key === item.key }"
  89. @click="handleSelectEditMode(item)"
  90. >
  91. <div class="edit-mode-item-icon" :class="`mode-icon-${item.key}`"></div>
  92. <div class="edit-mode-item-main">
  93. <span class="edit-mode-item-label">{{ item.label }}</span>
  94. <span class="edit-mode-item-desc">{{ item.desc }}</span>
  95. </div>
  96. <div class="edit-mode-check" :class="{ visible: selectedEditMode.key === item.key }"></div>
  97. </div>
  98. </div>
  99. </div>
  100. <input ref="fileInputRef" type="file" style="display: none" @change="emit('file-change', $event)" />
  101. </div>
  102. <div class="action-right">
  103. <div class="btn-context-wrapper" ref="contextPopupRef" @mouseenter="showContextPopup = true" @mouseleave="showContextPopup = false">
  104. <div class="btn-context" @click="toggleContextPopup">
  105. <svg class="context-ring" viewBox="0 0 32 32">
  106. <circle class="context-ring-bg" cx="16" cy="16" r="13" />
  107. <circle
  108. class="context-ring-fill"
  109. cx="16"
  110. cy="16"
  111. r="13"
  112. :stroke-dasharray="contextCircumference"
  113. :stroke-dashoffset="contextOffset"
  114. :style="{ stroke: contextColor }"
  115. />
  116. </svg>
  117. <span class="context-percent">{{ contextPercent }}%</span>
  118. </div>
  119. <div v-if="showContextPopup" class="context-popup" @click.stop>
  120. <div class="context-popup-title">上下文容量</div>
  121. <div class="context-popup-info">
  122. <span class="context-used">{{ contextDisplayUsed }}</span>
  123. <span class="context-sep">/</span>
  124. <span class="context-max">{{ contextDisplayMax }}</span>
  125. <span class="context-pct">({{ contextPercent }}%)</span>
  126. </div>
  127. <div class="context-popup-bar-track">
  128. <div class="context-popup-bar-fill" :style="{ width: contextPercent + '%', background: contextColor }"></div>
  129. </div>
  130. <div class="context-breakdown">
  131. <div class="breakdown-item">
  132. <span class="breakdown-label">历史消息</span>
  133. <span class="breakdown-value">{{ formatTokens(props.contextBreakdown.messages) }}</span>
  134. </div>
  135. <div class="breakdown-item">
  136. <span class="breakdown-label">MCP工具</span>
  137. <span class="breakdown-value">{{ formatTokens(props.contextBreakdown.mcp) }}</span>
  138. </div>
  139. <div class="breakdown-item">
  140. <span class="breakdown-label">技能描述</span>
  141. <span class="breakdown-value">{{ formatTokens(props.contextBreakdown.skills) }}</span>
  142. </div>
  143. <div class="breakdown-item">
  144. <span class="breakdown-label">系统提示词</span>
  145. <span class="breakdown-value">{{ formatTokens(props.contextBreakdown.system_prompt) }}</span>
  146. </div>
  147. <div class="breakdown-item">
  148. <span class="breakdown-label">其他</span>
  149. <span class="breakdown-value">{{ formatTokens(props.contextBreakdown.other) }}</span>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. <!-- <div class="action-divider"></div>
  155. <div class="btn-model-wrapper" ref="modelPopupRef">
  156. <a-tooltip title="选择模型">
  157. <div class="btn-model" @click="toggleModelPopup">
  158. <span class="btn-text">{{ selectedModel.label }}</span>
  159. <div class="btn-arrow"></div>
  160. </div>
  161. </a-tooltip>
  162. <div v-if="showModelPopup" class="model-popup" @click.stop>
  163. <div
  164. v-for="item in modelOptions"
  165. :key="item.key"
  166. class="model-popup-item"
  167. :class="{ active: selectedModel.key === item.key }"
  168. @click="handleSelectModel(item)"
  169. >
  170. <div class="model-item-main">
  171. <span class="model-item-label">{{ item.label }}</span>
  172. <span class="model-item-desc">{{ item.desc }}</span>
  173. </div>
  174. <div class="model-item-check" :class="{ visible: selectedModel.key === item.key }"></div>
  175. </div>
  176. </div>
  177. </div> -->
  178. <div class="action-divider"></div>
  179. <div class="btn-think-wrapper" ref="thinkPopupRef">
  180. <a-tooltip title="思考级别">
  181. <div class="btn-think" @click="toggleThinkPopup">
  182. <div class="btn-icon think-icon"></div>
  183. <span class="btn-text">{{ selectedThinkLevel.label }}</span>
  184. <div class="btn-arrow"></div>
  185. </div>
  186. </a-tooltip>
  187. <div v-if="showThinkPopup" class="think-popup" @click.stop>
  188. <div
  189. v-for="item in thinkLevelOptions"
  190. :key="item.key"
  191. class="think-popup-item"
  192. :class="{ active: selectedThinkLevel.key === item.key }"
  193. @click="handleSelectThinkLevel(item)"
  194. >
  195. <div class="think-item-main">
  196. <span class="think-item-label">{{ item.label }}</span>
  197. <span class="think-item-desc">{{ item.desc }}</span>
  198. </div>
  199. <div class="think-item-check" :class="{ visible: selectedThinkLevel.key === item.key }"></div>
  200. </div>
  201. </div>
  202. </div>
  203. <div class="action-divider"></div>
  204. <div class="btn-send" :class="{ disabled: !streaming && (!modelValue.trim() || loading) }" @click="handleSendClick">
  205. <div class="send-icon" :class="{ 'stop-icon': streaming }"></div>
  206. </div>
  207. </div>
  208. <!-- 会话列表弹框 -->
  209. <div v-if="showSessionPopup" ref="sessionPopupRef" class="session-popup" @click.stop @pointerdown.stop>
  210. <div class="session-popup-header">
  211. <span>选择会话</span>
  212. <span class="session-count">{{ selectedSessions.length }}/5</span>
  213. </div>
  214. <div class="session-list">
  215. <div
  216. v-for="(task, index) in filteredSessionList"
  217. :key="task.id"
  218. class="session-item"
  219. :class="{
  220. active: index === activeSessionIndex,
  221. selected: isSessionSelected(task.id),
  222. disabled: (selectedSessions.length >= 5 && !isSessionSelected(task.id)) || task.id === props.currentTaskId,
  223. }"
  224. @click="handleSelectSession(task)"
  225. >
  226. <div class="session-checkbox" :class="{ checked: isSessionSelected(task.id) }">
  227. <span v-if="isSessionSelected(task.id)" class="check-mark">✓</span>
  228. </div>
  229. <div class="session-item-icon"></div>
  230. <span class="session-item-name">{{ task.name }}</span>
  231. </div>
  232. <div v-if="filteredSessionList.length === 0" class="session-empty">暂无匹配会话</div>
  233. </div>
  234. <div class="session-popup-footer">
  235. <span v-if="selectedSessions.length >= 5" class="max-hint">最多选择5个会话</span>
  236. <span v-else>点击选择会话(最多5个)</span>
  237. </div>
  238. </div>
  239. <!-- 技能列表弹框 -->
  240. <div v-if="showSkillPopup" ref="skillPopupRef" class="skill-popup" @click.stop @pointerdown.stop>
  241. <div class="skill-popup-header">
  242. <span>选择技能</span>
  243. <span class="skill-count">0/1</span>
  244. </div>
  245. <div class="skill-list">
  246. <div
  247. v-for="(skill, index) in filteredSkillList"
  248. :key="skill.name"
  249. class="skill-item"
  250. :class="{
  251. active: index === activeSkillIndex,
  252. selected: isSkillSelected(skill.name),
  253. }"
  254. @click="handleSelectSkill(skill)"
  255. >
  256. <div class="skill-item-checkbox" :class="{ checked: isSkillSelected(skill.name) }">
  257. <span v-if="isSkillSelected(skill.name)" class="check-mark">✓</span>
  258. </div>
  259. <div class="skill-item-icon"></div>
  260. <span class="skill-item-name">{{ skill.display_name }}</span>
  261. </div>
  262. <div v-if="filteredSkillList.length === 0" class="skill-empty">暂无匹配技能</div>
  263. </div>
  264. <div class="skill-popup-footer">
  265. <span>点击选择技能(仅可选1个)</span>
  266. </div>
  267. </div>
  268. </div>
  269. </div>
  270. </template>
  271. <script setup lang="ts">
  272. import { ref, computed, watch, nextTick, onMounted } from 'vue';
  273. import { onClickOutside } from '@vueuse/core';
  274. import { CloseOutlined } from '@ant-design/icons-vue';
  275. import { formatFileSize } from './utils';
  276. import { getSkills } from '../../api';
  277. import type { AttachedFile, Task } from './types';
  278. const props = withDefaults(
  279. defineProps<{
  280. modelValue: string;
  281. pendingFile: AttachedFile | null;
  282. loading: boolean;
  283. streaming?: boolean;
  284. contextUsed?: number;
  285. contextMax?: number;
  286. contextPercent?: number;
  287. contextBreakdown?: { messages: number; mcp: number; skills: number; system_prompt: number; other: number };
  288. initialThinkLevel?: string;
  289. initialEditMode?: string;
  290. taskList?: Task[];
  291. currentTaskId?: string;
  292. }>(),
  293. {
  294. contextUsed: 0,
  295. contextMax: 1000000,
  296. contextPercent: 0,
  297. streaming: false,
  298. contextBreakdown: () => ({ messages: 0, mcp: 0, skills: 0, system_prompt: 0, other: 0 }),
  299. initialThinkLevel: 'off',
  300. initialEditMode: 'full',
  301. taskList: () => [],
  302. currentTaskId: '',
  303. }
  304. );
  305. const emit = defineEmits<{
  306. (e: 'update:modelValue', value: string): void;
  307. (e: 'send'): void;
  308. (e: 'stop'): void;
  309. (e: 'file-upload'): void;
  310. (e: 'file-change', event: Event): void;
  311. (e: 'remove-pending-file'): void;
  312. (e: 'model-change', modelKey: string): void;
  313. (e: 'think-level-change', levelKey: string): void;
  314. (e: 'edit-mode-change', modeKey: string): void;
  315. (e: 'update:selectedSessions', sessions: Array<{ id: string; name: string }>): void;
  316. (e: 'update:selectedSkill', skill: { name: string; display_name: string } | null): void;
  317. }>();
  318. const handleSelectModel = (item: ModelOption) => {
  319. selectedModel.value = item;
  320. showModelPopup.value = false;
  321. emit('model-change', item.key);
  322. };
  323. const fileInputRef = ref<HTMLInputElement>();
  324. const popupRef = ref<HTMLElement>();
  325. const showPopup = ref(false);
  326. // 上下文容量
  327. const contextPopupRef = ref<HTMLElement>();
  328. const showContextPopup = ref(false);
  329. const contextPercent = computed(() => {
  330. return props.contextPercent;
  331. });
  332. const contextCircumference = computed(() => 2 * Math.PI * 13);
  333. const contextOffset = computed(() => contextCircumference.value * (1 - contextPercent.value / 100));
  334. const contextColor = computed(() => {
  335. if (contextPercent.value >= 90) return '#ff4d4f';
  336. if (contextPercent.value >= 70) return '#faad14';
  337. return '#52c41a';
  338. });
  339. const contextDisplayUsed = computed(() => {
  340. if (props.contextUsed >= 10000) return (props.contextUsed / 10000).toFixed(1) + '万';
  341. return props.contextUsed.toLocaleString();
  342. });
  343. const contextDisplayMax = computed(() => {
  344. if (props.contextMax >= 10000) return (props.contextMax / 10000).toFixed(0) + '万';
  345. return props.contextMax.toLocaleString();
  346. });
  347. const formatTokens = (tokens: number) => {
  348. if (tokens >= 10000) return (tokens / 10000).toFixed(1) + '万';
  349. return tokens.toLocaleString();
  350. };
  351. const toggleContextPopup = () => {
  352. showContextPopup.value = !showContextPopup.value;
  353. };
  354. onClickOutside(contextPopupRef, () => {
  355. showContextPopup.value = false;
  356. });
  357. // 模型选择
  358. const modelPopupRef = ref<HTMLElement>();
  359. const showModelPopup = ref(false);
  360. interface ModelOption {
  361. key: string;
  362. label: string;
  363. desc: string;
  364. }
  365. const modelOptions: ModelOption[] = [
  366. { key: 'deepseek-v4-pro', label: 'DeepSeek-V4-Pro', desc: '默认模型,综合能力强' },
  367. { key: 'deepseek-v4', label: 'DeepSeek-V4', desc: '轻量快速,适合简单任务' },
  368. { key: 'gpt-4o', label: 'GPT-4o', desc: 'OpenAI 多模态模型' },
  369. { key: 'gpt-4o-mini', label: 'GPT-4o Mini', desc: 'OpenAI 轻量模型' },
  370. { key: 'claude-sonnet-4', label: 'Claude Sonnet 4', desc: 'Anthropic 高性能模型' },
  371. { key: 'qwen-max', label: '通义千问 Max', desc: '阿里云旗舰模型' },
  372. ];
  373. const selectedModel = ref<ModelOption>(modelOptions[0]);
  374. const toggleModelPopup = () => {
  375. showModelPopup.value = !showModelPopup.value;
  376. };
  377. onClickOutside(modelPopupRef, () => {
  378. showModelPopup.value = false;
  379. });
  380. // 思考级别
  381. const thinkPopupRef = ref<HTMLElement>();
  382. const showThinkPopup = ref(false);
  383. interface ThinkLevelOption {
  384. key: string;
  385. label: string;
  386. desc: string;
  387. }
  388. const thinkLevelOptions: ThinkLevelOption[] = [
  389. { key: 'off', label: '关闭', desc: '不使用深度思考,响应最快' },
  390. { key: 'high', label: '高', desc: '深度思考,平衡速度与质量' },
  391. { key: 'highest', label: '最高', desc: '极致思考,质量最高但较慢' },
  392. ];
  393. const selectedThinkLevel = ref<ThinkLevelOption>(thinkLevelOptions[0]);
  394. watch(
  395. () => props.initialThinkLevel,
  396. (level) => {
  397. const found = thinkLevelOptions.find((opt) => opt.key === level);
  398. if (found) selectedThinkLevel.value = found;
  399. },
  400. { immediate: true }
  401. );
  402. const toggleThinkPopup = () => {
  403. showThinkPopup.value = !showThinkPopup.value;
  404. };
  405. const handleSelectThinkLevel = (item: ThinkLevelOption) => {
  406. selectedThinkLevel.value = item;
  407. showThinkPopup.value = false;
  408. emit('think-level-change', item.key);
  409. };
  410. onClickOutside(thinkPopupRef, () => {
  411. showThinkPopup.value = false;
  412. });
  413. const editModePopupRef = ref<HTMLElement>();
  414. const showEditModePopup = ref(false);
  415. interface EditModeOption {
  416. key: string;
  417. label: string;
  418. desc: string;
  419. }
  420. const editModeOptions: EditModeOption[] = [
  421. // { key: 'confirm', label: '变更前确认', desc: '改文件前先问我' },
  422. // { key: 'auto', label: '自动编辑', desc: '自动编辑文件' },
  423. { key: 'plan', label: '计划模式', desc: '编辑前先出计划' },
  424. { key: 'full', label: '完全访问', desc: '减少确认次数' },
  425. ];
  426. const selectedEditMode = ref<EditModeOption>(editModeOptions[1]);
  427. watch(
  428. () => props.initialEditMode,
  429. (mode) => {
  430. const found = editModeOptions.find((opt) => opt.key === mode);
  431. if (found) selectedEditMode.value = found;
  432. },
  433. { immediate: true }
  434. );
  435. onClickOutside(editModePopupRef, () => {
  436. showEditModePopup.value = false;
  437. });
  438. const toggleEditModePopup = () => {
  439. showEditModePopup.value = !showEditModePopup.value;
  440. };
  441. const handleSelectEditMode = (item: EditModeOption) => {
  442. selectedEditMode.value = item;
  443. showEditModePopup.value = false;
  444. emit('edit-mode-change', item.key);
  445. };
  446. onClickOutside(popupRef, () => {
  447. showPopup.value = false;
  448. });
  449. const togglePopup = () => {
  450. showPopup.value = !showPopup.value;
  451. };
  452. const handleAddAttachment = () => {
  453. showPopup.value = false;
  454. emit('file-upload');
  455. };
  456. const handleInsertMention = () => {
  457. showPopup.value = false;
  458. };
  459. // 会话列表弹框
  460. const textareaRef = ref<InstanceType<any>>();
  461. const sessionPopupRef = ref<HTMLElement>();
  462. const showSessionPopup = ref(false);
  463. const activeSessionIndex = ref(0);
  464. const selectedSessions = ref<Array<{ id: string; name: string }>>([]);
  465. const sessionPopupManual = ref(false);
  466. let isRemovingTag = false;
  467. let sessionJustSelected = false;
  468. // 技能列表弹框
  469. interface SkillItem {
  470. name: string;
  471. display_name: string;
  472. path: string;
  473. description: string;
  474. enabled: boolean;
  475. agents: string[];
  476. has_skill_md: boolean;
  477. }
  478. const skillPopupRef = ref<HTMLElement>();
  479. const showSkillPopup = ref(false);
  480. const activeSkillIndex = ref(0);
  481. const selectedSkill = ref<{ name: string; display_name: string } | null>(null);
  482. const skillPopupManual = ref(false);
  483. const skillList = ref<SkillItem[]>([]);
  484. let skillJustSelected = false;
  485. const fetchSkillList = async () => {
  486. try {
  487. const res = await getSkills();
  488. skillList.value = res?.skills || [];
  489. } catch {
  490. skillList.value = [];
  491. }
  492. };
  493. onMounted(() => {
  494. fetchSkillList();
  495. });
  496. const isSkillSelected = (name: string) => {
  497. return selectedSkill.value?.name === name;
  498. };
  499. const isSessionSelected = (sessionId: string) => {
  500. return selectedSessions.value.some((s) => s.id === sessionId);
  501. };
  502. const sessionSearchText = computed(() => {
  503. const val = props.modelValue || '';
  504. const hashIndex = val.lastIndexOf('#');
  505. if (hashIndex === -1) return '';
  506. const afterHash = val.substring(hashIndex + 1);
  507. if (afterHash.includes(' ')) return '';
  508. return afterHash.toLowerCase();
  509. });
  510. const filteredSessionList = computed(() => {
  511. const list = props.taskList.filter((t) => t.sessionId);
  512. if (!sessionSearchText.value) return list;
  513. return list.filter((t) => t.name.toLowerCase().includes(sessionSearchText.value));
  514. });
  515. watch(filteredSessionList, () => {
  516. activeSessionIndex.value = 0;
  517. });
  518. watch(showSessionPopup, (val) => {
  519. if (val) activeSessionIndex.value = 0;
  520. });
  521. const skillSearchText = computed(() => {
  522. const val = props.modelValue || '';
  523. const dollarIndex = val.lastIndexOf('$');
  524. if (dollarIndex === -1) return '';
  525. const afterDollar = val.substring(dollarIndex + 1);
  526. if (afterDollar.includes(' ')) return '';
  527. return afterDollar.toLowerCase();
  528. });
  529. const filteredSkillList = computed(() => {
  530. if (!skillSearchText.value) return skillList.value;
  531. return skillList.value.filter(
  532. (s) => s.display_name.toLowerCase().includes(skillSearchText.value) || s.name.toLowerCase().includes(skillSearchText.value)
  533. );
  534. });
  535. watch(filteredSkillList, () => {
  536. activeSkillIndex.value = 0;
  537. });
  538. watch(showSkillPopup, (val) => {
  539. if (val) activeSkillIndex.value = 0;
  540. });
  541. const handleSessionKeydown = (e: KeyboardEvent) => {
  542. if (showSkillPopup.value && filteredSkillList.value.length > 0) {
  543. if (e.key === 'ArrowDown') {
  544. e.preventDefault();
  545. activeSkillIndex.value = (activeSkillIndex.value + 1) % filteredSkillList.value.length;
  546. } else if (e.key === 'ArrowUp') {
  547. e.preventDefault();
  548. activeSkillIndex.value = (activeSkillIndex.value - 1 + filteredSkillList.value.length) % filteredSkillList.value.length;
  549. } else if (e.key === 'Enter') {
  550. e.preventDefault();
  551. const skill = filteredSkillList.value[activeSkillIndex.value];
  552. if (skill) {
  553. skillJustSelected = true;
  554. handleSelectSkill(skill);
  555. }
  556. }
  557. return;
  558. }
  559. if (showSessionPopup.value && filteredSessionList.value.length > 0) {
  560. if (e.key === 'ArrowDown') {
  561. e.preventDefault();
  562. activeSessionIndex.value = (activeSessionIndex.value + 1) % filteredSessionList.value.length;
  563. } else if (e.key === 'ArrowUp') {
  564. e.preventDefault();
  565. activeSessionIndex.value = (activeSessionIndex.value - 1 + filteredSessionList.value.length) % filteredSessionList.value.length;
  566. } else if (e.key === 'Enter') {
  567. e.preventDefault();
  568. const task = filteredSessionList.value[activeSessionIndex.value];
  569. if (task) {
  570. sessionJustSelected = true;
  571. handleSelectSession(task);
  572. }
  573. }
  574. }
  575. };
  576. const handleInsertSession = () => {
  577. showPopup.value = false;
  578. sessionPopupManual.value = true;
  579. showSessionPopup.value = true;
  580. const cur = props.modelValue || '';
  581. const needsSpace = cur && !cur.endsWith(' ') ? ' ' : '';
  582. emit('update:modelValue', `${cur}${needsSpace}#`);
  583. nextTick(() => {
  584. const el = textareaRef.value?.$el?.querySelector('textarea') || textareaRef.value?.$el;
  585. if (el) el.focus();
  586. });
  587. };
  588. const handleSelectSession = (task: Task) => {
  589. if (task.id === props.currentTaskId) return;
  590. const idx = selectedSessions.value.findIndex((s) => s.id === task.id);
  591. if (idx >= 0) {
  592. selectedSessions.value.splice(idx, 1);
  593. } else {
  594. if (selectedSessions.value.length >= 5) return;
  595. selectedSessions.value.push({ id: task.id, name: task.name });
  596. }
  597. removeSearchTag();
  598. emit('update:selectedSessions', [...selectedSessions.value]);
  599. };
  600. const handleInsertSkill = () => {
  601. showPopup.value = false;
  602. showSessionPopup.value = false;
  603. skillPopupManual.value = true;
  604. showSkillPopup.value = true;
  605. const cur = props.modelValue || '';
  606. const needsSpace = cur && !cur.endsWith(' ') ? ' ' : '';
  607. emit('update:modelValue', `${cur}${needsSpace}$`);
  608. nextTick(() => {
  609. const el = textareaRef.value?.$el?.querySelector('textarea') || textareaRef.value?.$el;
  610. if (el) el.focus();
  611. });
  612. };
  613. const handleSelectSkill = (skill: SkillItem) => {
  614. selectedSkill.value = { name: skill.name, display_name: skill.display_name };
  615. removeSkillSearchTag();
  616. showSkillPopup.value = false;
  617. skillPopupManual.value = false;
  618. emit('update:selectedSkill', { name: skill.name, display_name: skill.display_name });
  619. };
  620. const removeSkillSearchTag = () => {
  621. isRemovingTag = true;
  622. const val = props.modelValue || '';
  623. const dollarIndex = val.lastIndexOf('$');
  624. if (dollarIndex === -1) {
  625. isRemovingTag = false;
  626. return;
  627. }
  628. emit('update:modelValue', val.substring(0, dollarIndex).trimEnd());
  629. nextTick(() => {
  630. isRemovingTag = false;
  631. });
  632. };
  633. const removeSkill = () => {
  634. selectedSkill.value = null;
  635. emit('update:selectedSkill', null);
  636. };
  637. const removeSearchTag = () => {
  638. isRemovingTag = true;
  639. const val = props.modelValue || '';
  640. const hashIndex = val.lastIndexOf('#');
  641. if (hashIndex === -1) {
  642. isRemovingTag = false;
  643. return;
  644. }
  645. emit('update:modelValue', val.substring(0, hashIndex).trimEnd());
  646. nextTick(() => {
  647. isRemovingTag = false;
  648. });
  649. };
  650. watch(
  651. () => props.modelValue,
  652. (newVal, oldVal) => {
  653. if (isRemovingTag) return;
  654. if (oldVal && !newVal) {
  655. selectedSessions.value = [];
  656. selectedSkill.value = null;
  657. }
  658. }
  659. );
  660. const removeSession = (sessionId: string) => {
  661. selectedSessions.value = selectedSessions.value.filter((s) => s.id !== sessionId);
  662. emit('update:selectedSessions', [...selectedSessions.value]);
  663. };
  664. const handleTextareaInput = (val: string) => {
  665. emit('update:modelValue', val);
  666. // 技能弹框 $ 检测
  667. if (!skillPopupManual.value) {
  668. const dollarIndex = val.lastIndexOf('$');
  669. if (dollarIndex === -1) {
  670. showSkillPopup.value = false;
  671. } else {
  672. const afterDollar = val.substring(dollarIndex + 1);
  673. if (afterDollar.includes(' ')) {
  674. showSkillPopup.value = false;
  675. } else {
  676. showSkillPopup.value = true;
  677. showSessionPopup.value = false;
  678. }
  679. }
  680. }
  681. // 会话弹框 # 检测
  682. if (!sessionPopupManual.value) {
  683. const hashIndex = val.lastIndexOf('#');
  684. if (hashIndex === -1) {
  685. showSessionPopup.value = false;
  686. } else {
  687. const afterHash = val.substring(hashIndex + 1);
  688. if (afterHash.includes(' ')) {
  689. showSessionPopup.value = false;
  690. } else {
  691. showSessionPopup.value = true;
  692. showSkillPopup.value = false;
  693. }
  694. }
  695. }
  696. };
  697. const handleBackspace = (e: KeyboardEvent) => {
  698. const val = props.modelValue || '';
  699. if (val) return;
  700. if (selectedSkill.value) {
  701. e.preventDefault();
  702. selectedSkill.value = null;
  703. emit('update:selectedSkill', null);
  704. } else if (selectedSessions.value.length > 0) {
  705. e.preventDefault();
  706. selectedSessions.value.pop();
  707. emit('update:selectedSessions', [...selectedSessions.value]);
  708. }
  709. };
  710. onClickOutside(sessionPopupRef, () => {
  711. showSessionPopup.value = false;
  712. sessionPopupManual.value = false;
  713. });
  714. onClickOutside(skillPopupRef, () => {
  715. showSkillPopup.value = false;
  716. skillPopupManual.value = false;
  717. });
  718. const handleInsertCommand = () => {
  719. showPopup.value = false;
  720. };
  721. const handleEnterKey = (e: KeyboardEvent) => {
  722. if (showSessionPopup.value || showSkillPopup.value) return;
  723. if (sessionJustSelected) {
  724. sessionJustSelected = false;
  725. return;
  726. }
  727. if (skillJustSelected) {
  728. skillJustSelected = false;
  729. return;
  730. }
  731. if (!e.shiftKey && props.modelValue.trim() && !props.loading) {
  732. emit('send');
  733. }
  734. };
  735. const handleSend = () => {
  736. if (props.modelValue.trim() && !props.loading) {
  737. emit('send');
  738. }
  739. };
  740. const handleSendClick = () => {
  741. if (props.streaming) {
  742. emit('stop');
  743. return;
  744. }
  745. handleSend();
  746. };
  747. defineExpose({ fileInputRef });
  748. </script>
  749. <style scoped lang="less">
  750. .chat-input-area {
  751. position: relative;
  752. padding: 5px 10px;
  753. flex-shrink: 0;
  754. background-color: #002f4a;
  755. border: 1px solid #005482;
  756. border-radius: 4px;
  757. margin: 10px 16px 16px 16px;
  758. .pending-file-display {
  759. margin-bottom: 5px;
  760. .pending-file-card {
  761. display: flex;
  762. align-items: center;
  763. gap: 10px;
  764. padding: 10px 12px;
  765. background: rgba(10, 132, 255, 0.06);
  766. border: 1px solid rgba(63, 80, 106, 0.5);
  767. border-radius: 6px;
  768. transition: all 0.3s;
  769. &:hover {
  770. background: rgba(10, 132, 255, 0.1);
  771. }
  772. .file-icon-pending {
  773. width: 32px;
  774. height: 32px;
  775. background-image: var(--img-chat-attach-icon);
  776. background-repeat: no-repeat;
  777. background-size: 100% 100%;
  778. flex-shrink: 0;
  779. }
  780. .file-info-pending {
  781. flex: 1;
  782. min-width: 0;
  783. .file-name-pending {
  784. font-size: 12px;
  785. font-weight: 400;
  786. line-height: 1.4;
  787. color: #e0e6ed;
  788. overflow: hidden;
  789. text-overflow: ellipsis;
  790. white-space: nowrap;
  791. margin-bottom: 2px;
  792. }
  793. .file-size-pending {
  794. font-size: 11px;
  795. font-weight: 400;
  796. line-height: 1.3;
  797. color: #8b949e;
  798. }
  799. }
  800. .remove-pending {
  801. cursor: pointer;
  802. color: #8b949e;
  803. font-size: 14px;
  804. padding: 4px;
  805. border-radius: 4px;
  806. transition: all 0.3s;
  807. &:hover {
  808. color: #ff4d4f;
  809. background: rgba(220, 38, 38, 0.1);
  810. }
  811. }
  812. }
  813. }
  814. :deep(.chat-input) {
  815. color: #e0e6ed;
  816. background-color: transparent !important;
  817. border: none !important;
  818. &::placeholder {
  819. color: #8b949e !important;
  820. opacity: 1 !important;
  821. }
  822. &:focus,
  823. &:hover,
  824. &:active {
  825. border: none !important;
  826. box-shadow: none !important;
  827. outline: none !important;
  828. }
  829. }
  830. .input-actions {
  831. display: flex;
  832. justify-content: space-between;
  833. align-items: center;
  834. margin-top: 12px;
  835. .mode-icon-confirm {
  836. background-image: var(--img-chat-mode-confirm-icon);
  837. }
  838. .mode-icon-auto {
  839. background-image: var(--img-chat-mode-auto-icon);
  840. }
  841. .mode-icon-plan {
  842. background-image: var(--img-chat-mode-plan-icon);
  843. }
  844. .mode-icon-full {
  845. background-image: var(--img-chat-mode-full-icon);
  846. }
  847. .action-left,
  848. .action-right {
  849. display: flex;
  850. gap: 8px;
  851. .action-divider {
  852. width: 1px;
  853. height: 18px;
  854. background: rgba(255, 255, 255, 0.15);
  855. align-self: center;
  856. flex-shrink: 0;
  857. }
  858. .btn-icon {
  859. width: 14px;
  860. height: 14px;
  861. background-repeat: no-repeat;
  862. background-size: 100% 100%;
  863. flex-shrink: 0;
  864. }
  865. .think-icon {
  866. background-image: var(--img-chat-thinking-icon);
  867. }
  868. .btn-text {
  869. font-size: 12px;
  870. color: #e0e6ed;
  871. white-space: nowrap;
  872. }
  873. .btn-arrow {
  874. width: 0;
  875. height: 0;
  876. border-left: 4px solid transparent;
  877. border-right: 4px solid transparent;
  878. border-top: 4px solid #8b949e;
  879. flex-shrink: 0;
  880. }
  881. .btn-upload-wrapper {
  882. position: relative;
  883. }
  884. .btn-upload {
  885. width: 30px;
  886. height: 30px;
  887. border-radius: 6px;
  888. display: flex;
  889. align-items: center;
  890. justify-content: center;
  891. cursor: pointer;
  892. }
  893. .plus-icon {
  894. width: 20px;
  895. height: 20px;
  896. background-image: var(--img-chat-input-bg);
  897. background-repeat: no-repeat;
  898. background-size: 100% 100%;
  899. cursor: pointer;
  900. }
  901. .upload-popup {
  902. position: absolute;
  903. bottom: 38px;
  904. left: 0;
  905. background: #0a2a3f;
  906. border: 1px solid #1a4a6f;
  907. border-radius: 8px;
  908. min-width: 160px;
  909. z-index: 1000;
  910. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  911. .popup-item {
  912. display: flex;
  913. align-items: center;
  914. gap: 10px;
  915. padding: 9px 16px;
  916. cursor: pointer;
  917. transition: background 0.2s;
  918. border-radius: 8px;
  919. &:hover {
  920. background: rgba(10, 132, 255, 0.15);
  921. }
  922. .popup-item-icon {
  923. width: 18px;
  924. height: 18px;
  925. background-repeat: no-repeat;
  926. background-size: 100% 100%;
  927. flex-shrink: 0;
  928. }
  929. .attach-icon {
  930. background-image: var(--img-chat-popup-attach-icon);
  931. }
  932. .mention-icon {
  933. background-image: var(--img-chat-popup-mention-icon);
  934. }
  935. .session-icon {
  936. background-image: var(--img-chat-popup-session-icon);
  937. }
  938. .skill-icon {
  939. background-image: var(--img-chat-options-skill-icon);
  940. }
  941. .command-icon {
  942. background-image: var(--img-chat-popup-command-icon);
  943. }
  944. .popup-item-text {
  945. font-size: 13px;
  946. color: #e0e6ed;
  947. white-space: nowrap;
  948. }
  949. }
  950. }
  951. .btn-edit-mode-wrapper {
  952. position: relative;
  953. }
  954. .btn-edit-mode {
  955. height: 28px;
  956. padding: 0 10px;
  957. border-radius: 6px;
  958. display: flex;
  959. align-items: center;
  960. gap: 4px;
  961. cursor: pointer;
  962. transition: all 0.2s;
  963. border: 1px solid rgba(255, 255, 255, 0.12);
  964. &:hover {
  965. border-color: #3a8fd4;
  966. background: rgba(10, 132, 255, 0.1);
  967. }
  968. }
  969. .edit-mode-popup {
  970. position: absolute;
  971. bottom: 38px;
  972. left: 50%;
  973. transform: translateX(-50%);
  974. background: #0a2a3f;
  975. border: 1px solid #1a4a6f;
  976. border-radius: 8px;
  977. min-width: 200px;
  978. z-index: 1000;
  979. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  980. .edit-mode-item {
  981. display: flex;
  982. align-items: center;
  983. justify-content: space-between;
  984. padding: 10px 12px;
  985. cursor: pointer;
  986. transition: background 0.2s;
  987. border-radius: 6px;
  988. &:hover {
  989. background: rgba(10, 132, 255, 0.15);
  990. }
  991. &.active {
  992. background: rgba(10, 132, 255, 0.1);
  993. }
  994. .edit-mode-item-icon {
  995. width: 18px;
  996. height: 18px;
  997. background-repeat: no-repeat;
  998. background-size: 100% 100%;
  999. flex-shrink: 0;
  1000. margin-right: 10px;
  1001. }
  1002. .edit-mode-item-main {
  1003. display: flex;
  1004. flex-direction: column;
  1005. gap: 2px;
  1006. .edit-mode-item-label {
  1007. font-size: 13px;
  1008. color: #e0e6ed;
  1009. white-space: nowrap;
  1010. }
  1011. .edit-mode-item-desc {
  1012. font-size: 11px;
  1013. color: #8b949e;
  1014. white-space: nowrap;
  1015. }
  1016. }
  1017. .edit-mode-check {
  1018. width: 16px;
  1019. height: 16px;
  1020. flex-shrink: 0;
  1021. display: flex;
  1022. align-items: center;
  1023. justify-content: center;
  1024. visibility: hidden;
  1025. &.visible {
  1026. visibility: visible;
  1027. }
  1028. &::after {
  1029. content: '✓';
  1030. font-size: 12px;
  1031. color: #3a8fd4;
  1032. }
  1033. }
  1034. }
  1035. }
  1036. .btn-context-wrapper {
  1037. position: relative;
  1038. display: flex;
  1039. align-items: center;
  1040. }
  1041. .btn-context {
  1042. width: 30px;
  1043. height: 30px;
  1044. display: flex;
  1045. align-items: center;
  1046. justify-content: center;
  1047. cursor: pointer;
  1048. position: relative;
  1049. border-radius: 6px;
  1050. transition: background 0.2s;
  1051. &:hover {
  1052. background: rgba(10, 132, 255, 0.1);
  1053. }
  1054. .context-ring {
  1055. width: 24px;
  1056. height: 24px;
  1057. transform: rotate(-90deg);
  1058. .context-ring-bg {
  1059. fill: none;
  1060. stroke: rgba(255, 255, 255, 0.1);
  1061. stroke-width: 3;
  1062. }
  1063. .context-ring-fill {
  1064. fill: none;
  1065. stroke-width: 3;
  1066. stroke-linecap: round;
  1067. transition: stroke-dashoffset 0.3s ease;
  1068. }
  1069. }
  1070. .context-percent {
  1071. position: absolute;
  1072. font-size: 8px;
  1073. color: #e0e6ed;
  1074. font-weight: 500;
  1075. line-height: 1;
  1076. }
  1077. }
  1078. .context-popup {
  1079. position: absolute;
  1080. bottom: 42px;
  1081. left: 50%;
  1082. transform: translateX(-50%);
  1083. background: #0a2a3f;
  1084. border: 1px solid #1a4a6f;
  1085. border-radius: 8px;
  1086. min-width: 200px;
  1087. padding: 14px 16px;
  1088. &::before {
  1089. content: '';
  1090. position: absolute;
  1091. bottom: -12px;
  1092. left: 0;
  1093. right: 0;
  1094. height: 12px;
  1095. }
  1096. z-index: 1000;
  1097. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1098. .context-popup-title {
  1099. font-size: 13px;
  1100. color: #8b949e;
  1101. margin-bottom: 8px;
  1102. }
  1103. .context-popup-info {
  1104. display: flex;
  1105. align-items: baseline;
  1106. gap: 2px;
  1107. margin-bottom: 10px;
  1108. .context-used {
  1109. font-size: 18px;
  1110. font-weight: 600;
  1111. color: #e0e6ed;
  1112. }
  1113. .context-sep {
  1114. font-size: 14px;
  1115. color: #8b949e;
  1116. }
  1117. .context-max {
  1118. font-size: 14px;
  1119. color: #8b949e;
  1120. }
  1121. .context-pct {
  1122. font-size: 13px;
  1123. color: #8b949e;
  1124. }
  1125. }
  1126. .context-popup-bar-track {
  1127. width: 100%;
  1128. height: 6px;
  1129. background: rgba(255, 255, 255, 0.08);
  1130. border-radius: 3px;
  1131. overflow: hidden;
  1132. .context-popup-bar-fill {
  1133. height: 100%;
  1134. border-radius: 3px;
  1135. transition: width 0.3s ease;
  1136. }
  1137. }
  1138. .context-breakdown {
  1139. margin-top: 10px;
  1140. padding-top: 10px;
  1141. border-top: 1px solid rgba(255, 255, 255, 0.08);
  1142. .breakdown-item {
  1143. display: flex;
  1144. justify-content: space-between;
  1145. align-items: center;
  1146. padding: 3px 0;
  1147. .breakdown-label {
  1148. font-size: 12px;
  1149. color: #8b949e;
  1150. }
  1151. .breakdown-value {
  1152. font-size: 12px;
  1153. color: #e0e6ed;
  1154. }
  1155. }
  1156. }
  1157. }
  1158. .btn-model-wrapper {
  1159. position: relative;
  1160. display: flex;
  1161. align-items: center;
  1162. }
  1163. .btn-model {
  1164. height: 28px;
  1165. padding: 0 10px;
  1166. border-radius: 6px;
  1167. display: flex;
  1168. align-items: center;
  1169. gap: 4px;
  1170. cursor: pointer;
  1171. transition: all 0.2s;
  1172. border: 1px solid rgba(255, 255, 255, 0.12);
  1173. &:hover {
  1174. border-color: #3a8fd4;
  1175. background: rgba(10, 132, 255, 0.1);
  1176. }
  1177. }
  1178. .model-popup {
  1179. position: absolute;
  1180. bottom: 38px;
  1181. left: 50%;
  1182. transform: translateX(-50%);
  1183. background: #0a2a3f;
  1184. border: 1px solid #1a4a6f;
  1185. border-radius: 8px;
  1186. min-width: 220px;
  1187. z-index: 1000;
  1188. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1189. .model-popup-item {
  1190. display: flex;
  1191. align-items: center;
  1192. justify-content: space-between;
  1193. padding: 10px 12px;
  1194. cursor: pointer;
  1195. transition: background 0.2s;
  1196. border-radius: 6px;
  1197. &:hover {
  1198. background: rgba(10, 132, 255, 0.15);
  1199. }
  1200. &.active {
  1201. background: rgba(10, 132, 255, 0.1);
  1202. }
  1203. .model-item-main {
  1204. display: flex;
  1205. flex-direction: column;
  1206. gap: 2px;
  1207. .model-item-label {
  1208. font-size: 13px;
  1209. color: #e0e6ed;
  1210. white-space: nowrap;
  1211. }
  1212. .model-item-desc {
  1213. font-size: 11px;
  1214. color: #8b949e;
  1215. white-space: nowrap;
  1216. }
  1217. }
  1218. .model-item-check {
  1219. width: 16px;
  1220. height: 16px;
  1221. flex-shrink: 0;
  1222. display: flex;
  1223. align-items: center;
  1224. justify-content: center;
  1225. visibility: hidden;
  1226. &.visible {
  1227. visibility: visible;
  1228. }
  1229. &::after {
  1230. content: '✓';
  1231. font-size: 12px;
  1232. color: #3a8fd4;
  1233. }
  1234. }
  1235. }
  1236. }
  1237. .btn-think-wrapper {
  1238. position: relative;
  1239. display: flex;
  1240. align-items: center;
  1241. }
  1242. .btn-think {
  1243. height: 28px;
  1244. padding: 0 10px;
  1245. border-radius: 6px;
  1246. display: flex;
  1247. align-items: center;
  1248. gap: 4px;
  1249. cursor: pointer;
  1250. transition: all 0.2s;
  1251. border: 1px solid rgba(255, 255, 255, 0.12);
  1252. &:hover {
  1253. border-color: #3a8fd4;
  1254. background: rgba(10, 132, 255, 0.1);
  1255. }
  1256. }
  1257. .think-popup {
  1258. position: absolute;
  1259. bottom: 38px;
  1260. left: 50%;
  1261. transform: translateX(-50%);
  1262. background: #0a2a3f;
  1263. border: 1px solid #1a4a6f;
  1264. border-radius: 8px;
  1265. min-width: 200px;
  1266. z-index: 1000;
  1267. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1268. .think-popup-item {
  1269. display: flex;
  1270. align-items: center;
  1271. justify-content: space-between;
  1272. padding: 10px 12px;
  1273. cursor: pointer;
  1274. transition: background 0.2s;
  1275. border-radius: 6px;
  1276. &:hover {
  1277. background: rgba(10, 132, 255, 0.15);
  1278. }
  1279. &.active {
  1280. background: rgba(10, 132, 255, 0.1);
  1281. }
  1282. .think-item-main {
  1283. display: flex;
  1284. flex-direction: column;
  1285. gap: 2px;
  1286. .think-item-label {
  1287. font-size: 13px;
  1288. color: #e0e6ed;
  1289. white-space: nowrap;
  1290. }
  1291. .think-item-desc {
  1292. font-size: 11px;
  1293. color: #8b949e;
  1294. white-space: nowrap;
  1295. }
  1296. }
  1297. .think-item-check {
  1298. width: 16px;
  1299. height: 16px;
  1300. flex-shrink: 0;
  1301. display: flex;
  1302. align-items: center;
  1303. justify-content: center;
  1304. visibility: hidden;
  1305. &.visible {
  1306. visibility: visible;
  1307. }
  1308. &::after {
  1309. content: '✓';
  1310. font-size: 12px;
  1311. color: #3a8fd4;
  1312. }
  1313. }
  1314. }
  1315. }
  1316. .btn-send {
  1317. width: 32px;
  1318. height: 32px;
  1319. display: flex;
  1320. align-items: center;
  1321. justify-content: center;
  1322. cursor: pointer;
  1323. opacity: 1;
  1324. transition: opacity 0.2s;
  1325. &.disabled {
  1326. opacity: 0.4;
  1327. cursor: not-allowed;
  1328. }
  1329. .send-icon {
  1330. width: 24px;
  1331. height: 24px;
  1332. background-image: var(--img-chat-send-icon);
  1333. background-repeat: no-repeat;
  1334. background-size: 100% 100%;
  1335. &.stop-icon {
  1336. background-image: var(--img-chat-stop-icon);
  1337. }
  1338. }
  1339. }
  1340. }
  1341. }
  1342. .session-chips {
  1343. display: flex;
  1344. flex-wrap: wrap;
  1345. gap: 6px;
  1346. margin-bottom: 5px;
  1347. .session-chip {
  1348. display: inline-flex;
  1349. align-items: center;
  1350. gap: 4px;
  1351. padding: 3px 6px 3px 4px;
  1352. background: rgba(10, 132, 255, 0.15);
  1353. border: 1px solid rgba(10, 132, 255, 0.3);
  1354. border-radius: 4px;
  1355. font-size: 12px;
  1356. color: #e0e6ed;
  1357. cursor: default;
  1358. .session-chip-icon {
  1359. width: 16px;
  1360. height: 16px;
  1361. background-image: var(--img-chat-popup-session-icon);
  1362. background-repeat: no-repeat;
  1363. background-size: 100% 100%;
  1364. flex-shrink: 0;
  1365. }
  1366. .session-chip-name {
  1367. max-width: 150px;
  1368. overflow: hidden;
  1369. text-overflow: ellipsis;
  1370. white-space: nowrap;
  1371. }
  1372. .session-chip-remove {
  1373. font-size: 10px;
  1374. color: #8b949e;
  1375. cursor: pointer;
  1376. padding: 0 2px;
  1377. transition: color 0.2s;
  1378. &:hover {
  1379. color: #ff4d4f;
  1380. }
  1381. }
  1382. }
  1383. }
  1384. .skill-chips {
  1385. display: flex;
  1386. flex-wrap: wrap;
  1387. gap: 6px;
  1388. margin-bottom: 5px;
  1389. .skill-chip {
  1390. display: inline-flex;
  1391. align-items: center;
  1392. gap: 4px;
  1393. padding: 3px 6px 3px 4px;
  1394. background: rgba(10, 132, 255, 0.15);
  1395. border: 1px solid rgba(10, 132, 255, 0.3);
  1396. border-radius: 4px;
  1397. font-size: 12px;
  1398. color: #e0e6ed;
  1399. cursor: default;
  1400. .skill-chip-icon {
  1401. width: 16px;
  1402. height: 16px;
  1403. background-image: var(--img-chat-options-skill-icon);
  1404. background-repeat: no-repeat;
  1405. background-size: 100% 100%;
  1406. flex-shrink: 0;
  1407. }
  1408. .skill-chip-name {
  1409. max-width: 150px;
  1410. overflow: hidden;
  1411. text-overflow: ellipsis;
  1412. white-space: nowrap;
  1413. }
  1414. .skill-chip-remove {
  1415. font-size: 10px;
  1416. color: #8b949e;
  1417. cursor: pointer;
  1418. padding: 0 2px;
  1419. transition: color 0.2s;
  1420. &:hover {
  1421. color: #ff4d4f;
  1422. }
  1423. }
  1424. }
  1425. }
  1426. .session-popup {
  1427. position: absolute;
  1428. bottom: 100%;
  1429. left: 0;
  1430. right: 0;
  1431. margin-bottom: 8px;
  1432. background: #0a2a3f;
  1433. border: 1px solid #1a4a6f;
  1434. border-radius: 8px;
  1435. max-height: 300px;
  1436. display: flex;
  1437. flex-direction: column;
  1438. z-index: 1000;
  1439. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1440. .session-popup-header {
  1441. display: flex;
  1442. justify-content: space-between;
  1443. align-items: center;
  1444. padding: 10px 14px 8px;
  1445. font-size: 13px;
  1446. color: #e0e6ed;
  1447. border-bottom: 1px solid rgba(63, 80, 106, 0.3);
  1448. flex-shrink: 0;
  1449. .session-count {
  1450. font-size: 12px;
  1451. color: #3a8fd4;
  1452. font-weight: 500;
  1453. }
  1454. }
  1455. .session-list {
  1456. flex: 1;
  1457. overflow-y: auto;
  1458. padding: 6px;
  1459. .session-item {
  1460. display: flex;
  1461. align-items: center;
  1462. gap: 10px;
  1463. padding: 8px 10px;
  1464. cursor: pointer;
  1465. border-radius: 6px;
  1466. transition: background 0.2s;
  1467. &:hover {
  1468. background: rgba(10, 132, 255, 0.15);
  1469. }
  1470. &.active {
  1471. background: rgba(10, 132, 255, 0.2);
  1472. }
  1473. &.selected {
  1474. background: rgba(10, 132, 255, 0.12);
  1475. }
  1476. &.disabled {
  1477. opacity: 0.4;
  1478. cursor: not-allowed;
  1479. &:hover {
  1480. background: transparent;
  1481. }
  1482. }
  1483. .session-checkbox {
  1484. width: 16px;
  1485. height: 16px;
  1486. border: 1.5px solid rgba(255, 255, 255, 0.25);
  1487. border-radius: 3px;
  1488. flex-shrink: 0;
  1489. display: flex;
  1490. align-items: center;
  1491. justify-content: center;
  1492. transition: all 0.2s;
  1493. &.checked {
  1494. background: #3a8fd4;
  1495. border-color: #3a8fd4;
  1496. }
  1497. .check-mark {
  1498. font-size: 11px;
  1499. color: #fff;
  1500. line-height: 1;
  1501. }
  1502. }
  1503. .session-item-icon {
  1504. width: 18px;
  1505. height: 18px;
  1506. background-image: var(--img-chat-popup-session-icon);
  1507. background-repeat: no-repeat;
  1508. background-size: 100% 100%;
  1509. flex-shrink: 0;
  1510. }
  1511. .session-item-name {
  1512. font-size: 13px;
  1513. color: #e0e6ed;
  1514. overflow: hidden;
  1515. text-overflow: ellipsis;
  1516. white-space: nowrap;
  1517. }
  1518. }
  1519. .session-empty {
  1520. text-align: center;
  1521. color: #8b949e;
  1522. font-size: 13px;
  1523. padding: 20px 0;
  1524. }
  1525. }
  1526. .session-popup-footer {
  1527. padding: 8px 14px;
  1528. font-size: 12px;
  1529. color: #8b949e;
  1530. text-align: center;
  1531. border-top: 1px solid rgba(63, 80, 106, 0.3);
  1532. flex-shrink: 0;
  1533. .max-hint {
  1534. color: #faad14;
  1535. }
  1536. }
  1537. }
  1538. .skill-popup {
  1539. position: absolute;
  1540. bottom: 100%;
  1541. left: 0;
  1542. right: 0;
  1543. margin-bottom: 8px;
  1544. background: #0a2a3f;
  1545. border: 1px solid #1a4a6f;
  1546. border-radius: 8px;
  1547. max-height: 300px;
  1548. display: flex;
  1549. flex-direction: column;
  1550. z-index: 1000;
  1551. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1552. .skill-popup-header {
  1553. display: flex;
  1554. justify-content: space-between;
  1555. align-items: center;
  1556. padding: 10px 14px 8px;
  1557. font-size: 13px;
  1558. color: #e0e6ed;
  1559. border-bottom: 1px solid rgba(63, 80, 106, 0.3);
  1560. flex-shrink: 0;
  1561. .skill-count {
  1562. font-size: 12px;
  1563. color: #3a8fd4;
  1564. font-weight: 500;
  1565. }
  1566. }
  1567. .skill-list {
  1568. flex: 1;
  1569. overflow-y: auto;
  1570. padding: 6px;
  1571. .skill-item {
  1572. display: flex;
  1573. align-items: center;
  1574. gap: 10px;
  1575. padding: 8px 10px;
  1576. cursor: pointer;
  1577. border-radius: 6px;
  1578. transition: background 0.2s;
  1579. &:hover {
  1580. background: rgba(10, 132, 255, 0.15);
  1581. }
  1582. &.active {
  1583. background: rgba(10, 132, 255, 0.2);
  1584. }
  1585. &.selected {
  1586. background: rgba(10, 132, 255, 0.12);
  1587. }
  1588. .skill-item-checkbox {
  1589. width: 16px;
  1590. height: 16px;
  1591. border: 1.5px solid rgba(255, 255, 255, 0.25);
  1592. border-radius: 3px;
  1593. flex-shrink: 0;
  1594. display: flex;
  1595. align-items: center;
  1596. justify-content: center;
  1597. transition: all 0.2s;
  1598. &.checked {
  1599. background: #3a8fd4;
  1600. border-color: #3a8fd4;
  1601. }
  1602. .check-mark {
  1603. font-size: 11px;
  1604. color: #fff;
  1605. line-height: 1;
  1606. }
  1607. }
  1608. .skill-item-icon {
  1609. width: 18px;
  1610. height: 18px;
  1611. background-image: var(--img-chat-options-skill-icon);
  1612. background-repeat: no-repeat;
  1613. background-size: 100% 100%;
  1614. flex-shrink: 0;
  1615. }
  1616. .skill-item-name {
  1617. font-size: 13px;
  1618. color: #e0e6ed;
  1619. overflow: hidden;
  1620. text-overflow: ellipsis;
  1621. white-space: nowrap;
  1622. }
  1623. }
  1624. .skill-empty {
  1625. text-align: center;
  1626. color: #8b949e;
  1627. font-size: 13px;
  1628. padding: 20px 0;
  1629. }
  1630. }
  1631. .skill-popup-footer {
  1632. padding: 8px 14px;
  1633. font-size: 12px;
  1634. color: #8b949e;
  1635. text-align: center;
  1636. border-top: 1px solid rgba(63, 80, 106, 0.3);
  1637. flex-shrink: 0;
  1638. }
  1639. }
  1640. }
  1641. </style>