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
+7 -1
View File
@@ -98,6 +98,12 @@ Future<IpcResponse> _draw(IpcRequest req, MessagePublisher? Function() publisher
);
}
publish('cli', drawShowChannel, {'svg': svg, if (doc.label != null) 'label': doc.label, if (doc.description != null) 'description': doc.description});
publish('cli', drawShowChannel, {
'svg': svg,
if (doc.label != null) 'label': doc.label,
if (doc.description != null) 'description': doc.description,
// d2 cards carry their source so the card can offer a "view source" peek.
if (doc.template == 'd2' && doc.fields['source'] is String) 'source': doc.fields['source'],
});
return IpcResponse.ok(id: req.id, data: {'shown': true, if (doc.template != null) 'template': doc.template});
}