linguabot commited on
Commit
e0aeefd
·
verified ·
1 Parent(s): e9db41c

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. client/src/components/Refinity.tsx +14 -8
client/src/components/Refinity.tsx CHANGED
@@ -159,6 +159,7 @@ const Refinity: React.FC = () => {
159
  const [revDownloadOpen, setRevDownloadOpen] = React.useState<boolean>(false);
160
  // --- Route persistence (hash-based) ---
161
  const restoringRef = React.useRef<boolean>(false);
 
162
  const initialRouteRef = React.useRef<{ stage?: Stage; taskId?: string; versionId?: string; previewId?: string; fullscreen?: boolean } | null>(null);
163
  const parseRouteHash = React.useCallback((): Record<string, string> => {
164
  try {
@@ -316,7 +317,7 @@ const Refinity: React.FC = () => {
316
  try { sessionStorage.setItem(versionsCacheKey(task.id), JSON.stringify(normalized)); } catch {}
317
  // Restore stage/version from initial route if present
318
  const init = initialRouteRef.current;
319
- if (init?.stage && normalized.length) {
320
  restoringRef.current = true;
321
  try {
322
  if (init.stage === 'editor' && init.versionId && normalized.some(v => v.id === init.versionId)) {
@@ -338,6 +339,8 @@ const Refinity: React.FC = () => {
338
  } finally {
339
  // small defer to avoid immediate hash writes during restore
340
  setTimeout(() => { restoringRef.current = false; }, 50);
 
 
341
  }
342
  } else {
343
  // No init; do not force stage change if already 'editor' or 'preview'
@@ -712,10 +715,11 @@ const Refinity: React.FC = () => {
712
  if (!resp.ok) throw new Error('Delete failed');
713
  setTasks(prev => prev.filter(t => t.id !== task.id));
714
  setVersions([]);
715
- setSelectedTaskId(prev => {
716
- const remaining = tasks.filter(t => t.id !== (task?.id || ''));
717
- return remaining.length ? remaining[0].id : '';
718
- });
 
719
  setStage('task');
720
  } catch {}
721
  }, [isAdmin, task?.id, tasks, username]);
@@ -1363,8 +1367,8 @@ const Refinity: React.FC = () => {
1363
  </div>
1364
  {compareModalOpen && (
1365
  <div className="fixed inset-0 z-50 bg-black/40 flex items-center justify-center p-4" role="dialog" aria-modal="true">
1366
- <div className="relative max-w-5xl w-full rounded-2xl bg-white shadow-2xl ring-1 ring-gray-200 p-6">
1367
- <div className="flex items-center justify-between mb-3">
1368
  <div className="text-gray-800 font-medium">Diff</div>
1369
  <div className="flex items-center gap-2">
1370
  <button onClick={async()=>{
@@ -1410,7 +1414,9 @@ const Refinity: React.FC = () => {
1410
  <button onClick={()=>setCompareModalOpen(false)} className="px-3 py-1.5 text-sm rounded-md border border-gray-300 bg-white">Close</button>
1411
  </div>
1412
  </div>
1413
- <div className="prose prose-sm max-w-none text-gray-900 whitespace-pre-wrap" dangerouslySetInnerHTML={{ __html: compareDiffHtml }} />
 
 
1414
  </div>
1415
  </div>
1416
  )}
 
159
  const [revDownloadOpen, setRevDownloadOpen] = React.useState<boolean>(false);
160
  // --- Route persistence (hash-based) ---
161
  const restoringRef = React.useRef<boolean>(false);
162
+ const appliedInitialRouteRef = React.useRef<boolean>(false);
163
  const initialRouteRef = React.useRef<{ stage?: Stage; taskId?: string; versionId?: string; previewId?: string; fullscreen?: boolean } | null>(null);
164
  const parseRouteHash = React.useCallback((): Record<string, string> => {
165
  try {
 
317
  try { sessionStorage.setItem(versionsCacheKey(task.id), JSON.stringify(normalized)); } catch {}
318
  // Restore stage/version from initial route if present
319
  const init = initialRouteRef.current;
320
+ if (!appliedInitialRouteRef.current && init?.stage && normalized.length && (!init.taskId || init.taskId === task.id)) {
321
  restoringRef.current = true;
322
  try {
323
  if (init.stage === 'editor' && init.versionId && normalized.some(v => v.id === init.versionId)) {
 
339
  } finally {
340
  // small defer to avoid immediate hash writes during restore
341
  setTimeout(() => { restoringRef.current = false; }, 50);
342
+ appliedInitialRouteRef.current = true;
343
+ initialRouteRef.current = null;
344
  }
345
  } else {
346
  // No init; do not force stage change if already 'editor' or 'preview'
 
715
  if (!resp.ok) throw new Error('Delete failed');
716
  setTasks(prev => prev.filter(t => t.id !== task.id));
717
  setVersions([]);
718
+ // Stay on landing; do not auto-navigate into flow for another task
719
+ const remaining = tasks.filter(t => t.id !== (task?.id || ''));
720
+ setSelectedTaskId(remaining.length ? remaining[0].id : '');
721
+ appliedInitialRouteRef.current = true; // prevent any hash restore from forcing stage
722
+ initialRouteRef.current = null;
723
  setStage('task');
724
  } catch {}
725
  }, [isAdmin, task?.id, tasks, username]);
 
1367
  </div>
1368
  {compareModalOpen && (
1369
  <div className="fixed inset-0 z-50 bg-black/40 flex items-center justify-center p-4" role="dialog" aria-modal="true">
1370
+ <div className="relative max-w-5xl w-full max-h-[85vh] rounded-2xl bg-white shadow-2xl ring-1 ring-gray-200 p-0 overflow-hidden">
1371
+ <div className="flex items-center justify-between px-6 pt-5 pb-3 border-b sticky top-0 z-10 bg-white">
1372
  <div className="text-gray-800 font-medium">Diff</div>
1373
  <div className="flex items-center gap-2">
1374
  <button onClick={async()=>{
 
1414
  <button onClick={()=>setCompareModalOpen(false)} className="px-3 py-1.5 text-sm rounded-md border border-gray-300 bg-white">Close</button>
1415
  </div>
1416
  </div>
1417
+ <div className="px-6 pb-6 overflow-auto max-h-[70vh]">
1418
+ <div className="prose prose-sm max-w-none text-gray-900 whitespace-pre-wrap break-words" dangerouslySetInnerHTML={{ __html: compareDiffHtml }} />
1419
+ </div>
1420
  </div>
1421
  </div>
1422
  )}