Better autosave behavior for notebook tab when there are 2 columns

This commit is contained in:
oobabooga 2025-06-18 15:54:32 -07:00
parent 197b327374
commit 6cc7bbf009
2 changed files with 20 additions and 57 deletions

View file

@ -11,7 +11,6 @@ from modules.text_generation import (
get_token_ids,
stop_everything_event
)
from modules.ui_default import autosave_prompt
from modules.utils import gradio
_notebook_file_lock = threading.Lock()
@ -249,6 +248,14 @@ def handle_rename_prompt_confirm_notebook(new_name, current_name):
]
def autosave_prompt(text, prompt_name):
"""Automatically save the text to the selected prompt file"""
if prompt_name and text.strip():
prompt_path = Path("user_data/logs/notebook") / f"{prompt_name}.txt"
prompt_path.parent.mkdir(parents=True, exist_ok=True)
prompt_path.write_text(text, encoding='utf-8')
def safe_autosave_prompt(content, prompt_name):
"""Thread-safe wrapper for autosave_prompt to prevent file corruption"""
with _notebook_file_lock: