diff options
Diffstat (limited to 'packages/app/src/components')
| -rw-r--r-- | packages/app/src/components/terminal.tsx | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/packages/app/src/components/terminal.tsx b/packages/app/src/components/terminal.tsx index fda66917f..840903293 100644 --- a/packages/app/src/components/terminal.tsx +++ b/packages/app/src/components/terminal.tsx @@ -10,6 +10,7 @@ import { useSDK } from "@/context/sdk" import { useServer } from "@/context/server" import { monoFontFamily, useSettings } from "@/context/settings" import type { LocalPTY } from "@/context/terminal" +import { terminalAttr, terminalProbe } from "@/testing/terminal" import { disposeIfDisposable, getHoveredLinkText, setOptionIfSupported } from "@/utils/runtime-adapters" import { terminalWriter } from "@/utils/terminal-writer" @@ -160,6 +161,7 @@ export const Terminal = (props: TerminalProps) => { let container!: HTMLDivElement const [local, others] = splitProps(props, ["pty", "class", "classList", "autoFocus", "onConnect", "onConnectError"]) const id = local.pty.id + const probe = terminalProbe(id) const restore = typeof local.pty.buffer === "string" ? local.pty.buffer : "" const restoreSize = restore && @@ -326,6 +328,9 @@ export const Terminal = (props: TerminalProps) => { } onMount(() => { + probe.init() + cleanups.push(() => probe.drop()) + const run = async () => { const loaded = await loadGhostty() if (disposed) return @@ -353,7 +358,13 @@ export const Terminal = (props: TerminalProps) => { } ghostty = g term = t - output = terminalWriter((data, done) => t.write(data, done)) + output = terminalWriter((data, done) => + t.write(data, () => { + probe.render(data) + probe.settle() + done?.() + }), + ) t.attachCustomKeyEventHandler((event) => { const key = event.key.toLowerCase() @@ -441,10 +452,6 @@ export const Terminal = (props: TerminalProps) => { startResize() } - // t.onScroll((ydisp) => { - // console.log("Scroll position:", ydisp) - // }) - const once = { value: false } let closing = false @@ -460,6 +467,7 @@ export const Terminal = (props: TerminalProps) => { ws = socket const handleOpen = () => { + probe.connect() local.onConnect?.() scheduleSize(t.cols, t.rows) } @@ -560,6 +568,7 @@ export const Terminal = (props: TerminalProps) => { <div ref={container} data-component="terminal" + {...{ [terminalAttr]: id }} data-prevent-autofocus tabIndex={-1} style={{ "background-color": terminalColors().background }} |
