Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat(cos): expandable output in agent feedback toast

Adam Eivyf045d553b2c7
diff --git a/.changelog/v0.27.x.md b/.changelog/v0.27.x.md
new file mode 100644
index 0000000000..7b83b7bf87
--- /dev/null
+++ b/.changelog/v0.27.x.md
@@ -0,0 +1,17 @@
+# Release v0.27.x - Changelog
+
+Released: YYYY-MM-DD
+
+## Overview
+
+Enhanced agent completion toast with expandable output view and smart dismiss behavior.
+
+## Features
+
+### Expandable output in agent feedback toast
+- Agent completion toast now includes a Show/Hide toggle to expand the full markdown output summary
+- Reuses shared `OutputBlocks` component (extracted from `AgentCard`) for consistent rendering
+- When expanded: auto-dismiss is paused and dismiss button is hidden — must provide thumbs up/down feedback or collapse first
+- When collapsed: retains original 15s auto-dismiss behavior with manual dismiss option
+- Output fetched via API on demand if not included in socket event data
+- Toast widens from 320px to 480px when expanded, with scrollable output (max 400px height)
diff --git a/client/src/components/cos/OutputBlocks.jsx b/client/src/components/cos/OutputBlocks.jsx
new file mode 100644
index 0000000000..c27b06a2fb
--- /dev/null
+++ b/client/src/components/cos/OutputBlocks.jsx
@@ -0,0 +1,53 @@
+import { useMemo } from 'react';
+import MarkdownOutput from './MarkdownOutput';
+
+export const isToolLine = (line) =>
+ line.startsWith('🔧') || line.startsWith(' →') || line.startsWith(' ↳') || line.startsWith('[stderr]');
+
+export default function OutputBlocks({ output }) {
+ // Group consecutive lines: tool lines render as monospace, content lines as markdown
+ const blocks = useMemo(() => {
+ const result = [];
+ let mdLines = [];
+
+ const flushMd = () => {
+ if (mdLines.length > 0) {
+ result.push({ type: 'md', content: mdLines.join('\n') });
+ mdLines = [];
+ }
+ };
+
+ for (const o of output) {
+ const line = o.line || '';
+ if (isToolLine(line)) {
+ flushMd();
+ result.push({ type: 'tool', line });
+ } else {
+ mdLines.push(line);
+ }
+ }
+ flushMd();
+ return result;
+ }, [output]);
+
+ return (
+ <div className="space-y-0.5">
+ {blocks.map((block, i) => {
+ if (block.type === 'tool') {
+ const line = block.line;
+ if (line.startsWith('🔧')) {
+ return <div key={i} className="py-0.5 text-xs font-mono text-port-accent">{line}</div>;
+ }
+ if (line.startsWith(' →')) {
+ return <div key={i} className="py-0.5 text-xs font-mono text-gray-500 pl-4">{line.substring(4)}</div>;
+ }
+ if (line.startsWith(' ↳')) {
+ return <div key={i} className="py-0.5 text-xs font-mono text-gray-600 pl-4">{line.substring(4)}</div>;
+ }
+ return <div key={i} className="py-0.5 text-xs font-mono text-yellow-500">{line}</div>;
+ }
+ return <MarkdownOutput key={i} content={block.content} />;
+ })}
+ </div>
+ );
+}
diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsx
index da5ad6ff00..fe6c8052c5 100644
--- a/client/src/components/cos/tabs/AgentCard.jsx
+++ b/client/src/components/cos/tabs/AgentCard.jsx
@@ -16,7 +16,7 @@ import {
ExternalLink
} from 'lucide-react';
import * as api from '../../../services/api';
-import MarkdownOutput from '../MarkdownOutput';
+import OutputBlocks from '../OutputBlocks';
import toast from 'react-hot-toast';
// Extract task type from description (matches server-side extractTaskType)
@@ -40,57 +40,6 @@ function extractTaskType(description) {
return 'feature';
}
-const isToolLine = (line) =>
- line.startsWith('🔧') || line.startsWith(' →') || line.startsWith(' ↳') || line.startsWith('[stderr]');
-
-function OutputBlocks({ output }) {
- // Group consecutive lines: tool lines render as monospace, content lines as markdown
- const blocks = useMemo(() => {
- const result = [];
- let mdLines = [];
-
- const flushMd = () => {
- if (mdLines.length > 0) {
- result.push({ type: 'md', content: mdLines.join('\n') });
- mdLines = [];
- }
- };
-
- for (const o of output) {
- const line = o.line || '';
- if (isToolLine(line)) {
- flushMd();
- result.push({ type: 'tool', line });
- } else {
- mdLines.push(line);
- }
- }
- flushMd();
- return result;
- }, [output]);
-
- return (
- <div className="space-y-0.5">
- {blocks.map((block, i) => {
- if (block.type === 'tool') {
- const line = block.line;
- if (line.startsWith('🔧')) {
- return <div key={i} className="py-0.5 text-xs font-mono text-port-accent">{line}</div>;
- }
- if (line.startsWith(' →')) {
- return <div key={i} className="py-0.5 text-xs font-mono text-gray-500 pl-4">{line.substring(4)}</div>;
- }
- if (line.startsWith(' ↳')) {
- return <div key={i} className="py-0.5 text-xs font-mono text-gray-600 pl-4">{line.substring(4)}</div>;
- }
- return <div key={i} className="py-0.5 text-xs font-mono text-yellow-500">{line}</div>;
- }
- return <MarkdownOutput key={i} content={block.content} />;
- })}
- </div>
- );
-}
-
export default function AgentCard({ agent, onKill, onDelete, onResume, completed, liveOutput, durations, onFeedbackChange, remote, peerName }) {
const [expanded, setExpanded] = useState(false);
const [now, setNow] = useState(Date.now());
diff --git a/client/src/hooks/useAgentFeedbackToast.jsx b/client/src/hooks/useAgentFeedbackToast.jsx
index fa44db9582..18ff7957ea 100644
--- a/client/src/hooks/useAgentFeedbackToast.jsx
+++ b/client/src/hooks/useAgentFeedbackToast.jsx
@@ -1,12 +1,129 @@
-import { useEffect, useCallback, useRef } from 'react';
+import { useState, useEffect, useCallback, useRef } from 'react';
import toast from 'react-hot-toast';
+import { ThumbsUp, ThumbsDown, Loader2 } from 'lucide-react';
import socket from '../services/socket';
import * as api from '../services/api';
+import OutputBlocks from '../components/cos/OutputBlocks';
+
+const AUTO_DISMISS_MS = 15000;
+
+/**
+ * Toast content component with expandable output and smart auto-dismiss.
+ * When collapsed: auto-dismisses after 15s, shows dismiss button.
+ * When expanded: no auto-dismiss, no dismiss — must give feedback or collapse first.
+ */
+function AgentFeedbackToast({ t, agentData, onFeedback }) {
+ const [expanded, setExpanded] = useState(false);
+ const [output, setOutput] = useState(agentData?.output || []);
+ const [loadingOutput, setLoadingOutput] = useState(false);
+ const dismissTimer = useRef(null);
+
+ const agentId = agentData?.id || agentData?.agentId;
+ const taskDesc = agentData?.metadata?.taskDescription || agentData?.taskId || 'Task';
+ const shortDesc = taskDesc.length > 50 ? taskDesc.substring(0, 50) + '...' : taskDesc;
+ const success = agentData?.result?.success;
+
+ // Auto-dismiss timer: active when collapsed, cleared when expanded
+ useEffect(() => {
+ if (dismissTimer.current) clearTimeout(dismissTimer.current);
+ if (!expanded) {
+ dismissTimer.current = setTimeout(() => toast.dismiss(t.id), AUTO_DISMISS_MS);
+ }
+ return () => {
+ if (dismissTimer.current) clearTimeout(dismissTimer.current);
+ };
+ }, [expanded, t.id]);
+
+ // Fetch output on expand if not already loaded
+ useEffect(() => {
+ if (expanded && output.length === 0 && !loadingOutput && agentId) {
+ setLoadingOutput(true);
+ api.getCosAgent(agentId)
+ .then(data => setOutput(data?.output || []))
+ .catch(() => {})
+ .finally(() => setLoadingOutput(false));
+ }
+ }, [expanded, output.length, loadingOutput, agentId]);
+
+ return (
+ <div className={`flex flex-col gap-2 transition-all ${expanded ? 'w-[480px]' : 'max-w-xs'}`}>
+ {/* Header */}
+ <div className="flex items-center gap-2">
+ <span className={success ? 'text-green-500' : 'text-red-500'}>
+ {success ? '✓' : '✗'}
+ </span>
+ <span className="font-medium text-white text-sm flex-1">Agent completed</span>
+ <button
+ onClick={() => setExpanded(!expanded)}
+ className="text-xs text-gray-500 hover:text-white transition-colors"
+ >
+ {expanded ? 'Hide' : 'Show'}
+ </button>
+ </div>
+
+ {/* Task description */}
+ <p className={`text-xs text-gray-400 ${expanded ? '' : 'truncate'}`} title={taskDesc}>
+ {expanded ? taskDesc : shortDesc}
+ </p>
+
+ {/* Expanded output */}
+ {expanded && (
+ <div className="border-t border-port-border/30 pt-2 max-h-[400px] overflow-y-auto">
+ {loadingOutput ? (
+ <div className="flex items-center gap-2 text-gray-500 text-xs">
+ <Loader2 size={12} className="animate-spin" />
+ Loading output...
+ </div>
+ ) : output.length > 0 ? (
+ <OutputBlocks output={output} />
+ ) : (
+ <div className="text-xs text-gray-500">No output captured</div>
+ )}
+ </div>
+ )}
+
+ {/* Feedback buttons */}
+ <div className="flex items-center gap-2 pt-1 border-t border-port-border/30">
+ <span className="text-xs text-gray-500">Was this helpful?</span>
+ <div className="flex gap-1 ml-auto">
+ <button
+ onClick={() => onFeedback(agentId, 'positive', t.id)}
+ className="p-1.5 rounded bg-green-500/20 hover:bg-green-500/30 text-green-400 transition-colors"
+ title="Helpful"
+ aria-label="Mark as helpful"
+ >
+ <ThumbsUp size={16} />
+ </button>
+ <button
+ onClick={() => onFeedback(agentId, 'negative', t.id)}
+ className="p-1.5 rounded bg-red-500/20 hover:bg-red-500/30 text-red-400 transition-colors"
+ title="Not helpful"
+ aria-label="Mark as not helpful"
+ >
+ <ThumbsDown size={16} />
+ </button>
+ {!expanded && (
+ <button
+ onClick={() => toast.dismiss(t.id)}
+ className="p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors"
+ title="Dismiss"
+ aria-label="Dismiss notification"
+ >
+ <svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
+ </svg>
+ </button>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+}
/**
* Hook that shows proactive feedback toast when agents complete tasks.
* Prompts users for quick feedback directly in the toast notification,
- * improving feedback collection without requiring navigation to the Agents tab.
+ * with expandable output view reusing shared OutputBlocks component.
*/
export function useAgentFeedbackToast() {
// Track which agents we've shown feedback toasts for to avoid duplicates
@@ -42,72 +159,27 @@ export function useAgentFeedbackToast() {
// Mark as shown to prevent duplicates
shownFeedbackFor.current.add(agentId);
- // Get task description for display
- const taskDesc = data?.metadata?.taskDescription || data?.taskId || 'Task';
- const shortDesc = taskDesc.length > 50 ? taskDesc.substring(0, 50) + '...' : taskDesc;
- const success = data?.result?.success;
-
// Generate unique toast ID
const toastId = `feedback-${agentId}`;
- // Show custom toast with inline feedback buttons
+ // Show custom toast with inline feedback and expandable output
toast(
(t) => (
- <div className="flex flex-col gap-2 max-w-xs">
- <div className="flex items-center gap-2">
- <span className={success ? 'text-green-500' : 'text-red-500'}>
- {success ? '✓' : '✗'}
- </span>
- <span className="font-medium text-white text-sm">Agent completed</span>
- </div>
- <p className="text-xs text-gray-400 truncate" title={taskDesc}>
- {shortDesc}
- </p>
- <div className="flex items-center gap-2 pt-1 border-t border-port-border/30">
- <span className="text-xs text-gray-500">Was this helpful?</span>
- <div className="flex gap-1 ml-auto">
- <button
- onClick={() => submitFeedback(agentId, 'positive', t.id)}
- className="p-1.5 rounded bg-green-500/20 hover:bg-green-500/30 text-green-400 transition-colors"
- title="Helpful"
- aria-label="Mark as helpful"
- >
- <svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5" />
- </svg>
- </button>
- <button
- onClick={() => submitFeedback(agentId, 'negative', t.id)}
- className="p-1.5 rounded bg-red-500/20 hover:bg-red-500/30 text-red-400 transition-colors"
- title="Not helpful"
- aria-label="Mark as not helpful"
- >
- <svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 14H5.236a2 2 0 01-1.789-2.894l3.5-7A2 2 0 018.736 3h4.018a2 2 0 01.485.06l3.76.94m-7 10v5a2 2 0 002 2h.096c.5 0 .905-.405.905-.904 0-.715.211-1.413.608-2.008L17 13V4m-7 10h2m5-10h2a2 2 0 012 2v6a2 2 0 01-2 2h-2.5" />
- </svg>
- </button>
- <button
- onClick={() => toast.dismiss(t.id)}
- className="p-1.5 rounded text-gray-500 hover:text-gray-300 transition-colors"
- title="Dismiss"
- aria-label="Dismiss notification"
- >
- <svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
- </svg>
- </button>
- </div>
- </div>
- </div>
+ <AgentFeedbackToast
+ t={t}
+ agentData={data}
+ onFeedback={submitFeedback}
+ />
),
{
id: toastId,
- duration: 15000, // 15 seconds - enough time to react but not annoying
+ duration: Infinity, // Component manages its own auto-dismiss
style: {
background: 'rgb(var(--port-card))',
border: '1px solid rgb(var(--port-border))',
padding: '12px 16px',
- borderRadius: '8px'
+ borderRadius: '8px',
+ maxWidth: '520px'
}
}
);
diff --git a/package-lock.json b/package-lock.json
index 680b28b593..a9a083454d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "0.26.2",
+ "version": "0.27.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "0.26.2",
+ "version": "0.27.0",
"license": "MIT",
"workspaces": [
"packages/*",
diff --git a/package.json b/package.json
index b47a8aab94..db9a336a37 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "0.26.2",
+ "version": "0.27.0",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",