Skip to content

fix(site): use WebGL renderer for terminal #9320

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

Merged
merged 2 commits into from
Aug 25, 2023
Merged
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
2 changes: 2 additions & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@
"xterm": "5.2.1",
"xterm-addon-canvas": "0.4.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should canvas addon be removed or is it still being used somewhere?

"xterm-addon-fit": "0.7.0",
"xterm-addon-unicode11": "0.5.0",
"xterm-addon-web-links": "0.8.0",
"xterm-addon-webgl": "0.15.0",
"yup": "1.2.0"
},
"devDependencies": {
Expand Down
22 changes: 22 additions & 0 deletions site/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion site/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export const AppRouter: FC = () => {
{/* Terminal and CLI auth pages don't have the dashboard layout */}
<Route
path="/:username/:workspace/terminal"
element={<TerminalPage renderer="canvas" />}
element={<TerminalPage renderer="webgl" />}
/>
<Route path="cli-auth" element={<CliAuthenticationPage />} />
</Route>
Expand Down
12 changes: 8 additions & 4 deletions site/src/pages/TerminalPage/TerminalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { useNavigate, useParams, useSearchParams } from "react-router-dom"
import { colors } from "theme/colors"
import { v4 as uuidv4 } from "uuid"
import * as XTerm from "xterm"
import { CanvasAddon } from "xterm-addon-canvas"
import { WebglAddon } from "xterm-addon-webgl"
import { FitAddon } from "xterm-addon-fit"
import { WebLinksAddon } from "xterm-addon-web-links"
import { Unicode11Addon } from "xterm-addon-unicode11"
import "xterm/css/xterm.css"
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"
import { pageTitle } from "../../utils/page"
Expand Down Expand Up @@ -57,7 +58,7 @@ const useTerminalWarning = ({ agent }: { agent?: WorkspaceAgent }) => {
}

type TerminalPageProps = React.PropsWithChildren<{
renderer: "canvas" | "dom"
renderer: "webgl" | "dom"
}>

const TerminalPage: FC<TerminalPageProps> = ({ renderer }) => {
Expand Down Expand Up @@ -176,6 +177,7 @@ const TerminalPage: FC<TerminalPageProps> = ({ renderer }) => {
return
}
const terminal = new XTerm.Terminal({
allowProposedApi: true,
allowTransparency: true,
disableStdin: false,
fontFamily: MONOSPACE_FONT_FAMILY,
Expand All @@ -185,12 +187,14 @@ const TerminalPage: FC<TerminalPageProps> = ({ renderer }) => {
},
})
// DOM is the default renderer.
if (renderer === "canvas") {
terminal.loadAddon(new CanvasAddon())
if (renderer === "webgl") {
terminal.loadAddon(new WebglAddon())
}
const fitAddon = new FitAddon()
setFitAddon(fitAddon)
terminal.loadAddon(fitAddon)
terminal.loadAddon(new Unicode11Addon())
terminal.unicode.activeVersion = "11"
terminal.loadAddon(
new WebLinksAddon((_, uri) => {
handleWebLink(uri)
Expand Down