Skip to content

Bug: Cannot send messages starting with / (even with leading whitespace) #22

@ptbsare

Description

@ptbsare

Bug Report

Describe the bug
Messages that start with / cannot be sent to the model. Even adding a leading space (e.g., /hello) does not work — the message is still intercepted as a slash command.

To Reproduce

  1. Type /hello in the composer input
  2. Press Enter to send
  3. The message is treated as a slash command instead of being sent to the model

Expected behavior

  • /hello should be treated as a slash command (current behavior is correct)
  • /hello (with a leading space) should be sent as a regular message to the model, not intercepted as a slash command

Root cause
In src/composer/composer.ts, the submit handler trims the input value before checking if it starts with /:

const message = elements.promptEl.value.trim();  // line 329
// ...
if (message.startsWith("/") && images.length === 0) {  // line 333

The trim() removes leading whitespace, so /hello becomes /hello and is incorrectly treated as a slash command.

Suggested fix
Check the raw input value instead of the trimmed value:

if (elements.promptEl.value.startsWith("/") && images.length === 0) {

This way, a leading space indicates the user intends to send a regular message, not invoke a slash command.

Environment

  • pi-web version: latest
  • Browser: all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions