MCPcopy
hub / github.com/codeaashu/claude-code / handleRewindFiles

Function handleRewindFiles

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

Source from the content-addressed store, hash-verified

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