Runs: multi-select delete, run sizes and Largest-first sort
- Select mode (bar Select or long-press): per-row checkboxes, per-day
Select all/Deselect all over finished runs only, "N selected" with the
selection size, Delete and Done. Active runs get a disabled checkbox
whose semantics give the reason.
- Native destructive confirmation, then delete_runs {run_ids} (batched by
1000); the nested runs_deleted reply removes deleted rows and reports
"Deleted N runs, freed X" plus refusals verbatim. runs_removed pushes
remove rows and close an open detail; a deleted open run closes too.
Delete run in the row and detail menus.
- size_bytes shown compactly in rows (0/absent = unknown, nothing shown),
updated from run_event frames that carry it; Largest first sort (flat,
unknowns last); the sort choice persists.
- Shared AppListRow gains selectionControl and onLongPress.
- Browser probe tool/runs_delete_probe.mjs; fixture server implements
delete_runs/runs_removed.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../domain/run_deletion.dart';
|
||||
import '../domain/run_models.dart';
|
||||
|
||||
/// Protocol failure kept separate from transport errors; server error envelopes
|
||||
@@ -10,6 +11,9 @@ class RunsRepositoryException implements Exception {
|
||||
String toString() => message;
|
||||
}
|
||||
|
||||
/// The most run ids one `delete_runs` request may carry.
|
||||
const deleteRunsBatch = 1000;
|
||||
|
||||
/// Run protocol requests over the application's shared gateway.
|
||||
class RunsRepository {
|
||||
RunsRepository(this._gateway);
|
||||
@@ -41,6 +45,49 @@ class RunsRepository {
|
||||
'run_detail',
|
||||
);
|
||||
|
||||
/// Deletes finished runs and their recorded data. The server answers
|
||||
/// `runs_deleted` with the ids it removed, the ones it refused (with its
|
||||
/// reason) and the bytes it freed.
|
||||
///
|
||||
/// The server accepts at most [deleteRunsBatch] ids per request, so a larger
|
||||
/// selection is sent in consecutive batches and the replies combined. A
|
||||
/// failing batch stops the rest; batches already answered are kept.
|
||||
Future<RunsDeletion> deleteRuns(List<int> ids) async {
|
||||
if (ids.isEmpty) {
|
||||
throw const RunsRepositoryException('Choose runs to delete.');
|
||||
}
|
||||
RunsDeletion? result;
|
||||
for (var start = 0; start < ids.length; start += deleteRunsBatch) {
|
||||
final batch = ids.sublist(
|
||||
start,
|
||||
(start + deleteRunsBatch).clamp(0, ids.length),
|
||||
);
|
||||
final RunsDeletion deletion;
|
||||
try {
|
||||
final reply = await _gateway.call('delete_runs', {'run_ids': batch});
|
||||
deletion =
|
||||
RunsDeletion.fromReply(reply) ??
|
||||
(throw const RunsRepositoryException(
|
||||
'The server returned no runs_deleted reply.',
|
||||
));
|
||||
} catch (error) {
|
||||
if (result == null) rethrow;
|
||||
// Report what earlier batches deleted, and the rest as not deleted.
|
||||
return result.merge(
|
||||
RunsDeletion(
|
||||
deleted: const [],
|
||||
refused: [
|
||||
for (final id in ids.sublist(start))
|
||||
(runId: id, reason: '$error'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
result = result == null ? deletion : result.merge(deletion);
|
||||
}
|
||||
return result!;
|
||||
}
|
||||
|
||||
/// Reads the exact recorded visit again; it never reruns its stage or tools.
|
||||
///
|
||||
/// The body is the web client's `repair_session_export` request: the run and
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// The Runs list's persisted sort choice.
|
||||
const runsSortStorageKey = 'pipelines.next.runsSort.v1';
|
||||
|
||||
/// The persistence seam for the Runs list's sort. Both directions may fail: a
|
||||
/// null read means "nothing saved", a false write means "this session only".
|
||||
abstract interface class RunsSortStore {
|
||||
Future<String?> read();
|
||||
|
||||
Future<bool> write(String value);
|
||||
}
|
||||
|
||||
/// `shared_preferences` storage under [runsSortStorageKey].
|
||||
class SharedPreferencesRunsSortStore implements RunsSortStore {
|
||||
const SharedPreferencesRunsSortStore();
|
||||
|
||||
@override
|
||||
Future<String?> read() async {
|
||||
try {
|
||||
return (await SharedPreferences.getInstance()).getString(
|
||||
runsSortStorageKey,
|
||||
);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> write(String value) async {
|
||||
try {
|
||||
return await (await SharedPreferences.getInstance()).setString(
|
||||
runsSortStorageKey,
|
||||
value,
|
||||
);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An in-memory store for tests and isolated fixtures.
|
||||
class MemoryRunsSortStore implements RunsSortStore {
|
||||
MemoryRunsSortStore([this.value]);
|
||||
|
||||
String? value;
|
||||
|
||||
@override
|
||||
Future<String?> read() async => value;
|
||||
|
||||
@override
|
||||
Future<bool> write(String value) async {
|
||||
this.value = value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user