@@ -13,6 +13,7 @@ import {
1313import { escapeRegExp } from '@sim/utils/string'
1414import { findWorkflowReferenceTokens } from '@sim/utils/workflow-references'
1515import { useVirtualizer } from '@tanstack/react-virtual'
16+ import { cva , type VariantProps } from 'class-variance-authority'
1617import { ChevronRight } from '../../icons'
1718import { cn } from '../../lib/cn'
1819import './code.css'
@@ -856,6 +857,18 @@ function applySearchHighlightingToLine(
856857 */
857858type CodeViewerDensity = 'default' | 'compact'
858859
860+ /** Container appearances shared by the standard and virtualized viewers. */
861+ export const codeViewerAppearanceVariants = cva ( '' , {
862+ variants : {
863+ appearance : {
864+ default : '' ,
865+ inspection : 'rounded-md border-0 bg-[var(--surface-4)]! dark:bg-[var(--surface-3)]!' ,
866+ flat : 'rounded-none border-0 bg-[var(--bg)] dark:bg-[var(--bg)]' ,
867+ } ,
868+ } ,
869+ defaultVariants : { appearance : 'default' } ,
870+ } )
871+
859872interface CodeViewerProps {
860873 /** Code content to display */
861874 code : string
@@ -865,6 +878,8 @@ interface CodeViewerProps {
865878 language ?: 'javascript' | 'json' | 'python' | 'bash' | 'toml'
866879 /** Additional CSS classes for the container */
867880 className ?: string
881+ /** Container appearance for code inspected in logs/previews or on flat surfaces. */
882+ appearance ?: NonNullable < VariantProps < typeof codeViewerAppearanceVariants > [ 'appearance' ] >
868883 /** Visual density for read-only code. */
869884 density ?: CodeViewerDensity
870885 /** Highlight Sim `{{ENV}}` and `<block.output>` references with the platform accent. */
@@ -948,6 +963,7 @@ type ViewerInnerProps = {
948963 language : 'javascript' | 'json' | 'python' | 'bash' | 'toml'
949964 /** Additional CSS classes for the container */
950965 className ?: string
966+ appearance : NonNullable < CodeViewerProps [ 'appearance' ] >
951967 /** Visual density for read-only code. */
952968 density : CodeViewerDensity
953969 highlightWorkflowReferences : boolean
@@ -978,6 +994,7 @@ const VirtualizedViewerInner = memo(function VirtualizedViewerInner({
978994 showGutter,
979995 language,
980996 className,
997+ appearance,
981998 density,
982999 highlightWorkflowReferences,
9831000 paddingLeft,
@@ -1147,6 +1164,7 @@ const VirtualizedViewerInner = memo(function VirtualizedViewerInner({
11471164 wrapText ? 'overflow-x-hidden' : 'overflow-x-auto' ,
11481165 'overflow-y-auto' ,
11491166 'dark:bg-[var(--code-bg)]' ,
1167+ codeViewerAppearanceVariants ( { appearance } ) ,
11501168 className
11511169 ) }
11521170 style = { { height : containerHeight } }
@@ -1196,6 +1214,7 @@ const ViewerInner = memo(function ViewerInner({
11961214 showGutter,
11971215 language,
11981216 className,
1217+ appearance,
11991218 density,
12001219 highlightWorkflowReferences,
12011220 paddingLeft,
@@ -1309,7 +1328,7 @@ const ViewerInner = memo(function ViewerInner({
13091328 // Grid-based rendering for gutter alignment (works with wrap)
13101329 if ( showGutter ) {
13111330 return (
1312- < Container className = { className } >
1331+ < Container className = { cn ( codeViewerAppearanceVariants ( { appearance } ) , className ) } >
13131332 < Content className = 'code-editor-theme' editorRef = { contentRef } >
13141333 < div
13151334 style = { {
@@ -1370,7 +1389,7 @@ const ViewerInner = memo(function ViewerInner({
13701389
13711390 // Simple display without gutter
13721391 return (
1373- < Container className = { className } >
1392+ < Container className = { cn ( codeViewerAppearanceVariants ( { appearance } ) , className ) } >
13741393 < Content className = 'code-editor-theme' editorRef = { contentRef } >
13751394 < pre
13761395 className = { cn (
@@ -1417,6 +1436,7 @@ function Viewer({
14171436 showGutter = false ,
14181437 language = 'json' ,
14191438 className,
1439+ appearance = 'default' ,
14201440 density = 'default' ,
14211441 highlightWorkflowReferences = false ,
14221442 paddingLeft = 0 ,
@@ -1434,6 +1454,7 @@ function Viewer({
14341454 showGutter,
14351455 language,
14361456 className,
1457+ appearance,
14371458 density,
14381459 highlightWorkflowReferences,
14391460 paddingLeft,
0 commit comments