MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / handleRewindFiles

Function handleRewindFiles

source code/cli/print.ts:4522–4568  ·  view source on GitHub ↗
(
  userMessageId: UUID,
  appState: AppState,
  setAppState: (updater: (prev: AppState) => AppState) => void,
  dryRun: boolean,
)

Source from the content-addressed store, hash-verified

4520}
4521
4522async function handleRewindFiles(
4523 userMessageId: UUID,
4524 appState: AppState,
4525 setAppState: (updater: (prev: AppState) => AppState) => void,
4526 dryRun: boolean,
4527): Promise<RewindFilesResult> {
4528 if (!fileHistoryEnabled()) {
4529 return { canRewind: false, error: 'File rewinding is not enabled.' }
4530 }
4531 if (!fileHistoryCanRestore(appState.fileHistory, userMessageId)) {
4532 return {
4533 canRewind: false,
4534 error: 'No file checkpoint found for this message.',
4535 }
4536 }
4537
4538 if (dryRun) {
4539 const diffStats = await fileHistoryGetDiffStats(
4540 appState.fileHistory,
4541 userMessageId,
4542 )
4543 return {
4544 canRewind: true,
4545 filesChanged: diffStats?.filesChanged,
4546 insertions: diffStats?.insertions,
4547 deletions: diffStats?.deletions,
4548 }
4549 }
4550
4551 try {
4552 await fileHistoryRewind(
4553 updater =>
4554 setAppState(prev => ({
4555 ...prev,
4556 fileHistory: updater(prev.fileHistory),
4557 })),
4558 userMessageId,
4559 )
4560 } catch (error) {
4561 return {
4562 canRewind: false,
4563 error: `Failed to rewind: ${errorMessage(error)}`,
4564 }
4565 }
4566
4567 return { canRewind: true }
4568}
4569
4570function handleSetPermissionMode(
4571 request: { mode: InternalPermissionMode },

Callers 2

runHeadlessFunction · 0.85
runHeadlessStreamingFunction · 0.85

Calls 5

fileHistoryEnabledFunction · 0.85
fileHistoryCanRestoreFunction · 0.85
fileHistoryGetDiffStatsFunction · 0.85
fileHistoryRewindFunction · 0.85
errorMessageFunction · 0.50

Tested by

no test coverage detected