@cryptiklemur/lattice 1.11.6 → 1.13.0

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.
@@ -6,6 +6,7 @@ import { useAttachments } from "../../hooks/useAttachments";
6
6
  import { useVoiceRecorder } from "../../hooks/useVoiceRecorder";
7
7
  import { AttachmentChips } from "./AttachmentChips";
8
8
  import { VoiceRecorder } from "./VoiceRecorder";
9
+ import { getSessionStore } from "../../stores/session";
9
10
 
10
11
  interface ChatInputProps {
11
12
  onSend: (text: string, attachmentIds: string[]) => void;
@@ -25,6 +26,9 @@ function getModKey(): string {
25
26
  return "Ctrl";
26
27
  }
27
28
 
29
+ var inputHistory: string[] = [];
30
+ var MAX_HISTORY = 100;
31
+
28
32
  export function ChatInput(props: ChatInputProps) {
29
33
  var textareaRef = useRef<HTMLTextAreaElement>(null);
30
34
  var popupRef = useRef<HTMLDivElement>(null);
@@ -35,6 +39,28 @@ export function ChatInput(props: ChatInputProps) {
35
39
  var [selectedIndex, setSelectedIndex] = useState(0);
36
40
  var [showMobileSettings, setShowMobileSettings] = useState(false);
37
41
  var modKey = useMemo(getModKey, []);
42
+ var [historyIndex, setHistoryIndex] = useState(-1);
43
+ var savedCurrentRef = useRef("");
44
+
45
+ useEffect(function () {
46
+ var store = getSessionStore();
47
+ var messages = store.state.messages;
48
+ var seen = new Set<string>();
49
+ for (var i = 0; i < messages.length; i++) {
50
+ if (messages[i].type === "user" && messages[i].text) {
51
+ var text = messages[i].text!.trim();
52
+ if (text && !seen.has(text)) {
53
+ seen.add(text);
54
+ if (inputHistory.indexOf(text) === -1) {
55
+ inputHistory.push(text);
56
+ }
57
+ }
58
+ }
59
+ }
60
+ if (inputHistory.length > MAX_HISTORY) {
61
+ inputHistory.splice(0, inputHistory.length - MAX_HISTORY);
62
+ }
63
+ }, []);
38
64
 
39
65
  var attachmentsHook = useAttachments();
40
66
  var voice = useVoiceRecorder();
@@ -161,6 +187,53 @@ export function ChatInput(props: ChatInputProps) {
161
187
  if (e.key === "Enter" && !e.shiftKey) {
162
188
  e.preventDefault();
163
189
  submit();
190
+ return;
191
+ }
192
+
193
+ if (e.key === "ArrowUp" && inputHistory.length > 0) {
194
+ var el = textareaRef.current;
195
+ if (!el) return;
196
+ var val = el.value;
197
+ var cursorPos = el.selectionStart;
198
+ var isAtTop = cursorPos === 0 || val.indexOf("\n") === -1 || cursorPos <= val.indexOf("\n");
199
+ if (isAtTop) {
200
+ e.preventDefault();
201
+ if (historyIndex === -1) {
202
+ savedCurrentRef.current = val;
203
+ }
204
+ var newIdx = historyIndex === -1 ? inputHistory.length - 1 : Math.max(0, historyIndex - 1);
205
+ setHistoryIndex(newIdx);
206
+ el.value = inputHistory[newIdx];
207
+ el.style.height = "auto";
208
+ el.style.height = Math.min(el.scrollHeight, 160) + "px";
209
+ el.setSelectionRange(0, 0);
210
+ }
211
+ return;
212
+ }
213
+
214
+ if (e.key === "ArrowDown" && historyIndex >= 0) {
215
+ var el = textareaRef.current;
216
+ if (!el) return;
217
+ var val = el.value;
218
+ var cursorPos = el.selectionStart;
219
+ var lastNewline = val.lastIndexOf("\n");
220
+ var isAtBottom = lastNewline === -1 || cursorPos > lastNewline;
221
+ if (isAtBottom) {
222
+ e.preventDefault();
223
+ if (historyIndex >= inputHistory.length - 1) {
224
+ setHistoryIndex(-1);
225
+ el.value = savedCurrentRef.current;
226
+ } else {
227
+ var newIdx = historyIndex + 1;
228
+ setHistoryIndex(newIdx);
229
+ el.value = inputHistory[newIdx];
230
+ }
231
+ el.style.height = "auto";
232
+ el.style.height = Math.min(el.scrollHeight, 160) + "px";
233
+ var len = el.value.length;
234
+ el.setSelectionRange(len, len);
235
+ }
236
+ return;
164
237
  }
165
238
  }
166
239
 
@@ -253,6 +326,14 @@ export function ChatInput(props: ChatInputProps) {
253
326
  if (!el) return;
254
327
  var text = el.value.trim();
255
328
  if ((!text && attachmentsHook.attachments.length === 0) || props.disabled || attachmentsHook.hasUploading) return;
329
+ if (text) {
330
+ if (inputHistory.length === 0 || inputHistory[inputHistory.length - 1] !== text) {
331
+ inputHistory.push(text);
332
+ if (inputHistory.length > MAX_HISTORY) inputHistory.shift();
333
+ }
334
+ }
335
+ setHistoryIndex(-1);
336
+ savedCurrentRef.current = "";
256
337
  props.onSend(text, attachmentsHook.readyIds);
257
338
  el.value = "";
258
339
  el.style.height = "auto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptiklemur/lattice",
3
- "version": "1.11.6",
3
+ "version": "1.13.0",
4
4
  "description": "Multi-machine agentic dashboard for Claude Code. Monitor sessions, manage MCP servers and skills, orchestrate across mesh-networked nodes.",
5
5
  "license": "MIT",
6
6
  "author": "Aaron Scherer <me@aaronscherer.me>",