



























@@ -58,6 +58,19 @@ import { resolveLocalUserName } from "../user-identity.ts";
5858import { renderMarkdownSidebar } from "./markdown-sidebar.ts";
5959import "../components/resizable-divider.ts";
606061+const COMPOSER_CHROME_INTERACTIVE_SELECTOR = [
62+"a[href]",
63+"button",
64+"input",
65+"select",
66+"textarea",
67+"summary",
68+"[contenteditable='true']",
69+"[role='button']",
70+"[role='listbox']",
71+"[role='option']",
72+].join(",");
73+6174export type ChatProps = {
6275sessionKey: string;
6376onSessionKeyChange: (next: string) => void;
@@ -324,6 +337,23 @@ function adjustTextareaHeight(el: HTMLTextAreaElement) {
324337el.style.height = `${Math.min(el.scrollHeight, 150)}px`;
325338}
326339340+function focusComposerFromChrome(event: MouseEvent, connected: boolean) {
341+if (!connected || event.defaultPrevented) {
342+return;
343+}
344+const target = event.target;
345+const currentTarget = event.currentTarget;
346+if (!(target instanceof Element) || !(currentTarget instanceof HTMLElement)) {
347+return;
348+}
349+if (target.closest(COMPOSER_CHROME_INTERACTIVE_SELECTOR)) {
350+return;
351+}
352+currentTarget
353+.querySelector<HTMLTextAreaElement>(".agent-chat__composer-combobox > textarea")
354+?.focus({ preventScroll: true });
355+}
356+327357function restoreHistoryCaret(target: HTMLTextAreaElement, direction: "up" | "down") {
328358requestAnimationFrame(() => {
329359if (document.activeElement !== target) {
@@ -1359,7 +1389,10 @@ export function renderChat(props: ChatProps) {
13591389 : nothing}
1360139013611391 <!-- Input bar -->
1362- <div class="agent-chat__input">
1392+ <div
1393+ class="agent-chat__input"
1394+ @click=${(event: MouseEvent) => focusComposerFromChrome(event, props.connected)}
1395+ >
13631396 ${renderSlashMenu(requestUpdate, props)} ${renderAttachmentPreview(props)}
1364139713651398 <input
@@ -1423,6 +1456,7 @@ export function renderChat(props: ChatProps) {
14231456 ?disabled=${!props.connected}
14241457 >
14251458 ${icons.paperclip}
1459+ <span class="agent-chat__control-label">${t("chat.composer.attachFile")}</span>
14261460 </button>
1427146114281462 ${props.onToggleRealtimeTalk
@@ -1441,6 +1475,11 @@ export function renderChat(props: ChatProps) {
14411475 ?disabled=${!props.connected}
14421476 >
14431477 ${props.realtimeTalkActive ? icons.volume2 : icons.radio}
1478+ <span class="agent-chat__control-label"
1479+ >${props.realtimeTalkActive
1480+ ? t("chat.composer.stopTalk")
1481+ : t("chat.composer.startTalk")}</span
1482+ >
14441483 </button>
14451484 <button
14461485 class="agent-chat__input-btn ${props.realtimeTalkOptionsOpen
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。