Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ui/messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "لا توجد أوراق محفوظة بعد.",
"library_add_papers": "إضافة أوراق",
"library_selected": "تم تحديد {count}",
"library_open_alphaxiv": "فتح alphaXiv"
"library_open_alphaxiv": "فتح alphaXiv",
"chat_resize_composer": "تغيير حجم مربع الرسالة",
"chat_resize_composer_hint": "اسحب لتغيير الحجم. انقر نقرًا مزدوجًا لإعادة الضبط."
}
4 changes: 3 additions & 1 deletion ui/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "No saved papers yet.",
"library_add_papers": "Add papers",
"library_selected": "{count} selected",
"library_open_alphaxiv": "Open alphaXiv"
"library_open_alphaxiv": "Open alphaXiv",
"chat_resize_composer": "Resize message box",
"chat_resize_composer_hint": "Drag to resize. Double-click to reset."
}
4 changes: 3 additions & 1 deletion ui/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "Aún no hay artículos guardados.",
"library_add_papers": "Añadir artículos",
"library_selected": "{count} seleccionados",
"library_open_alphaxiv": "Abrir alphaXiv"
"library_open_alphaxiv": "Abrir alphaXiv",
"chat_resize_composer": "Cambiar el tamaño del cuadro de mensaje",
"chat_resize_composer_hint": "Arrastra para cambiar el tamaño. Haz doble clic para restablecer."
}
4 changes: 3 additions & 1 deletion ui/messages/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "هنوز مقاله‌ای ذخیره نشده است.",
"library_add_papers": "افزودن مقاله‌ها",
"library_selected": "{count} انتخاب شده",
"library_open_alphaxiv": "باز کردن alphaXiv"
"library_open_alphaxiv": "باز کردن alphaXiv",
"chat_resize_composer": "تغییر اندازه کادر پیام",
"chat_resize_composer_hint": "برای تغییر اندازه بکشید. برای بازنشانی دوبار کلیک کنید."
}
4 changes: 3 additions & 1 deletion ui/messages/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "अभी कोई पेपर सहेजा नहीं गया है।",
"library_add_papers": "पेपर जोड़ें",
"library_selected": "{count} चुने गए",
"library_open_alphaxiv": "alphaXiv खोलें"
"library_open_alphaxiv": "alphaXiv खोलें",
"chat_resize_composer": "संदेश बॉक्स का आकार बदलें",
"chat_resize_composer_hint": "आकार बदलने के लिए खींचें। रीसेट करने के लिए डबल-क्लिक करें।"
}
4 changes: 3 additions & 1 deletion ui/messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "保存した論文はまだありません。",
"library_add_papers": "論文を追加",
"library_selected": "{count} 件選択中",
"library_open_alphaxiv": "alphaXiv を開く"
"library_open_alphaxiv": "alphaXiv を開く",
"chat_resize_composer": "メッセージボックスのサイズを変更",
"chat_resize_composer_hint": "ドラッグしてサイズを変更します。ダブルクリックでリセットします。"
}
4 changes: 3 additions & 1 deletion ui/messages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "저장한 논문이 없습니다.",
"library_add_papers": "논문 추가",
"library_selected": "{count}개 선택됨",
"library_open_alphaxiv": "alphaXiv 열기"
"library_open_alphaxiv": "alphaXiv 열기",
"chat_resize_composer": "메시지 상자 크기 조정",
"chat_resize_composer_hint": "드래그하여 크기를 조정합니다. 두 번 클릭하여 재설정합니다."
}
4 changes: 3 additions & 1 deletion ui/messages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "Nie ma jeszcze zapisanych publikacji.",
"library_add_papers": "Dodaj publikacje",
"library_selected": "Wybrano: {count}",
"library_open_alphaxiv": "Otwórz alphaXiv"
"library_open_alphaxiv": "Otwórz alphaXiv",
"chat_resize_composer": "Zmień rozmiar pola wiadomości",
"chat_resize_composer_hint": "Przeciągnij, aby zmienić rozmiar. Kliknij dwukrotnie, aby przywrócić."
}
4 changes: 3 additions & 1 deletion ui/messages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "Сохранённых статей пока нет.",
"library_add_papers": "Добавить статьи",
"library_selected": "Выбрано: {count}",
"library_open_alphaxiv": "Открыть alphaXiv"
"library_open_alphaxiv": "Открыть alphaXiv",
"chat_resize_composer": "Изменить размер поля сообщения",
"chat_resize_composer_hint": "Перетащите, чтобы изменить размер. Дважды щёлкните, чтобы сбросить."
}
4 changes: 3 additions & 1 deletion ui/messages/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "Henüz kayıtlı makale yok.",
"library_add_papers": "Makale ekle",
"library_selected": "{count} seçildi",
"library_open_alphaxiv": "alphaXiv'i aç"
"library_open_alphaxiv": "alphaXiv'i aç",
"chat_resize_composer": "Mesaj kutusunu yeniden boyutlandır",
"chat_resize_composer_hint": "Yeniden boyutlandırmak için sürükleyin. Sıfırlamak için çift tıklayın."
}
4 changes: 3 additions & 1 deletion ui/messages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1600,5 +1600,7 @@
"library_empty": "尚未保存论文。",
"library_add_papers": "添加论文",
"library_selected": "已选择 {count} 篇",
"library_open_alphaxiv": "打开 alphaXiv"
"library_open_alphaxiv": "打开 alphaXiv",
"chat_resize_composer": "调整消息框大小",
"chat_resize_composer_hint": "拖动以调整大小。双击以重置。"
}
145 changes: 144 additions & 1 deletion ui/src/components/ChatPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,43 @@ const TOOL_OUTPUT_SCAN_LIMIT = 20_000;
const SELECTION_ACTION_GAP_PX = 8;
const CHAT_ANNOTATION_HIGHLIGHT_NAME = "chat-annotations";
const SIDE_CHAT_ANNOTATION_HIGHLIGHT_NAME = "side-chat-annotations";
const COMPOSER_HEIGHT_KEY = "orx:composer-height";
const COMPOSER_MIN_HEIGHT = 72;
const COMPOSER_MAX_VIEWPORT_RATIO = 0.6;
const COMPOSER_PANE_RESERVE = 220;
const COMPOSER_KEYBOARD_STEP = 24;

