fix(web): hide Retry when blob unavailable; failed-state surfaces actionable error
Pending bubbles that survive a reload (or post-redeploy refresh) without a FileSystemFileHandle had no way to recover the original File bytes, so the Retry button silently no-op'd: resumeUpload set state back to 'paused' with no surfaced error, leaving the user stuck. - transferStore: add reactive hasInMemoryFile Set mirroring liveUploadFiles. setInMemoryRef helper keeps both in sync at every set/delete site (startUpload, resumeUpload, onSuccess, remove). Persisted shape is unchanged. - resumeUpload: when no blob is reachable (no in-memory File and no FS handle), call setError with an actionable "File no longer available — discard and re-upload" message instead of silently flipping back to 'paused'. - Message.tsx: compute canRetry reactively from transfersForRow + hasInMemoryFile; hide the Retry button when retry is infeasible. Discard remains. - AttachmentProgress: optional error prop surfaces transfer.error.message via title= on the failed-state ring for hover context. - Tests: existing 3 resumeUpload tests now assert state==='failed' with the actionable message; +2 new tests for hasInMemoryFile lifecycle (start/remove, abort retains).
This commit is contained in:
@@ -6,6 +6,8 @@ interface Props {
|
||||
total: number;
|
||||
state: TransferState;
|
||||
filename: string;
|
||||
/** Optional human-readable error surfaced as a hover tooltip when state==='failed'. */
|
||||
error?: string;
|
||||
onPause?: () => void;
|
||||
onResume?: () => void;
|
||||
onAbort?: () => void;
|
||||
@@ -19,7 +21,7 @@ function fmt(bytes: number): string {
|
||||
return `${(bytes / 1024 / 1024 / 1024).toFixed(2)} GB`;
|
||||
}
|
||||
|
||||
export function AttachmentProgress({ loaded, total, state, filename, onPause, onResume, onAbort, size = 'tile' }: Props) {
|
||||
export function AttachmentProgress({ loaded, total, state, filename, error, onPause, onResume, onAbort, size = 'tile' }: Props) {
|
||||
const pct = total > 0 ? Math.min(100, Math.round((loaded / total) * 100)) : 0;
|
||||
const bg = state === 'failed' ? 'bg-accent-rose/30' : 'bg-accent-mint/30';
|
||||
const isFinal = state === 'completed' || state === 'aborted';
|
||||
@@ -28,6 +30,7 @@ export function AttachmentProgress({ loaded, total, state, filename, onPause, on
|
||||
<div
|
||||
className={`w-9 h-9 rounded-full ${bg} flex items-center justify-center`}
|
||||
style={state !== 'failed' ? { background: `conic-gradient(rgba(180,220,200,.85) ${pct}%, rgba(255,255,255,.15) ${pct}%)` } : undefined}
|
||||
title={state === 'failed' ? error : undefined}
|
||||
>
|
||||
<div className="w-7 h-7 rounded-full bg-surface-overlay text-[10px] text-txt-primary flex items-center justify-center font-medium">
|
||||
{state === 'failed' ? '!' : `${pct}%`}
|
||||
|
||||
Reference in New Issue
Block a user