From 9920d899b5783918cc05d85524de631fcde651e2 Mon Sep 17 00:00:00 2001 From: Aliou Diallo Date: Tue, 3 Feb 2026 18:25:37 +0100 Subject: [PATCH] fix(tui): allow slash command menu on first line with existing text --- packages/tui/CHANGELOG.md | 4 ++++ packages/tui/src/components/editor.ts | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md index 6a112489..b346b8cf 100644 --- a/packages/tui/CHANGELOG.md +++ b/packages/tui/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Changed + +- Slash command menu now triggers on the first line even when other lines have content, allowing commands to be prepended to existing text ([#1227](https://github.com/badlogic/pi-mono/pull/1227) by [@aliou](https://github.com/aliou)) + ## [0.51.5] - 2026-02-04 ## [0.51.4] - 2026-02-03 diff --git a/packages/tui/src/components/editor.ts b/packages/tui/src/components/editor.ts index 507fa215..94f44205 100644 --- a/packages/tui/src/components/editor.ts +++ b/packages/tui/src/components/editor.ts @@ -1884,13 +1884,9 @@ export class Editor implements Component, Focusable { this.setCursorCol(newCol); } - // Slash menu only allowed when all other lines are empty (no mixed content) + // Slash menu only allowed on the first line of the editor private isSlashMenuAllowed(): boolean { - for (let i = 0; i < this.state.lines.length; i++) { - if (i === this.state.cursorLine) continue; - if (this.state.lines[i].trim() !== "") return false; - } - return true; + return this.state.cursorLine === 0; } // Helper method to check if cursor is at start of message (for slash command detection)