Support content references for inline visualizations (#37341)

## What changed

- Recognize structured `visualize` content references alongside the existing inline visualization directive in cached, streaming, and finalized TUI rendering.
- Resolve absolute visualization paths only when they belong to the active thread directory, and show the existing unavailable fallback for incomplete, invalid, or out-of-scope references.
- Let embedded visualizations inherit host color, typography, and radius tokens while retaining standalone defaults and legacy aliases. Keep Lucide icons at a stable size when model-authored chart styles are present.

## Testing

- Cover content-reference fallback, replay, render-cache bypass, and canonical streaming behavior.

GitOrigin-RevId: 887d13647df11c23d519e64d0958fdc41ef3f472
This commit is contained in:
Philipp Spiess authored and copyberry committed 2026-08-07 00:37:50 +00:00
1 parent f8ac8fa6c6
commit 29dce2db43
7 files changed
+209 -55

No files matched your search

+3 -3
View File
@@ -395,9 +395,9 @@ impl AgentMarkdownCell {
crate::inline_visualization::InlineVisualizationContext,
>,
) -> Self {
let rendered_lines = (!markdown_source
.contains(crate::inline_visualization::DIRECTIVE_PREFIX))
.then(MarkdownRenderCache::default);
let rendered_lines =
(!crate::inline_visualization::contains_inline_visualization(&markdown_source))
.then(MarkdownRenderCache::default);
Self {
markdown_source,
cwd: cwd.to_path_buf(),
@@ -71,12 +71,14 @@ fn raw_markdown_bypasses_the_rich_render_cache() {
#[test]
fn visualization_directives_are_not_cached() {
let cell = AgentMarkdownCell::new(
"::codex-inline-vis{file=\"chart.html\"}".to_string(),
Path::new("/tmp"),
);
for markdown in [
"::codex-inline-vis{file=\"chart.html\"}",
"\u{e200}visualize\u{e202}{\"path\":\"/tmp/chart.html\"}\u{e201}",
] {
let cell = AgentMarkdownCell::new(markdown.to_string(), Path::new("/tmp"));
cell.display_lines(/*width*/ 48);
cell.display_lines(/*width*/ 48);
assert!(cell.rendered_lines.is_none());
assert!(cell.rendered_lines.is_none());
}
}