Skip to content

feat: disable text styling in --no-interactive mode #2464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

StoneDot
Copy link

@StoneDot StoneDot commented Aug 1, 2025

Automatically partially disable ANSI color codes and styling when running in non-interactive mode.

  • Add a session-scoped enable_styling flag to ChatSession
  • Create conditional styling macros (execute_conditional!, queue_conditional!)
  • Implement an IsStyling trait for crossterm styling commands
  • Remove the response prefix ("> ") in non-interactive mode
  • Add a raw text output path that bypasses the markdown parser when styling is disabled
  • Text styling is automatically disabled when the --no-interactive flag is used

Issue #, if available:
#993

Description of changes:
Automatically disables text styling in --no-interactive mode to ensure clean output for programmatic usage and script integration.

Testing examples:

Before (non-interactive had ANSI codes):

$ q chat --no-interactive "Say just: Hello! How can I help you today?" 2>/dev/null | cat -v
^[[38;5;10m> ^[[39mHello! How can I help you today?^[[0m^[[0m

After (clean output):

$ q chat --no-interactive "Say just: Hello! How can I help you today?" 2>/dev/null | cat -v
Hello! How can I help you today?

Discussion notes:

I already noticed that other codes should also be changed to suppress styling. If complete stderr styling removal is needed, it can be addressed in follow-up PRs or added to this one based on feedback. However, I believe this PR can be a good starting point for these changes.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@StoneDot StoneDot changed the title feat: disable text styling in --no-interactive mode WIP feat: disable text styling in --no-interactive mode Aug 7, 2025
@StoneDot StoneDot marked this pull request as draft August 7, 2025 15:24
@StoneDot StoneDot force-pushed the remove-styling-when-interactive branch from bdbf2e1 to 1ec2b4c Compare August 7, 2025 16:59
@StoneDot StoneDot changed the title WIP feat: disable text styling in --no-interactive mode feat: disable text styling in --no-interactive mode Aug 7, 2025
Automatically partially disable ANSI color codes and styling when running in non-interactive mode.

- Add a session-scoped enable_styling flag to ChatSession
- Create conditional styling macros (execute_conditional!, queue_conditional!)
- Implement an IsStyling trait for crossterm styling commands
- Remove the response prefix ("> ") in non-interactive mode
- Add a raw text output path that bypasses the markdown parser when styling is disabled
- Text styling is automatically disabled when the --no-interactive flag is used
@StoneDot StoneDot force-pushed the remove-styling-when-interactive branch from 1ec2b4c to 5c91b63 Compare August 7, 2025 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant