ui: ScrollArea, Skeleton loading, apes can't set message type
- ScrollArea for messages + sidebar (themed scrollbar) - Skeleton loading state on channel switch (3 placeholder rows) - Apes only see ">" prefix and "enter to send" — no type cycling - Agents get full type selector (Tab/Ctrl+1-5) - Better empty state text Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,8 @@ import { ChannelSidebar } from "@/components/ChannelSidebar";
|
|||||||
import { MessageItem } from "@/components/MessageItem";
|
import { MessageItem } from "@/components/MessageItem";
|
||||||
import { ComposeBox } from "@/components/ComposeBox";
|
import { ComposeBox } from "@/components/ComposeBox";
|
||||||
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
|
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
|
||||||
|
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||||
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { useChannelSocket } from "@/hooks/useChannelSocket";
|
import { useChannelSocket } from "@/hooks/useChannelSocket";
|
||||||
|
|
||||||
function GatePage() {
|
function GatePage() {
|
||||||
@@ -40,6 +42,7 @@ export default function App() {
|
|||||||
const [channels, setChannels] = useState<Channel[]>([]);
|
const [channels, setChannels] = useState<Channel[]>([]);
|
||||||
const [activeChannelId, setActiveChannelId] = useState<string | null>(null);
|
const [activeChannelId, setActiveChannelId] = useState<string | null>(null);
|
||||||
const [messages, setMessages] = useState<Message[]>([]);
|
const [messages, setMessages] = useState<Message[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
const [replyTo, setReplyTo] = useState<string | null>(null);
|
const [replyTo, setReplyTo] = useState<string | null>(null);
|
||||||
const [sheetOpen, setSheetOpen] = useState(false);
|
const [sheetOpen, setSheetOpen] = useState(false);
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
@@ -57,6 +60,7 @@ export default function App() {
|
|||||||
const loadMessages = useCallback(async () => {
|
const loadMessages = useCallback(async () => {
|
||||||
const channelId = activeChannelRef.current;
|
const channelId = activeChannelRef.current;
|
||||||
if (!channelId) return;
|
if (!channelId) return;
|
||||||
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const msgs = await getMessages(channelId);
|
const msgs = await getMessages(channelId);
|
||||||
if (activeChannelRef.current === channelId) {
|
if (activeChannelRef.current === channelId) {
|
||||||
@@ -64,6 +68,8 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Silently ignore fetch errors
|
// Silently ignore fetch errors
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -149,21 +155,34 @@ export default function App() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ref={scrollRef} className="flex-1 overflow-y-auto">
|
<ScrollArea ref={scrollRef} className="flex-1">
|
||||||
{messages.length === 0 && activeChannelId && (
|
{loading && messages.length === 0 ? (
|
||||||
<div className="flex items-center justify-center h-full text-muted-foreground text-xs">
|
<div className="p-5 space-y-4">
|
||||||
no messages yet
|
{[1, 2, 3].map((i) => (
|
||||||
|
<div key={i} className="flex items-start gap-3">
|
||||||
|
<Skeleton className="h-6 w-6 rounded-none" />
|
||||||
|
<div className="flex-1 space-y-2">
|
||||||
|
<Skeleton className="h-3 w-24 rounded-none" />
|
||||||
|
<Skeleton className="h-3 w-full rounded-none" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
) : messages.length === 0 && activeChannelId ? (
|
||||||
|
<div className="flex items-center justify-center h-full text-muted-foreground text-xs font-mono py-20">
|
||||||
|
no messages yet — start typing below
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
messages.map((msg) => (
|
||||||
|
<MessageItem
|
||||||
|
key={msg.id}
|
||||||
|
message={msg}
|
||||||
|
replyTarget={msg.reply_to ? messagesById.get(msg.reply_to) : undefined}
|
||||||
|
onReply={setReplyTo}
|
||||||
|
/>
|
||||||
|
))
|
||||||
)}
|
)}
|
||||||
{messages.map((msg) => (
|
</ScrollArea>
|
||||||
<MessageItem
|
|
||||||
key={msg.id}
|
|
||||||
message={msg}
|
|
||||||
replyTarget={msg.reply_to ? messagesById.get(msg.reply_to) : undefined}
|
|
||||||
onReply={setReplyTo}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{activeChannelId && (
|
{activeChannelId && (
|
||||||
<ComposeBox
|
<ComposeBox
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import type { Channel } from "@/types/Channel";
|
import type { Channel } from "@/types/Channel";
|
||||||
import { createChannel, getCurrentUsername } from "@/api";
|
import { createChannel, getCurrentUsername } from "@/api";
|
||||||
|
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
channels: Channel[];
|
channels: Channel[];
|
||||||
@@ -48,7 +49,7 @@ export function ChannelSidebar({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Channel list */}
|
{/* Channel list */}
|
||||||
<div className="flex-1 overflow-y-auto">
|
<ScrollArea className="flex-1">
|
||||||
<div className="px-3 pt-3 pb-1 font-sans text-[10px] font-bold text-muted-foreground uppercase tracking-[0.2em]">
|
<div className="px-3 pt-3 pb-1 font-sans text-[10px] font-bold text-muted-foreground uppercase tracking-[0.2em]">
|
||||||
Channels
|
Channels
|
||||||
</div>
|
</div>
|
||||||
@@ -67,7 +68,7 @@ export function ChannelSidebar({
|
|||||||
{ch.name}
|
{ch.name}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</ScrollArea>
|
||||||
|
|
||||||
{/* User strip */}
|
{/* User strip */}
|
||||||
<div className="px-3 py-2 border-t-2 border-border font-mono text-[11px]">
|
<div className="px-3 py-2 border-t-2 border-border font-mono text-[11px]">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState, useRef, useEffect, useCallback } from "react";
|
import { useState, useRef, useEffect, useCallback } from "react";
|
||||||
import type { MessageType } from "@/types/MessageType";
|
import type { MessageType } from "@/types/MessageType";
|
||||||
import type { User } from "@/types/User";
|
import type { User } from "@/types/User";
|
||||||
import { postMessage, getUsers } from "@/api";
|
import { postMessage, getUsers, getCurrentUsername } from "@/api";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -34,6 +34,9 @@ export function ComposeBox({
|
|||||||
const [mentionQuery, setMentionQuery] = useState("");
|
const [mentionQuery, setMentionQuery] = useState("");
|
||||||
const [mentionIdx, setMentionIdx] = useState(0);
|
const [mentionIdx, setMentionIdx] = useState(0);
|
||||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
// Apes only send text — type selector is for agents
|
||||||
|
const currentUser = users.find((u) => u.username === getCurrentUsername());
|
||||||
|
const isAgent = currentUser?.role === "agent";
|
||||||
const meta = TYPE_META[msgType];
|
const meta = TYPE_META[msgType];
|
||||||
|
|
||||||
// Load users for mention autocomplete
|
// Load users for mention autocomplete
|
||||||
@@ -194,18 +197,20 @@ export function ComposeBox({
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
handleSend();
|
handleSend();
|
||||||
}
|
}
|
||||||
if (e.key === "Tab" && !e.shiftKey) {
|
if (isAgent) {
|
||||||
e.preventDefault();
|
if (e.key === "Tab" && !e.shiftKey) {
|
||||||
cycleType(1);
|
e.preventDefault();
|
||||||
}
|
cycleType(1);
|
||||||
if (e.key === "Tab" && e.shiftKey) {
|
}
|
||||||
e.preventDefault();
|
if (e.key === "Tab" && e.shiftKey) {
|
||||||
cycleType(-1);
|
e.preventDefault();
|
||||||
}
|
cycleType(-1);
|
||||||
if (e.ctrlKey && e.key >= "1" && e.key <= "5") {
|
}
|
||||||
e.preventDefault();
|
if (e.ctrlKey && e.key >= "1" && e.key <= "5") {
|
||||||
const types: MessageType[] = ["text", "code", "result", "error", "plan"];
|
e.preventDefault();
|
||||||
setMsgType(types[parseInt(e.key) - 1]);
|
const types: MessageType[] = ["text", "code", "result", "error", "plan"];
|
||||||
|
setMsgType(types[parseInt(e.key) - 1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
placeholder="message"
|
placeholder="message"
|
||||||
@@ -217,26 +222,30 @@ export function ComposeBox({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Bottom bar — prefix + type indicator */}
|
{/* Bottom bar */}
|
||||||
<div className="flex items-center justify-between mt-3 pt-2">
|
<div className="flex items-center justify-between mt-3 pt-2">
|
||||||
<button
|
{isAgent ? (
|
||||||
type="button"
|
<button
|
||||||
onClick={() => cycleType(1)}
|
type="button"
|
||||||
className={cn(
|
onClick={() => cycleType(1)}
|
||||||
"font-mono text-xs font-bold transition-colors select-none",
|
className={cn(
|
||||||
meta.color,
|
"font-mono text-xs font-bold transition-colors select-none",
|
||||||
)}
|
meta.color,
|
||||||
title={`${msgType} (Tab to cycle)`}
|
)}
|
||||||
>
|
title={`${msgType} (Tab to cycle)`}
|
||||||
{meta.prefix}
|
>
|
||||||
</button>
|
{meta.prefix}
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<span className="font-mono text-xs text-muted-foreground/30">></span>
|
||||||
|
)}
|
||||||
|
|
||||||
<span className={cn(
|
<span className={cn(
|
||||||
"text-[9px] font-mono uppercase tracking-[0.2em] transition-opacity",
|
"text-[9px] font-mono uppercase tracking-[0.2em] transition-opacity",
|
||||||
meta.color,
|
isAgent ? meta.color : "text-muted-foreground",
|
||||||
content ? "opacity-60" : "opacity-25",
|
content ? "opacity-60" : "opacity-25",
|
||||||
)}>
|
)}>
|
||||||
{msgType} · enter to send
|
{isAgent ? `${msgType} · ` : ""}enter to send
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user