Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Problem

Multiline content after the /compact command was being incorrectly parsed as flags, causing rejection or unexpected behavior.

Example of bug:

/compact
-t should be treated as message content

This would error with: -t requires a positive number, got should instead of treating the entire line as the continue message.

Root Cause

The parser was tokenizing the entire input (including content after newlines) and passing all tokens to minimist for flag parsing. This meant any text after a newline that looked like a flag (e.g., -t, -c, --anything) would be interpreted as a flag instead of message content.

Solution

Changed the /compact handler to:

  1. Split rawInput at the first newline
  2. Tokenize only the first line for flag parsing
  3. Use remaining lines (after first newline) as multiline continue message

This ensures content after newlines is never interpreted as flags.

Testing

New test cases added:

  • Multiline content starting with flag-like text (-t, -c)
  • Combination of flags on first line + flag-like text in multiline content

All existing tests pass (25/25 slash command tests, 537 total tests)

Generated with cmux

Multiline content after  command was incorrectly being parsed as flags. For example:

Would be parsed as a  flag instead of being part of the continue message.

The bug occurred because the parser was tokenizing the entire input including content after newlines, then passing all tokens to minimist for flag parsing.

Fix:
- Extract only the first line from rawInput for flag parsing
- Tokenize just the first line (before first newline)
- Use remaining lines as multiline continue message
- This ensures content after newlines is never interpreted as flags

Tests:
- Added test case for multiline content starting with flag-like text
- Added test case for flag + multiline content with flag-like text
- All existing tests continue to pass

_Generated with `cmux`_
@ammario ammario enabled auto-merge October 15, 2025 19:04
@ammario ammario added this pull request to the merge queue Oct 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 15, 2025
@ammario ammario merged commit 8600660 into main Oct 15, 2025
7 checks passed
@ammario ammario deleted the compact-flag-bug branch October 15, 2025 19:25
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.

2 participants