Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(ui): add onSubmit/disabled props to ChatInput, convert AppSidebar to children slot

Naiyuan Qing4ff227685e56
diff --git a/packages/ui/src/components/app-sidebar.tsx b/packages/ui/src/components/app-sidebar.tsx
index 6e780abf93..686e5b3c6d 100644
--- a/packages/ui/src/components/app-sidebar.tsx
+++ b/packages/ui/src/components/app-sidebar.tsx
@@ -3,25 +3,16 @@ import {
SidebarHeader,
SidebarContent,
SidebarFooter,
- SidebarGroup,
- SidebarGroupLabel,
- SidebarGroupContent,
SidebarMenu,
SidebarMenuItem,
- SidebarMenuButton,
} from "@multica/ui/components/ui/sidebar"
import { ThemeToggle } from "@multica/ui/components/theme-toggle"
-interface NavItem {
- title: string
- url: string
-}
-
interface AppSidebarProps {
- items: NavItem[]
+ children?: React.ReactNode
}
-export function AppSidebar({ items }: AppSidebarProps) {
+export function AppSidebar({ children }: AppSidebarProps) {
return (
<Sidebar>
<SidebarHeader>
@@ -36,20 +27,7 @@ export function AppSidebar({ items }: AppSidebarProps) {
</span>
</div>
</SidebarHeader>
- <SidebarContent>
- <SidebarGroup>
- <SidebarGroupLabel>Navigation</SidebarGroupLabel>
- <SidebarGroupContent>
- <SidebarMenu>
- {items.map((item) => (
- <SidebarMenuItem key={item.title}>
- <SidebarMenuButton>{item.title}</SidebarMenuButton>
- </SidebarMenuItem>
- ))}
- </SidebarMenu>
- </SidebarGroupContent>
- </SidebarGroup>
- </SidebarContent>
+ <SidebarContent>{children}</SidebarContent>
<SidebarFooter>
<SidebarMenu>
<SidebarMenuItem>
diff --git a/packages/ui/src/components/chat-input.tsx b/packages/ui/src/components/chat-input.tsx
index ae9d261065..16c25cc9bf 100644
--- a/packages/ui/src/components/chat-input.tsx
+++ b/packages/ui/src/components/chat-input.tsx
@@ -4,13 +4,18 @@ import { Button } from "@multica/ui/components/ui/button";
import { ArrowUpIcon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-export function ChatInput() {
+interface ChatInputProps {
+ onSubmit?: (value: string) => void;
+ disabled?: boolean;
+}
+
+export function ChatInput({ onSubmit, disabled }: ChatInputProps) {
const textareaRef = useRef<HTMLTextAreaElement>(null);
const handleSubmit = () => {
const value = textareaRef.current?.value ?? "";
if (!value.trim()) return;
- console.log("submit:", value);
+ onSubmit?.(value);
textareaRef.current!.value = "";
// reset height
textareaRef.current!.style.height = "auto";
@@ -21,6 +26,7 @@ export function ChatInput() {
<textarea
ref={textareaRef}
rows={2}
+ disabled={disabled}
placeholder="Type a message..."
onChange={(e) => {
e.target.style.height = "auto";
@@ -32,10 +38,10 @@ export function ChatInput() {
handleSubmit();
}
}}
- className="w-full resize-none bg-transparent px-1 py-1 text-sm text-foreground outline-none placeholder:text-muted-foreground"
+ className="w-full resize-none bg-transparent px-1 py-1 text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:opacity-50"
/>
<div className="flex items-center justify-end pt-2">
- <Button size="icon" onClick={handleSubmit}>
+ <Button size="icon" onClick={handleSubmit} disabled={disabled}>
<HugeiconsIcon strokeWidth={2.5} icon={ArrowUpIcon} />
</Button>
</div>