feat(frontend): add mobile composer tools menu and base branch select

This commit is contained in:
Chris Scott committed 2026-10-04 00:05:53 -04:00
1 parent fac23b1f1a
commit 4a2e695ec2
21 files changed
+819 -158

No files matched your search

+20 -6
View File
@@ -6,6 +6,7 @@ import { MessageThread } from "@/components/message/MessageThread";
import { PromptInput, type PromptInputHandle } from "@/components/message/PromptInput";
import { FloatingTTSButton } from '@/components/message/FloatingTTSButton'
import { X, CornerUpLeft } from "lucide-react";
import { SquareFill } from "@/components/ui/square-fill";
import { Header } from "@/components/ui/header";
import { SessionList } from "@/components/session/SessionList";
import { getSessionListPath } from '@/lib/navigation'
@@ -435,6 +436,12 @@ export function SessionDetail() {
promptInputRef.current?.openModelPicker();
}, [])
const handleInterruptSession = () => {
if (sessionId) {
interruptSession.mutate(sessionId);
}
};
const { leaderActive } = useKeyboardShortcuts({
openModelDialog: handleOpenModelDialog,
openSessions: handleShowSessionsDialog,
@@ -458,11 +465,7 @@ export function SessionDetail() {
) as HTMLButtonElement;
submitButton?.click();
},
interruptSession: () => {
if (sessionId) {
interruptSession.mutate(sessionId);
}
},
interruptSession: handleInterruptSession,
});
@@ -715,7 +718,7 @@ export function SessionDetail() {
style={{ bottom: inputBottomOffset }}
>
<div className="relative w-[94%] md:max-w-4xl">
<div className="absolute -top-9 right-0 z-50 flex flex-col items-end gap-2">
<div className="absolute bottom-full right-0 mb-2 z-50 flex flex-col items-end gap-2">
{ttsEnabled && !hasPromptContent && !isSessionActive && latestPlayableAssistant && (
<FloatingTTSButton
messageId={latestPlayableAssistant.messageId}
@@ -737,6 +740,17 @@ export function SessionDetail() {
<span className="text-sm font-medium hidden sm:inline">Clear</span>
</button>
)}
{isSessionActive && (
<button
type="button"
onClick={handleInterruptSession}
title="Stop"
aria-label="Stop"
className="md:hidden p-3 rounded-xl transition-all duration-200 active:scale-95 hover:scale-105 bg-destructive hover:bg-destructive/90 text-destructive-foreground border border-destructive/60 shadow-lg shadow-destructive/30"
>
<SquareFill className="w-5 h-5" />
</button>
)}
</div>
{leaderActive && (
<div className="absolute -top-12 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-xl bg-primary/90 text-primary-foreground border border-primary shadow-lg backdrop-blur-md animate-pulse">
@@ -22,6 +22,7 @@ const mocks = vi.hoisted(() => ({
useAutoScroll: vi.fn(),
useDialogParam: vi.fn(),
useSessionStatusForSession: vi.fn(),
interruptMutate: vi.fn(),
PromptInput: vi.fn(),
uiState: { isEditingMessage: false },
}))
@@ -39,7 +40,7 @@ vi.mock('@/config', () => ({
vi.mock('@/hooks/useOpenCode', () => ({
useSession: mocks.useSession,
useInterruptSession: vi.fn(() => ({ mutate: vi.fn() })),
useInterruptSession: vi.fn(() => ({ mutate: mocks.interruptMutate })),
useUpdateSession: vi.fn(() => ({ mutate: vi.fn() })),
useCreateSession: vi.fn(() => ({ mutateAsync: vi.fn() })),
useConfig: mocks.useConfig,
@@ -389,6 +390,22 @@ describe('SessionDetail scroll floating button', () => {
expect(screen.queryByLabelText('Clear')).not.toBeInTheDocument()
})
it('renders the mobile stop button while the session is active and interrupts on click', async () => {
renderWith({ mobile: true, showScrollButton: false, sessionActive: true })
const stopButton = await screen.findByTitle('Stop')
fireEvent.click(stopButton)
expect(mocks.interruptMutate).toHaveBeenCalledWith('test-session')
})
it('does not render the stop button while the session is idle', async () => {
renderWith({ mobile: true, showScrollButton: false, sessionActive: false })
await waitFor(() => expect(screen.getByText('MockedPromptInput')).toBeInTheDocument())
expect(screen.queryByTitle('Stop')).not.toBeInTheDocument()
})
it('clicking PromptInput scroll button calls scrollToBottom from useAutoScroll', async () => {
renderWith({ mobile: true, showScrollButton: true })