Repository navigation
feat: make web upload limits configurable - #41
Merged
Merged
Conversation
The largest attachment and the attachments per message of the web interface were fixed at 10 MB and 10 files. They become the settings WEB_UPLOAD_MAX_MB and WEB_MAX_ATTACHMENTS, edited live on the settings page (Advanced, Web interface) up to 100 MB and 50 files, the bounds the protocol keeps. The server checks each upload and message against the settings as they are, and tells every connection the limits in an upload.limits event after auth.ok and whenever either setting changes, so the composer refuses a file before uploading it. PROTOCOL_VERSION goes to 6.
WEB_UPLOAD_MAX_MB takes up to 1024 MB and WEB_MAX_ATTACHMENTS up to 100 attachments per message. The defaults stay at 10 MB and 10 files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The largest attachment and the number of attachments per message of the web interface were fixed at 10 MB and 10 files. They become two settings, edited live on the settings page (Advanced → Web interface).
WEB_UPLOAD_MAX_MB101024WEB_MAX_ATTACHMENTS10100The bounds are what the protocol keeps (
MAX_UPLOAD_MB,MAX_ATTACHMENTS). An upload is written to disk chunk by chunk, so a large file costs time and disk, not memory: with oneupload.ackper 32 KB chunk, 1 GB over remote access takes close to an hour.Changes
Protocol
limits.ts:MAX_UPLOAD_MB = 1024andBYTES_PER_MBreplaceMAX_UPLOAD_BYTES;MAX_ATTACHMENTSis100. Both are the ceilings of the schemas.SETTING_SCHEMASgetsWEB_UPLOAD_MAX_MBandWEB_MAX_ATTACHMENTS.upload.limits { maxBytes, maxAttachments }.PROTOCOL_VERSIONis 6.Server
webgroup,apply: 'live'.WebUploadLimitsServicereads both settings where they are used and broadcastsupload.limitsto every connection when either changes (ISettingsChangeNotifierPort).upload.limitsright afterauth.ok.WebUploadSessionsServicerefuses a file above the limit as it is when the upload starts:File is larger than N MB.SendConversationMessageUseCaserefuses a message with more attachments than the limit with the noticeA message takes at most N attachments. Remove some and send it again.and runs no turn.Web
ConnectionProviderkeeps the lastupload.limitsand exposes it asuploadLimitsinuseConnection().usePromptAttachmentstakes the limits: a file above it fails before uploading (File is larger than N MB), and extra files are dropped. Before the server tells its limits, the protocol's bounds apply.Docs
.env.example, and the settings, web-channel and web-app skills.Upgrading
PROTOCOL_VERSIONgoes to 6, so the hosted web app of remote access needs a server with this change.Testing
pnpm ts,pnpm lint,pnpm test:covandpnpm test:e2epass.upload.limitsafterauth.ok, and broadcast only on a change of these settings;ConnectionProviderkeeping the limits;