(command: HistoryEntry | string)
| 409 | } |
| 410 | |
| 411 | export 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 | |
| 436 | export function clearPendingHistoryEntries(): void { |
| 437 | pendingEntries = [] |
no test coverage detected