Spaces:
Sleeping
Sleeping
Update ui.py
Browse files
ui.py
CHANGED
|
@@ -165,8 +165,6 @@ def render_speaker_samples_tab(speakerNames, raw_to_display, currFile):
|
|
| 165 |
if not has_samples:
|
| 166 |
st.info("Audio samples are only available for files analyzed from audio (not RTTM/CSV/TXT).")
|
| 167 |
|
| 168 |
-
NEW_NAME_SENTINEL = "+ Type a new name…"
|
| 169 |
-
|
| 170 |
for sp in speakerNames:
|
| 171 |
display_name = raw_to_display.get(sp, sp)
|
| 172 |
edit_key = (currFile, sp)
|
|
@@ -181,40 +179,38 @@ def render_speaker_samples_tab(speakerNames, raw_to_display, currFile):
|
|
| 181 |
confirm_key = f"inline_rename_confirm_{currFile}_{sp}"
|
| 182 |
cancel_key = f"inline_rename_cancel_{currFile}_{sp}"
|
| 183 |
|
| 184 |
-
history
|
| 185 |
-
current_val
|
| 186 |
-
|
| 187 |
-
# Dropdown options: history entries first, then sentinel for free text
|
| 188 |
-
options = history + [NEW_NAME_SENTINEL]
|
| 189 |
-
|
| 190 |
-
# Pre-select current name if it's already in history
|
| 191 |
-
default_idx = history.index(current_val) if current_val in history else len(history)
|
| 192 |
|
| 193 |
with row_cols[0]:
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
new_name = st.text_input(
|
| 205 |
-
"
|
| 206 |
value=current_val,
|
| 207 |
key=input_key,
|
| 208 |
label_visibility="collapsed",
|
| 209 |
placeholder=f"Rename {sp}…",
|
| 210 |
)
|
| 211 |
-
else:
|
| 212 |
-
new_name = chosen
|
| 213 |
|
| 214 |
btn_col1, btn_col2 = st.columns(2)
|
| 215 |
if btn_col1.button("✓", key=confirm_key, help="Confirm rename"):
|
| 216 |
confirmed = new_name.strip()
|
| 217 |
-
if confirmed
|
| 218 |
apply_inline_rename(currFile, sp, confirmed)
|
| 219 |
if confirmed not in st.session_state.inline_rename_history:
|
| 220 |
st.session_state.inline_rename_history.append(confirmed)
|
|
|
|
| 165 |
if not has_samples:
|
| 166 |
st.info("Audio samples are only available for files analyzed from audio (not RTTM/CSV/TXT).")
|
| 167 |
|
|
|
|
|
|
|
| 168 |
for sp in speakerNames:
|
| 169 |
display_name = raw_to_display.get(sp, sp)
|
| 170 |
edit_key = (currFile, sp)
|
|
|
|
| 179 |
confirm_key = f"inline_rename_confirm_{currFile}_{sp}"
|
| 180 |
cancel_key = f"inline_rename_cancel_{currFile}_{sp}"
|
| 181 |
|
| 182 |
+
history = st.session_state.inline_rename_history
|
| 183 |
+
current_val = display_name if display_name != sp else ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
with row_cols[0]:
|
| 186 |
+
if history:
|
| 187 |
+
# Selectbox with index=None shows placeholder and lets user
|
| 188 |
+
# type to filter — single combined widget, no separate input.
|
| 189 |
+
options = history
|
| 190 |
+
default_idx = history.index(current_val) if current_val in history else None
|
| 191 |
+
chosen = st.selectbox(
|
| 192 |
+
"Rename",
|
| 193 |
+
options=options,
|
| 194 |
+
index=default_idx,
|
| 195 |
+
key=select_key,
|
| 196 |
+
label_visibility="collapsed",
|
| 197 |
+
placeholder="Type or select a name…",
|
| 198 |
+
)
|
| 199 |
+
new_name = chosen or ""
|
| 200 |
+
else:
|
| 201 |
+
# No history yet — plain text input
|
| 202 |
new_name = st.text_input(
|
| 203 |
+
"Rename",
|
| 204 |
value=current_val,
|
| 205 |
key=input_key,
|
| 206 |
label_visibility="collapsed",
|
| 207 |
placeholder=f"Rename {sp}…",
|
| 208 |
)
|
|
|
|
|
|
|
| 209 |
|
| 210 |
btn_col1, btn_col2 = st.columns(2)
|
| 211 |
if btn_col1.button("✓", key=confirm_key, help="Confirm rename"):
|
| 212 |
confirmed = new_name.strip()
|
| 213 |
+
if confirmed:
|
| 214 |
apply_inline_rename(currFile, sp, confirmed)
|
| 215 |
if confirmed not in st.session_state.inline_rename_history:
|
| 216 |
st.session_state.inline_rename_history.append(confirmed)
|