Skip to content

CLI mode with -q flag hangs and doesn't exit immediately after command completion #3

Description

@gnosis23

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

  1. Run the CLI with a prompt: node dist/chat-cli.js -q "your command here"
  2. Observe that after the command completes, the application doesn't exit
  3. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions