-
Notifications
You must be signed in to change notification settings - Fork 894
feat: support configurable web terminal rendering #10095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Added a deployment option for configuring web terminal rendering. Valid values are 'webgl', 'canvas', and 'dom'.
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { colors } from "theme/colors"; | |
import { v4 as uuidv4 } from "uuid"; | ||
import * as XTerm from "xterm"; | ||
import { WebglAddon } from "xterm-addon-webgl"; | ||
import { CanvasAddon } from "xterm-addon-canvas"; | ||
import { FitAddon } from "xterm-addon-fit"; | ||
import { WebLinksAddon } from "xterm-addon-web-links"; | ||
import { Unicode11Addon } from "xterm-addon-unicode11"; | ||
|
@@ -28,18 +29,16 @@ import { | |
LoadedScriptsAlert, | ||
LoadingScriptsAlert, | ||
} from "./TerminalAlerts"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { deploymentConfig } from "api/queries/deployment"; | ||
|
||
export const Language = { | ||
workspaceErrorMessagePrefix: "Unable to fetch workspace: ", | ||
workspaceAgentErrorMessagePrefix: "Unable to fetch workspace agent: ", | ||
websocketErrorMessagePrefix: "WebSocket failed: ", | ||
}; | ||
|
||
type TerminalPageProps = React.PropsWithChildren<{ | ||
renderer: "webgl" | "dom"; | ||
}>; | ||
|
||
const TerminalPage: FC<TerminalPageProps> = ({ renderer }) => { | ||
const TerminalPage: FC = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we are getting a test failure because the test looks for HTML elements so it relies on the |
||
const navigate = useNavigate(); | ||
const styles = useStyles(); | ||
const { proxy } = useProxy(); | ||
|
@@ -101,6 +100,8 @@ const TerminalPage: FC<TerminalPageProps> = ({ renderer }) => { | |
prevLifecycleState.current = lifecycleState; | ||
}, [lifecycleState]); | ||
|
||
const config = useQuery(deploymentConfig()); | ||
|
||
// handleWebLink handles opening of URLs in the terminal! | ||
const handleWebLink = useCallback( | ||
(uri: string) => { | ||
|
@@ -166,9 +167,13 @@ const TerminalPage: FC<TerminalPageProps> = ({ renderer }) => { | |
background: colors.gray[16], | ||
}, | ||
}); | ||
// DOM is the default renderer. | ||
if (renderer === "webgl") { | ||
if (config.data && config.data.config.web_terminal_renderer === "webgl") { | ||
sreya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
terminal.loadAddon(new WebglAddon()); | ||
} else if ( | ||
config.data && | ||
config.data.config.web_terminal_renderer === "canvas" | ||
sreya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) { | ||
terminal.loadAddon(new CanvasAddon()); | ||
} | ||
const fitAddon = new FitAddon(); | ||
setFitAddon(fitAddon); | ||
|
@@ -208,7 +213,7 @@ const TerminalPage: FC<TerminalPageProps> = ({ renderer }) => { | |
window.removeEventListener("resize", listener); | ||
terminal.dispose(); | ||
}; | ||
}, [renderer, sendEvent, xtermRef, handleWebLink]); | ||
}, [config.data, sendEvent, xtermRef, handleWebLink]); | ||
|
||
// Triggers the initial terminal connection using | ||
// the reconnection token and workspace name found | ||
|
Uh oh!
There was an error while loading. Please reload this page.