MCPcopy
hub / github.com/claude-code-best/claude-code / addToHistory

Function addToHistory

src/history.ts:411–434  ·  view source on GitHub ↗
(command: HistoryEntry | string)

Source from the content-addressed store, hash-verified

409}
410
411export function addToHistory(command: HistoryEntry | string): void {
412 // Skip history when running in a tmux session spawned by Claude Code's Tungsten tool.
413 // This prevents verification/test sessions from polluting the user's real command history.
414 if (isEnvTruthy(process.env.CLAUDE_CODE_SKIP_PROMPT_HISTORY)) {
415 return
416 }
417
418 // Register cleanup on first use
419 if (!cleanupRegistered) {
420 cleanupRegistered = true
421 registerCleanup(async () => {
422 // If there's an in-progress flush, wait for it
423 if (currentFlushPromise) {
424 await currentFlushPromise
425 }
426 // If there are still pending entries after the flush completed, do one final flush
427 if (pendingEntries.length > 0) {
428 await immediateFlushHistory()
429 }
430 })
431 }
432
433 void addToPromptHistory(command)
434}
435
436export function clearPendingHistoryEntries(): void {
437 pendingEntries = []

Callers 3

runFunction · 0.85
REPLFunction · 0.85
useTextInputFunction · 0.85

Calls 4

registerCleanupFunction · 0.85
immediateFlushHistoryFunction · 0.85
addToPromptHistoryFunction · 0.85
isEnvTruthyFunction · 0.50

Tested by

no test coverage detected