v2.3.0-sampling-params-ask-user: agent sampling params, ask_user_input in CoderPane, UX polish
Add top_p/top_k/min_p/presence_penalty to AGENTS.md frontmatter and thread through inference (agents.ts parser → Agent type → stream-phase → sentinel summaries). Null means omit from request body, preserving provider defaults. Wire ask_user_input interactive card into both BooCoder frontends: the CoderPane in BooChat's SPA (CoderMessageList now renders AskUserInputCard instead of ToolCallLine for ask_user_input tool calls) and the standalone coder SPA (MessageBubble + new AskUserInputCard + shadcn ui primitives). Additional fixes: SessionLandingPage uses ChatInput with slash-command support and lazy chat creation; Session.tsx hydrate-race fix for empty pane promotion; AgentPicker wider dropdown with line-clamp; ModelPicker min-width; Textarea converted to forwardRef; Recon agent added to AGENTS.md; codecontext host port exposed in docker-compose. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -96,7 +96,7 @@ export function AgentPicker({ projectId, value, onChange }: Props) {
|
||||
<ChevronDown className="size-3 opacity-70" />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start" className="max-h-80 overflow-y-auto w-72">
|
||||
<DropdownMenuContent align="start" className="max-h-80 overflow-y-auto w-96">
|
||||
{error && (
|
||||
<div className="px-2 py-1.5 text-xs text-destructive">{error}</div>
|
||||
)}
|
||||
@@ -128,7 +128,7 @@ export function AgentPicker({ projectId, value, onChange }: Props) {
|
||||
<span className="font-medium">{a.name}</span>
|
||||
</div>
|
||||
{a.description && (
|
||||
<span className="text-muted-foreground pl-[18px] truncate w-full">
|
||||
<span className="text-muted-foreground pl-[18px] line-clamp-2 w-full">
|
||||
{a.description}
|
||||
</span>
|
||||
)}
|
||||
|
||||
@@ -107,7 +107,7 @@ export function ModelPicker({ value, onChange }: Props) {
|
||||
<ChevronDown className="size-3 opacity-70" />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="max-h-72 overflow-y-auto">
|
||||
<DropdownMenuContent align="end" className="max-h-72 min-w-[16rem] overflow-y-auto">
|
||||
{error && (
|
||||
<div className="px-2 py-1.5 text-xs text-destructive">{error}</div>
|
||||
)}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { useState } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Archive, MessageSquare, Send, ChevronDown, ChevronRight, RotateCcw, Trash2 } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
import type { Chat } from '@/api/types';
|
||||
import { api } from '@/api/client';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { ChatInput } from '@/components/ChatInput';
|
||||
import {
|
||||
ContextMenu,
|
||||
ContextMenuContent,
|
||||
@@ -25,6 +27,8 @@ interface Props {
|
||||
chats: Chat[];
|
||||
onOpenChat: (chatId: string) => void;
|
||||
onSend: (content: string) => void;
|
||||
/** Create a chat and return its id. Used by slash-command handler. */
|
||||
createChat: () => Promise<{ id: string }>;
|
||||
onReopenChat: (chatId: string) => Promise<void>;
|
||||
onArchiveChat: (chatId: string) => Promise<void>;
|
||||
onRenameChat: (chatId: string, name: string) => Promise<void>;
|
||||
@@ -153,12 +157,15 @@ export function SessionLandingPage({
|
||||
chats,
|
||||
onOpenChat,
|
||||
onSend,
|
||||
projectId,
|
||||
createChat,
|
||||
onReopenChat,
|
||||
onArchiveChat,
|
||||
onRenameChat,
|
||||
onDeleteChat,
|
||||
}: Props) {
|
||||
const [composerValue, setComposerValue] = useState('');
|
||||
const [chatId, setChatId] = useState<string | null>(null);
|
||||
const [showArchived, setShowArchived] = useState(false);
|
||||
const [renamingId, setRenamingId] = useState<string | null>(null);
|
||||
const [renameValue, setRenameValue] = useState('');
|
||||
@@ -172,13 +179,43 @@ export function SessionLandingPage({
|
||||
.filter((c) => c.status === 'archived')
|
||||
.sort((a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime());
|
||||
|
||||
function handleSend() {
|
||||
// Create a chat lazily on first send or slash command.
|
||||
const ensureChat = useCallback(async (): Promise<string> => {
|
||||
if (chatId) return chatId;
|
||||
try {
|
||||
const chat = await createChat();
|
||||
setChatId(chat.id);
|
||||
return chat.id;
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : 'Failed to create chat');
|
||||
throw err;
|
||||
}
|
||||
}, [chatId, createChat]);
|
||||
|
||||
async function handleSend() {
|
||||
const text = composerValue.trim();
|
||||
if (!text) return;
|
||||
onSend(text);
|
||||
setComposerValue('');
|
||||
try {
|
||||
const cid = await ensureChat();
|
||||
onSend(text);
|
||||
setComposerValue('');
|
||||
} catch {
|
||||
// Error already surfaced via toast.
|
||||
}
|
||||
}
|
||||
|
||||
// v2.3: slash-command dispatch on landing page. Creates a chat first if
|
||||
// one doesn't exist, then invokes the skill on that chat.
|
||||
const handleSlashCommand = useCallback(async (skillName: string, userMessage: string) => {
|
||||
try {
|
||||
const cid = await ensureChat();
|
||||
await api.chats.skillInvoke(cid, skillName, userMessage.length > 0 ? userMessage : null);
|
||||
setComposerValue('');
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : `/${skillName} failed`);
|
||||
}
|
||||
}, [ensureChat]);
|
||||
|
||||
function startRename(chat: Chat) {
|
||||
setRenamingId(chat.id);
|
||||
setRenameValue(chat.name ?? '');
|
||||
@@ -293,33 +330,17 @@ export function SessionLandingPage({
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="border-t px-4 py-3 flex items-end gap-2 shrink-0">
|
||||
<Textarea
|
||||
value={composerValue}
|
||||
onChange={(e) => setComposerValue(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
|
||||
e.preventDefault();
|
||||
handleSend();
|
||||
return;
|
||||
}
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
handleSend();
|
||||
}
|
||||
}}
|
||||
placeholder="Start a new chat..."
|
||||
rows={2}
|
||||
className="resize-none min-h-[52px] max-h-[160px]"
|
||||
{/* v2.3: ChatInput with slash-command support replaces the bare Textarea.
|
||||
chatId is created lazily on first send/slash. */}
|
||||
<div className="border-t px-4 py-3 shrink-0">
|
||||
<ChatInput
|
||||
projectId={projectId}
|
||||
onSend={handleSend}
|
||||
onSlashCommand={handleSlashCommand}
|
||||
chatId={chatId ?? undefined}
|
||||
chatLabel={chatId ? undefined : 'Chat'}
|
||||
disabled={false}
|
||||
/>
|
||||
<Button
|
||||
onClick={handleSend}
|
||||
disabled={!composerValue.trim()}
|
||||
size="icon-lg"
|
||||
aria-label="Send"
|
||||
>
|
||||
<Send />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Dialog open={archiveConfirm !== null} onOpenChange={(open) => { if (!open) setArchiveConfirm(null); }}>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { MessageSquare, Terminal, Code, Clipboard, Plus, X } from 'lucide-react';
|
||||
import { api } from '@/api/client';
|
||||
import type { Chat, Project, Session, WorkspacePane } from '@/api/types';
|
||||
import { MAX_PANES, activePaneChatId, type UseWorkspacePanesResult } from '@/hooks/useWorkspacePanes';
|
||||
import type { UseSessionChatsResult } from '@/hooks/useSessionChats';
|
||||
@@ -386,6 +387,7 @@ export function Workspace({
|
||||
sessionId={sessionId}
|
||||
projectId={projectId}
|
||||
chats={chats}
|
||||
createChat={() => api.chats.create(sessionId)}
|
||||
onOpenChat={(chatId) => openChatInPane(idx, chatId)}
|
||||
onSend={(content) => void handleLandingSend(idx, content)}
|
||||
onReopenChat={async (chatId) => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, type ReactNode } from 'react';
|
||||
import { MarkdownRenderer } from '@/components/MarkdownRenderer';
|
||||
import { ToolCallGroup } from '@/components/ToolCallGroup';
|
||||
import { ToolCallLine, type ToolRun } from '@/components/ToolCallLine';
|
||||
import { AskUserInputCard } from '@/components/AskUserInputCard';
|
||||
import { wireToolCallToRun, type CoderToolCallWire } from '@/lib/coder-tools';
|
||||
|
||||
export interface CoderMessageWire {
|
||||
@@ -116,6 +117,11 @@ function groupToolRuns(items: RenderItem[]): RenderItem[] {
|
||||
continue;
|
||||
}
|
||||
const name = item.run.call.name;
|
||||
if (name === 'ask_user_input') {
|
||||
out.push(item);
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
let j = i + 1;
|
||||
while (
|
||||
j < items.length &&
|
||||
@@ -178,10 +184,11 @@ function CoderTextBubble({ message }: { message: CoderMessageWire }) {
|
||||
|
||||
interface Props {
|
||||
messages: CoderTimelineWire[];
|
||||
chatId?: string;
|
||||
footer?: ReactNode;
|
||||
}
|
||||
|
||||
export function CoderMessageList({ messages, footer }: Props) {
|
||||
export function CoderMessageList({ messages, chatId, footer }: Props) {
|
||||
const endRef = useRef<HTMLDivElement>(null);
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
const isNearBottomRef = useRef(true);
|
||||
@@ -216,6 +223,16 @@ export function CoderMessageList({ messages, footer }: Props) {
|
||||
return <CoderTextBubble key={item.message.id} message={item.message} />;
|
||||
}
|
||||
if (item.kind === 'tool_run') {
|
||||
if (item.run.call.name === 'ask_user_input' && chatId) {
|
||||
return (
|
||||
<AskUserInputCard
|
||||
key={item.key}
|
||||
toolCall={item.run.call}
|
||||
toolResult={item.run.result}
|
||||
chatId={chatId}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return <ToolCallLine key={item.key} run={item.run} />;
|
||||
}
|
||||
return <ToolCallGroup key={item.key} runs={item.runs} />;
|
||||
|
||||
@@ -703,6 +703,7 @@ export function CoderPane({
|
||||
) : (
|
||||
<CoderMessageList
|
||||
messages={messages as CoderTimelineWire[]}
|
||||
chatId={chatId}
|
||||
footer={
|
||||
activeTaskId && !permissionPrompt && sending === false ? (
|
||||
<p className="text-xs text-muted-foreground animate-pulse">Agent running…</p>
|
||||
|
||||
@@ -2,9 +2,10 @@ import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
||||
return (
|
||||
const Textarea = React.forwardRef<HTMLTextAreaElement, React.ComponentProps<"textarea">>(
|
||||
({ className, ...props }, ref) => (
|
||||
<textarea
|
||||
ref={ref}
|
||||
data-slot="textarea"
|
||||
className={cn(
|
||||
"flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||
@@ -13,6 +14,7 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
)
|
||||
Textarea.displayName = "Textarea"
|
||||
|
||||
export { Textarea }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
Link,
|
||||
useLocation,
|
||||
@@ -75,6 +75,19 @@ function SessionInner({ sessionId }: { sessionId: string }) {
|
||||
});
|
||||
const { chats, renameChat } = chatsHook;
|
||||
|
||||
// v2.3: fix hydrate race — if workspace hydrate clobbers the chat-pane
|
||||
// promotion (panes[0] is still 'empty' while an open chat exists),
|
||||
// re-promote immediately. Guarded by a ref to avoid infinite loops.
|
||||
const promotedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
if (panes.length !== 1 || panes[0]?.kind !== 'empty') return;
|
||||
const openChat = chats.find((c) => c.status === 'open');
|
||||
if (!openChat) return;
|
||||
if (promotedRef.current) return;
|
||||
promotedRef.current = true;
|
||||
initializeFirstChatIfEmpty(openChat.id);
|
||||
}, [panes, chats, initializeFirstChatIfEmpty]);
|
||||
|
||||
// v1.8 Level 1: branch indicator. Polls every 30s; server caches the same
|
||||
// span so back-to-back loads are cheap. Returns null until the first fetch
|
||||
// resolves or if the project isn't a git repo.
|
||||
|
||||
Reference in New Issue
Block a user