fix: Update directory browsing to correctly sync input fields and session state

This commit is contained in:
Bobby Abellana (aider) 2025-02-11 11:05:44 -08:00
parent c6dc3455ac
commit f010ee57cf

View File

@ -155,24 +155,30 @@ with col1:
help=f"You can upload multiple {file_type} files" help=f"You can upload multiple {file_type} files"
) )
else: # Select Directory else: # Select Directory
# Source Directory
source_dir = st.text_input("Source Directory Path", source_dir = st.text_input("Source Directory Path",
value=st.session_state.get('source_dir', ''), value=st.session_state.get('source_dir', ''),
key='source_dir_input',
help="Enter the full path to the directory containing files to process") help="Enter the full path to the directory containing files to process")
source_browse = st.button("Browse Source Directory") source_browse = st.button("Browse Source Directory")
if source_browse: if source_browse:
path = get_directory_path("Select Source Directory") path = get_directory_path("Select Source Directory")
if path: if path:
st.session_state['source_dir'] = path st.session_state['source_dir'] = path
st.session_state['source_dir_input'] = path
st.experimental_rerun() st.experimental_rerun()
# Destination Directory
dest_dir = st.text_input("Destination Directory Path", dest_dir = st.text_input("Destination Directory Path",
value=st.session_state.get('dest_dir', ''), value=st.session_state.get('dest_dir', ''),
key='dest_dir_input',
help="Enter the full path where processed files will be saved") help="Enter the full path where processed files will be saved")
dest_browse = st.button("Browse Destination Directory") dest_browse = st.button("Browse Destination Directory")
if dest_browse: if dest_browse:
path = get_directory_path("Select Destination Directory") path = get_directory_path("Select Destination Directory")
if path: if path:
st.session_state['dest_dir'] = path st.session_state['dest_dir'] = path
st.session_state['dest_dir_input'] = path
st.experimental_rerun() st.experimental_rerun()
with col2: with col2: