Skip to content

利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.

fix(webui): decouple upload_post_enabled from auto_upload in settings (#1259)

Danny McGean248f65843404
diff --git a/test/services/test_webui_i18n.py b/test/services/test_webui_i18n.py
index 7aa08dda..2d4f4d36 100644
--- a/test/services/test_webui_i18n.py
+++ b/test/services/test_webui_i18n.py
@@ -31,6 +31,7 @@ ENGLISH_FALLBACK_KEYS = frozenset(
"Confirm AI Video Charge Help",
"Confirm AI Video Charge Required",
"Custom API Endpoint",
+ "Enable Upload-Post Integration",
"API Platform",
"llm_provider_endpoint_selector.moonshot",
"llm_provider_endpoint_selector_help.moonshot",
diff --git a/test/services/test_webui_upload_post_settings.py b/test/services/test_webui_upload_post_settings.py
index 0a600731..cbf51d8c 100644
--- a/test/services/test_webui_upload_post_settings.py
+++ b/test/services/test_webui_upload_post_settings.py
@@ -34,8 +34,11 @@ def test_webui_upload_post_setup_guide_links_to_required_pages():
assert "https://app.upload-post.com/manage-users" in setup_guide.value
-def test_webui_upload_post_checkbox_syncs_persisted_mismatch():
- # Persisted mismatch: enabled=True, auto_upload=False
+def test_webui_upload_post_checkboxes_stay_decoupled():
+ # enabled=True / auto_upload=False is a deliberate split: an external
+ # pipeline may call Upload-Post while auto-publish stays off. Opening the
+ # settings dialog must not rewrite either key, and each checkbox must
+ # reflect and write only its own key.
test_app_config = dict(
config.app,
upload_post_enabled=True,
@@ -51,16 +54,18 @@ def test_webui_upload_post_checkbox_syncs_persisted_mismatch():
app.session_state["settings_dialog_open"] = True
app.run()
- # When UI runs, it sees enabled=True and auto_upload=False.
- # Checkbox should be UNCHECKED because ui_state = is_enabled and is_auto
- checkbox = _widget_by_key(app.checkbox, "upload_post_enabled_checkbox")
- assert checkbox.value is False
+ enabled_box = _widget_by_key(app.checkbox, "upload_post_enabled_checkbox")
+ auto_box = _widget_by_key(app.checkbox, "upload_post_auto_upload_checkbox")
+ assert enabled_box.value is True
+ assert auto_box.value is False
- # Now user clicks it to TRUE
- checkbox.set_value(True)
- app.run()
+ # Merely rendering the dialog must not have rewritten the split config
+ assert config.app["upload_post_enabled"] is True
+ assert config.app["upload_post_auto_upload"] is False
- # Verify it updated both
+ # Toggling auto_upload on must leave enabled untouched
+ auto_box.set_value(True)
+ app.run()
assert config.app["upload_post_enabled"] is True
assert config.app["upload_post_auto_upload"] is True
diff --git a/webui/Main.py b/webui/Main.py
index 8944c470..349aee5e 100644
--- a/webui/Main.py
+++ b/webui/Main.py
@@ -2608,16 +2608,25 @@ def _render_settings_dialog():
is_enabled = config.app.get("upload_post_enabled", False)
is_auto = config.app.get("upload_post_auto_upload", False)
- ui_state = is_enabled and is_auto
+ # 两个键各自独立:enabled 允许外部流程调用 Upload-Post,
+ # auto_upload 才决定渲染完成后是否自动发布。合并成一个复选框会在
+ # 两键不一致的配置下,仅打开设置对话框就把 enabled 改写为 False。
upload_post_enabled = st.checkbox(
- tr("Enable Auto-Publish"),
- value=ui_state,
+ tr("Enable Upload-Post Integration"),
+ value=is_enabled,
key="upload_post_enabled_checkbox"
)
- if upload_post_enabled != is_enabled or upload_post_enabled != is_auto:
+ if upload_post_enabled != is_enabled:
_set_runtime_config("app", "upload_post_enabled", upload_post_enabled)
- _set_runtime_config("app", "upload_post_auto_upload", upload_post_enabled)
+
+ upload_post_auto_upload = st.checkbox(
+ tr("Enable Auto-Publish"),
+ value=is_auto,
+ key="upload_post_auto_upload_checkbox"
+ )
+ if upload_post_auto_upload != is_auto:
+ _set_runtime_config("app", "upload_post_auto_upload", upload_post_auto_upload)
upload_post_api_key = st.text_input(
tr("Upload-Post API Key"),
diff --git a/webui/i18n/en.json b/webui/i18n/en.json
index 30bcac11..1fa462b1 100644
--- a/webui/i18n/en.json
+++ b/webui/i18n/en.json
@@ -391,6 +391,7 @@
"Auto-Publish Settings": "Auto-Publish Settings",
"Automatically publish generated videos to social media using upload-post.com": "Automatically publish generated videos to social media using upload-post.com",
"Enable Auto-Publish": "Enable Auto-Publish",
+ "Enable Upload-Post Integration": "Enable Upload-Post Integration",
"Platforms": "Platforms",
"Upload-Post API Key": "Upload-Post API Key",
"Upload-Post API Key Help": "Create and copy an API key on the [Upload-Post API Keys page]({api_keys_url}).",