feat: add Rewind Confirmation dialog and Rewind Viewer component (#15717)

This commit is contained in:
Adib234
2026-01-14 10:22:21 -05:00
committed by GitHub
parent 3b55581aaf
commit dfb7dc7069
19 changed files with 1318 additions and 27 deletions

View File

@@ -61,3 +61,37 @@ export const formatDuration = (milliseconds: number): string => {
return parts.join(' ');
};
export const formatTimeAgo = (date: string | number | Date): string => {
const past = new Date(date);
if (isNaN(past.getTime())) {
return 'invalid date';
}
const now = new Date();
const diffMs = now.getTime() - past.getTime();
if (diffMs < 60000) {
return 'just now';
}
return `${formatDuration(diffMs)} ago`;
};
const REFERENCE_CONTENT_START = '--- Content from referenced files ---';
const REFERENCE_CONTENT_END = '--- End of content ---';
/**
* Removes content bounded by reference content markers from the given text.
* The markers are "--- Content from referenced files ---" and "--- End of content ---".
*
* @param text The input text containing potential reference blocks.
* @returns The text with reference blocks removed and trimmed.
*/
export function stripReferenceContent(text: string): string {
// Match optional newline, the start marker, content (non-greedy), and the end marker
const pattern = new RegExp(
`\\n?${REFERENCE_CONTENT_START}[\\s\\S]*?${REFERENCE_CONTENT_END}`,
'g',
);
return text.replace(pattern, '').trim();
}