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(issue-4037): revert draft on confirmed discard, not just hide it

[._.]/ Adam Eivya91293bb8b11
diff --git a/client/src/components/cos/tabs/TaskItem.jsx b/client/src/components/cos/tabs/TaskItem.jsx
index 2871d4bab2..d97ef9ff7e 100644
--- a/client/src/components/cos/tabs/TaskItem.jsx
+++ b/client/src/components/cos/tabs/TaskItem.jsx
@@ -199,8 +199,20 @@ export default function TaskItem({ task, isSystem, onRefresh, providers, duratio
}
};
+ // Discarding must actually revert the draft, not just hide it — without this,
+ // reopening Edit after a confirmed discard would show the just-discarded text
+ // again instead of the task's real values, since editData is otherwise only
+ // ever seeded once at mount.
const handleConfirmDiscard = () => {
- confirmDiscard(() => setEditing(false));
+ confirmDiscard(() => {
+ setEditData({
+ description: task.description,
+ context: task.metadata?.context || '',
+ model: task.metadata?.model || '',
+ provider: task.metadata?.provider || ''
+ });
+ setEditing(false);
+ });
};
const handleDelete = async () => {
diff --git a/client/src/components/cos/tabs/TaskItem.test.jsx b/client/src/components/cos/tabs/TaskItem.test.jsx
index 6dc2aca824..564d26bac5 100644
--- a/client/src/components/cos/tabs/TaskItem.test.jsx
+++ b/client/src/components/cos/tabs/TaskItem.test.jsx
@@ -306,6 +306,19 @@ describe('TaskItem cancel-edit confirmation (#4037)', () => {
expect(screen.getByRole('button', { name: 'Edit task' })).toBeInTheDocument();
});
+ it('reverts the draft, not just hides it, so reopening Edit does not resurrect the discarded text', () => {
+ render(<TaskItem task={task} isSystem onRefresh={vi.fn()} providers={providers} />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Edit task' }));
+ fireEvent.change(screen.getByDisplayValue(task.description), { target: { value: 'Edited description' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Discard' }));
+
+ fireEvent.click(screen.getByRole('button', { name: 'Edit task' }));
+ expect(screen.getByDisplayValue(task.description)).toBeInTheDocument();
+ expect(screen.queryByDisplayValue('Edited description')).not.toBeInTheDocument();
+ });
+
it('returns to the edit fields when the discard confirm is itself canceled', () => {
render(<TaskItem task={task} isSystem onRefresh={vi.fn()} providers={providers} />);