Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

Adds support for custom slash commands that run executables in the workspace.

Features

  • Discovery: Executables at .mux/commands/<name> are discovered and appear in slash command autocomplete
  • Execution: /<name> [args...] runs the command with:
    • First line tokens become argv
    • Lines after the first become stdin
    • Stdout streams in real-time via init events
    • Stdout becomes the user message on success
  • Environment: Commands receive MUX_* env vars (project path, runtime, workspace name, workspace path)

Example

#!/bin/bash
# .mux/commands/refinement
echo "Refine this:"
cat

Then use with: /refinement\n<text to refine>

Implementation

  • Backend: SlashCommandService for discovery and execution with streaming
  • Frontend: Parser extended with rawInput for unknown commands
  • Frontend: ChatInput wired to execute custom commands and show autocomplete
  • Docs: New page at docs/hooks/slash-commands.mdx

Testing

  • All slash command parser and suggestion tests pass
  • Static checks pass
  • New functionality is exercised through manual testing

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high • Cost: $11.85

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8152aa515

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammar-agent ammar-agent added the docs Improvements or additions to documentation label Jan 9, 2026
@ammar-agent
Copy link
Collaborator Author

@codex review

Addressed the P1 and P2 review comments:

  • P1: Now quoting command path before exec to handle spaces in workspace paths
  • P2: Removed .trim() from stdin processing to preserve whitespace

Also added:

  • Exit code 2 handling (show output but don't send to model)
  • Progressive examples in docs (static msg, args, stdin)
  • UI integration tests covering suggestions, execution, exit codes
  • Unit tests for custom command suggestions

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ccbeaea806

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammar-agent
Copy link
Collaborator Author

@codex review

Addressed additional review comments:

  • P2: Now accumulating raw stdout bytes to preserve blank lines (LineBuffer drops empty lines for streaming display, but the final output preserves them)
  • P3: Now restoring input when command produces no output (consistent with other error paths)

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04ddac9a3d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammar-agent
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11cc4f1b8e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Adds support for custom slash commands that run executables in the workspace.

## Features

- **Discovery**: Executables at `.mux/commands/<name>` are discovered and
  appear in slash command autocomplete.

- **Execution**: `/<name> [args...]` runs the command with:
  - First line tokens become argv
  - Lines after the first become stdin
  - Stdout streams in real-time via init events
  - Stdout becomes the user message on success

- **Environment**: Commands receive MUX_* env vars (project path, runtime,
  workspace name, workspace path).

## Implementation

- Backend: SlashCommandService for discovery and execution with streaming
- Frontend: Parser extended with rawInput for unknown commands
- Frontend: ChatInput wired to execute custom commands and show autocomplete
- Docs: New page at docs/hooks/slash-commands.mdx

## Example

```bash
#!/bin/bash
# .mux/commands/refinement
echo "Refine this:"
cat
```

Then use with: `/refinement\n<text to refine>`
- Quote command path before exec to handle spaces in workspace paths (P1)
- Preserve stdin whitespace - don't trim multiline input (P2)
- Add exit code 2 handling: show output but don't send to model
- Update docs with progressive examples (static msg, args, stdin)
- Add comprehensive UI integration tests for custom slash commands
- Add unit tests for custom command suggestions
- Remove UI integration tests that were timing out in CI
- Add backend integration tests for slash command functionality:
  - Command discovery (list)
  - Command execution (run)
  - Exit code handling (0, 2, others)
  - Argument and stdin passing
- P2: Preserve blank lines in command stdout by accumulating raw bytes
  instead of using LineBuffer (which drops empty lines)
- P3: Restore input when command produces no output (consistent error handling)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant