Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flav/input bar uses file api #5997

Merged
merged 16 commits into from
Jul 4, 2024
Merged

Flav/input bar uses file api #5997

merged 16 commits into from
Jul 4, 2024

Conversation

flvndvd
Copy link
Contributor

@flvndvd flvndvd commented Jul 2, 2024

Description

In #5977, we introduced a file API to manage all file-related tasks. This PR begins using that endpoint.

The key changes include:

  • Implementing the file API to upload "raw" conversational attachments from the input bar.
  • Removing the legacy logic for uploading raw content fragments. The old endpoint still exists since we can't ensure all users will reload their front-end immediately, but it will be removed in a few days.
  • Enhancing the FileUploaderService to handle all file upload logic. It now exposes a state representing the current status of each file, and the UI adapts based on this status to reflect the latest changes. This is the main change, as we previously did not perform any heavy processing before the user submitted the message. From now on, adding files in the input bar will trigger remote actions. While we best clean up orphaned files, some may inevitably be missed.

Demo:
InputBarUploadFile

Risk

If we rollback, all conversations created during this time, won't support new messages.

Deploy Plan

@flvndvd flvndvd marked this pull request as ready for review July 2, 2024 12:37
@flvndvd flvndvd self-assigned this Jul 2, 2024
Copy link
Contributor

@JulesBelveze JulesBelveze left a comment

Choose a reason for hiding this comment

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

LGTM modulo one comment 🤓 🔥

Comment on lines 1637 to 1651
if (url && url.startsWith(FileResource.baseFileUrl(owner))) {
// Use the provided URL if it is an internal file path.
sourceUrl = url;
} else if (isSupportedUploadableContentFragmentType(contentType)) {
// Deprecated, for supported content types, create a file path and use its download URL.
sourceUrl = fileAttachmentLocation({
workspaceId: owner.sId,
conversationId: conversation.sId,
messageId,
contentFormat: "raw",
}).downloadUrl;
} else {
// Otherwise, use the provided URL (e.g., a Slack thread).
sourceUrl = url;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what's different than previously?
Basically if we not in isSupportedUploadableContentFragmentType(contentType) we set sourceUrl = url, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The difference is that know the client passes an url that points toward our own infrastructure, if this is the case, we use it as the url, otherwise we fallback to the previous logic.

Copy link
Contributor

@JulesBelveze JulesBelveze Jul 2, 2024

Choose a reason for hiding this comment

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

Nitpicking here but unless I'm missing something this is equivalent to:

if (isSupportedUploadableContentFragmentType(contentType)) {
    // Deprecated, for supported content types, create a file path and use its download URL.
    sourceUrl = fileAttachmentLocation({
      workspaceId: owner.sId,
      conversationId: conversation.sId,
      messageId,
      contentFormat: "raw",
    }).downloadUrl;
  } else {
    sourceUrl = url;
  }

@@ -83,6 +88,10 @@ export class FileResource extends BaseResource<FileModel> {
});
}

static baseFileUrl(owner: LightWorkspaceType): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on my previous comment this might be deadcode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is temporary, we will rework this API to accept either a fileId or a content. This is an intermediary state.

@flvndvd flvndvd marked this pull request as draft July 3, 2024 16:30
@flvndvd flvndvd marked this pull request as ready for review July 4, 2024 12:42
Copy link
Contributor

@JulesBelveze JulesBelveze left a comment

Choose a reason for hiding this comment

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

LGTM, super nice 🔥

onClose={() => {
fileUploaderService.removeFile(blob.id);
}}
isLoading={blob.isUploading}
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥

@flvndvd flvndvd merged commit 618f150 into main Jul 4, 2024
5 checks passed
@flvndvd flvndvd deleted the flav/input-bar-uses-file-api branch July 4, 2024 13:15
albandum pushed a commit that referenced this pull request Jul 4, 2024
* Use file upload API in the input bar

* Stop uploading raw content fragment

* ✨

* 👕

* 📝

* ✨

* ✂️

* ✂️

* ✂️

* ✂️

* :sparkles

* ✨
albandum pushed a commit that referenced this pull request Aug 28, 2024
* Use file upload API in the input bar

* Stop uploading raw content fragment

* ✨

* 👕

* 📝

* ✨

* ✂️

* ✂️

* ✂️

* ✂️

* :sparkles

* ✨
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.

2 participants