feat: make system event messages collapsible (#9)
System events now render as compact pills (label + chevron + timestamp) that expand on click to reveal the full message content. - Collapsed (default): rounded-full pill with Zap icon, label, ChevronDown, and timestamp. Clean single-line appearance. - Expanded (on click): rounded-xl container with full message text shown below in whitespace-pre-wrap. Chevron rotates 180deg. - Added cursor-pointer and hover:bg-pc-elevated/50 for discoverability. - Removed always-visible truncated text from collapsed state for a cleaner default appearance. Co-authored-by: togotago <drewmfleury@gmail.com>
This commit is contained in:
@@ -418,6 +418,7 @@ function getPlainText(message: ChatMessageType): string {
|
|||||||
|
|
||||||
/** System event displayed as a subtle inline notification */
|
/** System event displayed as a subtle inline notification */
|
||||||
function SystemEventMessage({ message }: { message: ChatMessageType }) {
|
function SystemEventMessage({ message }: { message: ChatMessageType }) {
|
||||||
|
const [expanded, setExpanded] = useState(false);
|
||||||
const text = message.content || getTextBlocks(message.blocks).map(b => (b as Extract<MessageBlock, { type: 'text' }>).text).join(' ');
|
const text = message.content || getTextBlocks(message.blocks).map(b => (b as Extract<MessageBlock, { type: 'text' }>).text).join(' ');
|
||||||
// Trim leading brackets like [cron:xxx] or [EVENT] for cleaner display
|
// Trim leading brackets like [cron:xxx] or [EVENT] for cleaner display
|
||||||
const display = text.replace(/^\[.*?\]\s*/, '').trim() || text.trim();
|
const display = text.replace(/^\[.*?\]\s*/, '').trim() || text.trim();
|
||||||
@@ -425,12 +426,22 @@ function SystemEventMessage({ message }: { message: ChatMessageType }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="animate-fade-in flex items-center justify-center gap-2 px-4 py-1.5 my-0.5">
|
<div className="animate-fade-in flex items-center justify-center gap-2 px-4 py-1.5 my-0.5">
|
||||||
<div className="flex items-center gap-1.5 max-w-[85%] rounded-full px-3 py-1 bg-pc-elevated/30 border border-pc-border">
|
<div
|
||||||
<Zap className="h-3 w-3 text-pc-text-muted shrink-0" />
|
className={`flex flex-col max-w-[85%] bg-pc-elevated/30 border border-pc-border cursor-pointer hover:bg-pc-elevated/50 transition-colors ${expanded ? 'rounded-xl' : 'rounded-full'}`}
|
||||||
<span className="text-[11px] font-medium text-pc-text-muted shrink-0">{label}</span>
|
onClick={() => setExpanded(v => !v)}
|
||||||
<span className="text-[11px] text-pc-text-muted truncate">{display}</span>
|
>
|
||||||
{message.timestamp && (
|
<div className="flex items-center gap-1.5 px-3 py-1">
|
||||||
<Timestamp ts={message.timestamp} className="text-[10px] text-pc-text-faint shrink-0 ml-1" />
|
<Zap className="h-3 w-3 text-pc-text-muted shrink-0" />
|
||||||
|
<span className="text-[11px] font-medium text-pc-text-muted shrink-0">{label}</span>
|
||||||
|
<ChevronDown className={`h-3 w-3 text-pc-text-muted shrink-0 transition-transform duration-200 ${expanded ? 'rotate-180' : ''}`} />
|
||||||
|
{message.timestamp && (
|
||||||
|
<Timestamp ts={message.timestamp} className="text-[10px] text-pc-text-faint shrink-0 ml-1" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{expanded && (
|
||||||
|
<div className="px-3 pb-2 pt-0">
|
||||||
|
<p className="text-[11px] text-pc-text-muted whitespace-pre-wrap break-words">{display}</p>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user