diff --git a/apps/web/app/components/subagent-panel.tsx b/apps/web/app/components/subagent-panel.tsx index 0012620c8d8..2d43216bbb0 100644 --- a/apps/web/app/components/subagent-panel.tsx +++ b/apps/web/app/components/subagent-panel.tsx @@ -12,6 +12,8 @@ type SubagentPanelProps = { task: string; label?: string; onBack: () => void; + onSubagentClick?: (task: string) => void; + onFilePathClick?: (path: string) => Promise | boolean | void; }; type QueuedMessage = { @@ -20,7 +22,146 @@ type QueuedMessage = { mentionedFiles: Array<{ name: string; path: string }>; }; -function taskMessage(sessionKey: string, task: string): UIMessage { +function QueueItem({ + msg, + idx, + onEdit, + onSendNow, + onRemove, +}: { + msg: QueuedMessage; + idx: number; + onEdit: (id: string, text: string) => void; + onSendNow: (id: string) => void; + onRemove: (id: string) => void; +}) { + const [editing, setEditing] = useState(false); + const [draft, setDraft] = useState(msg.text); + const inputRef = useRef(null); + + const autoResize = () => { + const el = inputRef.current; + if (!el) { + return; + } + el.style.height = "auto"; + el.style.height = `${el.scrollHeight}px`; + }; + + useEffect(() => { + if (!editing) { + return; + } + inputRef.current?.focus(); + const len = inputRef.current?.value.length ?? 0; + inputRef.current?.setSelectionRange(len, len); + autoResize(); + }, [editing]); + + const commitEdit = () => { + const trimmed = draft.trim(); + if (trimmed && trimmed !== msg.text) { + onEdit(msg.id, trimmed); + } else { + setDraft(msg.text); + } + setEditing(false); + }; + + return ( +
0 ? "border-t" : ""}`} + style={idx > 0 ? { borderColor: "var(--color-border)" } : undefined} + > + + {idx + 1} + + {editing ? ( +