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

Function close

packages/opencode/src/cli/cmd/run/runtime.lifecycle.ts:305–351  ·  view source on GitHub ↗
(next: {
      showExit: boolean
      sessionTitle?: string
      sessionID?: string
      history?: RunPrompt[]
    })

Source from the content-addressed store, hash-verified

303 attachSigint()
304
305 const close = async (next: {
306 showExit: boolean
307 sessionTitle?: string
308 sessionID?: string
309 history?: RunPrompt[]
310 }) => {
311 if (closed) {
312 return
313 }
314
315 closed = true
316 detachSigint()
317 let wroteExit = false
318
319 try {
320 await footer.idle().catch(() => {})
321
322 const show = renderer.isDestroyed ? false : next.showExit
323 if (!renderer.isDestroyed && show) {
324 const sessionID = next.sessionID || input.getSessionID?.() || input.sessionID
325 const splash = splashInfo(next.sessionTitle ?? input.sessionTitle, next.history ?? input.history)
326 wroteExit = queueSplash(
327 renderer,
328 state,
329 "exit",
330 exitSplash({
331 ...splashMeta({
332 title: splash.title,
333 session_id: sessionID,
334 }),
335 theme: footer.currentTheme().splash,
336 }),
337 )
338 await renderer.idle().catch(() => {})
339 }
340 } finally {
341 footer.close()
342 await footer.idle().catch(() => {})
343 footer.destroy()
344 unregisterKeymap?.()
345 shutdown(renderer)
346 if (!wroteExit) {
347 process.stdout.write("\n")
348 }
349 source.cleanup?.()
350 }
351 }
352
353 return {
354 footer,

Callers

nothing calls this directly

Calls 12

exitSplashFunction · 0.90
splashMetaFunction · 0.90
detachSigintFunction · 0.85
splashInfoFunction · 0.85
queueSplashFunction · 0.85
idleMethod · 0.80
getSessionIDMethod · 0.80
currentThemeMethod · 0.80
writeMethod · 0.80
shutdownFunction · 0.70
destroyMethod · 0.65
closeMethod · 0.45

Tested by

no test coverage detected