fix(ui): one download helper, and delete the dead wordpress client

Plan 76 milestone F3 (the blob half) plus the C4-interim dead-file deletion the
audit called out.

The six-line "save this to disk" anchor ritual was pasted into 14 components,
and the copies had drifted in two ways that decide whether the download
actually happens:

- only 3 of 14 appended the anchor to the document. Chrome dispatches a click
  on a detached anchor; Firefox has not always done so, which makes "the
  download button does nothing" a browser-specific bug that never reproduces
  for whoever wrote it.
- most revoked the object URL on the very next line after click(). The download
  starts asynchronously, so revoking immediately can cancel it — showing up as
  a flaky empty-or-missing file rather than a clean failure.

utils/downloadBlob.js does both correctly (append, click, remove, revoke on a
later task) and accepts either a string or an existing Blob, which is what
FleetCapacityPanel needs since its CSV arrives from the API already blobbed.

Also deletes src/services/wordpress.js: 494 lines, zero importers, and a stale
duplicate of the live src/services/api/wordpress.js that the ApiService barrel
actually wires in. Verified by import graph and a clean production build.

Ratchet: the boundary check now fails on any `.download =` assignment outside
the helper — a zero baseline, not a shrinking one, since every site is
migrated. Verified non-vacuous: an injected anchor fails it, revert passes.

Gate: npm run build clean, npm run lint 0 errors / 954 warnings (unchanged),
npm test 72 passed, boundary check green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Juan DenisandClaude Opus 5 committed 2026-08-18 21:39:36 -04:00
1 parent 6333f2a0a4
commit 375677ab0c
17 files changed
+87 -600

No files matched your search

@@ -4,6 +4,7 @@ import { useToast } from '../../contexts/ToastContext';
import { runQuery, connKey } from './dbAdapter';
import ResultsGrid from './ResultsGrid';
import SqlEditor from './SqlEditor';
import { downloadBlob } from '@/utils/downloadBlob';
const HISTORY_KEY = 'serverkit_query_history';
const MAX_HISTORY = 50;
@@ -106,12 +107,7 @@ export default function ConsoleTab({ conn, tabId, active, isAdmin, initialQuery
results.columns.map(esc).join(','),
...results.rows.map((r) => r.map(esc).join(',')),
].join('\n');
const url = URL.createObjectURL(new Blob([csv], { type: 'text/csv' }));
const a = document.createElement('a');
a.href = url;
a.download = `${conn.name || 'query'}_${new Date().toISOString().slice(0, 10)}.csv`;
a.click();
URL.revokeObjectURL(url);
downloadBlob(csv, `${conn.name || 'query'}_${new Date().toISOString().slice(0, 10)}.csv`, { type: 'text/csv' });
toast.success('Exported results to CSV');
}