codeep 1.0.37 → 1.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useMemo, useEffect } from 'react';
3
- import { Text, Box, useInput, useStdin } from 'ink';
2
+ import { useState, useMemo, useEffect, useRef } from 'react';
3
+ import { Text, Box, useInput } from 'ink';
4
4
  const COMMANDS = [
5
5
  { cmd: '/help', desc: 'Show help' },
6
6
  { cmd: '/status', desc: 'Show status' },
@@ -32,7 +32,10 @@ export const ChatInput = ({ onSubmit, disabled, history = [], clearTrigger = 0 }
32
32
  const [selectedIndex, setSelectedIndex] = useState(0);
33
33
  const [pasteInfo, setPasteInfo] = useState(null);
34
34
  const [historyIndex, setHistoryIndex] = useState(-1);
35
- const { stdin } = useStdin();
35
+ // Paste detection using timing - chars arriving < 5ms apart = paste
36
+ const inputBuffer = useRef('');
37
+ const lastInputTime = useRef(0);
38
+ const pasteTimeout = useRef(null);
36
39
  // Clear input when clearTrigger changes
37
40
  useEffect(() => {
38
41
  if (clearTrigger > 0) {
@@ -55,24 +58,22 @@ export const ChatInput = ({ onSubmit, disabled, history = [], clearTrigger = 0 }
55
58
  setSelectedIndex(0);
56
59
  }
57
60
  }, [suggestions.length]);
58
- // Listen for raw stdin data to detect paste (multiple chars at once)
59
- useEffect(() => {
60
- if (disabled || !stdin)
61
+ // Process buffered input - called after paste timeout
62
+ const processBuffer = () => {
63
+ const buffer = inputBuffer.current;
64
+ inputBuffer.current = '';
65
+ if (!buffer)
61
66
  return;
62
- const handleData = (data) => {
63
- const str = data.toString();
64
- // Detect paste: multiple printable characters arriving at once
65
- // Exclude control sequences (start with ESC)
66
- if (str.length > 1 && !str.startsWith('\x1b') && !str.startsWith('\x16')) {
67
- // This is likely a paste - multiple chars at once
68
- handlePastedText(str, true);
69
- }
70
- };
71
- stdin.on('data', handleData);
72
- return () => {
73
- stdin.off('data', handleData);
74
- };
75
- }, [disabled, stdin]);
67
+ // If buffer has multiple chars (> 20), treat as paste and show indicator
68
+ if (buffer.length > 20) {
69
+ handlePastedText(buffer, true);
70
+ }
71
+ else {
72
+ // Short buffer - just add to value normally
73
+ setValue(prev => prev + buffer);
74
+ setCursorPos(prev => prev + buffer.length);
75
+ }
76
+ };
76
77
  const handlePastedText = (text, fromCtrlV = false) => {
77
78
  const trimmed = text.trim();
78
79
  if (!trimmed)
@@ -228,13 +229,29 @@ export const ChatInput = ({ onSubmit, disabled, history = [], clearTrigger = 0 }
228
229
  }
229
230
  // Regular character input
230
231
  if (input && !key.ctrl && !key.meta) {
231
- // If we have paste info, clear it when user starts typing
232
+ // If we have paste info and user types new char, clear paste
232
233
  if (pasteInfo) {
233
234
  setPasteInfo(null);
234
235
  setValue('');
235
236
  setCursorPos(0);
236
237
  }
237
- // Normal single character input
238
+ const now = Date.now();
239
+ const timeSinceLastInput = now - lastInputTime.current;
240
+ lastInputTime.current = now;
241
+ // If chars arrive very fast (< 5ms apart), buffer them as paste
242
+ if (timeSinceLastInput < 5 || inputBuffer.current.length > 0) {
243
+ inputBuffer.current += input;
244
+ // Clear existing timeout
245
+ if (pasteTimeout.current) {
246
+ clearTimeout(pasteTimeout.current);
247
+ }
248
+ // Set timeout to process buffer
249
+ pasteTimeout.current = setTimeout(() => {
250
+ processBuffer();
251
+ }, 10);
252
+ return; // Don't add to value yet
253
+ }
254
+ // Normal single character input (slow typing)
238
255
  setValue(prev => prev.slice(0, cursorPos) + input + prev.slice(cursorPos));
239
256
  setCursorPos(prev => prev + input.length);
240
257
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",