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
This commit is contained in:
pyr0ball 2026-03-21 02:53:29 -07:00
parent 3bcc08c080
commit 6093275549
4 changed files with 17 additions and 18 deletions

View file

@ -983,6 +983,7 @@ 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."""
try:
data = load_user_profile(_user_yaml_path())
data["name"] = payload.name
data["email"] = payload.email
@ -990,6 +991,8 @@ def sync_identity(payload: IdentitySyncPayload):
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")

View file

@ -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

View file

@ -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,

View file

@ -138,7 +138,7 @@
<div class="tag-list">
<span
v-for="(company, idx) in store.nda_companies"
:key="idx"
:key="company"
class="tag"
>
{{ 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()
}