Bug Description
When using the CLI mode with the -q (prompt) flag, the application successfully executes the command but then hangs and doesn't exit immediately. Users have to manually press Ctrl+C to exit the application.
Expected Behavior
After executing a command in CLI mode (-q flag), the application should immediately exit and return control to the terminal.
Current Behavior
The application completes the command execution but remains in a hanging state, requiring manual intervention to exit.
Steps to Reproduce
- Run the CLI with a prompt:
node dist/chat-cli.js -q "your command here"
- Observe that after the command completes, the application doesn't exit
- User has to press Ctrl+C to force exit
Code Analysis
Looking at the codebase, the issue appears to be in the exit handling mechanism in CLI mode:
- In
src/hooks/use-ai-chat.js lines 54-56, there's a setTimeout(() => exit(), 100) that should exit after 100ms
- However, this timeout might not be firing correctly, or there might be other async operations preventing clean exit
- The
exit() function from useApp() might not be properly terminating the Ink application
Environment
- Node.js version: >=16
- Platform: All platforms affected
- Version: 0.2.0
Additional Context
This issue affects automation and scripting use cases where the CLI should complete and exit cleanly after processing a command.
EOF < /dev/null
Bug Description
When using the CLI mode with the -q (prompt) flag, the application successfully executes the command but then hangs and doesn't exit immediately. Users have to manually press Ctrl+C to exit the application.
Expected Behavior
After executing a command in CLI mode (-q flag), the application should immediately exit and return control to the terminal.
Current Behavior
The application completes the command execution but remains in a hanging state, requiring manual intervention to exit.
Steps to Reproduce
node dist/chat-cli.js -q "your command here"Code Analysis
Looking at the codebase, the issue appears to be in the exit handling mechanism in CLI mode:
src/hooks/use-ai-chat.jslines 54-56, there's asetTimeout(() => exit(), 100)that should exit after 100msexit()function fromuseApp()might not be properly terminating the Ink applicationEnvironment
Additional Context
This issue affects automation and scripting use cases where the CLI should complete and exit cleanly after processing a command.
EOF < /dev/null