function composerHeightStorageKey(embedded: boolean): string {
return embedded ? `${COMPOSER_HEIGHT_KEY}:side` : COMPOSER_HEIGHT_KEY;
}

function initialComposerHeight(key: string): number | null {
try {
const height = Number(localStorage.getItem(key));
return Number.isFinite(height) && height >= COMPOSER_MIN_HEIGHT && height <= 4000
? Math.round(height)
: null;
} catch {
return null;
}
}

function persistComposerHeight(key: string, height: number | null): void {
try {
if (height === null) localStorage.removeItem(key);
else localStorage.setItem(key, String(Math.round(height)));
} catch {}
}

function maxComposerHeight(textarea: HTMLTextAreaElement | null): number {
if (typeof window === "undefined") return COMPOSER_MIN_HEIGHT;
const pane = textarea?.closest(".chat-pane") as HTMLElement | null;
const paneHeight = pane?.clientHeight ?? window.innerHeight;
return Math.max(
COMPOSER_MIN_HEIGHT,
Math.min(window.innerHeight * COMPOSER_MAX_VIEWPORT_RATIO, paneHeight - COMPOSER_PANE_RESERVE),
);
}

interface SelectionAction {
text: string;
Expand Down Expand Up @@ -5051,6 +5088,15 @@ export function ChatPanel({
const stickToBottom = useRef(true);
const [transcriptAtBottom, setTranscriptAtBottom] = useState(true);
const composerRef = useRef<HTMLTextAreaElement>(null);
const composerStorageKey = composerHeightStorageKey(embedded);
const [composerHeight, setComposerHeight] = useState<number | null>(() => initialComposerHeight(composerStorageKey));
const composerHeightRef = useRef(composerHeight);
composerHeightRef.current = composerHeight;
const [composerLimit, setComposerLimit] = useState(() => maxComposerHeight(null));
const composerAriaValue = Math.min(
composerLimit,
Math.round(composerHeight ?? composerRef.current?.getBoundingClientRect().height ?? COMPOSER_MIN_HEIGHT),
);
const connection = useRemoteConnection();
const resumeCancelRef = useRef<(() => void) | null>(null);
const dataSources = usePopover();
Expand Down Expand Up @@ -5204,6 +5250,86 @@ export function ChatPanel({
}
}

useEffect(() => {
persistComposerHeight(composerStorageKey, composerHeight);
}, [composerStorageKey, composerHeight]);

useEffect(() => {
const textarea = composerRef.current;
if (!textarea) return;
const pane = textarea.closest(".chat-pane") as HTMLElement | null;
const clamp = () => {
const limit = maxComposerHeight(textarea);
setComposerLimit(limit);
const current = composerHeightRef.current;
if (current !== null && current > limit) setComposerHeight(limit);
};
clamp();
const observer = pane && typeof ResizeObserver !== "undefined"
? new ResizeObserver(clamp)
: null;
if (observer && pane) observer.observe(pane);
window.addEventListener("resize", clamp);
return () => {
observer?.disconnect();
window.removeEventListener("resize", clamp);
};
}, []);
Comment thread
sBaydin marked this conversation as resolved.
Resolved

function resizeComposer(event: React.PointerEvent<HTMLDivElement>) {
const textarea = composerRef.current;
if (!textarea) return;
event.preventDefault();
event.currentTarget.focus({ preventScroll: true });
event.currentTarget.setPointerCapture(event.pointerId);
const startY = event.clientY;
const startHeight = textarea.getBoundingClientRect().height;
const limit = maxComposerHeight(textarea);
const previousUserSelect = document.body.style.userSelect;
document.body.style.userSelect = "none";
const onMove = (moveEvent: PointerEvent) => {
setComposerHeight(Math.round(Math.min(
Math.max(startHeight + startY - moveEvent.clientY, COMPOSER_MIN_HEIGHT),
limit,
)));
};
const stop = () => {
window.removeEventListener("pointermove", onMove);
window.removeEventListener("pointerup", stop);
window.removeEventListener("pointercancel", stop);
document.body.style.userSelect = previousUserSelect;
};
window.addEventListener("pointermove", onMove);
window.addEventListener("pointerup", stop);
window.addEventListener("pointercancel", stop);
}

function resetComposerHeight() {
setComposerHeight(null);
}

function nudgeComposerHeight(delta: number) {
const textarea = composerRef.current;
const startHeight = composerHeight ?? textarea?.getBoundingClientRect().height ?? COMPOSER_MIN_HEIGHT;
setComposerHeight(Math.round(Math.min(
Math.max(startHeight + delta, COMPOSER_MIN_HEIGHT),
maxComposerHeight(textarea),
)));
}

function onComposerResizeKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {
if (event.key === "ArrowUp") {
event.preventDefault();
nudgeComposerHeight(COMPOSER_KEYBOARD_STEP);
} else if (event.key === "ArrowDown") {
event.preventDefault();
nudgeComposerHeight(-COMPOSER_KEYBOARD_STEP);
} else if (event.key === "Home") {
event.preventDefault();
resetComposerHeight();
}
}

// The open session, if any (its harness is locked; its model/mode/reasoning
// are what the composer should reflect and edit).
const openSession = sessions.find((s) => s.id === activeId);
Expand Down Expand Up @@ -7378,7 +7504,7 @@ export function ChatPanel({

{/* Docked while a plan awaits a decision, so the approval controls never
scroll away. Actions mirror the (now compact) inline card's wire. */}
<div inert={contentLoading || Boolean(contentError) || historyLoading} className="composer px-3 pb-3 shrink-0 relative z-4 bg-background w-full max-w-readable my-0 mx-auto [&_textarea]:border-0 [&_textarea]:bg-none [&_textarea]:bg-transparent [&_textarea]:resize-none [&_textarea]:pt-2.5 [&_textarea]:px-3 [&_textarea]:pb-1 [&_textarea]:text-base [&_textarea]:field-sizing-content [&_textarea]:min-h-18 [&_textarea]:max-h-45">
<div inert={contentLoading || Boolean(contentError) || historyLoading} className={`composer px-3 pb-3 shrink-0 relative z-4 bg-background w-full max-w-readable my-0 mx-auto [&_textarea]:border-0 [&_textarea]:bg-none [&_textarea]:bg-transparent [&_textarea]:resize-none [&_textarea]:pt-2.5 [&_textarea]:px-3 [&_textarea]:pb-1 [&_textarea]:text-base [&_textarea]:min-h-18 ${composerHeight === null ? "[&_textarea]:field-sizing-content [&_textarea]:max-h-45" : "[&_textarea]:field-sizing-fixed [&_textarea]:max-h-none [&_textarea]:overflow-y-auto"}`}>
{threadMounted && (
<Tooltip interactive content={m.chat_scroll_to_bottom()} className={`absolute bottom-full left-1/2 z-5 mb-6 -translate-x-1/2 transition-opacity duration-150 ease-standard ${transcriptAtBottom ? "pointer-events-none opacity-0" : "opacity-100"}`}>
<IconButton
Expand Down Expand Up @@ -7532,6 +7658,22 @@ export function ChatPanel({
)}
<RemoteConnectionStrip />
<div inert={connection !== null} className={`composer-box relative flex flex-col border ${bashMode ? "border-accent-amber" : "border-border"} rounded-lg bg-background shadow-control-subtle${connection ? " opacity-60" : ""}`} data-onboarding="composer">
<div
role="separator"
aria-orientation="horizontal"
aria-label={m.chat_resize_composer()}
aria-valuemin={COMPOSER_MIN_HEIGHT}
aria-valuemax={composerLimit}
aria-valuenow={composerAriaValue}
title={m.chat_resize_composer_hint()}
tabIndex={0}
onPointerDown={resizeComposer}
onDoubleClick={resetComposerHeight}
onKeyDown={onComposerResizeKeyDown}
Comment thread
sBaydin marked this conversation as resolved.
Resolved
className="composer-resizer group flex h-2.5 w-full shrink-0 cursor-row-resize touch-none select-none items-center justify-center outline-none"
>
<span className={`h-0.5 w-8 rounded-full transition-colors group-hover:bg-resizer-hover group-active:bg-resizer-hover group-focus-visible:ring-2 group-focus-visible:ring-focus-ring group-focus-visible:ring-offset-2 group-focus-visible:ring-offset-background ${composerHeight === null ? "bg-border" : "bg-border-strong"}`} />
</div>
{unconfirmedSend !== null && (
<div id={unconfirmedSendId} role="alert" className="flex items-start gap-2 pt-2 px-3 text-sm text-text">
<span className="flex-1" dir="auto">{m.chat_send_unconfirmed({ error: ltr(unconfirmedSend) })}</span>
Expand Down Expand Up @@ -7638,6 +7780,7 @@ export function ChatPanel({
aria-describedby={[demoHintVisible && demoHintId, unconfirmedSend !== null && unconfirmedSendId].filter(Boolean).join(" ") || undefined}
// Native prose stays visible; the aligned mirror paints only skill tokens.
className="relative z-1 min-w-0 overflow-x-hidden bg-transparent"
style={composerHeight === null ? undefined : { height: composerHeight, maxHeight: "60vh" }}
value={draft}
placeholder={
steering && activeHarness
Expand Down
Loading