ChatInputArea.vue 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839
  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. &:hover {
  964. border-color: #3a8fd4;
  965. background: rgba(10, 132, 255, 0.1);
  966. }
  967. }
  968. .edit-mode-popup {
  969. position: absolute;
  970. bottom: 38px;
  971. left: 50%;
  972. transform: translateX(-50%);
  973. background: #0a2a3f;
  974. border: 1px solid #1a4a6f;
  975. border-radius: 8px;
  976. min-width: 200px;
  977. z-index: 1000;
  978. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  979. .edit-mode-item {
  980. display: flex;
  981. align-items: center;
  982. justify-content: space-between;
  983. padding: 10px 12px;
  984. cursor: pointer;
  985. transition: background 0.2s;
  986. border-radius: 6px;
  987. &:hover {
  988. background: rgba(10, 132, 255, 0.15);
  989. }
  990. &.active {
  991. background: rgba(10, 132, 255, 0.1);
  992. }
  993. .edit-mode-item-icon {
  994. width: 18px;
  995. height: 18px;
  996. background-repeat: no-repeat;
  997. background-size: 100% 100%;
  998. flex-shrink: 0;
  999. margin-right: 10px;
  1000. }
  1001. .edit-mode-item-main {
  1002. display: flex;
  1003. flex-direction: column;
  1004. gap: 2px;
  1005. .edit-mode-item-label {
  1006. font-size: 13px;
  1007. color: #e0e6ed;
  1008. white-space: nowrap;
  1009. }
  1010. .edit-mode-item-desc {
  1011. font-size: 11px;
  1012. color: #8b949e;
  1013. white-space: nowrap;
  1014. }
  1015. }
  1016. .edit-mode-check {
  1017. width: 16px;
  1018. height: 16px;
  1019. flex-shrink: 0;
  1020. display: flex;
  1021. align-items: center;
  1022. justify-content: center;
  1023. visibility: hidden;
  1024. &.visible {
  1025. visibility: visible;
  1026. }
  1027. &::after {
  1028. content: '✓';
  1029. font-size: 12px;
  1030. color: #3a8fd4;
  1031. }
  1032. }
  1033. }
  1034. }
  1035. .btn-context-wrapper {
  1036. position: relative;
  1037. display: flex;
  1038. align-items: center;
  1039. }
  1040. .btn-context {
  1041. width: 30px;
  1042. height: 30px;
  1043. display: flex;
  1044. align-items: center;
  1045. justify-content: center;
  1046. cursor: pointer;
  1047. position: relative;
  1048. border-radius: 6px;
  1049. transition: background 0.2s;
  1050. &:hover {
  1051. background: rgba(10, 132, 255, 0.1);
  1052. }
  1053. .context-ring {
  1054. width: 24px;
  1055. height: 24px;
  1056. transform: rotate(-90deg);
  1057. .context-ring-bg {
  1058. fill: none;
  1059. stroke: rgba(255, 255, 255, 0.1);
  1060. stroke-width: 3;
  1061. }
  1062. .context-ring-fill {
  1063. fill: none;
  1064. stroke-width: 3;
  1065. stroke-linecap: round;
  1066. transition: stroke-dashoffset 0.3s ease;
  1067. }
  1068. }
  1069. .context-percent {
  1070. position: absolute;
  1071. font-size: 8px;
  1072. color: #e0e6ed;
  1073. font-weight: 500;
  1074. line-height: 1;
  1075. }
  1076. }
  1077. .context-popup {
  1078. position: absolute;
  1079. bottom: 42px;
  1080. left: 50%;
  1081. transform: translateX(-50%);
  1082. background: #0a2a3f;
  1083. border: 1px solid #1a4a6f;
  1084. border-radius: 8px;
  1085. min-width: 200px;
  1086. padding: 14px 16px;
  1087. &::before {
  1088. content: '';
  1089. position: absolute;
  1090. bottom: -12px;
  1091. left: 0;
  1092. right: 0;
  1093. height: 12px;
  1094. }
  1095. z-index: 1000;
  1096. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1097. .context-popup-title {
  1098. font-size: 13px;
  1099. color: #8b949e;
  1100. margin-bottom: 8px;
  1101. }
  1102. .context-popup-info {
  1103. display: flex;
  1104. align-items: baseline;
  1105. gap: 2px;
  1106. margin-bottom: 10px;
  1107. .context-used {
  1108. font-size: 18px;
  1109. font-weight: 600;
  1110. color: #e0e6ed;
  1111. }
  1112. .context-sep {
  1113. font-size: 14px;
  1114. color: #8b949e;
  1115. }
  1116. .context-max {
  1117. font-size: 14px;
  1118. color: #8b949e;
  1119. }
  1120. .context-pct {
  1121. font-size: 13px;
  1122. color: #8b949e;
  1123. }
  1124. }
  1125. .context-popup-bar-track {
  1126. width: 100%;
  1127. height: 6px;
  1128. background: rgba(255, 255, 255, 0.08);
  1129. border-radius: 3px;
  1130. overflow: hidden;
  1131. .context-popup-bar-fill {
  1132. height: 100%;
  1133. border-radius: 3px;
  1134. transition: width 0.3s ease;
  1135. }
  1136. }
  1137. .context-breakdown {
  1138. margin-top: 10px;
  1139. padding-top: 10px;
  1140. border-top: 1px solid rgba(255, 255, 255, 0.08);
  1141. .breakdown-item {
  1142. display: flex;
  1143. justify-content: space-between;
  1144. align-items: center;
  1145. padding: 3px 0;
  1146. .breakdown-label {
  1147. font-size: 12px;
  1148. color: #8b949e;
  1149. }
  1150. .breakdown-value {
  1151. font-size: 12px;
  1152. color: #e0e6ed;
  1153. }
  1154. }
  1155. }
  1156. }
  1157. .btn-model-wrapper {
  1158. position: relative;
  1159. display: flex;
  1160. align-items: center;
  1161. }
  1162. .btn-model {
  1163. height: 28px;
  1164. padding: 0 10px;
  1165. border-radius: 6px;
  1166. display: flex;
  1167. align-items: center;
  1168. gap: 4px;
  1169. cursor: pointer;
  1170. transition: all 0.2s;
  1171. border: 1px solid rgba(255, 255, 255, 0.12);
  1172. &:hover {
  1173. border-color: #3a8fd4;
  1174. background: rgba(10, 132, 255, 0.1);
  1175. }
  1176. }
  1177. .model-popup {
  1178. position: absolute;
  1179. bottom: 38px;
  1180. left: 50%;
  1181. transform: translateX(-50%);
  1182. background: #0a2a3f;
  1183. border: 1px solid #1a4a6f;
  1184. border-radius: 8px;
  1185. min-width: 220px;
  1186. z-index: 1000;
  1187. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1188. .model-popup-item {
  1189. display: flex;
  1190. align-items: center;
  1191. justify-content: space-between;
  1192. padding: 10px 12px;
  1193. cursor: pointer;
  1194. transition: background 0.2s;
  1195. border-radius: 6px;
  1196. &:hover {
  1197. background: rgba(10, 132, 255, 0.15);
  1198. }
  1199. &.active {
  1200. background: rgba(10, 132, 255, 0.1);
  1201. }
  1202. .model-item-main {
  1203. display: flex;
  1204. flex-direction: column;
  1205. gap: 2px;
  1206. .model-item-label {
  1207. font-size: 13px;
  1208. color: #e0e6ed;
  1209. white-space: nowrap;
  1210. }
  1211. .model-item-desc {
  1212. font-size: 11px;
  1213. color: #8b949e;
  1214. white-space: nowrap;
  1215. }
  1216. }
  1217. .model-item-check {
  1218. width: 16px;
  1219. height: 16px;
  1220. flex-shrink: 0;
  1221. display: flex;
  1222. align-items: center;
  1223. justify-content: center;
  1224. visibility: hidden;
  1225. &.visible {
  1226. visibility: visible;
  1227. }
  1228. &::after {
  1229. content: '✓';
  1230. font-size: 12px;
  1231. color: #3a8fd4;
  1232. }
  1233. }
  1234. }
  1235. }
  1236. .btn-think-wrapper {
  1237. position: relative;
  1238. display: flex;
  1239. align-items: center;
  1240. }
  1241. .btn-think {
  1242. height: 28px;
  1243. padding: 0 10px;
  1244. border-radius: 6px;
  1245. display: flex;
  1246. align-items: center;
  1247. gap: 4px;
  1248. cursor: pointer;
  1249. transition: all 0.2s;
  1250. &:hover {
  1251. border-color: #3a8fd4;
  1252. background: rgba(10, 132, 255, 0.1);
  1253. }
  1254. }
  1255. .think-popup {
  1256. position: absolute;
  1257. bottom: 38px;
  1258. left: 50%;
  1259. transform: translateX(-50%);
  1260. background: #0a2a3f;
  1261. border: 1px solid #1a4a6f;
  1262. border-radius: 8px;
  1263. min-width: 200px;
  1264. z-index: 1000;
  1265. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1266. .think-popup-item {
  1267. display: flex;
  1268. align-items: center;
  1269. justify-content: space-between;
  1270. padding: 10px 12px;
  1271. cursor: pointer;
  1272. transition: background 0.2s;
  1273. border-radius: 6px;
  1274. &:hover {
  1275. background: rgba(10, 132, 255, 0.15);
  1276. }
  1277. &.active {
  1278. background: rgba(10, 132, 255, 0.1);
  1279. }
  1280. .think-item-main {
  1281. display: flex;
  1282. flex-direction: column;
  1283. gap: 2px;
  1284. .think-item-label {
  1285. font-size: 13px;
  1286. color: #e0e6ed;
  1287. white-space: nowrap;
  1288. }
  1289. .think-item-desc {
  1290. font-size: 11px;
  1291. color: #8b949e;
  1292. white-space: nowrap;
  1293. }
  1294. }
  1295. .think-item-check {
  1296. width: 16px;
  1297. height: 16px;
  1298. flex-shrink: 0;
  1299. display: flex;
  1300. align-items: center;
  1301. justify-content: center;
  1302. visibility: hidden;
  1303. &.visible {
  1304. visibility: visible;
  1305. }
  1306. &::after {
  1307. content: '✓';
  1308. font-size: 12px;
  1309. color: #3a8fd4;
  1310. }
  1311. }
  1312. }
  1313. }
  1314. .btn-send {
  1315. width: 32px;
  1316. height: 32px;
  1317. display: flex;
  1318. align-items: center;
  1319. justify-content: center;
  1320. cursor: pointer;
  1321. opacity: 1;
  1322. transition: opacity 0.2s;
  1323. &.disabled {
  1324. opacity: 0.4;
  1325. cursor: not-allowed;
  1326. }
  1327. .send-icon {
  1328. width: 24px;
  1329. height: 24px;
  1330. background-image: var(--img-chat-send-icon);
  1331. background-repeat: no-repeat;
  1332. background-size: 100% 100%;
  1333. &.stop-icon {
  1334. background-image: var(--img-chat-stop-icon);
  1335. }
  1336. }
  1337. }
  1338. }
  1339. }
  1340. .session-chips {
  1341. display: flex;
  1342. flex-wrap: wrap;
  1343. gap: 6px;
  1344. margin-bottom: 5px;
  1345. .session-chip {
  1346. display: inline-flex;
  1347. align-items: center;
  1348. gap: 4px;
  1349. padding: 3px 6px 3px 4px;
  1350. background: rgba(10, 132, 255, 0.15);
  1351. border: 1px solid rgba(10, 132, 255, 0.3);
  1352. border-radius: 4px;
  1353. font-size: 12px;
  1354. color: #e0e6ed;
  1355. cursor: default;
  1356. .session-chip-icon {
  1357. width: 16px;
  1358. height: 16px;
  1359. background-image: var(--img-chat-popup-session-icon);
  1360. background-repeat: no-repeat;
  1361. background-size: 100% 100%;
  1362. flex-shrink: 0;
  1363. }
  1364. .session-chip-name {
  1365. max-width: 150px;
  1366. overflow: hidden;
  1367. text-overflow: ellipsis;
  1368. white-space: nowrap;
  1369. }
  1370. .session-chip-remove {
  1371. font-size: 10px;
  1372. color: #8b949e;
  1373. cursor: pointer;
  1374. padding: 0 2px;
  1375. transition: color 0.2s;
  1376. &:hover {
  1377. color: #ff4d4f;
  1378. }
  1379. }
  1380. }
  1381. }
  1382. .skill-chips {
  1383. display: flex;
  1384. flex-wrap: wrap;
  1385. gap: 6px;
  1386. margin-bottom: 5px;
  1387. .skill-chip {
  1388. display: inline-flex;
  1389. align-items: center;
  1390. gap: 4px;
  1391. padding: 3px 6px 3px 4px;
  1392. background: rgba(10, 132, 255, 0.15);
  1393. border: 1px solid rgba(10, 132, 255, 0.3);
  1394. border-radius: 4px;
  1395. font-size: 12px;
  1396. color: #e0e6ed;
  1397. cursor: default;
  1398. .skill-chip-icon {
  1399. width: 16px;
  1400. height: 16px;
  1401. background-image: var(--img-chat-options-skill-icon);
  1402. background-repeat: no-repeat;
  1403. background-size: 100% 100%;
  1404. flex-shrink: 0;
  1405. }
  1406. .skill-chip-name {
  1407. max-width: 150px;
  1408. overflow: hidden;
  1409. text-overflow: ellipsis;
  1410. white-space: nowrap;
  1411. }
  1412. .skill-chip-remove {
  1413. font-size: 10px;
  1414. color: #8b949e;
  1415. cursor: pointer;
  1416. padding: 0 2px;
  1417. transition: color 0.2s;
  1418. &:hover {
  1419. color: #ff4d4f;
  1420. }
  1421. }
  1422. }
  1423. }
  1424. .session-popup {
  1425. position: absolute;
  1426. bottom: 100%;
  1427. left: 0;
  1428. right: 0;
  1429. margin-bottom: 8px;
  1430. background: #0a2a3f;
  1431. border: 1px solid #1a4a6f;
  1432. border-radius: 8px;
  1433. max-height: 300px;
  1434. display: flex;
  1435. flex-direction: column;
  1436. z-index: 1000;
  1437. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1438. .session-popup-header {
  1439. display: flex;
  1440. justify-content: space-between;
  1441. align-items: center;
  1442. padding: 10px 14px 8px;
  1443. font-size: 13px;
  1444. color: #e0e6ed;
  1445. border-bottom: 1px solid rgba(63, 80, 106, 0.3);
  1446. flex-shrink: 0;
  1447. .session-count {
  1448. font-size: 12px;
  1449. color: #3a8fd4;
  1450. font-weight: 500;
  1451. }
  1452. }
  1453. .session-list {
  1454. flex: 1;
  1455. overflow-y: auto;
  1456. padding: 6px;
  1457. .session-item {
  1458. display: flex;
  1459. align-items: center;
  1460. gap: 10px;
  1461. padding: 8px 10px;
  1462. cursor: pointer;
  1463. border-radius: 6px;
  1464. transition: background 0.2s;
  1465. &:hover {
  1466. background: rgba(10, 132, 255, 0.15);
  1467. }
  1468. &.active {
  1469. background: rgba(10, 132, 255, 0.2);
  1470. }
  1471. &.selected {
  1472. background: rgba(10, 132, 255, 0.12);
  1473. }
  1474. &.disabled {
  1475. opacity: 0.4;
  1476. cursor: not-allowed;
  1477. &:hover {
  1478. background: transparent;
  1479. }
  1480. }
  1481. .session-checkbox {
  1482. width: 16px;
  1483. height: 16px;
  1484. border: 1.5px solid rgba(255, 255, 255, 0.25);
  1485. border-radius: 3px;
  1486. flex-shrink: 0;
  1487. display: flex;
  1488. align-items: center;
  1489. justify-content: center;
  1490. transition: all 0.2s;
  1491. &.checked {
  1492. background: #3a8fd4;
  1493. border-color: #3a8fd4;
  1494. }
  1495. .check-mark {
  1496. font-size: 11px;
  1497. color: #fff;
  1498. line-height: 1;
  1499. }
  1500. }
  1501. .session-item-icon {
  1502. width: 18px;
  1503. height: 18px;
  1504. background-image: var(--img-chat-popup-session-icon);
  1505. background-repeat: no-repeat;
  1506. background-size: 100% 100%;
  1507. flex-shrink: 0;
  1508. }
  1509. .session-item-name {
  1510. font-size: 13px;
  1511. color: #e0e6ed;
  1512. overflow: hidden;
  1513. text-overflow: ellipsis;
  1514. white-space: nowrap;
  1515. }
  1516. }
  1517. .session-empty {
  1518. text-align: center;
  1519. color: #8b949e;
  1520. font-size: 13px;
  1521. padding: 20px 0;
  1522. }
  1523. }
  1524. .session-popup-footer {
  1525. padding: 8px 14px;
  1526. font-size: 12px;
  1527. color: #8b949e;
  1528. text-align: center;
  1529. border-top: 1px solid rgba(63, 80, 106, 0.3);
  1530. flex-shrink: 0;
  1531. .max-hint {
  1532. color: #faad14;
  1533. }
  1534. }
  1535. }
  1536. .skill-popup {
  1537. position: absolute;
  1538. bottom: 100%;
  1539. left: 0;
  1540. right: 0;
  1541. margin-bottom: 8px;
  1542. background: #0a2a3f;
  1543. border: 1px solid #1a4a6f;
  1544. border-radius: 8px;
  1545. max-height: 300px;
  1546. display: flex;
  1547. flex-direction: column;
  1548. z-index: 1000;
  1549. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  1550. .skill-popup-header {
  1551. display: flex;
  1552. justify-content: space-between;
  1553. align-items: center;
  1554. padding: 10px 14px 8px;
  1555. font-size: 13px;
  1556. color: #e0e6ed;
  1557. border-bottom: 1px solid rgba(63, 80, 106, 0.3);
  1558. flex-shrink: 0;
  1559. .skill-count {
  1560. font-size: 12px;
  1561. color: #3a8fd4;
  1562. font-weight: 500;
  1563. }
  1564. }
  1565. .skill-list {
  1566. flex: 1;
  1567. overflow-y: auto;
  1568. padding: 6px;
  1569. .skill-item {
  1570. display: flex;
  1571. align-items: center;
  1572. gap: 10px;
  1573. padding: 8px 10px;
  1574. cursor: pointer;
  1575. border-radius: 6px;
  1576. transition: background 0.2s;
  1577. &:hover {
  1578. background: rgba(10, 132, 255, 0.15);
  1579. }
  1580. &.active {
  1581. background: rgba(10, 132, 255, 0.2);
  1582. }
  1583. &.selected {
  1584. background: rgba(10, 132, 255, 0.12);
  1585. }
  1586. .skill-item-checkbox {
  1587. width: 16px;
  1588. height: 16px;
  1589. border: 1.5px solid rgba(255, 255, 255, 0.25);
  1590. border-radius: 3px;
  1591. flex-shrink: 0;
  1592. display: flex;
  1593. align-items: center;
  1594. justify-content: center;
  1595. transition: all 0.2s;
  1596. &.checked {
  1597. background: #3a8fd4;
  1598. border-color: #3a8fd4;
  1599. }
  1600. .check-mark {
  1601. font-size: 11px;
  1602. color: #fff;
  1603. line-height: 1;
  1604. }
  1605. }
  1606. .skill-item-icon {
  1607. width: 18px;
  1608. height: 18px;
  1609. background-image: var(--img-chat-options-skill-icon);
  1610. background-repeat: no-repeat;
  1611. background-size: 100% 100%;
  1612. flex-shrink: 0;
  1613. }
  1614. .skill-item-name {
  1615. font-size: 13px;
  1616. color: #e0e6ed;
  1617. overflow: hidden;
  1618. text-overflow: ellipsis;
  1619. white-space: nowrap;
  1620. }
  1621. }
  1622. .skill-empty {
  1623. text-align: center;
  1624. color: #8b949e;
  1625. font-size: 13px;
  1626. padding: 20px 0;
  1627. }
  1628. }
  1629. .skill-popup-footer {
  1630. padding: 8px 14px;
  1631. font-size: 12px;
  1632. color: #8b949e;
  1633. text-align: center;
  1634. border-top: 1px solid rgba(63, 80, 106, 0.3);
  1635. flex-shrink: 0;
  1636. }
  1637. }
  1638. }
  1639. </style>