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: discard a typed Artificial Analysis key when the prompt is cancelled

Adam Eivy4fe432fa76fe
diff --git a/client/src/components/models/ModelComparison.jsx b/client/src/components/models/ModelComparison.jsx
index a67a785178..54b5170884 100644
--- a/client/src/components/models/ModelComparison.jsx
+++ b/client/src/components/models/ModelComparison.jsx
@@ -305,6 +305,16 @@ export default function ModelComparison() {
});
};
+ // Dismissing the prompt discards the typed key. Without this it survives in
+ // state, and the next click of a button that no longer opens the dialog would
+ // silently sync — and re-save — the key the user just backed out of.
+ const closeSyncModal = () => {
+ setSyncModalOpen(false);
+ setSyncKey('');
+ setSyncError('');
+ setSyncStatus('');
+ };
+
// A configured key makes the dialog a pure speed bump — sync straight away and
// only prompt when there is nothing stored to sync with.
const startSyncAA = () => {
@@ -659,7 +669,7 @@ export default function ModelComparison() {
are the caller's. Without them the dialog renders transparent. */}
<Modal
open={syncModalOpen}
- onClose={() => setSyncModalOpen(false)}
+ onClose={closeSyncModal}
size="sm"
ariaLabelledBy="aa-sync-title"
>
@@ -695,7 +705,7 @@ export default function ModelComparison() {
<button
type="button"
className="px-3 py-1.5 text-sm border border-port-border rounded-lg hover:bg-port-bg"
- onClick={() => setSyncModalOpen(false)}
+ onClick={closeSyncModal}
disabled={syncing}
>
Cancel
diff --git a/client/src/components/models/ModelComparison.test.jsx b/client/src/components/models/ModelComparison.test.jsx
index cbeb9c4262..d4710cd493 100644
--- a/client/src/components/models/ModelComparison.test.jsx
+++ b/client/src/components/models/ModelComparison.test.jsx
@@ -150,6 +150,19 @@ it('syncs straight away without a key prompt when one is already configured', as
expect(screen.queryByLabelText(/Artificial Analysis API Key/i)).toBeNull();
});
+it('discards a typed key when the prompt is cancelled', async () => {
+ render(<MemoryRouter><ModelComparison /></MemoryRouter>);
+ await act(async () => {});
+
+ fireEvent.click(screen.getByRole('button', { name: /Sync from Artificial Analysis/i }));
+ fireEvent.change(screen.getByLabelText(/Artificial Analysis API Key/i), { target: { value: 'abandoned-key' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
+
+ fireEvent.click(screen.getByRole('button', { name: /Sync from Artificial Analysis/i }));
+ expect(screen.getByLabelText(/Artificial Analysis API Key/i)).toHaveValue('');
+ expect(api.syncArtificialAnalysis).not.toHaveBeenCalled();
+});
+
it('falls back to the key prompt when a sync with the stored key is rejected', async () => {
api.getModelComparison.mockResolvedValue({ schemaVersion: 1, observations: [observation], inventory: [], artificialAnalysisKeyConfigured: true });
api.syncArtificialAnalysis.mockRejectedValue(new Error('Artificial Analysis API failed (401): Unauthorized'));