mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Render inline visualization links in the TUI (#33925)
## Why
Assistant-authored inline visualizations need a terminal fallback that lets users open generated artifacts in a browser.
## What changed
- Recognize `::codex-inline-vis{file="..."}` directives in assistant Markdown and replace them with browser links during streaming, finalized history rendering, and local transcript previews.
- Materialize visualization fragments in sandboxed viewer documents with a content security policy, while restricting artifacts to HTML files within the thread's visualization directory and limiting their size.
- Show an explicit unavailable message for invalid or missing artifacts, hide incomplete streaming directives, and preserve directive text in code blocks and user Markdown.
- Add a trusted file-link path for generated viewers without enabling arbitrary `file:` links in Markdown.
## Testing
Add coverage for directive rewriting, streaming and replay, artifact validation, sandboxed viewer generation, trusted terminal hyperlinks, and literal preservation.
GitOrigin-RevId: a666b4ebc82bb5798ad45bd137fd815d538e1de2
This commit is contained in:
1 parent
97dbd01a3d
commit
f896ab9f25
23 files changed
+2123
-106
No files matched your search
@@ -17,6 +17,7 @@ use super::resize_reflow::trailing_run_start;
|
||||
use crate::app_event::ConsolidationScrollbackReflow;
|
||||
use crate::history_cell;
|
||||
use crate::history_cell::HistoryCell;
|
||||
use crate::inline_visualization::InlineVisualizationContext;
|
||||
use crate::pager_overlay::Overlay;
|
||||
use crate::tui;
|
||||
|
||||
@@ -26,6 +27,7 @@ impl App {
|
||||
tui: &mut tui::Tui,
|
||||
source: String,
|
||||
cwd: PathBuf,
|
||||
inline_visualization_context: Option<InlineVisualizationContext>,
|
||||
scrollback_reflow: ConsolidationScrollbackReflow,
|
||||
deferred_history_cell: Option<Box<dyn HistoryCell>>,
|
||||
) -> Result<()> {
|
||||
@@ -52,8 +54,13 @@ impl App {
|
||||
tracing::debug!(
|
||||
"ConsolidateAgentMessage: replacing cells [{start}..{end}] with AgentMarkdownCell"
|
||||
);
|
||||
let consolidated: Arc<dyn HistoryCell> =
|
||||
Arc::new(history_cell::AgentMarkdownCell::new(source, &cwd));
|
||||
let consolidated: Arc<dyn HistoryCell> = Arc::new(
|
||||
history_cell::AgentMarkdownCell::new_with_inline_visualizations(
|
||||
source,
|
||||
&cwd,
|
||||
inline_visualization_context,
|
||||
),
|
||||
);
|
||||
self.transcript_cells
|
||||
.splice(start..end, std::iter::once(consolidated.clone()));
|
||||
|
||||
|
||||
@@ -317,6 +317,7 @@ impl App {
|
||||
AppEvent::ConsolidateAgentMessage {
|
||||
source,
|
||||
cwd,
|
||||
inline_visualization_context,
|
||||
scrollback_reflow,
|
||||
deferred_history_cell,
|
||||
} => {
|
||||
@@ -324,6 +325,7 @@ impl App {
|
||||
tui,
|
||||
source,
|
||||
cwd,
|
||||
inline_visualization_context,
|
||||
scrollback_reflow,
|
||||
deferred_history_cell,
|
||||
)?;
|
||||
|
||||
@@ -5036,6 +5036,7 @@ async fn required_stream_reflow_during_capped_initial_replay_survives_transcript
|
||||
"Final answer:\n\n| Pattern | Outcome |\n| --- | --- |\n| Table tail | Preserved |"
|
||||
.to_string(),
|
||||
PathBuf::from("/tmp"),
|
||||
/*inline_visualization_context*/ None,
|
||||
ConsolidationScrollbackReflow::Required,
|
||||
/*deferred_history_cell*/ None,
|
||||
)?;
|
||||
|
||||
Reference in new issue
Block a user