teqo-backup/src/components/campaign/shell/ai/CampaignAISidebar.tsx
Francisco Solla 0e38d19d42 feat(B167): migra o chat Sollinha entre painel e drawer ao redimensionar
- Converse (useChat) lifts to the provider: survives desktop panel <-> mobile
  drawer swaps, internal /campanha navigation and resize (new tab still resets).
- Chat Panel/Separator always mounted (RRP panel-count change forces a full
  navigation); footprint hidden via elementRef + .b167-ai-chat-hidden
  (display:none !important), avoiding RRP's imperative collapse/expand races.
- Single 'open' flag drives both surfaces (open && viewport); reconciled with
  the panel at desktop settle and on user drag-collapse (gated by isUserInteraction).
- Mobile Drawer extracted to CampaignAIDrawer; FAB/setOpen unified; focus moves
  into the chat on the mobile->desktop swap.
- e2e campaignAiChatResize: desktop->mobile, mobile->desktop, closed stays
  closed, fresh mobile visit closed, navigation survival, new tab resets.
- Impl plan: docs/plans/migrar-chat-painel-drawer-resize-impl.md

Closes #416
2026-08-08 17:52:02 -03:00

31 lines
947 B
TypeScript

'use client'
import { Bot, X } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { CampaignAIChat } from '@/components/campaign/shell/ai/CampaignAIChat'
import { useAISidebar } from '@/components/campaign/shell/ai/CampaignAISidebarContext'
export const CampaignAISidebar = () => {
const ctx = useAISidebar()
if (!ctx) return null
const { setOpen } = ctx
return (
<div className="grid h-full grid-rows-[auto_1fr] border-l border-border bg-background">
<div className="flex min-h-11 shrink-0 items-center justify-between border-b border-border px-4">
<div className="flex items-center gap-2 text-sm font-medium">
<Bot className="size-4" />
Sollinha
</div>
<Button variant="ghost" size="icon-sm" onClick={() => setOpen(false)} aria-label="Fechar">
<X className="size-4" />
</Button>
</div>
<CampaignAIChat />
</div>
)
}