Skip to content

feat: track upload progress in attachment preview components#3060

Open
szuperaz wants to merge 6 commits intomasterfrom
file-upload-on-progress
Open

feat: track upload progress in attachment preview components#3060
szuperaz wants to merge 6 commits intomasterfrom
file-upload-on-progress

Conversation

@szuperaz
Copy link
Copy Markdown
Contributor

@szuperaz szuperaz commented Mar 25, 2026

🎯 Goal

https://linear.app/stream/issue/REACT-925/upload-progress-tracking

Depends on: https://github.com/GetStream/stream-chat-js/pull/1708/changes#diff-61c3f170c2f20982af303989006c8317adf3006784ed2b37513e1c50487353d0

🛠 Implementation details

  • New component: ProgressIndicator -> displays a circular progress indicator to track progress from 0 - 100%
  • New component: AttachmentUploadProgressIndicator -> if upload progress is available, it displays ProgressIndicator, otherwise the LoadingIndicator. When is upload progress not available?
    • It's possible that axios can't retrieve upload progress info
    • If someone uses custom CDN uploads, they may not be able to/want to provide progress tracking
  • New component: AttachmentUploadedSizeIndicatorProps to display file size:
    • During upload: 4 MB / 24 MB
    • After upload finished: 24 MB

🎨 UI Changes

Implementing this design: https://www.figma.com/design/Us73erK1xFNcB5EH3hyq6Y/Chat-SDK-Design-System?node-id=3517-102932&t=fizGA6SsyGt3g08F-0

Screenshot 2026-03-25 at 13 51 12 Screenshot 2026-03-25 at 16 01 36

@szuperaz szuperaz force-pushed the file-upload-on-progress branch from 1c15431 to 6c93b9b Compare March 25, 2026 15:14
@szuperaz szuperaz force-pushed the file-upload-on-progress branch from 6c93b9b to 50c8b11 Compare March 25, 2026 15:19
@szuperaz szuperaz marked this pull request as ready for review March 26, 2026 09:59
@szuperaz szuperaz force-pushed the file-upload-on-progress branch 2 times, most recently from d281040 to 9c79553 Compare March 26, 2026 15:05
@szuperaz szuperaz force-pushed the file-upload-on-progress branch from e3e0a90 to db938aa Compare April 1, 2026 14:37
};

/** Circular progress indicator with input from 0 to 100. */
export const ProgressIndicator = ({ percent }: ProgressIndicatorProps) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const ProgressIndicator = ({ percent }: ProgressIndicatorProps) => {
export const CircularProgressIndicator = ({ percent }: ProgressIndicatorProps) => {

In case we added LinearProgressIndicator or any other type of progress indicator.

Comment on lines +24 to +26
const { ProgressIndicator = DefaultProgressIndicator } = useComponentContext(
'AttachmentUploadProgressIndicator',
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { ProgressIndicator = DefaultProgressIndicator } = useComponentContext(
'AttachmentUploadProgressIndicator',
);
const { ProgressIndicator = DefaultProgressIndicator } = useComponentContext();

No need to add the hook arg.

/** Shown when `uploadProgress` is `undefined` (e.g. progress tracking disabled). */
fallback?: ReactNode;
uploadProgress?: number;
variant: AttachmentUploadProgressVariant;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to document what inline and overlay variants mean.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, these names were just derived by AI from the specific way it used them - on overlay and somewhere in text. I see in the CSS that overlay styles icons and inline styles text. But if the designer decided to have the x MB / y MB indicator on the overlay, then we would have the inline variant on the overlay :).

I would be also thinking about what other possible progress indicators are being used generally in other apps, so that more generic names can be applied for variant.

export type AttachmentUploadProgressIndicatorProps = {
className?: string;
/** Shown when `uploadProgress` is `undefined` (e.g. progress tracking disabled). */
fallback?: ReactNode;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be made ComponentType instead of ReactNode? I am thinking that it provides more flexibility to render the component in place, where it is returned, instead somewhere up in the tree.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this prop can be removed if the LoadingIndicator is consumed from the context

<div className='str-chat__attachment-preview-file__data'>
{uploadState === 'uploading' && <LoadingIndicatorIcon />}
{uploadState === 'uploading' && (
<AttachmentUploadProgressIndicator
Copy link
Copy Markdown
Contributor

@MartinCupela MartinCupela Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could introduce UploadIndicator into component context or into the props of this component.

<>
{!resolvedDuration && !progressPercent && !isPlaying && (
<FileSizeIndicator fileSize={attachment.file_size} />
<AttachmentUploadedSizeIndicator attachment={attachment} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could introduce FileSizeIndicator into ComponentContext and the default one could be handling what AttachmentUploadedSizeIndicator handles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants