feat: add launch view preference toggle to StartSessionInput
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,8 @@ import { cn } from '@/lib/utils'
|
||||
import { uploadsApi } from '@/api/uploads'
|
||||
import { toast } from '@/lib/toast'
|
||||
import type { PendingUpload } from '@/types/upload'
|
||||
import { useFeatureFlag } from '@/hooks/useFeatureFlag'
|
||||
import { useUserPreferencesStore } from '@/store/userPreferencesStore'
|
||||
|
||||
const SUGGESTIONS: { icon: LucideIcon; label: string }[] = [
|
||||
{ icon: Globe, label: 'VPN not connecting' },
|
||||
@@ -25,6 +27,9 @@ export function StartSessionInput() {
|
||||
const [pendingUploads, setPendingUploads] = useState<PendingUpload[]>([])
|
||||
const [isDragOver, setIsDragOver] = useState(false)
|
||||
const navigate = useNavigate()
|
||||
const hasCockpit = useFeatureFlag('flowpilot_cockpit')
|
||||
const preferredView = useUserPreferencesStore(s => s.preferredFlowPilotView)
|
||||
const setPreferredView = useUserPreferencesStore(s => s.setPreferredFlowPilotView)
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||
const dragCounterRef = useRef(0)
|
||||
@@ -52,7 +57,8 @@ export function StartSessionInput() {
|
||||
if (completedUploadIds.length > 0) {
|
||||
state.uploadIds = completedUploadIds
|
||||
}
|
||||
navigate('/assistant', { state })
|
||||
const target = hasCockpit && preferredView === 'cockpit' ? '/cockpit' : '/assistant'
|
||||
navigate(target, { state })
|
||||
}
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
@@ -63,7 +69,8 @@ export function StartSessionInput() {
|
||||
}
|
||||
|
||||
const handleSuggestionClick = (suggestion: string) => {
|
||||
navigate('/assistant', { state: { prefill: suggestion } })
|
||||
const target = hasCockpit && preferredView === 'cockpit' ? '/cockpit' : '/assistant'
|
||||
navigate(target, { state: { prefill: suggestion } })
|
||||
}
|
||||
|
||||
// ── File handling ──────────────────────────────
|
||||
@@ -319,6 +326,36 @@ export function StartSessionInput() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* View preference toggle */}
|
||||
{hasCockpit && (
|
||||
<div className="flex items-center rounded-lg border border-border bg-card p-0.5 text-xs mr-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setPreferredView('flowpilot')}
|
||||
className={cn(
|
||||
'rounded-md px-2 py-1 font-medium transition-colors',
|
||||
preferredView === 'flowpilot'
|
||||
? 'bg-elevated text-foreground'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
)}
|
||||
>
|
||||
FlowPilot
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setPreferredView('cockpit')}
|
||||
className={cn(
|
||||
'rounded-md px-2 py-1 font-medium transition-colors',
|
||||
preferredView === 'cockpit'
|
||||
? 'bg-elevated text-foreground'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
)}
|
||||
>
|
||||
Cockpit
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Send button */}
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user