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

fix: only prompt for agent feedback where the server accepts it

[._.]/ Adam Eivyf9dc4d46bce4
diff --git a/client/src/hooks/useAgentFeedbackToast.jsx b/client/src/hooks/useAgentFeedbackToast.jsx
index cb26b289da..c66df66581 100644
--- a/client/src/hooks/useAgentFeedbackToast.jsx
+++ b/client/src/hooks/useAgentFeedbackToast.jsx
@@ -4,7 +4,7 @@ import { ThumbsUp, ThumbsDown, Loader2, AlertTriangle } from 'lucide-react';
import socket from '../services/socket';
import * as api from '../services/api';
import OutputBlocks from '../components/cos/OutputBlocks';
-import { isAgentHandoff } from '../lib/agentOutcome';
+import { isAgentFeedbackEligible } from '../lib/cosAgentFeedback';
import { agentIssueLinkifier } from '../lib/issueRefs';
const AUTO_DISMISS_MS = 15000;
@@ -168,15 +168,15 @@ export function useAgentFeedbackToast() {
// Handle agent completion events
const handleAgentCompleted = (data) => {
- // Skip system agents and already-shown agents
const agentId = data?.id || data?.agentId;
- const isSystem = data?.taskId?.startsWith('sys-') || agentId?.startsWith('sys-');
- // A record Resume/Relaunch retired is a handoff, not a completion: pressing
- // Relaunch popped "✗ Agent completed — rate the result" in the corner for a
- // run the user had just moved to another provider, and the run it handed the
- // task to raises this toast itself when it actually finishes.
- if (!agentId || isSystem || isAgentHandoff(data) || shownFeedbackFor.current.has(agentId)) {
+ // Only offer a rating the server will accept: the same shared predicate
+ // gates submitAgentFeedback, so an autonomous run (a scheduled claim-issue
+ // task, an improvement task) no longer pops a card whose thumbs answer
+ // "Can only submit feedback for completed agents". It also skips system
+ // agents and Resume/Relaunch handoffs — the run the task was handed to
+ // raises this toast itself when it actually finishes.
+ if (!agentId || !isAgentFeedbackEligible(data) || shownFeedbackFor.current.has(agentId)) {
return;
}
diff --git a/client/src/hooks/useAgentFeedbackToast.test.jsx b/client/src/hooks/useAgentFeedbackToast.test.jsx
new file mode 100644
index 0000000000..11d78673da
--- /dev/null
+++ b/client/src/hooks/useAgentFeedbackToast.test.jsx
@@ -0,0 +1,45 @@
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
+import { renderHook, cleanup } from '@testing-library/react';
+
+// Capture the `cos:agent:completed` handler so tests can drive completions.
+const handlers = new Map();
+vi.mock('../services/socket', () => ({
+ default: {
+ on: (event, fn) => { handlers.set(event, fn); },
+ off: (event, fn) => { if (handlers.get(event) === fn) handlers.delete(event); },
+ emit: () => {},
+ },
+}));
+
+const toastSpy = vi.fn();
+vi.mock('../components/ui/Toast', () => ({ default: Object.assign((...a) => toastSpy(...a), { dismiss: vi.fn() }) }));
+
+const { useAgentFeedbackToast } = await import('./useAgentFeedbackToast.jsx');
+const fire = (agent) => handlers.get('cos:agent:completed')?.(agent);
+const completed = (overrides = {}) => ({
+ id: 'agent-1',
+ taskId: 'task-1',
+ status: 'completed',
+ metadata: { taskType: 'user', taskDescription: 'Do the thing' },
+ result: { success: true },
+ ...overrides,
+});
+
+describe('useAgentFeedbackToast', () => {
+ beforeEach(() => { handlers.clear(); toastSpy.mockClear(); });
+ afterEach(cleanup);
+
+ it('prompts for a rating when a manual user task completes', () => {
+ renderHook(() => useAgentFeedbackToast());
+ fire(completed());
+ expect(toastSpy).toHaveBeenCalledTimes(1);
+ });
+
+ // The server rejects feedback for autonomous runs ("Can only submit feedback
+ // for completed agents"), so the toast must not offer thumbs it will refuse.
+ it('stays silent for an autonomous scheduled run the server will not accept feedback for', () => {
+ renderHook(() => useAgentFeedbackToast());
+ fire(completed({ id: 'agent-2', metadata: { taskType: 'internal', taskDescription: 'claim-issue' } }));
+ expect(toastSpy).not.toHaveBeenCalled();
+ });
+});