Skip to content

feat(macos): render native visualization blocks in chat - #2098

Merged
LHagfoss merged 1 commit into
mainfrom
feat/macos-native-visualizations
Oct 16, 2026
Merged

LHagfoss merged 1 commit into
mainfrom
feat/macos-native-visualizations

Conversation

@LHagfoss

Copy link
Copy Markdown
Owner

Closes #2097. Part of #2088. Stacked on #2094; the base is feat/tui-native-visualizations.

Summary

  • RustCodeKit/Visualization.swift parses rustcode-viz payloads with the TUI's version 1 schema, limits and fallback reasons:
    • 16 KiB payload; 30 bars; 50 shown rows and 8 columns; 120 nodes and depth 8;
    • title 80, summary 300, label 40 and cell 60 characters, truncated with …;
    • control characters become spaces.
  • MarkdownBlock.parse(_:visualizations:) produces .visualization blocks only when asked to. The block keeps its full source fence, and its state is rendered, invalid (with a reason) or incomplete.
  • RustCode/VisualizationView.swift draws the widgets in SwiftUI:
    • bar_chart uses Swift Charts. Hovering a bar highlights it and shows its exact value, and every bar carries a value label.
    • table headers sort it (ascending, then descending). Numeric columns sort by value and align right. sort_by sets the initial order, and the sort covers every row while at most 50 are shown.
    • tree branches collapse and expand. The first two levels start open.
    • The card's Copy button and context menu copy the source fence.
  • Fallback matches the TUI. A block whose fence has not closed shows a "Building visualization…" placeholder while the reply streams. Once the reply is final, or when the block is invalid, it shows its source in the normal code block with a note.
  • Only assistant replies render widgets (AssistantMessage passes visualizations: true). Command output, user messages and tool output keep the fence as code. Nothing in a payload is executed.
  • The ACP initialize request advertises clientCapabilities._meta.rustcode.visualizations = 1, so the engine (since feat(tui): render native visualization blocks in chat #2094) adds the prompt guidance for this app.
  • docs/visualizations.md gains a macOS section and a row for the app in the frontend table.

Verification

  • swift build --package-path macos
  • swift test --package-path macos: 57 tests, 0 failures, 11 of them new. They cover parsing, every fallback reason, the payload, item, row, column, node and depth limits, text truncation, control characters, table sorting, tree ids, partial fences, unchanged ordinary fences and tables, and the initialize capability.
  • No Rust changes beyond feat(tui): render native visualization blocks in chat #2094.

The widgets have not been checked by eye in a running app yet. Layout, hover and sorting are covered only by the build, so they need a manual look before merging.

@github-actions github-actions Bot added the feature New feature or request label Oct 16, 2026
@LHagfoss
LHagfoss changed the base branch from feat/tui-native-visualizations to main October 16, 2026 21:51
Assistant replies draw rustcode-viz fences as SwiftUI widgets with the
TUI's schema, limits and fallback: a Swift Charts bar chart with hover
values, a table with sortable headers, and a collapsible tree. Streaming
blocks show a placeholder; invalid or unfinished ones show their source.
The app advertises _meta.rustcode.visualizations in its ACP initialize so
the engine sends the prompt guidance.
@LHagfoss
LHagfoss force-pushed the feat/macos-native-visualizations branch from 42fc594 to 3a03e16 Compare October 16, 2026 21:56
@LHagfoss
LHagfoss merged commit 58c0ba8 into main Oct 16, 2026
7 checks passed
@LHagfoss
LHagfoss deleted the feat/macos-native-visualizations branch October 16, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(macos): render native visualization blocks in chat

1 participant