Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Fix a bug where a removed name still appeared in rename drop-down list
Browse files
ui.py
CHANGED
|
@@ -226,14 +226,27 @@ def render_speaker_samples_tab(speakerNames, raw_to_display, currFile):
|
|
| 226 |
if "inline_rename_active" not in st.session_state:
|
| 227 |
st.session_state.inline_rename_active = {}
|
| 228 |
|
| 229 |
-
# Build the history list
|
| 230 |
-
#
|
| 231 |
-
#
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
|
| 238 |
def _get_role(sp):
|
| 239 |
"""Return the role name assigned to this speaker, or empty string."""
|
|
|
|
| 226 |
if "inline_rename_active" not in st.session_state:
|
| 227 |
st.session_state.inline_rename_active = {}
|
| 228 |
|
| 229 |
+
# Build the history list fresh each render:
|
| 230 |
+
# 1. Names currently in globalRenames (sidebar rename entries)
|
| 231 |
+
# 2. Names actively used in speakerRenames (confirmed via rename tab)
|
| 232 |
+
# Deleted sidebar entries are excluded automatically since we rebuild from scratch.
|
| 233 |
+
global_names = {entry["name"] for entry in st.session_state.globalRenames}
|
| 234 |
+
active_names = {
|
| 235 |
+
name
|
| 236 |
+
for renames in st.session_state.speakerRenames.values()
|
| 237 |
+
for name in renames.values()
|
| 238 |
+
}
|
| 239 |
+
# Preserve any tab-confirmed names that aren't in either set (typed manually)
|
| 240 |
+
# but drop names that were only ever in globalRenames and have since been removed.
|
| 241 |
+
prev_history = st.session_state.get("inline_rename_history", [])
|
| 242 |
+
st.session_state.inline_rename_history = [
|
| 243 |
+
name for name in prev_history
|
| 244 |
+
if name in global_names or name in active_names
|
| 245 |
+
]
|
| 246 |
+
# Add any new names from globalRenames not yet in history
|
| 247 |
+
for name in global_names:
|
| 248 |
+
if name not in st.session_state.inline_rename_history:
|
| 249 |
+
st.session_state.inline_rename_history.append(name)
|
| 250 |
|
| 251 |
def _get_role(sp):
|
| 252 |
"""Return the role name assigned to this speaker, or empty string."""
|