Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions frontend/src/components/common/LogViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import DialogContent from '@mui/material/DialogContent';
import Grid from '@mui/material/Grid';
import InputBase from '@mui/material/InputBase';
import Paper from '@mui/material/Paper';
import { useTheme } from '@mui/material/styles';
import { FitAddon } from '@xterm/addon-fit';
import { ISearchOptions, SearchAddon } from '@xterm/addon-search';
import { Terminal as XTerminal } from '@xterm/xterm';
Expand Down Expand Up @@ -64,6 +65,7 @@ export function LogViewer(props: LogViewerProps) {
...other
} = props;
const { t } = useTranslation();
const theme = useTheme();
const xtermRef = React.useRef<XTerminal | null>(null);
const fitAddonRef = React.useRef<any>(null);
const searchAddonRef = React.useRef<any>(null);
Expand Down Expand Up @@ -95,12 +97,22 @@ export function LogViewer(props: LogViewerProps) {
fitAddonRef.current = new FitAddon();
searchAddonRef.current = new SearchAddon();

const isDarkMode = theme.palette.mode === 'dark';

xtermRef.current = new XTerminal({
cursorStyle: 'bar',
scrollback: 10000,
rows: 30, // initial rows before fit
lineHeight: 1.21,
allowProposedApi: true,
theme: {
background: isDarkMode ? '#111' : '#f0f0f0',
foreground: isDarkMode ? '#d4d4d4' : '#000000',
cursor: isDarkMode ? '#ffffff' : '#000000',
cursorAccent: isDarkMode ? '#000000' : '#ffffff',
selectionBackground: isDarkMode ? '#264f78' : '#add6ff',
selectionForeground: isDarkMode ? '#ffffff' : '#000000',
},
});

if (!!outXtermRef) {
Expand Down Expand Up @@ -168,6 +180,7 @@ export function LogViewer(props: LogViewerProps) {
overflow: 'hidden',
width: '100%',
height: '100%',
backgroundColor: theme.palette.mode === 'dark' ? '#1e1e1e' : '#ffffff',
'& .terminal.xterm': {
padding: theme.spacing(1),
},
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion frontend/src/storybook.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,25 @@ function replaceUseId(node: any) {
}
}

// Replace dynamic xterm owner classes in both className property and class attribute
if (node.className && typeof node.className === 'string') {
// Replace dynamic xterm owner classes with a fixed value
node.className = node.className.replace(
/xterm-dom-renderer-owner-\d+/g,
'xterm-dom-renderer-owner'
);
}

// Also handle the class attribute directly
const classAttr = node.getAttribute('class');
if (classAttr) {
const normalizedClass = classAttr.replace(
/xterm-dom-renderer-owner-\d+/g,
'xterm-dom-renderer-owner'
);
if (normalizedClass !== classAttr) {
node.setAttribute('class', normalizedClass);
}
}
}

// Recursively update child nodes
Expand Down
Loading