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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: avoid reporting failed template usage as successful (#5494)
[._.]/ Adam Eivyfa328f90590e
diff --git a/client/src/components/cos/TaskAddForm.jsx b/client/src/components/cos/TaskAddForm.jsxindex 338501f512..6e2719b37c 100644--- a/client/src/components/cos/TaskAddForm.jsx+++ b/client/src/components/cos/TaskAddForm.jsx@@ -373,8 +373,13 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fasetWorktreeChangesExpected(false);}descriptionRef.current?.focus();- await api.applyCosTaskTemplate(template.id).catch(() => {});- toast.success(`Template applied: ${template.name}`);+ const usageRecorded = await api.applyCosTaskTemplate(template.id, { silent: true })+ .then(() => true)+ .catch(() => {+ toast.warning('Template applied locally, but usage could not be recorded');+ return false;+ });+ if (usageRecorded) toast.success(`Template applied: ${template.name}`);}, [newTask.app, planOnly, providers, selectedApp]);// Save current form as template (inline input instead of window.prompt)diff --git a/client/src/components/cos/TaskAddForm.test.jsx b/client/src/components/cos/TaskAddForm.test.jsxindex 7138167b9b..0dda1d3d30 100644--- a/client/src/components/cos/TaskAddForm.test.jsx+++ b/client/src/components/cos/TaskAddForm.test.jsx@@ -17,8 +17,16 @@ const api = vi.hoisted(() => ({// useAssignableInstances reads the instance registry straight off apiSystem, so// the picker (#4520) has to be driven from there rather than the `api` barrel.const apiSystem = vi.hoisted(() => ({ getAssignableInstances: vi.fn() }));+const toast = vi.hoisted(() => {+ const toastFn = vi.fn();+ toastFn.success = vi.fn();+ toastFn.error = vi.fn();+ toastFn.warning = vi.fn();+ return toastFn;+});vi.mock('../../services/apiSystem', () => apiSystem);vi.mock('../../services/api', () => api);+vi.mock('../ui/Toast', () => ({ default: toast }));const worktreeToggle = () => screen.getByTitle(/isolated git worktree/i).closest('label').querySelector('input');const openPrToggle = () => screen.getByTitle(/Open a pull request/i).closest('label').querySelector('input');@@ -287,7 +295,7 @@ describe('TaskAddForm quick templates', () => {await waitFor(() => expect(planOnlyToggle()).toBeChecked());expect(screen.queryByTitle(/isolated git worktree/i)).toBeNull();expect(screen.getByPlaceholderText('Task description *')).toHaveValue('Investigate and file an issue for: ');- expect(api.applyCosTaskTemplate).toHaveBeenCalledWith('builtin-do-plan-task');+ expect(api.applyCosTaskTemplate).toHaveBeenCalledWith('builtin-do-plan-task', { silent: true });});it('leaves the toggles as-is for a template with no settings block', async () => {@@ -308,6 +316,25 @@ describe('TaskAddForm quick templates', () => {// clearing it also silently reset the app's worktree/PR defaults.expect(screen.getByLabelText(/target application/i)).toHaveValue('example-app');});++ it('keeps the local template application and warns when usage recording fails', async () => {+ const user = userEvent.setup();+ api.getCosPopularTemplates.mockResolvedValue({+ templates: [{ id: 'user-failed', name: 'Offline Template', description: 'Do the thing locally', isBuiltin: false }]+ });+ api.applyCosTaskTemplate.mockRejectedValue(new Error('Server unreachable'));++ renderForm();+ await openTemplates(user);+ await user.click(screen.getByText('Offline Template'));++ await waitFor(() => expect(api.applyCosTaskTemplate).toHaveBeenCalledWith('user-failed', { silent: true }));+ expect(screen.getByPlaceholderText('Task description *')).toHaveValue('Do the thing locally');+ await waitFor(() => expect(toast.warning).toHaveBeenCalledWith(+ 'Template applied locally, but usage could not be recorded'+ ));+ expect(toast.success).not.toHaveBeenCalled();+ });});// #3651: the slashdo catalog's deliverable posture (`worktreeChangesExpected`,diff --git a/client/src/services/apiAgents.js b/client/src/services/apiAgents.jsindex 4496fbe496..a48bcf87d5 100644--- a/client/src/services/apiAgents.js+++ b/client/src/services/apiAgents.js@@ -270,7 +270,10 @@ export const createCosTemplateFromTask = (task, templateName) => request('/cos/tmethod: 'POST',body: JSON.stringify({ task, templateName })});-export const applyCosTaskTemplate = (id) => request(`/cos/templates/${id}/use`, { method: 'POST' });+export const applyCosTaskTemplate = (id, options = {}) => request(`/cos/templates/${id}/use`, {+ method: 'POST',+ ...options+});export const updateCosTaskTemplate = (id, data) => request(`/cos/templates/${id}`, {method: 'PUT',body: JSON.stringify(data)