b3c9575fde
- A stage refused for a Claude usage limit no longer fails its run: the runner tries the chats' Claude account auto-switch (per-home setting) and reruns the visit, else parks the run in the new waiting_quota status (persisted, with reset/resume time in run summaries, details and events) and resumes the same visit at reset + 1 min, also after a restart. resume_run / `pipelines resume` resumes now; cancel works on parked runs. The rerun visit gets a "# Previous attempt" interruption note. Subscription limits no longer say "top up the provider account". - run/retry into an account known to be limited are deferred (quota_policy defer/refuse/now; CLI refuses under --json/--yes unless --defer or --now). - failure_class on runs (quota, loop_exhausted, timeout, permission_denied, harness_error, blocked, environment, canceled, interrupted, budget, check_failed, other) in RunSummary/RunDetail/events, CLI inspect/runs/wait/ stats and the app failure line. - Claude permission denials (permission_denials / refused tool results) fail a blocked visit with permission_denied naming the tool use. - Harness failures are classified transient vs deterministic; deterministic ones (and a repeated empty readback) skip error self-loops; transient self-loops back off 15 s, 1 min, 4 min. - Whole-run USD budget: run --budget, server default (run-budget / get/set_run_settings); 80% warning notification, stop with class budget. - App: waiting_quota status/filter with resume time, Resume now and Cancel, failure class wording. Docs and skill references updated. Merges main (check stage, delivery gate, Claude stage restart survival, schedule changes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
118 lines
4.0 KiB
Dart
118 lines
4.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../../core/transport/pipelines_client.dart';
|
|
import '../domain/artifact_chat_context.dart';
|
|
import '../domain/artifact_groups.dart';
|
|
import 'artifact_external_open.dart';
|
|
import 'artifact_gallery_page.dart';
|
|
|
|
/// The run detail's action label key, so a host can find the one action.
|
|
const ValueKey<String> runArtifactsButtonKey = ValueKey<String>(
|
|
'run-detail-artifacts',
|
|
);
|
|
|
|
const Set<String> _executingStatuses = {
|
|
'queued',
|
|
'running',
|
|
'waiting',
|
|
'waiting_quota',
|
|
};
|
|
|
|
/// The detail's `steps` exactly as returned by the server. The pushed page
|
|
/// snapshots the returned list once, so it never re-derives on each rebuild.
|
|
List<JsonMap> runDetailArtifactSteps(JsonMap run) {
|
|
final steps = run['steps'];
|
|
if (steps is List<JsonMap>) return steps;
|
|
if (steps is List) return steps.cast<JsonMap>();
|
|
return const <JsonMap>[];
|
|
}
|
|
|
|
/// Whether the run detail offers the gallery action at all: only once the
|
|
/// loaded detail actually carries steps. A run with no steps has nothing to
|
|
/// list, so the action is absent rather than opening a page that says so.
|
|
bool showRunArtifactsAction(JsonMap run) =>
|
|
runDetailArtifactSteps(run).isNotEmpty;
|
|
|
|
/// How many recorded entries the run's gallery lists (stage files plus
|
|
/// recorded turn documents), as the gallery header counts them.
|
|
int runArtifactCount(JsonMap run) => galleryGroups(
|
|
runDetailArtifactSteps(run),
|
|
).fold<int>(0, (sum, group) => sum + group.recordedCount);
|
|
|
|
/// Whether the run is still executing, so the page can say capture pending
|
|
/// instead of claiming nothing was recorded.
|
|
bool runDetailExecuting(JsonMap run) => _runExecuting(run);
|
|
|
|
bool _runExecuting(JsonMap run) =>
|
|
run['executing'] == true ||
|
|
_executingStatuses.contains('${run['status'] ?? ''}'.trim().toLowerCase());
|
|
|
|
/// The run detail's standard native action that opens the recorded artifact
|
|
/// groups. It is composed only when [showRunArtifactsAction] is true.
|
|
class RunArtifactsButton extends StatelessWidget {
|
|
const RunArtifactsButton({
|
|
super.key,
|
|
required this.run,
|
|
required this.gateway,
|
|
this.onSendToChat,
|
|
});
|
|
|
|
final JsonMap run;
|
|
final ApiGateway gateway;
|
|
final void Function(String draft)? onSendToChat;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final steps = runDetailArtifactSteps(run);
|
|
void open() => showArtifactGallery(
|
|
context,
|
|
steps: steps,
|
|
executing: _runExecuting(run),
|
|
configuredEndpoint: configuredGatewayEndpoint(gateway),
|
|
artifactChatContext: ArtifactChatContext(
|
|
runId: '${run['id'] ?? ''}',
|
|
runTitle: '${run['title'] ?? run['name'] ?? ''}',
|
|
pipelineName: '${run['name'] ?? ''}',
|
|
pipelineVersion: run['version'] is num
|
|
? (run['version'] as num).toInt().toString()
|
|
: null,
|
|
configuredEndpoint: configuredGatewayEndpoint(gateway),
|
|
),
|
|
onSendToChat: onSendToChat,
|
|
);
|
|
return OutlinedButton.icon(
|
|
key: runArtifactsButtonKey,
|
|
onPressed: open,
|
|
icon: const Icon(Icons.inventory_2_outlined),
|
|
label: const Text(artifactGalleryTitle),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Opens the recorded artifact groups on a native page. The steps are
|
|
/// snapshotted once; the page never re-fetches or re-derives them.
|
|
Future<void> showArtifactGallery(
|
|
BuildContext context, {
|
|
required List<JsonMap> steps,
|
|
int? focusIndex,
|
|
bool executing = false,
|
|
String configuredEndpoint = '',
|
|
ArtifactExternalOpen openExternal = openArtifactExternally,
|
|
ArtifactChatContext? artifactChatContext,
|
|
void Function(String draft)? onSendToChat,
|
|
}) {
|
|
final page = ArtifactGalleryPage(
|
|
steps: List<JsonMap>.unmodifiable(steps),
|
|
focusIndex: focusIndex,
|
|
executing: executing,
|
|
configuredEndpoint: configuredEndpoint,
|
|
openExternal: openExternal,
|
|
artifactChatContext: artifactChatContext,
|
|
onSendToChat: onSendToChat,
|
|
);
|
|
return Navigator.of(
|
|
context,
|
|
).push<void>(MaterialPageRoute<void>(builder: (_) => page));
|
|
}
|