MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / undoAvailabilityFromContext

Function undoAvailabilityFromContext

apps/kimi-code/src/tui/commands/undo.ts:214–232  ·  view source on GitHub ↗
(
  history: readonly ContextMessage[],
)

Source from the content-addressed store, hash-verified

212}
213
214function undoAvailabilityFromContext(
215 history: readonly ContextMessage[],
216): UndoAvailability {
217 let maxCount = 0;
218 let stoppedAtCompaction = false;
219
220 for (let i = history.length - 1; i >= 0; i--) {
221 const message = history[i];
222 if (message === undefined) continue;
223 if (message.origin?.kind === 'injection') continue;
224 if (message.origin?.kind === 'compaction_summary') {
225 stoppedAtCompaction = true;
226 break;
227 }
228 if (isContextUndoAnchor(message)) maxCount++;
229 }
230
231 return { maxCount, stoppedAtCompaction };
232}
233
234function isContextUndoAnchor(message: ContextMessage): boolean {
235 if (message.role !== 'user') return false;

Callers 1

resolveUndoAvailabilityFunction · 0.85

Calls 1

isContextUndoAnchorFunction · 0.85

Tested by

no test coverage detected