codeep 1.0.36 → 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,7 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useMemo, useEffect, useRef } from 'react';
3
3
  import { Text, Box, useInput } from 'ink';
4
- import clipboard from 'clipboardy';
5
4
  const COMMANDS = [
6
5
  { cmd: '/help', desc: 'Show help' },
7
6
  { cmd: '/status', desc: 'Show status' },
@@ -33,8 +32,10 @@ export const ChatInput = ({ onSubmit, disabled, history = [], clearTrigger = 0 }
33
32
  const [selectedIndex, setSelectedIndex] = useState(0);
34
33
  const [pasteInfo, setPasteInfo] = useState(null);
35
34
  const [historyIndex, setHistoryIndex] = useState(-1);
36
- const lastInputTime = useRef(0);
35
+ // Paste detection using timing - chars arriving < 5ms apart = paste
37
36
  const inputBuffer = useRef('');
37
+ const lastInputTime = useRef(0);
38
+ const pasteTimeout = useRef(null);
38
39
  // Clear input when clearTrigger changes
39
40
  useEffect(() => {
40
41
  if (clearTrigger > 0) {
@@ -57,27 +58,21 @@ export const ChatInput = ({ onSubmit, disabled, history = [], clearTrigger = 0 }
57
58
  setSelectedIndex(0);
58
59
  }
59
60
  }, [suggestions.length]);
60
- // Detect paste by checking for rapid input (multiple chars in < 50ms)
61
- const detectPaste = (newChars) => {
62
- const now = Date.now();
63
- const timeDiff = now - lastInputTime.current;
64
- // If multiple characters arrive very quickly, it's likely a paste
65
- if (timeDiff < 50 && newChars.length > 0) {
66
- inputBuffer.current += newChars;
67
- return true;
61
+ // Process buffered input - called after paste timeout
62
+ const processBuffer = () => {
63
+ const buffer = inputBuffer.current;
64
+ inputBuffer.current = '';
65
+ if (!buffer)
66
+ return;
67
+ // If buffer has multiple chars (> 20), treat as paste and show indicator
68
+ if (buffer.length > 20) {
69
+ handlePastedText(buffer, true);
68
70
  }
69
- // Process any buffered paste
70
- if (inputBuffer.current.length > 5) {
71
- // This was a paste that just finished
72
- const pastedText = inputBuffer.current;
73
- inputBuffer.current = '';
74
- handlePastedText(pastedText);
75
- lastInputTime.current = now;
76
- return true;
71
+ else {
72
+ // Short buffer - just add to value normally
73
+ setValue(prev => prev + buffer);
74
+ setCursorPos(prev => prev + buffer.length);
77
75
  }
78
- inputBuffer.current = newChars;
79
- lastInputTime.current = now;
80
- return false;
81
76
  };
82
77
  const handlePastedText = (text, fromCtrlV = false) => {
83
78
  const trimmed = text.trim();
@@ -113,15 +108,6 @@ export const ChatInput = ({ onSubmit, disabled, history = [], clearTrigger = 0 }
113
108
  useInput((input, key) => {
114
109
  if (disabled)
115
110
  return;
116
- // Handle Ctrl+V paste
117
- if (key.ctrl && input === 'v') {
118
- clipboard.read().then(text => {
119
- if (text) {
120
- handlePastedText(text, true);
121
- }
122
- }).catch(() => { });
123
- return;
124
- }
125
111
  // Handle Enter - submit
126
112
  if (key.return) {
127
113
  if (value.trim()) {
@@ -243,34 +229,33 @@ export const ChatInput = ({ onSubmit, disabled, history = [], clearTrigger = 0 }
243
229
  }
244
230
  // Regular character input
245
231
  if (input && !key.ctrl && !key.meta) {
246
- // If we have paste info, clear it when user starts typing
232
+ // If we have paste info and user types new char, clear paste
247
233
  if (pasteInfo) {
248
234
  setPasteInfo(null);
249
235
  setValue('');
250
236
  setCursorPos(0);
251
237
  }
252
- // 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)
253
255
  setValue(prev => prev.slice(0, cursorPos) + input + prev.slice(cursorPos));
254
256
  setCursorPos(prev => prev + input.length);
255
257
  }
256
258
  }, { isActive: !disabled });
257
- // Process any remaining buffered input after a delay
258
- useEffect(() => {
259
- const timer = setTimeout(() => {
260
- if (inputBuffer.current.length > 0) {
261
- const buffered = inputBuffer.current;
262
- inputBuffer.current = '';
263
- if (buffered.length > 5) {
264
- handlePastedText(buffered);
265
- }
266
- else {
267
- setValue(prev => prev + buffered);
268
- setCursorPos(prev => prev + buffered.length);
269
- }
270
- }
271
- }, 100);
272
- return () => clearTimeout(timer);
273
- }, [value]);
274
259
  // Render input with cursor
275
260
  const renderInput = () => {
276
261
  if (!value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.0.36",
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",