Skip to content

feat(FileUploader): empty the uploader after a successful submit - #15

Merged
thorwhalen merged 3 commits into
masterfrom
feat/clear-file-uploader-after-submit
Oct 13, 2026
Merged

thorwhalen merged 3 commits into
masterfrom
feat/clear-file-uploader-after-submit

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

Fixes i2mint/front#24 (needs the clear_after_submit field from i2mint/front#35, merged; the code reads it with a default of True so it also runs on an older front).

After a successful, non-auto_submit submit, every FileUploader of the section (also inside a MultiSourceInput) with clear_after_submit (default True) is emptied, so the next batch doesn't start from the previous selection. Streamlit can only empty an uploader by giving it a new key, so the uploader keeps an st.empty() slot, bumps a key generation in session state and draws a fresh uploader into the same slot in the same run: no rerun, so the output and anything the function or on_submit draws stay in place. clear_after_submit=False keeps the old behaviour. The widget now has an explicit key (this also fixes a crash with two identical unkeyed uploaders on a page).

Tests: tests/test_file_uploader_clear.py runs the app headlessly with AppTest (clears, output kept, second batch clean, opt-out, failed submit keeps the selection, multi-source).

Adversarial review (fresh Opus subagent, two rounds): round 1 found my first design (rerun + stashed output) lost anything drawn by the function/on_submit, and keyed the stash by section name: replaced by the in-place redraw. Round 2 found a stale slot could be redrawn for a source not drawn in this run (apps cached across runs): slots are now reset at the start of each run. Deferred: uploaders inside a KwargsInput are not cleared (#14).

Dependents gate (priv test-dependents streamlitfront --transitive): pass.

🤖 Generated with Claude Code

thorwhalen and others added 3 commits October 13, 2026 05:49
…int/front#24)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… and anything drawn on submit stay (#front24)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit 922d8b0 into master Oct 13, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the feat/clear-file-uploader-after-submit branch October 13, 2026 06:00
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.

Consecutive file uploads should not show previous selections by default

1 participant