feat: the send button as in Telegram - a blue plane with no plate, coming in only when there is something to send; the empty chat shows a chat mark and «Спросите AI помощника»
This commit is contained in:
1 parent
37ae830cbf
commit
35ad2d435b
2 files changed
+34
-9
No files matched your search
@@ -24,7 +24,7 @@
|
||||
'<span class="muted ai-where"></span><span class="spacer"></span>' +
|
||||
'<button type="button" class="btn ghost small icon close x ai-close" aria-label="Закрыть"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"><path d="M18 6 6 18M6 6l12 12"/></svg></button></div>' +
|
||||
'<div class="ai-chats" inert><div class="ai-chats-in"><button type="button" class="ai-chatnew">+ Новый чат</button><div class="ai-chatlist"></div></div></div>' +
|
||||
'<div class="ai-chat-body"><div class="ai-list"><p class="muted ai-hello">Спросите о том, что открыто в панели.</p></div>' +
|
||||
'<div class="ai-chat-body"><div class="ai-list"><div class="ai-hello"><span class="ai-hello-icon"><svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 12.5a7.5 7.5 0 0 1-11.06 6.6L4 20.5l1.4-4.6A7.5 7.5 0 1 1 20 12.5z"/><path d="M8.6 12.5h.01M12.5 12.5h.01M16.4 12.5h.01" stroke-width="2.4"/></svg></span><span class="ai-hello-text">Спросите AI помощника</span></div></div>' +
|
||||
'<button type="button" class="ai-jump" hidden title="К последним сообщениям" aria-label="К последним сообщениям"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14M5 12l7 7 7-7"/></svg></button></div>' +
|
||||
'<div class="ai-pills">' +
|
||||
'<button type="button" class="ai-pill" data-mode="agent" aria-pressed="false" title="Сам выполняет шаги один за другим, спрашивая перед каждой командой и записью файла">' +
|
||||
@@ -471,6 +471,7 @@
|
||||
function renderAttachments() {
|
||||
attachList.innerHTML = '';
|
||||
attachList.hidden = !attachments.length;
|
||||
sendState();
|
||||
attachments.forEach((a, i) => {
|
||||
const chip = document.createElement('span'); chip.className = 'ai-file-chip';
|
||||
const name = document.createElement('span'); name.textContent = a.name; name.title = a.name;
|
||||
@@ -627,6 +628,7 @@
|
||||
el.querySelector('.ai-body').innerHTML = '<span class="ai-typing" aria-label="печатает"><i></i><i></i><i></i></span>';
|
||||
ac = new AbortController();
|
||||
send.innerHTML = STOP; send.title = 'Остановить';
|
||||
sendState();
|
||||
let answer = '';
|
||||
try {
|
||||
await loadMachines();
|
||||
@@ -701,6 +703,7 @@
|
||||
}
|
||||
ac = null;
|
||||
send.innerHTML = PLANE; send.title = 'Отправить';
|
||||
sendState();
|
||||
}
|
||||
const form = q('.ai-form-in'), attachBtn = q('.ai-attach');
|
||||
attachBtn.onclick = () => attachInput.click();
|
||||
@@ -763,6 +766,14 @@
|
||||
setDragging(on) { form.classList.toggle('drag', !!on); },
|
||||
dropFiles: addPaneFiles
|
||||
};
|
||||
// Send shows only when there is something to send, or an answer to stop.
|
||||
function sendState() {
|
||||
const on = !!ac || !!input.value.trim() || attachments.length > 0;
|
||||
send.classList.toggle('show', on);
|
||||
send.tabIndex = on ? 0 : -1;
|
||||
}
|
||||
input.addEventListener('input', sendState);
|
||||
sendState();
|
||||
// The field grows with the text, up to a few lines.
|
||||
function grow() { input.style.height = '40px'; input.style.height = Math.min(140, input.scrollHeight + 2) + 'px'; }
|
||||
input.addEventListener('input', grow);
|
||||
|
||||
Reference in new issue
Block a user