MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / addToHistory

Function addToHistory

apps/cli/src/lib/storage/history.ts:90–109  ·  view source on GitHub ↗
(entry: string)

Source from the content-addressed store, hash-verified

88 * Returns the updated history array
89 */
90export async function addToHistory(entry: string): Promise<string[]> {
91 const trimmed = entry.trim()
92
93 // Don't add empty entries
94 if (!trimmed) {
95 return await loadHistory()
96 }
97
98 const history = await loadHistory()
99
100 // Don't add consecutive duplicates
101 if (history.length > 0 && history[history.length - 1] === trimmed) {
102 return history
103 }
104
105 const updated = [...history, trimmed]
106 await saveHistory(updated)
107
108 return updated.slice(-MAX_HISTORY_ENTRIES)
109}

Callers 2

history.test.tsFile · 0.85
useInputHistoryFunction · 0.85

Calls 2

loadHistoryFunction · 0.85
saveHistoryFunction · 0.85

Tested by

no test coverage detected