Repository navigation
Make hosted Gradio sessions identity-aware, release hand-off sessions and fix non-ASCII downloads - #21
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Addresses review on RosettaCommons#21: - results_by_client is now a bounded OrderedDict (MAX_TRACKED_CLIENTS); evicting the oldest tab releases its tracked sessions, so a public host cannot grow the registry without bound. - A generation that fails partway (e.g. a later design fails to open) now closes the result sessions it already opened, instead of leaking them. - When a tab generates from one of its own earlier designs, that design is kept in the registry so a later generation from a different source still releases it, rather than leaving it until global eviction. Three regression tests, each failing before the change and passing after.
|
Thanks — all three points addressed in the latest commit:
Three regression tests, each failing before the change and passing after. |
49782f3 to
6bad979
Compare
Addresses review on RosettaCommons#21: - results_by_client is now a bounded OrderedDict (MAX_TRACKED_CLIENTS); evicting the oldest tab releases its tracked sessions, so a public host cannot grow the registry without bound. - A generation that fails partway (e.g. a later design fails to open) now closes the result sessions it already opened, instead of leaking them. - When a tab generates from one of its own earlier designs, that design is kept in the registry so a later generation from a different source still releases it, rather than leaving it until global eviction. Three regression tests, each failing before the change and passing after.
Addresses the second review on RosettaCommons#21: a call to the exposed generate API without a Gradio session_hash skipped the registry, so its result sessions stayed in the store until Studio's global eviction. Such a call now gets its own key in the same bounded registry, so its results are released in order when the registry evicts it. The caller still receives the session ids it was returned.
- GET /sessions/{id}/cif returned 500 (UnicodeEncodeError: 'latin-1') when
the uploaded file name was not Latin-1, e.g. a Cyrillic name. It now emits
an RFC 6266 header: a sanitized ASCII filename plus filename*=UTF-8''.
- The per-document interaction-analysis cache was unbounded within a revision
(keys include full selection tuples). It is now an 8-entry LRU.
- Forward the proxy-authenticated identity header on in-process Studio hand-off calls. In ANNOTATION_STUDIO_IDENTITY_HEADER mode every hand-off was a 401, so generation could not run, and results are now owned by the user whose iframe opens them. - Release hand-off sessions: generate_cif deletes its temporary input session, and a browser tab's earlier designs are deleted when it generates again (the session it generated from is kept). Unreleased sessions filled the 64-slot store and evicted other users' live sessions. - Persist the document revision in session snapshots so a client's stale expected_revision cannot match a different state after a restart. Undo history is still memory-only.
Addresses review on RosettaCommons#21: - results_by_client is now a bounded OrderedDict (MAX_TRACKED_CLIENTS); evicting the oldest tab releases its tracked sessions, so a public host cannot grow the registry without bound. - A generation that fails partway (e.g. a later design fails to open) now closes the result sessions it already opened, instead of leaking them. - When a tab generates from one of its own earlier designs, that design is kept in the registry so a later generation from a different source still releases it, rather than leaving it until global eviction. Three regression tests, each failing before the change and passing after.
Addresses the second review on RosettaCommons#21: a call to the exposed generate API without a Gradio session_hash skipped the registry, so its result sessions stayed in the store until Studio's global eviction. Such a call now gets its own key in the same bounded registry, so its results are released in order when the registry evicts it. The caller still receives the session ids it was returned.
6bad979 to
392bc03
Compare
|
Rebased onto current Conflicts resolved in One gap to flag: the new design-card mode ( |


What this fixes
ANNOTATION_STUDIO_IDENTITY_HEADERset, every in-processStudioHandoffcall returned 401, so Generate design and thegenerate_cifAPI could not run. The ASGI transport never forwarded the user's identity. The hand-off now forwards the configured header from the incominggr.Request. That request came through the same trusted proxy, so the header is as trustworthy as the browser's own Studio requests. Results are owned by that user, so the iframe can open them and other users get 404.generate_cifopened one more, all left in the 64-slot store. The store evicts by global LRU, so after 64 opens another user's live session returned 404 and their unsaved edits were gone. Nowgenerate_cifdeletes its temporary session, and a tab's earlier designs are deleted when it generates again. The session it generated from is kept, even if it is itself an earlier design.ANNOTATION_STUDIO_SESSION_DIR, a reload restartedrevisionat 0. A client's staleexpected_revision, such as a target-discard confirmation, could then match a different document state. The revision is now stored in the snapshot metadata. Old snapshots without it still load. Undo history stays memory-only, because persisting it would cost one CIF serialization per entry on every edit (60–100 ms each on the bundled examples).UnicodeEncodeError: 'latin-1'). The handler now emits an RFC 6266 header: a sanitized ASCIIfilenameplusfilename*=UTF-8''….Validation
unitsuite: 389 passed, 19 skipped, 0 failed.ruffis clean.tests/test_backend_review_fixes.pyfails on Fix CI: open rebuilt examples as Annotated CIF and protonate them #20's code and passes here. It uses a minimal stand-inGenerationProvider, so it does not depend on the RFD4 provider's controls.test_api.pygains a non-ASCII download test.Heads-up: overlap with
codex/generation-progress-layoutThat unmerged branch edits the same lines in
gradio.py. Merging the two produces 3 small conflicts, each resolved by keeping both sides (the newclose()alongside yourframe(..., example=), andheadersalongside yourvalidate_input). With that resolution the full suite passes: 403 passed, 0 failed. Happy to rebase this onto it once it lands.Not addressed
Store eviction is still global LRU with no per-owner quota. That is a policy choice I left for you.