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 { uploadsApi } from '@/api/uploads'
|
||||||
import { toast } from '@/lib/toast'
|
import { toast } from '@/lib/toast'
|
||||||
import type { PendingUpload } from '@/types/upload'
|
import type { PendingUpload } from '@/types/upload'
|
||||||
|
import { useFeatureFlag } from '@/hooks/useFeatureFlag'
|
||||||
|
import { useUserPreferencesStore } from '@/store/userPreferencesStore'
|
||||||
|
|
||||||
const SUGGESTIONS: { icon: LucideIcon; label: string }[] = [
|
const SUGGESTIONS: { icon: LucideIcon; label: string }[] = [
|
||||||
{ icon: Globe, label: 'VPN not connecting' },
|
{ icon: Globe, label: 'VPN not connecting' },
|
||||||
@@ -25,6 +27,9 @@ export function StartSessionInput() {
|
|||||||
const [pendingUploads, setPendingUploads] = useState<PendingUpload[]>([])
|
const [pendingUploads, setPendingUploads] = useState<PendingUpload[]>([])
|
||||||
const [isDragOver, setIsDragOver] = useState(false)
|
const [isDragOver, setIsDragOver] = useState(false)
|
||||||
const navigate = useNavigate()
|
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 textareaRef = useRef<HTMLTextAreaElement>(null)
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||||
const dragCounterRef = useRef(0)
|
const dragCounterRef = useRef(0)
|
||||||
@@ -52,7 +57,8 @@ export function StartSessionInput() {
|
|||||||
if (completedUploadIds.length > 0) {
|
if (completedUploadIds.length > 0) {
|
||||||
state.uploadIds = completedUploadIds
|
state.uploadIds = completedUploadIds
|
||||||
}
|
}
|
||||||
navigate('/assistant', { state })
|
const target = hasCockpit && preferredView === 'cockpit' ? '/cockpit' : '/assistant'
|
||||||
|
navigate(target, { state })
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||||
@@ -63,7 +69,8 @@ export function StartSessionInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSuggestionClick = (suggestion: string) => {
|
const handleSuggestionClick = (suggestion: string) => {
|
||||||
navigate('/assistant', { state: { prefill: suggestion } })
|
const target = hasCockpit && preferredView === 'cockpit' ? '/cockpit' : '/assistant'
|
||||||
|
navigate(target, { state: { prefill: suggestion } })
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── File handling ──────────────────────────────
|
// ── File handling ──────────────────────────────
|
||||||
@@ -319,6 +326,36 @@ export function StartSessionInput() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</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 */}
|
{/* Send button */}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
Reference in New Issue
Block a user