MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / handleRewindFiles

Function handleRewindFiles

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

Source from the content-addressed store, hash-verified

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