feat: app.py checks wizard_complete flag to gate main app

This commit is contained in:
pyr0ball 2026-02-25 09:43:53 -08:00
parent 3eb08dcb92
commit 692c68d024
2 changed files with 23 additions and 1 deletions

View file

@ -65,7 +65,11 @@ _startup()
from scripts.user_profile import UserProfile as _UserProfile from scripts.user_profile import UserProfile as _UserProfile
_USER_YAML = Path(__file__).parent.parent / "config" / "user.yaml" _USER_YAML = Path(__file__).parent.parent / "config" / "user.yaml"
if not _UserProfile.exists(_USER_YAML): _show_wizard = (
not _UserProfile.exists(_USER_YAML)
or not _UserProfile(_USER_YAML).wizard_complete
)
if _show_wizard:
_setup_page = st.Page("pages/0_Setup.py", title="Setup", icon="👋") _setup_page = st.Page("pages/0_Setup.py", title="Setup", icon="👋")
st.navigation({"": [_setup_page]}).run() st.navigation({"": [_setup_page]}).run()
st.stop() st.stop()
@ -114,6 +118,8 @@ def _task_indicator():
label = "Enriching" label = "Enriching"
elif task_type == "scrape_url": elif task_type == "scrape_url":
label = "Scraping URL" label = "Scraping URL"
elif task_type == "wizard_generate":
label = "Wizard generation"
elif task_type == "enrich_craigslist": elif task_type == "enrich_craigslist":
label = "Enriching listing" label = "Enriching listing"
else: else:

View file

@ -21,3 +21,19 @@ def test_wizard_gating_empty_file_still_exists(tmp_path):
p = tmp_path / "user.yaml" p = tmp_path / "user.yaml"
p.write_text("") p.write_text("")
assert UserProfile.exists(p) assert UserProfile.exists(p)
def test_wizard_incomplete_triggers_wizard(tmp_path):
"""wizard_complete: false should be treated as 'wizard not done'."""
p = tmp_path / "user.yaml"
p.write_text("name: T\nemail: t@t.com\ncareer_summary: x\nwizard_complete: false\n")
from scripts.user_profile import UserProfile
u = UserProfile(p)
assert u.wizard_complete is False
def test_wizard_complete_does_not_trigger(tmp_path):
p = tmp_path / "user.yaml"
p.write_text("name: T\nemail: t@t.com\ncareer_summary: x\nwizard_complete: true\n")
from scripts.user_profile import UserProfile
u = UserProfile(p)
assert u.wizard_complete is True