Files
pipelines/app/lib/features/artifacts/domain/artifact_chat_context.dart
T
alan 5425001d82 Send artifacts, runs and pipelines to a new or existing chat
One picker offers a new chat (the saved Open in chat harness and model)
or any open chat. An existing chat gets the reference appended to its
draft and focused, never sent. Artifacts gain the action in their viewer
and gallery; the run and pipeline item becomes Send to chat.
2026-11-13 18:43:14 +00:00

51 lines
1.6 KiB
Dart

import '../../../core/api_gateway.dart';
import 'artifact_record.dart';
import 'artifact_url.dart';
import 'artifact_groups.dart';
/// Run provenance supplied by the owner of an artifact gallery.
class ArtifactChatContext {
const ArtifactChatContext({
required this.runId,
required this.runTitle,
required this.pipelineName,
this.pipelineVersion,
this.stageKey,
this.visit,
this.configuredEndpoint = '',
this.recordedSteps = const <String, dynamic>{},
});
final String runId;
final String runTitle;
final String pipelineName;
final String? pipelineVersion;
final String? stageKey;
final int? visit;
final String configuredEndpoint;
final JsonMap recordedSteps;
}
String artifactChatReference(
ArtifactChatContext context,
ArtifactGroup group,
ArtifactRecord artifact,
) {
final resolved = artifact.hasUrl
? resolveArtifactUrl(context.configuredEndpoint, artifact.url)
: null;
final readable = resolved == null
? 'The server did not provide a safe readable URL for this artifact; '
'inspect the run to locate it.'
: 'The chat agent can read it at ${resolved.url}';
final version = context.pipelineVersion == null
? ''
: ' v${context.pipelineVersion}';
return 'Artifact "${artifact.name}" from run ${context.runId} '
'("${context.runTitle}"), pipeline "${context.pipelineName}"$version, '
'stage "${context.stageKey ?? group.stageKey}", visit '
'${context.visit ?? group.visit}. $readable. '
'Use `pipelines inspect ${context.runId}` for the authoritative run '
'and artifact metadata.';
}