Repository navigation
feat(app): add typed ApiResult and migrate the conversation list and detail - #14403
Git-on-my-level wants to merge 8 commits into
Conversation
makeApiCall still returns null for the 28 existing conversations.dart callers; ConversationApi is the first path where 403, 503, and a missing row are distinct, and an injected outage renders error instead of the empty hero. Co-authored-by: Cursor <[email protected]>
…d-result Co-authored-by: Cursor <[email protected]> # Conflicts: # contracts/spine/files.json # scripts/dev-harness/PENDING_CONTRACTS.md
The remote tip carried a merge of an older origin/main; this branch already contains current origin/main plus 20 commits. Merged to restore a fast-forward path without rewriting published history. Co-Authored-By: Claude Opus 5 <[email protected]>
Take the spine PENDING_CONTRACTS wording from #14328, including the Map-identity expect rule, and retire the C3 fallback-map pending marker now that recordFallback is implemented. Co-authored-by: Cursor <[email protected]>
…ook like an empty account main.dart and hermetic boot now call createProductionConversationProvider, which always constructs ConversationApi. An unused import would satisfy the dead-code ratchet; the new test asserts the live call site and that a 503 on that factory-built provider renders the error surface on ConversationsPage. Co-authored-by: Cursor <[email protected]>
Bring the C3 oracle-only revision split and the origin/main conflict resolutions forward so this published child still fast-forwards from the contract branch.
Forward the three-way C3 split so this published child still fast-forwards from the contract branch.
kodjima33
left a comment
There was a problem hiding this comment.
Typed ApiResult conversation list/detail migration, no abuse signal (mergeStateStatus UNKNOWN, not eligible to merge anyway); approve-only per standing account flag.
|
Auto-closed when base branch was deleted after the parent squash-merged. Head unchanged at |
|
Hey @Git-on-my-level 👋 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:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. 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
C3 PR1: typed
ApiResult<T>never null, one shared uncaught send, conversation list/detail as the first migrated file, old and new coexisting. Stacked ontask/msd-spine-a-api-result(#14328). Branchtask/msd-core-c3-typed-result. Not pushed.This closes the HTTP subset where
makeApiCallreturning null made an outage indistinguishable from an empty account, and wheregetConversationByIdreturned null identically for transport failure, 403, 503, and a missing row. 402 and 422 now have terminal kinds with no retry loop.What changed and why
ApiResult<T>—ApiSuccess(data, rejectedRows)orApiFailure(ApiProblem), never null. Taxonomy matchesapp/lib/backend/http/API_RESULTS.md. Programming errors (StateError,NoSuchMethodError) propagate fromexecuteApi; onlyFormatExceptioninside decoding becomesdecode.sendUncaughtApiCallis the oldmakeApiCalltry-body (headers, pool, timeouts, clock skew, 401 replay).makeApiCallis now the null-wrapping catch only.executeApidefaults to that uncaught path. It does not wrap nullablemakeApiCalland guess why it failed. Thesendseam is already-authenticated I/O;executioninjects transport + header builder +AuthServiceinto the same production request path with no global defaults.refreshAndReplayAfter401gainedonAuthRefreshsoexecuteApican see the observedAuthTokenResult. A transient refresh that returns the original 401 isauthTransient, not collapsed intoauthTerminal.ConversationApi.list/byIdlive inapp/lib/backend/http/api/conversations.dartnext to the legacy functions. Why this file: the note's evidence is conversation-detail conflation (getConversationById→ null for 403, 503, and missing) plus list empty-vs-outage (cfaaaf2fb9db,06597a0757cb). All 28 existingmakeApiCallcall sites in that file stay.getConversationById/getConversationsstay. ProductionConversationProvider()withoutconversationApiis unchanged.composeTypedConversationProviderreturns the realConversationProvider.apiViewState,ConversationApiStatus(keysomi.conversations.error/.locked/.terminal/.auth/.empty, retry only whenretryable, error is a Semantics liveRegion) precedes the empty hero onConversationsPage. 402/422 on typed detail leave Processing and do not poll.Widget tests drive
getInitialConversationsinsiderunAsync(as the spine test already does).ConversationsPage(requestInitialLoad: false)is a test-harness-only constructor defaulting to true in production, so initState does not queuefailNexton the fake-async clock where loopback I/O never completes. The page still mounts for real, and still uses the production status-before-hero branch.Product invariants affected
none (
scripts/pr-preflight --suggest)How it was verified
TZ=UTC bash app/test.shthenTZ=UTC flutter test: 2137 tests, all passed.python3 scripts/check_spine_contracts.py: pass. One remaining C3 marker (see below). 29 pending markers repo-wide (rest are V1).make preflight: 21 checks passed in 62.45s. No harness-port flake this run.dart format --line-length 120on the production/test files we own. Spine tests were restored to contract-branch originals then had markers removed only.make lane-bootstrap(this worktree had no venv) thenmake mobile-verify ARGS="fast --paths …": outcome passed, 20/20.Could not run: physical device. Production
ConversationProvider()withoutconversationApistill usesmakeApiCall(intentional coexistence).Tests
app/test/spine/c3_*: markers retired except one (below). Assertions untouched.app/test/unit/backend/http/api_send_extraction_test.dart:sendUncaughtApiCallthrows;makeApiCallreturns null on the same failure. 402/422: one send,retryable == false, decode not called.ConversationsPageviabuildTypedConversationScreen. Outage isApiViewPhase.error+omi.conversations.error, notEmptyConversationsWidget. Recovery afteroutage=falseis empty. 402/422 leave Processing with one GET and no retry on a 2-minute pump.Self-check: 28
makeApiCallcallersrg -c makeApiCall app/lib/backend/http/api/conversations.dart→ 28. None of those sites were migrated.git diffofshared.dart: the uncaught body is the previousmakeApiCalltry-block;makeApiCallnow only callssendUncaughtApiCalland applies the sameAuthTokenUnavailableException/ catch → null policy.makeApiCallnever passesexecutionoronAuthRefresh, so those seams cannot change legacy behavior. Extraction test proves throw vs null wrap, not a source-string assertion.TZ=UTC flutter testincludes the existing conversation provider/HTTP suites that still go throughmakeApiCall.Self-check: 402 / 422 terminal, no retry, never uploaded
executeApimaps 402 →paymentRequired, 422 →unprocessable, bothretryable == false, one send, decode not invoked (api_send_extraction_testthrows if decode runs). Typed detailrefreshTypedDetailremoves the row fromprocessingConversationsand does not schedule a timer. Spine pumps 2 minutes and asserts still one GET. WAL upload is not on this file; we did not add a 402/422 success path that could mark a recording uploaded.Self-check: injected outage renders error, not empty list
Spine
c3_conversation_testusesJourneyFixtureBackend.failNext(..., status: 503)(the journeys'fixture_backend.dart). Status widget and the realConversationsPageboth showomi.conversations.errorand notEmptyConversationsWidget/omi.conversations.empty. Retry /forceRefreshafter the fault is cleared renders empty.Pending marker kept on purpose
C3 fallback emitter uses shared closed fields and one eventstill haspendingContract('C3'). The implementation emits the exact closed fields (component/area=other,from/to=none,reason=other,outcome=degraded, eventfallback_triggered). DartRecord.==usesMap.==, which is identity, soexpect(emitted, [(name, map)])cannot pass even when the maps are key-for-key equal. I did not rewrite the spine assertion (markers only). Architect: changing that expect toexpect(emitted.single.$1, 'fallback_triggered'); expect(emitted.single.$2, map);would let DeepCollectionEquality apply to the map and we can retire the marker.Failure class (fixes)
Not declared. This commit is
feat(app):(new typed surface + first exemplar).scripts/pr-preflight --suggestsaid nofix:commit was detected. Ask before defining a failure class — if you want this labelled as afix:instance of outage-as-empty / detail-null-conflation, say whichFC-*(ornew) to use and I will add the declaration in a follow-up commit.Scoped notes
makeApiCallsiblings inshared.dartare untouched.contracts/**.makeApiCallsites inconversations.dart. C4 can batch those.🤖 Generated with Claude Code
Failure class (fixes)
Failure-Class: none
This is a new typed surface plus its first exemplar migration rather than a fix of a specific
instance, so the commit is
feat(app):andscripts/pr-preflight --suggestdetected nofix:commit. The defect class it exists to close — an outage rendering as an empty account, and
getConversationByIdreturning null identically for transport failure, 403, 503 and a missingrow — is the contract C3 itself records.
🤖 Generated with Claude Code