()
| 19 | let exitHandlerRegistered = false |
| 20 | |
| 21 | function 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 | |
| 42 | function exitCli(): void { |
| 43 | if (IS_FREEBUFF) { |
no test coverage detected