Skip to content

Disable auto-delete when auto archive is turned off - #1

Open
WarheadTaylor with Copilot wants to merge 3 commits into
masterfrom
copilot/add-option-disable-auto-archive
Open

WarheadTaylor with Copilot wants to merge 3 commits into
masterfrom
copilot/add-option-disable-auto-archive

Conversation

Copilot AI commented Mar 10, 2026

Copy link
Copy Markdown

Disabling auto archive previously only skipped the archive copy; Auto Delete Original Recording could remain enabled even though there was no archive target. This change makes those settings consistent by forcing auto delete off whenever auto archive is disabled.

  • Settings behavior

    • Treat disable_archive as authoritative for archive-related side effects
    • Force auto_delete_recordings=False in the effective loaded settings when auto archive is disabled
    • Preserve existing behavior when auto archive remains enabled
  • OBS script UI

    • Add a modified callback on Disable Auto Archive
    • Immediately uncheck Auto Delete Original Recording when archive disabling is enabled
    • Disable the auto-delete control while auto archive is off so the UI reflects the effective runtime behavior
  • Docs

    • Update the settings description to clarify that turning off auto archive also turns off automatic deletion of the source recording
return ScriptSettings(
    ...
    disable_archive=disable_archive,
    auto_delete_recordings=obs.obs_data_get_bool(obs_settings, "auto_delete_recordings") and not disable_archive,
    ...
)

def _on_disable_archive_modified(props, _property, settings) -> bool:
    disable_archive = obs.obs_data_get_bool(settings, "disable_archive")
    auto_delete = obs.obs_properties_get(props, "auto_delete_recordings")
    if auto_delete is not None:
        obs.obs_property_set_enabled(auto_delete, not disable_archive)
    if disable_archive:
        obs.obs_data_set_bool(settings, "auto_delete_recordings", False)
    return True
    • UI preview showing Auto Delete Original Recording disabled when Disable Auto Archive is enabled:
      Disable auto archive disables auto delete

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: WarheadTaylor <4128606+WarheadTaylor@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to disable auto archive Add a setting to disable automatic archive copies Mar 10, 2026
Co-authored-by: WarheadTaylor <4128606+WarheadTaylor@users.noreply.github.com>
Copilot AI changed the title Add a setting to disable automatic archive copies Disable auto-delete when auto archive is turned off Mar 10, 2026
@WarheadTaylor
WarheadTaylor marked this pull request as ready for review March 11, 2026 00:01
@WarheadTaylor
WarheadTaylor requested a review from Copilot March 11, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns runtime settings and OBS UI behavior so that disabling auto-archive also disables (and forces off) automatic deletion of the original recording, preventing “delete without an archive target” configurations.

Changes:

  • Adds disable_archive to ScriptSettings and enforces auto_delete_recordings=False in loaded settings when archive is disabled.
  • Updates the OBS script to (a) skip archive submission when disabled and (b) disable/uncheck the auto-delete UI control via a modified callback.
  • Extends tests and updates README to document the coupled behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_settings.py Imports ScriptSettings and adds a basic regression test for the new field.
tests/test_auto_record_games.py Adds integration-style tests that load the OBS script with a stubbed obspython module to validate the new behavior.
src/obs_auto_record/settings.py Adds disable_archive to the settings dataclass.
obs_scripts/auto_record_games.py Introduces the new setting, enforces effective auto-delete behavior, adds UI callback, and skips archive submission when disabled.
README.md Documents that disabling auto-archive also disables automatic deletion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +106 to +114
with patch.dict(sys.modules, {"obspython": obs_module}, clear=False), patch.object(
ctypes,
"WinDLL",
return_value=_FakeKernel32(),
create=True,
):
sys.modules.pop(module_name, None)
sys.modules[module_name] = module
spec.loader.exec_module(module)

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_load_script_module() imports obs_scripts/auto_record_games.py, which in turn imports obs_auto_record.process_scan while ctypes.WinDLL is patched. That leaves obs_auto_record.process_scan (and any other imported modules) cached in sys.modules with the fake WinDLL-backed globals after the context manager exits, which can leak into other tests in the same pytest process. Consider snapshotting/restoring the affected sys.modules entries (or explicitly removing obs_auto_record.process_scan / obs_auto_record.* from sys.modules in a finally) so this helper doesn’t contaminate the rest of the suite.

Suggested change
with patch.dict(sys.modules, {"obspython": obs_module}, clear=False), patch.object(
ctypes,
"WinDLL",
return_value=_FakeKernel32(),
create=True,
):
sys.modules.pop(module_name, None)
sys.modules[module_name] = module
spec.loader.exec_module(module)
# Snapshot any existing obs_auto_record modules so we can restore them after importing
# auto_record_games.py with a patched WinDLL. This prevents leaking fake WinDLL-backed
# modules into other tests in the same process.
_obs_auto_record_prefix = "obs_auto_record"
_saved_obs_auto_record_modules = {
name: m
for name, m in sys.modules.items()
if name == _obs_auto_record_prefix or name.startswith(_obs_auto_record_prefix + ".")
}
try:
with patch.dict(sys.modules, {"obspython": obs_module}, clear=False), patch.object(
ctypes,
"WinDLL",
return_value=_FakeKernel32(),
create=True,
):
sys.modules.pop(module_name, None)
sys.modules[module_name] = module
spec.loader.exec_module(module)
finally:
# Remove any obs_auto_record modules that were introduced during the patched import
# and restore the previously saved ones.
for name in list(sys.modules):
if name == _obs_auto_record_prefix or name.startswith(_obs_auto_record_prefix + "."):
if name not in _saved_obs_auto_record_modules:
sys.modules.pop(name, None)
for name, m in _saved_obs_auto_record_modules.items():
sys.modules[name] = m

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants