Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(ripple): add Browse Mode sidebar with chat UI components
- Create RippleSidebarProvider with independent React context, isEnabled
  gating, animation management, and resize persistence
- Create RippleSidebar attached panel component with PixelBasedResizablePanel
- Build chat UI: RippleSidebarInner orchestrator, MessageBubble, ToolCall,
  ChatMessages, ChatInput, SettingsPanel, and SessionList components
- Sidebar is always on the opposite side of the main sidebar
- One session per tab model for Browse Mode
  • Loading branch information
iamEvanYT committed Mar 3, 2026
commit df1c2d63fcd6ef8e66e28127bb1a6f34fd72c30d
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { cn } from "@/lib/utils";
import { useCallback, useRef, useState } from "react";

interface ChatInputProps {
onSend: (text: string) => void;
onAbort: () => void;
isStreaming: boolean;
disabled: boolean;
}

export function ChatInput({ onSend, onAbort, isStreaming, disabled }: ChatInputProps) {
const [text, setText] = useState("");
const textareaRef = useRef<HTMLTextAreaElement>(null);

const handleSend = useCallback(() => {
const trimmed = text.trim();
if (!trimmed || disabled) return;

onSend(trimmed);
setText("");

// Reset textarea height
if (textareaRef.current) {
textareaRef.current.style.height = "auto";
}
}, [text, disabled, onSend]);

const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
if (isStreaming) return;
handleSend();
}
};

const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
setText(e.target.value);

// Auto-resize textarea
const el = e.target;
el.style.height = "auto";
el.style.height = `${Math.min(el.scrollHeight, 120)}px`;
};

return (
<div className="shrink-0 px-3 pb-3">
<div className="flex items-end gap-1.5 bg-white/5 rounded-lg border border-white/10 p-1.5">
<textarea
ref={textareaRef}
value={text}
onChange={handleInput}
onKeyDown={handleKeyDown}
placeholder="Ask about this page..."
disabled={disabled}
rows={1}
className={cn(
"flex-1 bg-transparent text-sm text-white/90 placeholder:text-white/30",
"resize-none outline-none min-h-[28px] max-h-[120px] py-1 px-1.5",
"leading-snug",
disabled && "opacity-50 cursor-not-allowed"
)}
/>
{isStreaming ? (
<button
type="button"
onClick={onAbort}
className={cn(
"shrink-0 size-7 rounded-md flex items-center justify-center",
"bg-red-500/80 hover:bg-red-500 text-white transition-colors",
"text-xs font-medium"
)}
title="Stop generating"
>
{"\u25A0"}
</button>
) : (
<button
type="button"
onClick={handleSend}
disabled={!text.trim() || disabled}
className={cn(
"shrink-0 size-7 rounded-md flex items-center justify-center",
"bg-blue-600/80 hover:bg-blue-600 text-white transition-colors",
"text-xs font-medium",
(!text.trim() || disabled) && "opacity-30 cursor-not-allowed"
)}
title="Send message"
>
{"\u2191"}
</button>
)}
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import type { RippleMessageInfo } from "~/flow/interfaces/ripple/interface";
import { MessageBubble } from "./message-bubble";
import { useEffect, useRef } from "react";

interface ChatMessagesProps {
messages: RippleMessageInfo[];
isStreaming: boolean;
}

export function ChatMessages({ messages, isStreaming }: ChatMessagesProps) {
const scrollRef = useRef<HTMLDivElement>(null);
const isAtBottomRef = useRef(true);

// Auto-scroll to bottom when new messages arrive (if user is already at bottom)
useEffect(() => {
const container = scrollRef.current;
if (!container) return;

if (isAtBottomRef.current) {
container.scrollTop = container.scrollHeight;
}
}, [messages, isStreaming]);

const handleScroll = () => {
const container = scrollRef.current;
if (!container) return;

const { scrollTop, scrollHeight, clientHeight } = container;
isAtBottomRef.current = scrollHeight - scrollTop - clientHeight < 40;
};

if (messages.length === 0) {
return (
<div className="flex-1 flex items-center justify-center px-4">
<div className="text-center">
<div className="text-white/30 text-sm">Ask about this page</div>
<div className="text-white/20 text-xs mt-1">
Ripple can read, navigate, and interact with the current web page.
</div>
</div>
</div>
);
}

return (
<div ref={scrollRef} className="flex-1 min-h-0 overflow-y-auto px-3 py-2" onScroll={handleScroll}>
<div className="flex flex-col gap-3">
{messages.map((msg) => (
<MessageBubble key={msg.id} role={msg.role} parts={msg.parts} />
))}
{isStreaming && (
<div className="flex justify-start">
<div className="bg-white/10 rounded-lg px-3 py-2 rounded-bl-sm">
<div className="flex gap-1">
<span className="w-1.5 h-1.5 rounded-full bg-white/40 animate-bounce [animation-delay:0ms]" />
<span className="w-1.5 h-1.5 rounded-full bg-white/40 animate-bounce [animation-delay:150ms]" />
<span className="w-1.5 h-1.5 rounded-full bg-white/40 animate-bounce [animation-delay:300ms]" />
</div>
</div>
</div>
)}
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { cn } from "@/lib/utils";
import type { RippleMessagePart } from "~/flow/interfaces/ripple/interface";
import { ToolCall } from "./tool-call";

interface MessageBubbleProps {
role: "user" | "assistant";
parts: RippleMessagePart[];
}

export function MessageBubble({ role, parts }: MessageBubbleProps) {
const isUser = role === "user";

return (
<div className={cn("flex w-full", isUser ? "justify-end" : "justify-start")}>
<div
className={cn(
"max-w-[85%] rounded-lg px-3 py-2 text-sm",
isUser ? "bg-blue-600 text-white rounded-br-sm" : "bg-white/10 text-white/90 rounded-bl-sm"
)}
>
{parts.map((part, i) => (
<MessagePart key={i} part={part} />
))}
</div>
</div>
);
}

function MessagePart({ part }: { part: RippleMessagePart }) {
switch (part.type) {
case "text":
return <TextContent text={part.text} />;
case "tool-invocation":
return <ToolCall toolName={part.toolName} args={part.args} result={part.result} state={part.state} />;
case "step-start":
return part.title ? <div className="text-white/40 text-xs italic py-1">{part.title}</div> : null;
default:
return null;
}
}

function TextContent({ text }: { text: string }) {
if (!text) return null;

// Split on newlines to preserve basic formatting
const lines = text.split("\n");

return (
<div className="whitespace-pre-wrap break-words leading-relaxed">
{lines.map((line, i) => (
<span key={i}>
{line}
{i < lines.length - 1 && <br />}
</span>
))}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { cn } from "@/lib/utils";
import type { RippleSessionInfo } from "~/flow/interfaces/ripple/interface";

interface SessionListProps {
sessions: RippleSessionInfo[];
activeSessionId: string | null;
onSelectSession: (sessionId: string) => void;
isOpen: boolean;
onClose: () => void;
}

export function SessionList({ sessions, activeSessionId, onSelectSession, isOpen, onClose }: SessionListProps) {
if (!isOpen) return null;

return (
<div className="absolute inset-x-0 top-10 z-10 mx-2">
{/* Backdrop */}
<div className="fixed inset-0 z-0" onClick={onClose} />

{/* Dropdown */}
<div className="relative z-10 rounded-lg border border-white/10 bg-black/95 shadow-lg overflow-hidden max-h-60">
<div className="overflow-y-auto max-h-60">
{sessions.length === 0 ? (
<div className="px-3 py-4 text-sm text-white/30 text-center">No sessions yet</div>
) : (
sessions.map((session) => (
<button
key={session.id}
type="button"
onClick={() => {
onSelectSession(session.id);
onClose();
}}
className={cn(
"w-full text-left px-3 py-2 text-sm transition-colors",
"hover:bg-white/10",
session.id === activeSessionId ? "text-white bg-white/5" : "text-white/60"
)}
>
<div className="truncate">{session.title || `Session ${session.id.slice(0, 8)}`}</div>
<div className="text-[10px] text-white/30 mt-0.5">{new Date(session.createdAt).toLocaleString()}</div>
</button>
))
)}
</div>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { cn } from "@/lib/utils";

interface SettingsPanelProps {
isOpen: boolean;
onClose: () => void;
fsAccessEnabled: boolean;
onToggleFsAccess: (enabled: boolean) => void;
}

export function SettingsPanel({ isOpen, onClose, fsAccessEnabled, onToggleFsAccess }: SettingsPanelProps) {
if (!isOpen) return null;

return (
<div className="absolute inset-0 z-10 flex flex-col bg-black/95">
{/* Header */}
<div className="flex items-center justify-between px-3 py-2 border-b border-white/10">
<span className="text-sm font-medium text-white/80">Settings</span>
<button
type="button"
onClick={onClose}
className="size-6 rounded flex items-center justify-center text-white/50 hover:text-white/80 hover:bg-white/10 transition-colors text-sm"
>
{"\u2715"}
</button>
</div>

{/* Settings */}
<div className="flex-1 overflow-y-auto p-3 space-y-4">
{/* Filesystem Access */}
<div className="space-y-1.5">
<div className="text-xs text-white/50 uppercase tracking-wider">Permissions</div>
<label className="flex items-center justify-between gap-3 cursor-pointer group">
<div>
<div className="text-sm text-white/80">Filesystem access</div>
<div className="text-xs text-white/40">Allow Ripple to read and write files on your system</div>
</div>
<button
type="button"
role="switch"
aria-checked={fsAccessEnabled}
onClick={() => onToggleFsAccess(!fsAccessEnabled)}
className={cn(
"relative shrink-0 inline-flex h-5 w-9 items-center rounded-full transition-colors",
fsAccessEnabled ? "bg-blue-600" : "bg-white/20"
)}
>
<span
className={cn(
"inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",
fsAccessEnabled ? "translate-x-4" : "translate-x-0.5"
)}
/>
</button>
</label>
</div>
</div>
</div>
);
}
Loading