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" @click="emit('pending-file-preview', pendingFile)">
  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.stop="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: 'pending-file-preview', file: AttachedFile): void;
  313. (e: 'model-change', modelKey: string): void;
  314. (e: 'think-level-change', levelKey: string): void;
  315. (e: 'edit-mode-change', modeKey: string): void;
  316. (e: 'update:selectedSessions', sessions: Array<{ id: string; name: string }>): void;
  317. (e: 'update:selectedSkill', skill: { name: string; display_name: string } | null): void;
  318. }>();
  319. const handleSelectModel = (item: ModelOption) => {
  320. selectedModel.value = item;
  321. showModelPopup.value = false;
  322. emit('model-change', item.key);
  323. };
  324. const fileInputRef = ref<HTMLInputElement>();
  325. const popupRef = ref<HTMLElement>();
  326. const showPopup = ref(false);
  327. // 上下文容量
  328. const contextPopupRef = ref<HTMLElement>();
  329. const showContextPopup = ref(false);
  330. const contextPercent = computed(() => {
  331. return props.contextPercent;
  332. });
  333. const contextCircumference = computed(() => 2 * Math.PI * 13);
  334. const contextOffset = computed(() => contextCircumference.value * (1 - contextPercent.value / 100));
  335. const contextColor = computed(() => {
  336. if (contextPercent.value >= 90) return '#ff4d4f';
  337. if (contextPercent.value >= 70) return '#faad14';
  338. return '#52c41a';
  339. });
  340. const contextDisplayUsed = computed(() => {
  341. if (props.contextUsed >= 10000) return (props.contextUsed / 10000).toFixed(1) + '万';
  342. return props.contextUsed.toLocaleString();
  343. });
  344. const contextDisplayMax = computed(() => {
  345. if (props.contextMax >= 10000) return (props.contextMax / 10000).toFixed(0) + '万';
  346. return props.contextMax.toLocaleString();
  347. });
  348. const formatTokens = (tokens: number) => {
  349. if (tokens >= 10000) return (tokens / 10000).toFixed(1) + '万';
  350. return tokens.toLocaleString();
  351. };
  352. const toggleContextPopup = () => {
  353. showContextPopup.value = !showContextPopup.value;
  354. };
  355. onClickOutside(contextPopupRef, () => {
  356. showContextPopup.value = false;
  357. });
  358. // 模型选择
  359. const modelPopupRef = ref<HTMLElement>();
  360. const showModelPopup = ref(false);
  361. interface ModelOption {
  362. key: string;
  363. label: string;
  364. desc: string;
  365. }
  366. const modelOptions: ModelOption[] = [
  367. { key: 'deepseek-v4-pro', label: 'DeepSeek-V4-Pro', desc: '默认模型,综合能力强' },
  368. { key: 'deepseek-v4', label: 'DeepSeek-V4', desc: '轻量快速,适合简单任务' },
  369. { key: 'gpt-4o', label: 'GPT-4o', desc: 'OpenAI 多模态模型' },
  370. { key: 'gpt-4o-mini', label: 'GPT-4o Mini', desc: 'OpenAI 轻量模型' },
  371. { key: 'claude-sonnet-4', label: 'Claude Sonnet 4', desc: 'Anthropic 高性能模型' },
  372. { key: 'qwen-max', label: '通义千问 Max', desc: '阿里云旗舰模型' },
  373. ];
  374. const selectedModel = ref<ModelOption>(modelOptions[0]);
  375. const toggleModelPopup = () => {
  376. showModelPopup.value = !showModelPopup.value;
  377. };
  378. onClickOutside(modelPopupRef, () => {
  379. showModelPopup.value = false;
  380. });
  381. // 思考级别
  382. const thinkPopupRef = ref<HTMLElement>();
  383. const showThinkPopup = ref(false);
  384. interface ThinkLevelOption {
  385. key: string;
  386. label: string;
  387. desc: string;
  388. }
  389. const thinkLevelOptions: ThinkLevelOption[] = [
  390. { key: 'off', label: '关闭', desc: '不使用深度思考,响应最快' },
  391. { key: 'high', label: '高', desc: '深度思考,平衡速度与质量' },
  392. { key: 'highest', label: '最高', desc: '极致思考,质量最高但较慢' },
  393. ];
  394. const selectedThinkLevel = ref<ThinkLevelOption>(thinkLevelOptions[0]);
  395. watch(
  396. () => props.initialThinkLevel,
  397. (level) => {
  398. const found = thinkLevelOptions.find((opt) => opt.key === level);
  399. if (found) selectedThinkLevel.value = found;
  400. },
  401. { immediate: true }
  402. );
  403. const toggleThinkPopup = () => {
  404. showThinkPopup.value = !showThinkPopup.value;
  405. };
  406. const handleSelectThinkLevel = (item: ThinkLevelOption) => {
  407. selectedThinkLevel.value = item;
  408. showThinkPopup.value = false;
  409. emit('think-level-change', item.key);
  410. };
  411. onClickOutside(thinkPopupRef, () => {
  412. showThinkPopup.value = false;
  413. });
  414. const editModePopupRef = ref<HTMLElement>();
  415. const showEditModePopup = ref(false);
  416. interface EditModeOption {
  417. key: string;
  418. label: string;
  419. desc: string;
  420. }
  421. const editModeOptions: EditModeOption[] = [
  422. // { key: 'confirm', label: '变更前确认', desc: '改文件前先问我' },
  423. // { key: 'auto', label: '自动编辑', desc: '自动编辑文件' },
  424. { key: 'plan', label: '计划模式', desc: '编辑前先出计划' },
  425. { key: 'full', label: '完全访问', desc: '减少确认次数' },
  426. ];
  427. const selectedEditMode = ref<EditModeOption>(editModeOptions[1]);
  428. watch(
  429. () => props.initialEditMode,
  430. (mode) => {
  431. const found = editModeOptions.find((opt) => opt.key === mode);
  432. if (found) selectedEditMode.value = found;
  433. },
  434. { immediate: true }
  435. );
  436. onClickOutside(editModePopupRef, () => {
  437. showEditModePopup.value = false;
  438. });
  439. const toggleEditModePopup = () => {
  440. showEditModePopup.value = !showEditModePopup.value;
  441. };
  442. const handleSelectEditMode = (item: EditModeOption) => {
  443. selectedEditMode.value = item;
  444. showEditModePopup.value = false;
  445. emit('edit-mode-change', item.key);
  446. };
  447. onClickOutside(popupRef, () => {
  448. showPopup.value = false;
  449. });
  450. const togglePopup = () => {
  451. showPopup.value = !showPopup.value;
  452. };
  453. const handleAddAttachment = () => {
  454. showPopup.value = false;
  455. emit('file-upload');
  456. };
  457. const handleInsertMention = () => {
  458. showPopup.value = false;
  459. };
  460. // 会话列表弹框
  461. const textareaRef = ref<InstanceType<any>>();
  462. const sessionPopupRef = ref<HTMLElement>();
  463. const showSessionPopup = ref(false);
  464. const activeSessionIndex = ref(0);
  465. const selectedSessions = ref<Array<{ id: string; name: string }>>([]);
  466. const sessionPopupManual = ref(false);
  467. let isRemovingTag = false;
  468. let sessionJustSelected = false;
  469. // 技能列表弹框
  470. interface SkillItem {
  471. name: string;
  472. display_name: string;
  473. path: string;
  474. description: string;
  475. enabled: boolean;
  476. agents: string[];
  477. has_skill_md: boolean;
  478. }
  479. const skillPopupRef = ref<HTMLElement>();
  480. const showSkillPopup = ref(false);
  481. const activeSkillIndex = ref(0);
  482. const selectedSkill = ref<{ name: string; display_name: string } | null>(null);
  483. const skillPopupManual = ref(false);
  484. const skillList = ref<SkillItem[]>([]);
  485. let skillJustSelected = false;
  486. const fetchSkillList = async () => {
  487. try {
  488. const res = await getSkills();
  489. skillList.value = res?.skills || [];
  490. } catch {
  491. skillList.value = [];
  492. }
  493. };
  494. onMounted(() => {
  495. fetchSkillList();
  496. });
  497. const isSkillSelected = (name: string) => {
  498. return selectedSkill.value?.name === name;
  499. };
  500. const isSessionSelected = (sessionId: string) => {
  501. return selectedSessions.value.some((s) => s.id === sessionId);
  502. };
  503. const sessionSearchText = computed(() => {
  504. const val = props.modelValue || '';
  505. const hashIndex = val.lastIndexOf('#');
  506. if (hashIndex === -1) return '';
  507. const afterHash = val.substring(hashIndex + 1);
  508. if (afterHash.includes(' ')) return '';
  509. return afterHash.toLowerCase();
  510. });
  511. const filteredSessionList = computed(() => {
  512. const list = props.taskList.filter((t) => t.sessionId);
  513. if (!sessionSearchText.value) return list;
  514. return list.filter((t) => t.name.toLowerCase().includes(sessionSearchText.value));
  515. });
  516. watch(filteredSessionList, () => {
  517. activeSessionIndex.value = 0;
  518. });
  519. watch(showSessionPopup, (val) => {
  520. if (val) activeSessionIndex.value = 0;
  521. });
  522. const skillSearchText = computed(() => {
  523. const val = props.modelValue || '';
  524. const dollarIndex = val.lastIndexOf('$');
  525. if (dollarIndex === -1) return '';
  526. const afterDollar = val.substring(dollarIndex + 1);
  527. if (afterDollar.includes(' ')) return '';
  528. return afterDollar.toLowerCase();
  529. });
  530. const filteredSkillList = computed(() => {
  531. if (!skillSearchText.value) return skillList.value;
  532. return skillList.value.filter(
  533. (s) => s.display_name.toLowerCase().includes(skillSearchText.value) || s.name.toLowerCase().includes(skillSearchText.value)
  534. );
  535. });
  536. watch(filteredSkillList, () => {
  537. activeSkillIndex.value = 0;
  538. });
  539. watch(showSkillPopup, (val) => {
  540. if (val) activeSkillIndex.value = 0;
  541. });
  542. const handleSessionKeydown = (e: KeyboardEvent) => {
  543. if (showSkillPopup.value && filteredSkillList.value.length > 0) {
  544. if (e.key === 'ArrowDown') {
  545. e.preventDefault();
  546. activeSkillIndex.value = (activeSkillIndex.value + 1) % filteredSkillList.value.length;
  547. } else if (e.key === 'ArrowUp') {
  548. e.preventDefault();
  549. activeSkillIndex.value = (activeSkillIndex.value - 1 + filteredSkillList.value.length) % filteredSkillList.value.length;
  550. } else if (e.key === 'Enter') {
  551. e.preventDefault();
  552. const skill = filteredSkillList.value[activeSkillIndex.value];
  553. if (skill) {
  554. skillJustSelected = true;
  555. handleSelectSkill(skill);
  556. }
  557. }
  558. return;
  559. }
  560. if (showSessionPopup.value && filteredSessionList.value.length > 0) {
  561. if (e.key === 'ArrowDown') {
  562. e.preventDefault();
  563. activeSessionIndex.value = (activeSessionIndex.value + 1) % filteredSessionList.value.length;
  564. } else if (e.key === 'ArrowUp') {
  565. e.preventDefault();
  566. activeSessionIndex.value = (activeSessionIndex.value - 1 + filteredSessionList.value.length) % filteredSessionList.value.length;
  567. } else if (e.key === 'Enter') {
  568. e.preventDefault();
  569. const task = filteredSessionList.value[activeSessionIndex.value];
  570. if (task) {
  571. sessionJustSelected = true;
  572. handleSelectSession(task);
  573. }
  574. }
  575. }
  576. };
  577. const handleInsertSession = () => {
  578. showPopup.value = false;
  579. sessionPopupManual.value = true;
  580. showSessionPopup.value = true;
  581. const cur = props.modelValue || '';
  582. const needsSpace = cur && !cur.endsWith(' ') ? ' ' : '';
  583. emit('update:modelValue', `${cur}${needsSpace}#`);
  584. nextTick(() => {
  585. const el = textareaRef.value?.$el?.querySelector('textarea') || textareaRef.value?.$el;
  586. if (el) el.focus();
  587. });
  588. };
  589. const handleSelectSession = (task: Task) => {
  590. if (task.id === props.currentTaskId) return;
  591. const idx = selectedSessions.value.findIndex((s) => s.id === task.id);
  592. if (idx >= 0) {
  593. selectedSessions.value.splice(idx, 1);
  594. } else {
  595. if (selectedSessions.value.length >= 5) return;
  596. selectedSessions.value.push({ id: task.id, name: task.name });
  597. }
  598. removeSearchTag();
  599. emit('update:selectedSessions', [...selectedSessions.value]);
  600. };
  601. const handleInsertSkill = () => {
  602. showPopup.value = false;
  603. showSessionPopup.value = false;
  604. skillPopupManual.value = true;
  605. showSkillPopup.value = true;
  606. const cur = props.modelValue || '';
  607. const needsSpace = cur && !cur.endsWith(' ') ? ' ' : '';
  608. emit('update:modelValue', `${cur}${needsSpace}$`);
  609. nextTick(() => {
  610. const el = textareaRef.value?.$el?.querySelector('textarea') || textareaRef.value?.$el;
  611. if (el) el.focus();
  612. });
  613. };
  614. const handleSelectSkill = (skill: SkillItem) => {
  615. selectedSkill.value = { name: skill.name, display_name: skill.display_name };
  616. removeSkillSearchTag();
  617. showSkillPopup.value = false;
  618. skillPopupManual.value = false;
  619. emit('update:selectedSkill', { name: skill.name, display_name: skill.display_name });
  620. };
  621. const removeSkillSearchTag = () => {
  622. isRemovingTag = true;
  623. const val = props.modelValue || '';
  624. const dollarIndex = val.lastIndexOf('$');
  625. if (dollarIndex === -1) {
  626. isRemovingTag = false;
  627. return;
  628. }
  629. emit('update:modelValue', val.substring(0, dollarIndex).trimEnd());
  630. nextTick(() => {
  631. isRemovingTag = false;
  632. });
  633. };
  634. const removeSkill = () => {
  635. selectedSkill.value = null;
  636. emit('update:selectedSkill', null);
  637. };
  638. const removeSearchTag = () => {
  639. isRemovingTag = true;
  640. const val = props.modelValue || '';
  641. const hashIndex = val.lastIndexOf('#');
  642. if (hashIndex === -1) {
  643. isRemovingTag = false;
  644. return;
  645. }
  646. emit('update:modelValue', val.substring(0, hashIndex).trimEnd());
  647. nextTick(() => {
  648. isRemovingTag = false;
  649. });
  650. };
  651. watch(
  652. () => props.modelValue,
  653. (newVal, oldVal) => {
  654. if (isRemovingTag) return;
  655. if (oldVal && !newVal) {
  656. selectedSessions.value = [];
  657. selectedSkill.value = null;
  658. }
  659. }
  660. );
  661. const removeSession = (sessionId: string) => {
  662. selectedSessions.value = selectedSessions.value.filter((s) => s.id !== sessionId);
  663. emit('update:selectedSessions', [...selectedSessions.value]);
  664. };
  665. const handleTextareaInput = (val: string) => {
  666. emit('update:modelValue', val);
  667. // 技能弹框 $ 检测
  668. if (!skillPopupManual.value) {
  669. const dollarIndex = val.lastIndexOf('$');
  670. if (dollarIndex === -1) {
  671. showSkillPopup.value = false;
  672. } else {
  673. const afterDollar = val.substring(dollarIndex + 1);
  674. if (afterDollar.includes(' ')) {
  675. showSkillPopup.value = false;
  676. } else {
  677. showSkillPopup.value = true;
  678. showSessionPopup.value = false;
  679. }
  680. }
  681. }
  682. // 会话弹框 # 检测
  683. if (!sessionPopupManual.value) {
  684. const hashIndex = val.lastIndexOf('#');
  685. if (hashIndex === -1) {
  686. showSessionPopup.value = false;
  687. } else {
  688. const afterHash = val.substring(hashIndex + 1);
  689. if (afterHash.includes(' ')) {
  690. showSessionPopup.value = false;
  691. } else {
  692. showSessionPopup.value = true;
  693. showSkillPopup.value = false;
  694. }
  695. }
  696. }
  697. };
  698. const handleBackspace = (e: KeyboardEvent) => {
  699. const val = props.modelValue || '';
  700. if (val) return;
  701. if (selectedSkill.value) {
  702. e.preventDefault();
  703. selectedSkill.value = null;
  704. emit('update:selectedSkill', null);
  705. } else if (selectedSessions.value.length > 0) {
  706. e.preventDefault();
  707. selectedSessions.value.pop();
  708. emit('update:selectedSessions', [...selectedSessions.value]);
  709. }
  710. };
  711. onClickOutside(sessionPopupRef, () => {
  712. showSessionPopup.value = false;
  713. sessionPopupManual.value = false;
  714. });
  715. onClickOutside(skillPopupRef, () => {
  716. showSkillPopup.value = false;
  717. skillPopupManual.value = false;
  718. });
  719. const handleInsertCommand = () => {
  720. showPopup.value = false;
  721. };
  722. const handleEnterKey = (e: KeyboardEvent) => {
  723. if (showSessionPopup.value || showSkillPopup.value) return;
  724. if (sessionJustSelected) {
  725. sessionJustSelected = false;
  726. return;
  727. }
  728. if (skillJustSelected) {
  729. skillJustSelected = false;
  730. return;
  731. }
  732. if (!e.shiftKey && props.modelValue.trim() && !props.loading) {
  733. emit('send');
  734. }
  735. };
  736. const handleSend = () => {
  737. if (props.modelValue.trim() && !props.loading) {
  738. emit('send');
  739. }
  740. };
  741. const handleSendClick = () => {
  742. if (props.streaming) {
  743. emit('stop');
  744. return;
  745. }
  746. handleSend();
  747. };
  748. defineExpose({ fileInputRef });
  749. </script>
  750. <style scoped lang="less">
  751. .chat-input-area {
  752. position: relative;
  753. padding: 5px 10px;
  754. flex-shrink: 0;
  755. background-color: #002f4a;
  756. border: 1px solid #005482;
  757. border-radius: 4px;
  758. margin: 10px 16px 16px 16px;
  759. .pending-file-display {
  760. margin-bottom: 5px;
  761. .pending-file-card {
  762. display: flex;
  763. align-items: center;
  764. gap: 10px;
  765. padding: 10px 12px;
  766. background: rgba(10, 132, 255, 0.06);
  767. border: 1px solid rgba(63, 80, 106, 0.5);
  768. border-radius: 6px;
  769. transition: all 0.3s;
  770. cursor: pointer;
  771. &:hover {
  772. background: rgba(10, 132, 255, 0.1);
  773. }
  774. .file-icon-pending {
  775. width: 32px;
  776. height: 32px;
  777. background-image: var(--img-chat-attach-icon);
  778. background-repeat: no-repeat;
  779. background-size: 100% 100%;
  780. flex-shrink: 0;
  781. }
  782. .file-info-pending {
  783. flex: 1;
  784. min-width: 0;
  785. .file-name-pending {
  786. font-size: 12px;
  787. font-weight: 400;
  788. line-height: 1.4;
  789. color: #e0e6ed;
  790. overflow: hidden;
  791. text-overflow: ellipsis;
  792. white-space: nowrap;
  793. margin-bottom: 2px;
  794. }
  795. .file-size-pending {
  796. font-size: 11px;
  797. font-weight: 400;
  798. line-height: 1.3;
  799. color: #8b949e;
  800. }
  801. }
  802. .remove-pending {
  803. cursor: pointer;
  804. color: #8b949e;
  805. font-size: 14px;
  806. padding: 4px;
  807. border-radius: 4px;
  808. transition: all 0.3s;
  809. &:hover {
  810. color: #ff4d4f;
  811. background: rgba(220, 38, 38, 0.1);
  812. }
  813. }
  814. }
  815. }
  816. :deep(.chat-input) {
  817. color: #e0e6ed;
  818. background-color: transparent !important;
  819. border: none !important;
  820. &::placeholder {
  821. color: #8b949e !important;
  822. opacity: 1 !important;
  823. }
  824. &:focus,
  825. &:hover,
  826. &:active {
  827. border: none !important;
  828. box-shadow: none !important;
  829. outline: none !important;
  830. }
  831. }
  832. .input-actions {
  833. display: flex;
  834. justify-content: space-between;
  835. align-items: center;
  836. margin-top: 12px;
  837. .mode-icon-confirm {
  838. background-image: var(--img-chat-mode-confirm-icon);
  839. }
  840. .mode-icon-auto {
  841. background-image: var(--img-chat-mode-auto-icon);
  842. }
  843. .mode-icon-plan {
  844. background-image: var(--img-chat-mode-plan-icon);
  845. }
  846. .mode-icon-full {
  847. background-image: var(--img-chat-mode-full-icon);
  848. }
  849. .action-left,
  850. .action-right {
  851. display: flex;
  852. gap: 8px;
  853. .action-divider {
  854. width: 1px;
  855. height: 18px;
  856. background: rgba(255, 255, 255, 0.15);
  857. align-self: center;
  858. flex-shrink: 0;
  859. }
  860. .btn-icon {
  861. width: 14px;
  862. height: 14px;
  863. background-repeat: no-repeat;
  864. background-size: 100% 100%;
  865. flex-shrink: 0;
  866. }
  867. .think-icon {
  868. background-image: var(--img-chat-thinking-icon);
  869. }
  870. .btn-text {
  871. font-size: 12px;
  872. color: #e0e6ed;
  873. white-space: nowrap;
  874. }
  875. .btn-arrow {
  876. width: 0;
  877. height: 0;
  878. border-left: 4px solid transparent;
  879. border-right: 4px solid transparent;
  880. border-top: 4px solid #8b949e;
  881. flex-shrink: 0;
  882. }
  883. .btn-upload-wrapper {
  884. position: relative;
  885. }
  886. .btn-upload {
  887. width: 30px;
  888. height: 30px;
  889. border-radius: 6px;
  890. display: flex;
  891. align-items: center;
  892. justify-content: center;
  893. cursor: pointer;
  894. }
  895. .plus-icon {
  896. width: 20px;
  897. height: 20px;
  898. background-image: var(--img-chat-input-bg);
  899. background-repeat: no-repeat;
  900. background-size: 100% 100%;
  901. cursor: pointer;
  902. }
  903. .upload-popup {
  904. position: absolute;
  905. bottom: 38px;
  906. left: 0;
  907. background: #0a2a3f;
  908. border: 1px solid #1a4a6f;
  909. border-radius: 8px;
  910. min-width: 160px;
  911. z-index: 1000;
  912. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  913. .popup-item {
  914. display: flex;
  915. align-items: center;
  916. gap: 10px;
  917. padding: 9px 16px;
  918. cursor: pointer;
  919. transition: background 0.2s;
  920. border-radius: 8px;
  921. &:hover {
  922. background: rgba(10, 132, 255, 0.15);
  923. }
  924. .popup-item-icon {
  925. width: 18px;
  926. height: 18px;
  927. background-repeat: no-repeat;
  928. background-size: 100% 100%;
  929. flex-shrink: 0;
  930. }
  931. .attach-icon {
  932. background-image: var(--img-chat-popup-attach-icon);
  933. }
  934. .mention-icon {
  935. background-image: var(--img-chat-popup-mention-icon);
  936. }
  937. .session-icon {
  938. background-image: var(--img-chat-popup-session-icon);
  939. }
  940. .skill-icon {
  941. background-image: var(--img-chat-options-skill-icon);
  942. }
  943. .command-icon {
  944. background-image: var(--img-chat-popup-command-icon);
  945. }
  946. .popup-item-text {
  947. font-size: 13px;
  948. color: #e0e6ed;
  949. white-space: nowrap;
  950. }
  951. }
  952. }
  953. .btn-edit-mode-wrapper {
  954. position: relative;
  955. }
  956. .btn-edit-mode {
  957. height: 28px;
  958. padding: 0 10px;
  959. border-radius: 6px;
  960. display: flex;
  961. align-items: center;
  962. gap: 4px;
  963. cursor: pointer;
  964. transition: all 0.2s;
  965. &:hover {
  966. border-color: #3a8fd4;
  967. background: rgba(10, 132, 255, 0.1);
  968. }
  969. }
  970. .edit-mode-popup {
  971. position: absolute;
  972. bottom: 38px;
  973. left: 50%;
  974. transform: translateX(-50%);
  975. background: #0a2a3f;
  976. border: 1px solid #1a4a6f;
  977. border-radius: 8px;
  978. min-width: 200px;
  979. z-index: 1000;
  980. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  981. .edit-mode-item {
  982. display: flex;
  983. align-items: center;
  984. justify-content: space-between;
  985. padding: 10px 12px;
  986. cursor: pointer;
  987. transition: background 0.2s;
  988. border-radius: 6px;
  989. &:hover {
  990. background: rgba(10, 132, 255, 0.15);
  991. }
  992. &.active {
  993. background: rgba(10, 132, 255, 0.1);
  994. }
  995. .edit-mode-item-icon {
  996. width: 18px;
  997. height: 18px;
  998. background-repeat: no-repeat;
  999. background-size: 100% 100%;
  1000. flex-shrink: 0;
  1001. margin-right: 10px;
  1002. }
  1003. .edit-mode-item-main {
  1004. display: flex;
  1005. flex-direction: column;
  1006. gap: 2px;
  1007. .edit-mode-item-label {
  1008. font-size: 13px;
  1009. color: #e0e6ed;
  1010. white-space: nowrap;
  1011. }
  1012. .edit-mode-item-desc {
  1013. font-size: 11px;
  1014. color: #8b949e;
  1015. white-space: nowrap;
  1016. }
  1017. }
  1018. .edit-mode-check {
  1019. width: 16px;
  1020. height: 16px;
  1021. flex-shrink: 0;
  1022. display: flex;
  1023. align-items: center;
  1024. justify-content: center;
  1025. visibility: hidden;
  1026. &.visible {
  1027. visibility: visible;
  1028. }
  1029. &::after {
  1030. content: '✓';
  1031. font-size: 12px;
  1032. color: #3a8fd4;
  1033. }
  1034. }
  1035. }
  1036. }
  1037. .btn-context-wrapper {
  1038. position: relative;
  1039. display: flex;
  1040. align-items: center;
  1041. }
  1042. .btn-context {
  1043. width: 30px;
  1044. height: 30px;
  1045. display: flex;
  1046. align-items: center;
  1047. justify-content: center;
  1048. cursor: pointer;
  1049. position: relative;
  1050. border-radius: 6px;
  1051. transition: background 0.2s;
  1052. &:hover {
  1053. background: rgba(10, 132, 255, 0.1);
  1054. }
  1055. .context-ring {
  1056. width: 24px;
  1057. height: 24px;
  1058. transform: rotate(-90deg);
  1059. .context-ring-bg {
  1060. fill: none;
  1061. stroke: rgba(255, 255, 255, 0.1);
  1062. stroke-width: 3;
  1063. }
  1064. .context-ring-fill {
  1065. fill: none;
  1066. stroke-width: 3;
  1067. stroke-linecap: round;
  1068. transition: stroke-dashoffset 0.3s ease;
  1069. }
  1070. }
  1071. .context-percent {
  1072. position: absolute;
  1073. font-size: 8px;
  1074. color: #e0e6ed;
  1075. font-weight: 500;
  1076. line-height: 1;
  1077. }
  1078. }
  1079. .context-popup {
  1080. position: absolute;
  1081. bottom: 42px;
  1082. left: 50%;
  1083. transform: translateX(-50%);
  1084. background: #0a2a3f;
  1085. border: 1px solid #1a4a6f;
  1086. border-radius: 8px;
  1087. min-width: 200px;
  1088. padding: 14px 16px;
  1089. &::before {
  1090. content: '';
  1091. position: absolute;
  1092. bottom: -12px;
  1093. left: 0;
  1094. right: 0;
  1095. height: 12px;
  1096. }
  1097. z-index: 1000;
  1098. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1099. .context-popup-title {
  1100. font-size: 13px;
  1101. color: #8b949e;
  1102. margin-bottom: 8px;
  1103. }
  1104. .context-popup-info {
  1105. display: flex;
  1106. align-items: baseline;
  1107. gap: 2px;
  1108. margin-bottom: 10px;
  1109. .context-used {
  1110. font-size: 18px;
  1111. font-weight: 600;
  1112. color: #e0e6ed;
  1113. }
  1114. .context-sep {
  1115. font-size: 14px;
  1116. color: #8b949e;
  1117. }
  1118. .context-max {
  1119. font-size: 14px;
  1120. color: #8b949e;
  1121. }
  1122. .context-pct {
  1123. font-size: 13px;
  1124. color: #8b949e;
  1125. }
  1126. }
  1127. .context-popup-bar-track {
  1128. width: 100%;
  1129. height: 6px;
  1130. background: rgba(255, 255, 255, 0.08);
  1131. border-radius: 3px;
  1132. overflow: hidden;
  1133. .context-popup-bar-fill {
  1134. height: 100%;
  1135. border-radius: 3px;
  1136. transition: width 0.3s ease;
  1137. }
  1138. }
  1139. .context-breakdown {
  1140. margin-top: 10px;
  1141. padding-top: 10px;
  1142. border-top: 1px solid rgba(255, 255, 255, 0.08);
  1143. .breakdown-item {
  1144. display: flex;
  1145. justify-content: space-between;
  1146. align-items: center;
  1147. padding: 3px 0;
  1148. .breakdown-label {
  1149. font-size: 12px;
  1150. color: #8b949e;
  1151. }
  1152. .breakdown-value {
  1153. font-size: 12px;
  1154. color: #e0e6ed;
  1155. }
  1156. }
  1157. }
  1158. }
  1159. .btn-model-wrapper {
  1160. position: relative;
  1161. display: flex;
  1162. align-items: center;
  1163. }
  1164. .btn-model {
  1165. height: 28px;
  1166. padding: 0 10px;
  1167. border-radius: 6px;
  1168. display: flex;
  1169. align-items: center;
  1170. gap: 4px;
  1171. cursor: pointer;
  1172. transition: all 0.2s;
  1173. border: 1px solid rgba(255, 255, 255, 0.12);
  1174. &:hover {
  1175. border-color: #3a8fd4;
  1176. background: rgba(10, 132, 255, 0.1);
  1177. }
  1178. }
  1179. .model-popup {
  1180. position: absolute;
  1181. bottom: 38px;
  1182. left: 50%;
  1183. transform: translateX(-50%);
  1184. background: #0a2a3f;
  1185. border: 1px solid #1a4a6f;
  1186. border-radius: 8px;
  1187. min-width: 220px;
  1188. z-index: 1000;
  1189. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1190. .model-popup-item {
  1191. display: flex;
  1192. align-items: center;
  1193. justify-content: space-between;
  1194. padding: 10px 12px;
  1195. cursor: pointer;
  1196. transition: background 0.2s;
  1197. border-radius: 6px;
  1198. &:hover {
  1199. background: rgba(10, 132, 255, 0.15);
  1200. }
  1201. &.active {
  1202. background: rgba(10, 132, 255, 0.1);
  1203. }
  1204. .model-item-main {
  1205. display: flex;
  1206. flex-direction: column;
  1207. gap: 2px;
  1208. .model-item-label {
  1209. font-size: 13px;
  1210. color: #e0e6ed;
  1211. white-space: nowrap;
  1212. }
  1213. .model-item-desc {
  1214. font-size: 11px;
  1215. color: #8b949e;
  1216. white-space: nowrap;
  1217. }
  1218. }
  1219. .model-item-check {
  1220. width: 16px;
  1221. height: 16px;
  1222. flex-shrink: 0;
  1223. display: flex;
  1224. align-items: center;
  1225. justify-content: center;
  1226. visibility: hidden;
  1227. &.visible {
  1228. visibility: visible;
  1229. }
  1230. &::after {
  1231. content: '✓';
  1232. font-size: 12px;
  1233. color: #3a8fd4;
  1234. }
  1235. }
  1236. }
  1237. }
  1238. .btn-think-wrapper {
  1239. position: relative;
  1240. display: flex;
  1241. align-items: center;
  1242. }
  1243. .btn-think {
  1244. height: 28px;
  1245. padding: 0 10px;
  1246. border-radius: 6px;
  1247. display: flex;
  1248. align-items: center;
  1249. gap: 4px;
  1250. cursor: pointer;
  1251. transition: all 0.2s;
  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>