MCPcopy
hub / github.com/anomalyco/opencode / focusTerminalById

Function focusTerminalById

packages/app/src/pages/session/helpers.ts:81–99  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

79}
80
81export const focusTerminalById = (id: string) => {
82 const wrapper = document.getElementById(`terminal-wrapper-${id}`)
83 const terminal = wrapper?.querySelector('[data-component="terminal"]')
84 if (!(terminal instanceof HTMLElement)) return false
85
86 const textarea = terminal.querySelector("textarea")
87 if (textarea instanceof HTMLTextAreaElement) {
88 textarea.focus()
89 return true
90 }
91
92 terminal.focus()
93 terminal.dispatchEvent(
94 typeof PointerEvent === "function"
95 ? new PointerEvent("pointerdown", { bubbles: true, cancelable: true })
96 : new MouseEvent("pointerdown", { bubbles: true, cancelable: true }),
97 )
98 return true
99}
100
101const skip = new Set(["Alt", "Control", "Meta", "Shift"])
102

Callers 6

focusFunction · 0.90
toggleTerminalFunction · 0.90
handleKeyDownFunction · 0.90
helpers.test.tsFile · 0.90
focusFunction · 0.90
handleTerminalDragEndFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected