fix(projects): tag scan-minted system projects to the scanned profile

The all-profiles sidebar scan walks every profile's state.db in one
request. When it lazily minted a "Webhooks" / "Cron Jobs" project for a
profile that had webhook/cron rows, ensure_webhook_project() and
ensure_cron_project() tagged the new entry with get_active_profile_name()
-- the UI-selected profile -- instead of the profile whose rows triggered
it. A webhook-only profile therefore leaked a "Webhooks" project onto
whichever profile was selected; deleting it did nothing because the next
sidebar poll re-minted it, and switching profiles minted one per profile.

ensure_webhook_project / ensure_cron_project / _profile_has_user_projects
now take an explicit profile (default: active profile), and the scan
passes _cli_profile through, so the opt-in gate and the tag both key on
the scanned profile. Existing stubs in tests updated to accept the kwargs.
This commit is contained in:
carlotestor committed 2026-09-18 09:13:09 +00:00
1 parent adbb3258ef
commit 46e60616f6
5 files changed
+200 -16

No files matched your search

@@ -123,7 +123,7 @@ def test_cron_state_projection_preserves_archived_sidecar(monkeypatch, tmp_path)
encoding="utf-8",
)
monkeypatch.setattr(models, "SESSION_DIR", session_dir)
monkeypatch.setattr(models, "_profile_has_user_projects", lambda: False)
monkeypatch.setattr(models, "_profile_has_user_projects", lambda *_a, **_kw: False)
monkeypatch.setattr(models, "ensure_cron_project", lambda **_: "cron-project")
models.clear_sidecar_metadata_cache()