Phone header: assistant button in the corner, gated on an available provider as the sidebar entry is; header triggers on the right at 44px

This commit is contained in:
2026-10-14 23:41:30 +02:00
parent e35eb67a21
commit 6ca2a484ed
+27 -3
View File
@@ -1,16 +1,23 @@
import { useQuery } from "@tanstack/react-query"
import { import {
createFileRoute, createFileRoute,
Outlet, Outlet,
redirect, redirect,
useRouterState, useRouterState,
} from "@tanstack/react-router" } from "@tanstack/react-router"
import { Bot } from "lucide-react"
import { ControlTrigger } from "@/components/Chat/ChatPanel" import {
aiStatusQueryOptions,
ControlTrigger,
} from "@/components/Chat/ChatPanel"
import { chatStore } from "@/components/Chat/chatStore"
import { ConnectionNotice } from "@/components/Common/ConnectionNotice" import { ConnectionNotice } from "@/components/Common/ConnectionNotice"
import ErrorComponent from "@/components/Common/ErrorComponent" import ErrorComponent from "@/components/Common/ErrorComponent"
import { Footer } from "@/components/Common/Footer" import { Footer } from "@/components/Common/Footer"
import { useFlowSocket } from "@/components/Flow/useFlowSocket" import { useFlowSocket } from "@/components/Flow/useFlowSocket"
import AppSidebar from "@/components/Sidebar/AppSidebar" import AppSidebar from "@/components/Sidebar/AppSidebar"
import { Button } from "@/components/ui/button"
import { import {
SidebarInset, SidebarInset,
SidebarProvider, SidebarProvider,
@@ -38,6 +45,8 @@ function Layout() {
// here rather than only inside the editor. // here rather than only inside the editor.
useFlowSocket() useFlowSocket()
const home = useRouterState({ select: (s) => s.location.pathname === "/" }) const home = useRouterState({ select: (s) => s.location.pathname === "/" })
// Gated as the sidebar's entry is: with no provider there is nothing to open.
const assistant = useQuery(aiStatusQueryOptions())
return ( return (
<SidebarProvider className="bg-card"> <SidebarProvider className="bg-card">
@@ -48,10 +57,25 @@ function Layout() {
<ConnectionNotice /> <ConnectionNotice />
{/* The sidebar carries its own collapse control; a phone has no {/* The sidebar carries its own collapse control; a phone has no
sidebar on screen to carry it. Home's chat sits opposite, where sidebar on screen to carry it. Home's chat sits opposite, where
the brain view has it on a wider screen. */} the brain view has it on a wider screen, and the assistant in the
corner, one tap away rather than behind the sidebar sheet. */}
<header className="sticky top-0 z-10 flex h-16 shrink-0 items-center gap-2 px-4 md:hidden"> <header className="sticky top-0 z-10 flex h-16 shrink-0 items-center gap-2 px-4 md:hidden">
<SidebarTrigger className="-ml-1 text-muted-foreground" /> <SidebarTrigger className="-ml-1 text-muted-foreground" />
{home ? <ControlTrigger className="-mr-1 ml-auto" /> : null} <div className="-mr-3 ml-auto flex items-center">
{home ? <ControlTrigger className="size-11" /> : null}
{assistant.data?.available ? (
<Button
variant="ghost"
size="icon-touch"
className="text-muted-foreground"
onClick={chatStore.toggle}
aria-label="Assistant"
title="Assistant"
>
<Bot />
</Button>
) : null}
</div>
</header> </header>
<main className="flex-1 p-4 sm:p-6 md:p-8"> <main className="flex-1 p-4 sm:p-6 md:p-8">
<div className="mx-auto max-w-7xl"> <div className="mx-auto max-w-7xl">