MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / setupExitMessageHandler

Function setupExitMessageHandler

cli/src/hooks/use-exit-handler.ts:21–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19let exitHandlerRegistered = false
20
21function setupExitMessageHandler() {
22 if (exitHandlerRegistered) return
23 exitHandlerRegistered = true
24
25 process.on('exit', () => {
26 try {
27 const chatId = getCurrentChatId()
28 if (chatId) {
29 // This runs synchronously during the exit phase
30 // OpenTUI has already cleaned up by this point
31 const cliName = IS_FREEBUFF ? 'freebuff' : 'codebuff'
32 process.stdout.write(
33 `\nTo continue this session later, run:\n${cliName} --continue ${chatId}\n`,
34 )
35 }
36 } catch {
37 // Silent fail - don't block exit
38 }
39 })
40}
41
42function exitCli(): void {
43 if (IS_FREEBUFF) {

Callers 1

useExitHandlerFunction · 0.85

Calls 2

getCurrentChatIdFunction · 0.90
onMethod · 0.65

Tested by

no test coverage detected