fix(desktop): align API response keys with Python backend#6381
Conversation
Three response format mismatches after desktop→Python backend migration:
- ActionItemsListResponse: map `items` to `action_items` key from backend
- Goals endpoints: backend returns plain array, not `{goals:[...]}` wrapper
- Apps v2: reduce default limit from 100 to 50 (backend maximum)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR aligns three Swift decoding mismatches with the Python backend: maps the
Confidence Score: 4/5Safe to merge for the three described fixes, but the Goals History page remains broken due to a missing Python backend endpoint. The action items key mapping and apps v2 limit reduction are correct and unambiguous fixes. The getGoals() plain-array decode is also correct. However, getCompletedGoals() calls GET /v1/goals/completed which does not exist in the Python backend (confirmed by reading backend/routers/goals.py) — the Goals History page will continue to surface a 404 error, a current defect the PR description claims to fix but does not. desktop/Desktop/Sources/APIClient.swift (getCompletedGoals at line 2048) and backend/routers/goals.py (missing /v1/goals/completed endpoint) Important Files Changed
Sequence DiagramsequenceDiagram
participant Swift as Swift APIClient
participant Py as Python Backend (api.omi.me)
Note over Swift,Py: Action Items (FIXED)
Swift->>Py: GET /v1/action-items
Py-->>Swift: {"action_items": [...], "has_more": false}
Note right of Swift: Decoded via CodingKeys: items="action_items" ✓
Note over Swift,Py: Goals - getGoals() (FIXED)
Swift->>Py: GET /v1/goals/all
Py-->>Swift: [...] plain array
Note right of Swift: Decoded as [Goal] ✓
Note over Swift,Py: Goals - getCompletedGoals() (STILL BROKEN)
Swift->>Py: GET /v1/goals/completed
Py-->>Swift: 404 Not Found
Note right of Swift: Endpoint does not exist in Python backend ✗
Note over Swift,Py: Apps V2 (FIXED)
Swift->>Py: GET /v2/apps?limit=50
Py-->>Swift: 200 OK (was 422 with limit=100)
|
| func getCompletedGoals() async throws -> [Goal] { | ||
| let response: GoalsListResponse = try await get("v1/goals/completed") | ||
| return response.goals | ||
| let goals: [Goal] = try await get("v1/goals/completed") | ||
| return goals |
There was a problem hiding this comment.
Missing
/v1/goals/completed endpoint on Python backend
The Python backend (backend/routers/goals.py) has no GET /v1/goals/completed route — only /v1/goals/all exists as a list endpoint. Calling this will always return a 404, which surfaces as a visible error on the Goals History page (GoalsHistoryPage.swift:95) and produces empty goal history in GoalsAIService.swift:183. The decoding fix (plain [Goal] array) is correct for when the endpoint eventually exists, but it won't take effect until a /v1/goals/completed route is added to the Python backend router.
|
Merged into #6380 per manager request to combine both PRs. |
|
Hey @beastoin 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! 💜 |
Summary
action_itemskey but Swift decodeditems→ all task loading failed with "key 'items' not found"/v1/goals/alland/v1/goals/completedreturn plain JSON arrays, not{"goals": [...]}wrapper → "Expected Dictionary but found array" errorlimitfrom 100 to 50 to match backend validation max (was returning 422)These are response format mismatches introduced by the desktop → Python backend migration (#6174).
Test plan
🤖 Generated with Claude Code