From b5453ae5e001678c652f333930d4e7bf003f865a Mon Sep 17 00:00:00 2001 From: ai-bot Date: Tue, 13 Oct 2026 16:58:38 +0000 Subject: [PATCH] startos: remove the Delete history action, replaced by Delete all data --- startos/actions/deleteHistory.ts | 92 -------------------------------- 1 file changed, 92 deletions(-) delete mode 100644 startos/actions/deleteHistory.ts diff --git a/startos/actions/deleteHistory.ts b/startos/actions/deleteHistory.ts deleted file mode 100644 index fd40cc0..0000000 --- a/startos/actions/deleteHistory.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { i18n } from '../i18n' -import { sdk } from '../sdk' -import { dataMountpoint, imageId, volumeId } from '../utils' - -const { InputSpec, Value } = sdk - -// The history cannot be recovered once it is gone, so the action takes a -// confirmation box and the handler refuses to run without it (section 31 -// point 2). A toggle has no `required` flag, so the confirmation is enforced -// in the handler. -const inputSpec = InputSpec.of({ - confirm: Value.toggle({ - name: i18n( - 'I confirm that the stored history will be deleted and cannot be recovered', - ), - description: null, - default: false, - }), -}) - -const confirmationRequired = i18n( - 'The confirmation is required before the history can be deleted.', -) - -export const deleteHistory = sdk.Action.withInput( - // ID - 'delete-history', - - // Metadata - async () => ({ - name: i18n('Delete history'), - description: i18n( - 'Delete every saved health check, with the follow-up it closed. The key setup and the wallet software list are kept.', - ), - warning: null, - allowedStatuses: 'any', - group: null, - visibility: 'enabled', - }), - - inputSpec, - - // The box starts unticked, so the user confirms on every run. - async () => ({ confirm: false }), - - // Handler - async ({ effects, input }) => { - if (!input.confirm) { - throw new Error(confirmationRequired) - } - - // maintenance.py needs the volume and nothing else: the image's own - // DATABASE_PATH already points at /data/vardkey.sqlite3, which is where - // the volume is mounted. A temporary subcontainer is used, because the - // command is a one-off and not a daemon. - const mounts = sdk.Mounts.of().mountVolume({ - volumeId, - subpath: null, - mountpoint: dataMountpoint, - readonly: false, - }) - - let report = '' - await sdk.SubContainer.withTemp( - effects, - { imageId }, - mounts, - 'delete-history', - async (sub) => { - const result = await sub.exec([ - 'python3', - 'maintenance.py', - 'delete-history', - ]) - if (result.exitCode !== 0) { - // exec() reports stdout and stderr as either text or bytes, so both - // are normalised before they are used. - const stderr = String(result.stderr).trim() - throw new Error(stderr || i18n('The history could not be deleted.')) - } - report = String(result.stdout).trim() - }, - ) - - return { - version: '1', - title: i18n('History deleted'), - message: report, - result: null, - } - }, -)