From c4a58c7e2740692d62da83b8b46759b0319acbde Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sat, 21 Mar 2026 02:53:29 -0700 Subject: [PATCH] fix(settings): final code quality fixes for My Profile tab - add try/except to sync_identity endpoint - strip id field from mission_preferences save body - fix NDA v-for key to use company string (not index), add dedup guard - move imports out of save_user_profile function body --- dev-api.py | 17 ++++++++++------- scripts/user_profile.py | 8 ++------ web/src/stores/settings/profile.ts | 2 +- web/src/views/settings/MyProfileView.vue | 8 ++++---- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/dev-api.py b/dev-api.py index 7ec4baa..29d178f 100644 --- a/dev-api.py +++ b/dev-api.py @@ -983,13 +983,16 @@ class IdentitySyncPayload(BaseModel): @app.post("/api/settings/resume/sync-identity") def sync_identity(payload: IdentitySyncPayload): """Sync identity fields from profile store back to user.yaml.""" - data = load_user_profile(_user_yaml_path()) - data["name"] = payload.name - data["email"] = payload.email - data["phone"] = payload.phone - data["linkedin"] = payload.linkedin_url # yaml key is 'linkedin', not 'linkedin_url' - save_user_profile(_user_yaml_path(), data) - return {"ok": True} + try: + data = load_user_profile(_user_yaml_path()) + data["name"] = payload.name + data["email"] = payload.email + data["phone"] = payload.phone + data["linkedin"] = payload.linkedin_url # yaml key is 'linkedin', not 'linkedin_url' + save_user_profile(_user_yaml_path(), data) + return {"ok": True} + except Exception as e: + raise HTTPException(status_code=500, detail=str(e)) @app.put("/api/settings/profile") diff --git a/scripts/user_profile.py b/scripts/user_profile.py index 4334906..456b094 100644 --- a/scripts/user_profile.py +++ b/scripts/user_profile.py @@ -7,6 +7,8 @@ here so port/host/SSL changes propagate everywhere automatically. """ from __future__ import annotations from pathlib import Path +import os +import tempfile import yaml _DEFAULTS = { @@ -136,8 +138,6 @@ class UserProfile: def load_user_profile(config_path: str) -> dict: """Load user.yaml and return as a plain dict with safe defaults.""" - import yaml - from pathlib import Path path = Path(config_path) if not path.exists(): return {} @@ -148,10 +148,6 @@ def load_user_profile(config_path: str) -> dict: def save_user_profile(config_path: str, data: dict) -> None: """Atomically write the user profile dict to user.yaml.""" - import yaml - import os - import tempfile - from pathlib import Path path = Path(config_path) path.parent.mkdir(parents=True, exist_ok=True) # Write to temp file then rename for atomicity diff --git a/web/src/stores/settings/profile.ts b/web/src/stores/settings/profile.ts index 1812b9e..48eafca 100644 --- a/web/src/stores/settings/profile.ts +++ b/web/src/stores/settings/profile.ts @@ -57,7 +57,7 @@ export const useProfileStore = defineStore('settings/profile', () => { career_summary: career_summary.value, candidate_voice: candidate_voice.value, inference_profile: inference_profile.value, - mission_preferences: mission_preferences.value, + mission_preferences: mission_preferences.value.map(({ industry, note }) => ({ industry, note })), nda_companies: nda_companies.value, accessibility_focus: accessibility_focus.value, lgbtq_focus: lgbtq_focus.value, diff --git a/web/src/views/settings/MyProfileView.vue b/web/src/views/settings/MyProfileView.vue index 253209e..97fe0ca 100644 --- a/web/src/views/settings/MyProfileView.vue +++ b/web/src/views/settings/MyProfileView.vue @@ -138,7 +138,7 @@
{{ company }} @@ -224,9 +224,9 @@ function removeMission(idx: number) { // ── NDA helpers (autosave on add/remove) ──────────────── function addNda() { - const val = newNdaCompany.value.trim() - if (!val) return - store.nda_companies = [...store.nda_companies, val] + const trimmed = newNdaCompany.value.trim() + if (!trimmed || store.nda_companies.includes(trimmed)) return + store.nda_companies = [...store.nda_companies, trimmed] newNdaCompany.value = '' store.save() }