e30e75b5d4
Changesets / Create Version PR (push) Has been cancelled
Deploy Shadcn Registry / Deploy Production (push) Has been cancelled
Template Metrics / LOC + Bundle Size (push) Has been cancelled
Code Quality / Oxlint + Oxfmt (push) Has been cancelled
Code Quality / Template Sync (push) Has been cancelled
Code Quality / Build Changed Packages (push) Has been cancelled
Code Quality / Test Changed Packages (push) Has been cancelled
Deploy Expo Example / Deploy Production (push) Has been cancelled
Deploy Ink Example / Deploy Production (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.12) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Has been cancelled
83 lines
2.3 KiB
TypeScript
83 lines
2.3 KiB
TypeScript
"use client";
|
|
|
|
import { AssistantRuntimeProvider, Tools, useAui } from "@assistant-ui/react";
|
|
import {
|
|
SidebarInset,
|
|
SidebarProvider,
|
|
SidebarTrigger,
|
|
} from "@/components/ui/radix/sidebar";
|
|
import { Separator } from "@/components/ui/radix/separator";
|
|
import { ThreadListSidebar } from "@/components/assistant-ui/threadlist-sidebar";
|
|
import {
|
|
useOpenCodeRuntime,
|
|
useOpenCodeSession,
|
|
} from "@assistant-ui/react-opencode";
|
|
import {
|
|
Thread,
|
|
type ThreadComponents,
|
|
} from "@/components/assistant-ui/thread";
|
|
import { OpenCodeDataPart } from "@/components/opencode-data-part";
|
|
import { FallbackTool } from "@/components/tools/opencode-tools";
|
|
import { ReasoningGroup } from "@/components/tools/reasoning-ghost";
|
|
import { ToolGroup } from "@/components/tools/tool-group";
|
|
import toolkit from "@/components/tools/toolkit";
|
|
import { useEffect } from "react";
|
|
|
|
const THREAD_COMPONENTS: ThreadComponents = {
|
|
ToolFallback: FallbackTool,
|
|
ToolGroup,
|
|
ReasoningGroup,
|
|
};
|
|
|
|
export default function Home() {
|
|
const runtime = useOpenCodeRuntime({
|
|
baseUrl:
|
|
process.env.NEXT_PUBLIC_OPENCODE_BASE_URL ?? "http://localhost:4096",
|
|
});
|
|
|
|
const aui = useAui({
|
|
tools: Tools({ toolkit }),
|
|
});
|
|
|
|
useEffect(
|
|
() => aui.dataRenderers().setFallbackDataUI(OpenCodeDataPart),
|
|
[aui],
|
|
);
|
|
|
|
return (
|
|
<AssistantRuntimeProvider aui={aui} runtime={runtime}>
|
|
<SidebarProvider>
|
|
<div className="flex h-dvh w-full overflow-hidden pr-0.5">
|
|
<ThreadListSidebar />
|
|
<SidebarInset>
|
|
<header className="flex h-16 shrink-0 items-center gap-2 border-b px-4">
|
|
<SidebarTrigger />
|
|
<Separator orientation="vertical" className="mr-2 h-4" />
|
|
<div className="min-w-0">
|
|
<div className="text-sm font-medium">OpenCode</div>
|
|
<SelectedSessionTitle />
|
|
</div>
|
|
</header>
|
|
<div className="min-h-0 flex-1 overflow-hidden">
|
|
<Thread components={THREAD_COMPONENTS} />
|
|
</div>
|
|
</SidebarInset>
|
|
</div>
|
|
</SidebarProvider>
|
|
</AssistantRuntimeProvider>
|
|
);
|
|
}
|
|
|
|
function SelectedSessionTitle() {
|
|
const session = useOpenCodeSession();
|
|
const title = session?.title?.trim();
|
|
|
|
if (!title) return null;
|
|
|
|
return (
|
|
<div className="text-muted-foreground truncate text-xs leading-tight">
|
|
{title}
|
|
</div>
|
|
);
|
|
}
|