|
1 | | -import { green, yellow, cyan, bold, gray, blue, red, magenta } from 'picocolors' |
| 1 | +import { green, yellow, cyan, bold, gray, blue } from 'picocolors' |
2 | 2 | import stringWidth from 'string-width' |
3 | 3 | import wrapAnsi from 'wrap-ansi' |
4 | 4 |
|
| 5 | +import { logger } from '../utils/logger' |
5 | 6 | import { |
6 | 7 | ENTER_ALT_BUFFER, |
7 | 8 | EXIT_ALT_BUFFER, |
8 | 9 | CLEAR_SCREEN, |
9 | | - HIDE_CURSOR, |
10 | 10 | SHOW_CURSOR, |
11 | 11 | MOVE_CURSOR, |
12 | | - SET_CURSOR_STEADY_BAR, |
13 | 12 | SET_CURSOR_DEFAULT, |
14 | 13 | DISABLE_CURSOR_BLINK, |
| 14 | + CURSOR_SET_INVISIBLE_BLOCK, |
15 | 15 | } from '../utils/terminal' |
16 | | -import { logger } from '../utils/logger' |
17 | 16 |
|
18 | 17 | // Constants |
19 | 18 | const SIDE_PADDING = 2 |
@@ -182,18 +181,21 @@ function resetChatState(): void { |
182 | 181 | } |
183 | 182 |
|
184 | 183 | function setupRealCursor(): void { |
185 | | - // Set the real cursor to steady bar style and disable blinking |
186 | | - // This is the actual cursor that shows where typing will occur |
187 | | - process.stdout.write(SET_CURSOR_STEADY_BAR) |
| 184 | + // Hide cursor using invisible block style |
| 185 | + process.stdout.write(CURSOR_SET_INVISIBLE_BLOCK) |
| 186 | + |
| 187 | + // Disable cursor blinking for better invisibility |
188 | 188 | process.stdout.write(DISABLE_CURSOR_BLINK) |
189 | 189 | } |
190 | 190 |
|
191 | 191 | function restoreDefaultRealCursor(): void { |
192 | | - // Restore the real cursor to default style |
| 192 | + // Restore cursor to default style and visibility |
193 | 193 | process.stdout.write(SET_CURSOR_DEFAULT) |
194 | 194 | } |
195 | 195 |
|
196 | 196 | function positionRealCursor(): void { |
| 197 | + // Position cursor at the input area where typing occurs |
| 198 | + // Cursor hiding is handled separately in setupRealCursor() |
197 | 199 | const metrics = getTerminalMetrics() |
198 | 200 | const inputAreaHeight = calculateInputAreaHeight(metrics) |
199 | 201 |
|
@@ -227,9 +229,6 @@ function positionRealCursor(): void { |
227 | 229 |
|
228 | 230 | process.stdout.write(MOVE_CURSOR(cursorRow, cursorCol)) |
229 | 231 | } |
230 | | - |
231 | | - // Show the real cursor |
232 | | - process.stdout.write(SHOW_CURSOR) |
233 | 232 | } |
234 | 233 |
|
235 | 234 | export function isInChatMode(): boolean { |
@@ -404,14 +403,6 @@ function updateContentLines() { |
404 | 403 | } |
405 | 404 | }) |
406 | 405 |
|
407 | | - // Add fake visual cursor indicator for assistant messages that are currently streaming |
408 | | - // This is NOT the real cursor - it's a visual character (▊) to show streaming status |
409 | | - if (message.isStreaming && message.role === 'assistant') { |
410 | | - const indentSize = stringWidth(prefix) |
411 | | - const fakeVisualCursor = ' '.repeat(indentSize) + gray('▊') |
412 | | - lines.push(' '.repeat(metrics.sidePadding) + fakeVisualCursor) |
413 | | - } |
414 | | - |
415 | 406 | if (index < chatState.messages.length - 1) { |
416 | 407 | lines.push('') // Add spacing between messages |
417 | 408 | } |
|
0 commit comments