MCPcopy Create free account
hub / github.com/anomalyco/opencode / persistTerminal

Function persistTerminal

packages/app/src/components/terminal.tsx:130–155  ·  view source on GitHub ↗
(input: {
  term: Term | undefined
  addon: SerializeAddon | undefined
  cursor: number
  id: string
  onCleanup?: (pty: Partial<LocalPTY> & { id: string }) => void
})

Source from the content-addressed store, hash-verified

128}
129
130const persistTerminal = (input: {
131 term: Term | undefined
132 addon: SerializeAddon | undefined
133 cursor: number
134 id: string
135 onCleanup?: (pty: Partial<LocalPTY> & { id: string }) => void
136}) => {
137 if (!input.addon || !input.onCleanup || !input.term) return
138 const buffer = (() => {
139 try {
140 return input.addon.serialize()
141 } catch {
142 debugTerminal("failed to serialize terminal buffer")
143 return ""
144 }
145 })()
146
147 input.onCleanup({
148 id: input.id,
149 buffer,
150 cursor: input.cursor,
151 rows: input.term.rows,
152 cols: input.term.cols,
153 scrollY: input.term.getViewportY(),
154 })
155}
156
157export const Terminal = (props: TerminalProps) => {
158 const platform = usePlatform()

Callers 1

finalizeFunction · 0.85

Calls 2

debugTerminalFunction · 0.85
serializeMethod · 0.80

Tested by

no test coverage detected