diff --git a/packages/cli/src/ui/components/InputPrompt.test.tsx b/packages/cli/src/ui/components/InputPrompt.test.tsx index 5449db5e..cf8b9685 100644 --- a/packages/cli/src/ui/components/InputPrompt.test.tsx +++ b/packages/cli/src/ui/components/InputPrompt.test.tsx @@ -1307,7 +1307,7 @@ describe('InputPrompt', () => { mockBuffer.text = text; mockBuffer.lines = [text]; mockBuffer.viewportVisualLines = [text]; - mockBuffer.visualCursor = [0, 8]; // cursor after '👍' (length is 6 + 2 for emoji) + mockBuffer.visualCursor = [0, 7]; // cursor after '👍' (emoji is 1 code point, so total is 7) const { stdout, unmount } = renderWithProviders( , diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx index 8af77059..7d174250 100644 --- a/packages/cli/src/ui/components/InputPrompt.tsx +++ b/packages/cli/src/ui/components/InputPrompt.tsx @@ -707,15 +707,20 @@ export const InputPrompt: React.FC = ({ statusText = t('Accepting edits'); } + const borderColor = + isShellFocused && !isEmbeddedShellFocused + ? (statusColor ?? theme.border.focused) + : theme.border.default; + return ( <> = ({ isOnCursorLine && cursorVisualColAbsolute === cpLen(lineText) ) { + // Add zero-width space after cursor to prevent Ink from trimming trailing whitespace renderedLine.push( - {showCursor ? chalk.inverse(' ') : ' '} + {showCursor ? chalk.inverse(' ') + '\u200B' : ' \u200B'} , ); } diff --git a/packages/cli/src/ui/components/__snapshots__/InputPrompt.test.tsx.snap b/packages/cli/src/ui/components/__snapshots__/InputPrompt.test.tsx.snap index 9ae6eab1..efa14b8b 100644 --- a/packages/cli/src/ui/components/__snapshots__/InputPrompt.test.tsx.snap +++ b/packages/cli/src/ui/components/__snapshots__/InputPrompt.test.tsx.snap @@ -19,39 +19,39 @@ exports[`InputPrompt > command search (Ctrl+R when not in shell) > expands and c `; exports[`InputPrompt > command search (Ctrl+R when not in shell) > renders match window and expanded view (snapshots) > command-search-collapsed-match 1`] = ` -"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ (r:) commit │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ +"──────────────────────────────────────────────────────────────────────────────────────────────────── + (r:) commit +──────────────────────────────────────────────────────────────────────────────────────────────────── git commit -m "feat: add search" in src/app" `; exports[`InputPrompt > command search (Ctrl+R when not in shell) > renders match window and expanded view (snapshots) > command-search-expanded-match 1`] = ` -"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ (r:) commit │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ +"──────────────────────────────────────────────────────────────────────────────────────────────────── + (r:) commit +──────────────────────────────────────────────────────────────────────────────────────────────────── git commit -m "feat: add search" in src/app" `; exports[`InputPrompt > snapshots > should not show inverted cursor when shell is focused 1`] = ` -"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ > Type your message or @path/to/file │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────╯" +"──────────────────────────────────────────────────────────────────────────────────────────────────── + > Type your message or @path/to/file +────────────────────────────────────────────────────────────────────────────────────────────────────" `; exports[`InputPrompt > snapshots > should render correctly in shell mode 1`] = ` -"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ ! Type your message or @path/to/file │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────╯" +"──────────────────────────────────────────────────────────────────────────────────────────────────── + ! Type your message or @path/to/file +────────────────────────────────────────────────────────────────────────────────────────────────────" `; exports[`InputPrompt > snapshots > should render correctly in yolo mode 1`] = ` -"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ * Type your message or @path/to/file │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────╯" +"──────────────────────────────────────────────────────────────────────────────────────────────────── + * Type your message or @path/to/file +────────────────────────────────────────────────────────────────────────────────────────────────────" `; exports[`InputPrompt > snapshots > should render correctly when accepting edits 1`] = ` -"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ > Type your message or @path/to/file │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────╯" +"──────────────────────────────────────────────────────────────────────────────────────────────────── + > Type your message or @path/to/file +────────────────────────────────────────────────────────────────────────────────────────────────────" `;