feat(draw): fold the d2 source into a "view source" disclosure (T-494)

The rendered diagram leads; the d2 source carries through the draw bus and
folds into a collapsed ClideCollapserCard beneath the card (D-78 display-
only). en+nl catalogs. Also switches the d2 test to a null-aware element.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-29 12:08:33 +02:00
co-authored by Claude Opus 4.8
parent 64d77ec5dc
commit 5f8fa6af10
9 changed files with 82 additions and 4 deletions
+13 -1
View File
@@ -196,7 +196,15 @@ final class ImageMessage extends ConversationItem {
/// paints (already lowered from the doc's template / primitive source);
/// [label] / [description] are the optional card caption.
final class DrawingMessage extends ConversationItem {
const DrawingMessage({required super.uuid, required super.timestamp, required super.isSidechain, required this.svg, this.label, this.description});
const DrawingMessage({
required super.uuid,
required super.timestamp,
required super.isSidechain,
required this.svg,
this.label,
this.description,
this.source,
});
/// The SVG document source the renderer paints.
final String svg;
@@ -204,6 +212,10 @@ final class DrawingMessage extends ConversationItem {
/// Optional card-level caption (label + supporting description).
final String? label, description;
/// Optional template source (e.g. the d2 diagram text) — shown in a collapsed
/// "view source" disclosure on the card when present (T-494).
final String? source;
@override
String toString() => 'DrawingMessage(${label ?? '<svg>'})';
}