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

address review (opencode): preserve vault selection and clear stale notes

[._.]/ Adam Eivy1415e9f3fad6
diff --git a/client/src/components/brain/tabs/NotesTab.jsx b/client/src/components/brain/tabs/NotesTab.jsx
index c98c269d8c..70dafdaa90 100644
--- a/client/src/components/brain/tabs/NotesTab.jsx
+++ b/client/src/components/brain/tabs/NotesTab.jsx
@@ -129,7 +129,7 @@ export default function NotesTab() {
cancelDelete();
};
- const selectVault = vaultId => {
+ const selectVault = (vaultId, options = {}) => {
vaultScopeRef.current += 1;
scanSeqRef.current += 1;
searchSeqRef.current += 1;
@@ -149,7 +149,7 @@ export default function NotesTab() {
setCreating(false);
setScanning(false);
setScanError(false);
- updateParams({ vault: vaultId, folder: null, q: null, note: null });
+ updateParams({ vault: vaultId, folder: null, q: null, note: null }, options);
};
// Load vaults on mount
@@ -191,7 +191,7 @@ export default function NotesTab() {
? requestedVaultId
: data[0].id;
if (nextVaultId !== selectedVaultId) {
- updateParams({ vault: nextVaultId, folder: null, q: null, note: null }, { replace: true });
+ selectVault(nextVaultId, { replace: true });
}
}
if (data.length === 0) {
@@ -303,7 +303,7 @@ export default function NotesTab() {
if (result) {
toast.success(`Added vault: ${result.name}`);
setShowVaultSetup(false);
- updateParams({ vault: result.id, folder: null, q: null, note: null });
+ selectVault(result.id);
await loadVaults(result.id);
}
};
@@ -399,7 +399,7 @@ export default function NotesTab() {
<UnavailableState
title="Notes vaults are unavailable"
message="The vault list could not be read, so PortOS cannot tell whether this install has any notes."
- onRetry={loadVaults}
+ onRetry={() => loadVaults()}
/>
</div>
);
@@ -535,7 +535,7 @@ export default function NotesTab() {
<UnavailableState
title="Vault list refresh failed"
message="Showing the last successful vault list. Retry when the server is reachable."
- onRetry={loadVaults}
+ onRetry={() => loadVaults()}
/>
)}
diff --git a/client/src/components/brain/tabs/NotesTab.test.jsx b/client/src/components/brain/tabs/NotesTab.test.jsx
index 6509e14cf3..10047af972 100644
--- a/client/src/components/brain/tabs/NotesTab.test.jsx
+++ b/client/src/components/brain/tabs/NotesTab.test.jsx
@@ -479,6 +479,48 @@ describe('NotesTab URL state and unavailable reads', () => {
expect(await screen.findByRole('combobox', { name: 'Vault' })).toHaveValue('vault-1');
});
+ it('keeps the selected vault when retrying a failed vault list', async () => {
+ api.getNotesVaults.mockRejectedValueOnce(new Error('temporary outage'));
+ await renderTab('/brain/notes?vault=vault-2');
+
+ expect(await screen.findByText('Notes vaults are unavailable')).toBeInTheDocument();
+
+ api.getNotesVaults.mockResolvedValueOnce([
+ ...vaults,
+ { id: 'vault-2', name: 'Second Vault', path: '/second/vault' },
+ ]);
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Retry' })); });
+
+ expect(await screen.findByRole('combobox', { name: 'Vault' })).toHaveValue('vault-2');
+ expect(new URLSearchParams(screen.getByTestId('location').textContent).get('vault')).toBe('vault-2');
+ });
+
+ it('clears the previous vault list before loading a newly added vault', async () => {
+ const oldNote = { ...note, path: 'old.md', name: 'old', folder: '' };
+ api.scanNotesVault.mockResolvedValueOnce({ notes: [oldNote], total: 1 });
+ await renderTab('/brain/notes?vault=vault-1');
+ expect(await screen.findByText('old')).toBeInTheDocument();
+
+ let resolveScan;
+ const newScan = new Promise(resolve => { resolveScan = resolve; });
+ api.scanNotesVault.mockReturnValue(newScan);
+ api.addNotesVault.mockResolvedValueOnce({ id: 'vault-2', name: 'Second Vault' });
+ api.getNotesVaults.mockResolvedValueOnce([
+ ...vaults,
+ { id: 'vault-2', name: 'Second Vault', path: '/second/vault' },
+ ]);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Manage vaults' }));
+ fireEvent.change(screen.getByRole('textbox', { name: 'Custom vault path' }), {
+ target: { value: '/second/vault' },
+ });
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Add' })); });
+
+ expect(screen.getByRole('combobox', { name: 'Vault' })).toHaveValue('vault-2');
+ expect(screen.queryByText('old')).toBeNull();
+ resolveScan({ notes: [], total: 0 });
+ });
+
it('keeps scan failure distinct from an empty list and retries the failed region', async () => {
api.scanNotesVault.mockRejectedValueOnce(new Error('temporary outage'));
await renderTab();