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: a failed save/generate no longer leaves the button stuck disabled in three editors

Adam Eivyd01e64e1c77c
diff --git a/client/src/components/agents/tabs/ToolsTab.jsx b/client/src/components/agents/tabs/ToolsTab.jsx
index 48ec95124b..a95e6daee6 100644
--- a/client/src/components/agents/tabs/ToolsTab.jsx
+++ b/client/src/components/agents/tabs/ToolsTab.jsx
@@ -145,10 +145,12 @@ export default function ToolsTab({ agentId, agent }) {
if (!agentId || !selectedAccountId) return;
setGenerating(true);
const contentConfig = agent?.aiConfig?.content || agent?.aiConfig;
- const generated = await api.generateAgentPost({ agentId, accountId: selectedAccountId, submolt: selectedSubmolt, providerId: contentConfig?.providerId, model: contentConfig?.model });
+ // request() toasts a failure; release Generate rather than leave it spinning.
+ const generated = await api.generateAgentPost({ agentId, accountId: selectedAccountId, submolt: selectedSubmolt, providerId: contentConfig?.providerId, model: contentConfig?.model }).catch(() => null);
+ setGenerating(false);
+ if (!generated) return;
setPostTitle(generated.title);
setPostContent(generated.content);
- setGenerating(false);
const draft = await api.createAgentDraft({
agentId,
@@ -207,9 +209,10 @@ export default function ToolsTab({ agentId, agent }) {
const generated = await api.generateAgentComment({
agentId, accountId: selectedAccountId, postId: selectedPost.id, parentId: replyToId || undefined,
providerId: contentConfig?.providerId, model: contentConfig?.model
- });
- setCommentContent(generated.content);
+ }).catch(() => null);
setGeneratingComment(false);
+ if (!generated) return;
+ setCommentContent(generated.content);
const draft = await api.createAgentDraft({
agentId,
diff --git a/client/src/components/digital-twin/tabs/DocumentsTab.jsx b/client/src/components/digital-twin/tabs/DocumentsTab.jsx
index 34c0534500..c9efb1bfb3 100644
--- a/client/src/components/digital-twin/tabs/DocumentsTab.jsx
+++ b/client/src/components/digital-twin/tabs/DocumentsTab.jsx
@@ -51,12 +51,15 @@ export default function DocumentsTab({ onRefresh }) {
const handleSave = async () => {
if (!selectedDoc) return;
setSaving(true);
- await api.updateSoulDocument(selectedDoc.id, { content: editContent });
+ // request() already toasted a failure; release Save either way so the unsaved
+ // edit can be retried instead of stranding the editor behind a disabled button.
+ const saved = await api.updateSoulDocument(selectedDoc.id, { content: editContent }).then(() => true, () => false);
+ setSaving(false);
+ if (!saved) return;
toast.success('Document saved');
await loadDocuments();
await loadDocument(selectedDoc.id);
setEditMode(false);
- setSaving(false);
onRefresh();
};
@@ -89,15 +92,16 @@ export default function DocumentsTab({ onRefresh }) {
const filename = newDoc.filename.endsWith('.md') ? newDoc.filename : `${newDoc.filename}.md`;
setSaving(true);
- await api.createSoulDocument({
+ const created = await api.createSoulDocument({
...newDoc,
filename
- });
+ }).then(() => true, () => false);
+ setSaving(false);
+ if (!created) return;
toast.success('Document created');
await loadDocuments();
setShowCreate(false);
setNewDoc({ filename: '', title: '', category: 'core', content: '' });
- setSaving(false);
onRefresh();
};
diff --git a/client/src/components/digital-twin/tabs/DocumentsTab.test.jsx b/client/src/components/digital-twin/tabs/DocumentsTab.test.jsx
new file mode 100644
index 0000000000..46d4191945
--- /dev/null
+++ b/client/src/components/digital-twin/tabs/DocumentsTab.test.jsx
@@ -0,0 +1,48 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+
+vi.mock('../../../services/api', () => ({
+ getDigitalTwinDocuments: vi.fn(),
+ getDigitalTwinDocument: vi.fn(),
+ updateSoulDocument: vi.fn(),
+ createSoulDocument: vi.fn(),
+ deleteSoulDocument: vi.fn()
+}));
+
+vi.mock('../../ui/Toast', () => ({
+ default: { success: vi.fn(), error: vi.fn() }
+}));
+
+import DocumentsTab from './DocumentsTab';
+import * as api from '../../../services/api';
+import toast from '../../ui/Toast';
+
+const DOC = { id: 'doc-1', title: 'Core Values', category: 'core', enabled: true, weight: 5, content: 'original', lastModified: '2026-01-01T00:00:00.000Z' };
+
+describe('DocumentsTab failed save', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ api.getDigitalTwinDocuments.mockResolvedValue([DOC]);
+ api.getDigitalTwinDocument.mockResolvedValue(DOC);
+ });
+
+ it('re-enables Save after a rejected update so the unsaved edit can be retried', async () => {
+ api.updateSoulDocument.mockRejectedValueOnce(new Error('Document is locked'));
+ const user = userEvent.setup();
+ render(<DocumentsTab onRefresh={vi.fn()} />);
+
+ await user.click(await screen.findByRole('button', { name: /Core Values/ }));
+ await user.click(await screen.findByRole('button', { name: 'Edit' }));
+ await user.click(screen.getByRole('button', { name: 'Save' }));
+
+ await waitFor(() => expect(api.updateSoulDocument).toHaveBeenCalledTimes(1));
+ await waitFor(() => expect(screen.getByRole('button', { name: 'Save' })).not.toBeDisabled());
+ expect(toast.success).not.toHaveBeenCalled();
+
+ // The retry goes through: the editor was not stranded behind a stuck `saving` flag.
+ api.updateSoulDocument.mockResolvedValueOnce({});
+ await user.click(screen.getByRole('button', { name: 'Save' }));
+ await waitFor(() => expect(toast.success).toHaveBeenCalledWith('Document saved'));
+ });
+});
diff --git a/client/src/pages/JiraReports.jsx b/client/src/pages/JiraReports.jsx
index 82a378c6f4..8d6a654283 100644
--- a/client/src/pages/JiraReports.jsx
+++ b/client/src/pages/JiraReports.jsx
@@ -173,14 +173,16 @@ export default function JiraReports() {
const loadReports = async () => {
setLoading(true);
- const result = await api.getJiraReports();
- setReports(result || []);
+ // request() toasts a failure; keep the list we have and leave the loading state.
+ const result = await api.getJiraReports().catch(() => null);
+ if (result) setReports(result);
setLoading(false);
};
const handleGenerate = async (appId = null) => {
setGenerating(true);
- const result = await api.generateJiraReport(appId);
+ // A failed generation must re-enable the Generate buttons (request() toasts the error).
+ const result = await api.generateJiraReport(appId).catch(() => null);
if (result) {
toast.success(appId ? 'Report generated' : `Generated ${Array.isArray(result) ? result.length : 1} report(s)`);
await loadReports();