Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(memory): await async onErased callback after erase

Steven Enamakeld04f6e5b22c0
diff --git a/app/src/components/memory/MemoryEraseAllCard.test.tsx b/app/src/components/memory/MemoryEraseAllCard.test.tsx
index 4ab3f7cca6..399bbbde01 100644
--- a/app/src/components/memory/MemoryEraseAllCard.test.tsx
+++ b/app/src/components/memory/MemoryEraseAllCard.test.tsx
@@ -89,6 +89,35 @@ describe('MemoryEraseAllCard', () => {
);
});
+ it('contains a rejected async refresh callback', async () => {
+ hoisted.erase.mockResolvedValue({ erased_scopes: 1 });
+ const onErased = vi.fn(() => Promise.reject(new Error('refresh boom')));
+ renderWithProviders(<MemoryEraseAllCard onErased={onErased} />);
+ await openDialog();
+ fireEvent.click(screen.getByTestId('memory-erase-ack'));
+ fireEvent.click(screen.getByTestId('memory-erase-confirm'));
+
+ await waitFor(() => expect(onErased).toHaveBeenCalledTimes(1));
+ expect(screen.queryByTestId('memory-erase-error')).not.toBeInTheDocument();
+ });
+
+ it('translates an unauthorized failure without a success toast, event or refresh', async () => {
+ hoisted.erase.mockRejectedValue(
+ Object.assign(new Error('UNAUTHORIZED: secret'), { data: { code: 'UNAUTHORIZED' } })
+ );
+ const onErased = vi.fn();
+ renderWithProviders(<MemoryEraseAllCard onErased={onErased} />);
+ await openDialog();
+ fireEvent.click(screen.getByTestId('memory-erase-ack'));
+ fireEvent.click(screen.getByTestId('memory-erase-confirm'));
+
+ const error = await screen.findByTestId('memory-erase-error');
+ expect(error).not.toHaveTextContent('secret');
+ expect(onErased).not.toHaveBeenCalled();
+ expect(hoisted.toastAdd).not.toHaveBeenCalled();
+ expect(hoisted.track).not.toHaveBeenCalled();
+ });
+
it('shows a translated error and never the raw server text', async () => {
hoisted.erase.mockRejectedValue(
Object.assign(new Error('UNSUPPORTED: DELETE /memory returned 404 secret-detail'), {
diff --git a/app/src/components/memory/MemoryEraseAllCard.tsx b/app/src/components/memory/MemoryEraseAllCard.tsx
index 6c37a02d86..812d8ef3b6 100644
--- a/app/src/components/memory/MemoryEraseAllCard.tsx
+++ b/app/src/components/memory/MemoryEraseAllCard.tsx
@@ -60,7 +60,7 @@ interface MemoryEraseAllCardProps {
/** Memory is off: the control is shown disabled. */
disabled?: boolean;
/** Called after a successful erase so the page can re-read memory state. */
- onErased?: () => void;
+ onErased?: () => void | Promise<void>;
}
export default function MemoryEraseAllCard({
@@ -109,7 +109,7 @@ export default function MemoryEraseAllCard({
// The erase has already succeeded; a refresh failure must not read as one.
if (erased) {
try {
- onErased?.();
+ await onErased?.();
} catch (err) {
log('onErased callback failed: %s', err instanceof Error ? err.name : 'unknown');
}
diff --git a/gitbooks/guides/privacy-sensitive-data.md b/gitbooks/guides/privacy-sensitive-data.md
index 432e2fbd74..7e9b7723ea 100644
--- a/gitbooks/guides/privacy-sensitive-data.md
+++ b/gitbooks/guides/privacy-sensitive-data.md
@@ -33,10 +33,10 @@ These never leave your computer as raw data:
## Your memory is stored off your machine
-Documents, conversations, learnings and the beliefs built from them are stored in **CortexDB**, not on your computer:
+When memory is on, documents, conversations, learnings and the beliefs built from them are stored in **CortexDB**, not on your computer (with no engine available, memory is off and nothing is stored):
- **TinyHumans engine (default when signed in):** stored in the hosted CortexDB that TinyHumans runs, through the TinyHumans backend. Each account gets its own isolated tenant, so other users cannot see your memory. TinyHumans operates that service.
-- **CortexDB engine:** stored in your own CortexDB account or self-hosted CortexDB, reached directly with your key.
+- **CortexDB engine:** stored in your own CortexDB account or self-hosted CortexDB, reached directly with your key. A CortexDB you run on your own machine keeps the data on that machine.
Secrets and personal identifiers are scrubbed before an item is sent. You can forget single items or whole sources from the Memory page; see [Deleting memory](../features/privacy-and-security.md#deleting-memory) for erasing everything.