Skip to content

feat(app): chat history, new chats and greeting for Ask Omi on mobile - #19838

Merged
Git-on-my-level merged 1 commit into
BasedHardware:mainfrom
Itaxh1:feat/chat-presentation
Sep 30, 2026
Merged

Git-on-my-level merged 1 commit into
BasedHardware:mainfrom
Itaxh1:feat/chat-presentation

Conversation

@Itaxh1

@Itaxh1 Itaxh1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Ask Omi on mobile keeps one running thread, so every question lands in the same conversation. This adds chat
history to the Ask Omi sheet from #19730, and nothing else. It is based on main (ab28037f64) and uses the
chat-session endpoints the backend already serves, so there are no backend changes and no data migration.

Closes #19840. Refs #7152 (new chats, past chats, reopening one with its own context, automatic titles and
delete). Not addressed: rename, search and pinning from #7152, and sharing chats (#4483).

Piece Where What it does
Past chats (new) History button in the chat header New chat, "Ask Omi with" app rows, then saved chats with pull-to-refresh and pagination. Choosing a chat returns to the same sheet with that thread loaded.
Delete a chat (new) Row menu in Past chats Always asks first. The row goes only after the server confirms. Deleting the open chat starts a fresh one; deleting another leaves the open one alone.
Fresh chat on entry Home, the Ask Omi and voice quick actions, chat deep links, the conversation page's Ask Omi button Opens a new chat. App detail keeps its selected app.
Greeting (new) Empty chat Time-of-day greeting with the first name, today's conversation count counting up, then "What do you want to know?". Suggestion chips fill the composer and never send.
Follow-up Above the composer Only the latest completed reply's follow-up question. Older answers no longer show their own chips.
Pull to close (new) The sheet's header handle The sheet follows the finger. A short pull settles back with the draft kept; a longer pull or a flick closes it.

App side. ChatSessionsApi (backend/http/api/chat_sessions.dart) wraps /v2/chat-sessions,
/v2/messages?chat_session_id= and /v2/chat/generate-title with typed ApiResults. ChatHistoryState, a mixin
on MessageProvider, owns the selected thread. A fresh chat creates its session once, on the first question, then
sends with that explicit ID. If creation fails, the reply shows Retry and never falls back to the server's current
thread. A history read replaces the thread only after it succeeds and carries a revision, so a slow read cannot
overwrite a newer choice. Switching is blocked while a message sends, during voice work, uploads or a delete, and
text typed during a load is kept. Titles come from the title endpoint after the first completed reply. Clear Chat on
a saved chat clears only that chat. A pendant voice reply never lands in a past chat being viewed.

Presentation side. ChatEntrance runs one 1.1 s timeline (greeting 0 ms, count 120 ms, composer 150 ms,
suggestions 350 ms, question 500 ms) that streaming, focus changes and rebuilds never replay. The count uses the
conversations already loaded in ConversationProvider (not discarded, local day), so it adds no request. The drag
lives in upstream's ChatSheetRoute: past 22 % of the screen, or a downward flick of at least 32 pt at 900 pt/s,
closes it; transcript scrolling never does. Reduce Motion shows everything in its final state and stops the typing
dots. pages/chat/README.md documents the thread, draft and motion rules and the test map.

The microphone (Stop, transcribe, edit, Send, Discard), attachments, citations, streaming and retry keep their
behavior. The 17 new strings are translated for all 49 languages through app/scripts/l10n.py; generated
localization makes up 99 of the 132 changed files.

Screenshots

The empty Ask Omi chat on an iPhone 15 Pro Max, from a build of this branch: the greeting, today's conversation count, the question, the suggestion chips and the history button.

Ask Omi greeting with today's conversation count and suggestion chips

Product invariants affected

none

scripts/pr-preflight --suggest against main reports no locked-invariant paths. INV-CHAT-1 covers the desktop
kernel transcript; this PR only uses the existing backend chat sessions from mobile.

How it was verified

  • bash app/test.sh: 3,605 passed, 5 skipped, 0 failed.
  • make mobile-verify ARGS="fast --all": 23 of 23 hermetic journeys passed.
  • bash app/scripts/analyze_ratchet.sh: passed. python3 app/scripts/l10n.py check: 49 locales, 3,491 keys.
    git diff --check: clean.
  • scripts/pr-preflight --base upstream/main --pr-body-file: all 23 selected manifest checks passed.
  • Built from this branch for an iPhone 15 Pro Max on iOS 26.6.2 (flutter build ios --config-only --profile --flavor prod, then xcodebuild), installed clean and used against the production API. It was signed under a
    personal preview bundle id and App Group, a build-only change that is not in this PR.
  • The first full run caught the visual-audit chat-ask scenario leaving the title request's HTTP timeout pending
    when the widget tree was disposed. The scenario now settles until that request finishes and asserts it ran once.
    All six chat scenarios pass three runs in a row.

Tests

  • test/providers/chat_history_state_test.dart (11) covers:
    • a failed history read keeping the current thread, and a late read never replacing a newer one
    • failed session creation never sending into the server's current thread, with Retry creating first
    • single-flight creation, and switching blocked while a reply streams
    • older-message pagination, deleting the open thread, and disposal during a pending read
  • test/widgets/chat_history_navigation_test.dart (13): the real ChatPage to Past chats and back, selection,
    failed reads, the draft kept during a pending read, starter editing, follow-up sends and header-only dismissal.
  • test/widgets/chat_presentation_test.dart (6): draft and focus across rebuilds, no replay, Reduce Motion including
    the typing dots, and a small screen at large text.
  • test/backend/chat_sessions_api_test.dart (5): failed vs. empty history, malformed rows, encoded session targeting,
    pagination and delete failures.
  • test/widgets/chat_greeting_count_test.dart (4): text and stagger timing, the count-up, discarded and local-day
    filtering, Reduce Motion.
  • test/widgets/past_chats_page_test.dart (4): retry, selection, delete confirmation (Cancel keeps history) and
    pagination.
  • message_provider_voice_test.dart gains a case: a pendant voice reply stays out of a past chat being viewed.
    message_provider_failed_reply_test.dart, chat_content_block_test.dart, mobile_polish_test.dart, the chat
    visual-audit scenarios and the journey fixture backend (session, history and title routes) are updated.

Failure class (fixes)

Failure-Class: none

Review in cubic

@Itaxh1
Itaxh1 marked this pull request as ready for review September 29, 2026 19:17
@Itaxh1

Itaxh1 commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level could you take a look when you have a moment? This adds past chats, new chats and pull-to-close on top of your Ask Omi sheet from #19730, using the existing chat-session endpoints (no backend changes). Could you also add ci:full so the full mobile checks run? Thanks!

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @Itaxh1 — this is a substantial, well-structured contribution. I reviewed the full non-generated diff (33 files; the other ~99 are generated localization for the 17 new product strings across 49 locales) and verified the client against the backend contract on main. Detail below; two product questions at the end need a maintainer's call.

What I verified

  • backend/http/api/chat_sessions.dart matches the live backend wire shapes: ChatSessionResponse carries id/title/preview/created_at/updated_at/message_count (including the server-side 'New Chat' title default that ChatSessionSummary.hasTitle compares against); /v2/chat/generate-title returns {title}; GET/POST/DELETE /v2/messages all accept chat_session_id. Query and path encoding uses Uri.encodeQueryComponent/Uri.encodeComponent throughout — no injection surface.
  • providers/chat_history_state.dart is the strongest part of this PR: epoch-guarded async so a slow history read can never replace a newer selection or a disposed provider, single-flight session creation, and — importantly — creation failure fails closed: the failed reply offers Retry and never falls back to sending into the server-current thread. Deletes only commit after server success; pendant voice replies are isolated from archived threads. The test suite (chat_history_state_test.dart, 11 cases covering late-read races, creation-failure retry, switching blocked mid-stream; plus the 440-line chat_history_navigation_test.dart with real navigation and fake HTTP) actually exercises these paths rather than asserting trivia.
  • pages/chat/past_chats_page.dart: offset accounting counts server rows including rejected ones, so malformed rows can't silently break pagination; failure shows Retry rather than a false "no past chats".
  • chat_route.dart drag-to-dismiss correctly balances didStartUserGesture/didStopUserGesture even when the route is disposed mid-drag, and Reduce Motion paths are handled throughout (chat_entrance.dart, typing_indicator.dart).

Two product decisions I'd like a maintainer to sign off on (code quality is not in question):

  1. Fresh thread on every entry. All normal Ask Omi entries (Home, quick actions, chat deep links, conversation page) now pass startFresh: true — users no longer land back in the running conversation. This matches the PR's stated goal (closes Omi AI chat update on mobile: past chats, new chats, greeting and pull-to-close #19840), but it changes the core chat entry behavior, so it deserves explicit product sign-off rather than an automated sign-off.
  2. Mobile/desktop session mixing. The session list is per-user, so mobile Past Chats will also surface desktop-created v2 sessions (and vice versa). If cross-client visibility is intended multi-session sync, great — but it changes what "Past chats" means on each platform and is worth a conscious decision.

Minor, non-blocking: page sizes (50 sessions / 100 messages) are hardcoded in both past_chats_page.dart (received == 50) and chat_history_state.dart (_messageOffset == 100); a shared constant would prevent silent divergence if the backend default ever changes.

Also noting for the record: most CI suites are skipped on this fork PR, so the verification numbers in the description (3,605 tests, 23 journeys) are self-reported — the diff's own test infrastructure is consistent with them, but they haven't run on repo CI.

Leaving for human maintainer review on the two product questions above; no code changes requested.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge flutter flutter work labels Sep 29, 2026
@Git-on-my-level Git-on-my-level added the ci:full Maintainer-granted: run full CI on this fork PR label Sep 30, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Product sign-off from David (via maintainer channel) on the two questions raised in the review above:

  1. Fresh thread on every entry — approved. That behavior is the intent of Omi AI chat update on mobile: past chats, new chats, greeting and pull-to-close #19840 ("every question lands in the same conversation" is the complaint being fixed). Legacy history stays reachable through Past chats, and app-detail chat intentionally keeps its selected app with startFresh: false.
  2. Cross-client session visibility — accepted as intended. Sessions are per-user server objects; desktop-created v2 sessions appearing in mobile Past chats (and vice versa) is treated as multi-session sync, not a defect.

Verification status on head 25c0330 (unchanged since the review above):

  • Author added ci:full; full Mobile App Checks rerun is in flight on this exact head.
  • Local exact-head checkout (refs/pull/19838/head = 25c033039427): all 67 tests in the PR's new/updated test files pass (chat_sessions_api, chat_history_state, past_chats_page, chat_greeting_count, chat_history_navigation, chat_presentation, message_provider_voice, message_provider_failed_reply, chat_content_block, mobile_polish).
  • Non-ASCII diff scan: only legitimate translation strings in .arb files plus one arrow glyph in the new README; no agent-corruption class issues.

Merging on green per maintainer instruction (admin merge — the review requirement is satisfied by the review thread above plus this sign-off). The hardcoded page-size nit (50/100) stays open as accepted follow-up, not a merge blocker.

@Git-on-my-level
Git-on-my-level merged commit 2989661 into BasedHardware:main Sep 30, 2026
69 of 70 checks passed
@Git-on-my-level

Copy link
Copy Markdown
Member

Merged as squash commit 2989661fd6 on main (single parent, feat(app): add persistent chat history and presentation (#19838)).

  • Full Mobile App Checks green on the exact head 25c0330 (Dart Analyze & Tests, Generated Files, Seeded Journeys hermetic, Release Eligibility; native lanes skipped by design — no iOS/Android files touched).
  • Post-merge audit: all 132 owned files byte-identical between reviewed head and landed main (0 drift).
  • Local exact-head run: 67/67 tests in the PR's new/updated suites passing.
  • Linked issue Omi AI chat update on mobile: past chats, new chats, greeting and pull-to-close #19840 auto-closed as completed. Fork head deleted.
  • Post-merge push CI on main (including the Kiritimati TZ suite PRs skip) is being watched; will report if anything surfaces.

Accepted follow-ups: shared page-size constants (50/100); rename/search/pin (#7152 remainder) and chat sharing (#4483) remain open feature work.

xyz-is-best added a commit to xyz-is-best/omi that referenced this pull request Sep 30, 2026
The chat-history feature (BasedHardware#19838) added a hand-written Dart REST DTO for
`/v2/chat-sessions`, but that route was never on the app-client surface, so the
schema single-source gate reports one remaining manual Dart JSON schema file and
`test_app_client_schema_inventory.py` fails for every PR that selects the full
backend unit suite.

Add the chat-session routes to the app-client contract, generate
`gen/chat_sessions_wire.g.dart` from the committed spec, and rebuild
`ChatSessionSummary` as an adapter over the generated wire DTO so a field the
source gains can no longer be dropped in silence. Decode behavior is unchanged:
the wire decoder owns typing/required fields and the adapter still fills the
fields a partial producer omits.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <[email protected]>
xyz-is-best added a commit to xyz-is-best/omi that referenced this pull request Sep 30, 2026
The chat-history feature (BasedHardware#19838) added a hand-written Dart REST DTO for
`/v2/chat-sessions`, but that route was never on the app-client surface, so the
schema single-source gate reports one remaining manual Dart JSON schema file and
`test_app_client_schema_inventory.py` fails for every PR that selects the full
backend unit suite.

Add the chat-session routes to the app-client contract, generate
`gen/chat_sessions_wire.g.dart` from the committed spec, and rebuild
`ChatSessionSummary` as an adapter over the generated wire DTO so a field the
source gains can no longer be dropped in silence. Decode behavior is unchanged:
the wire decoder owns typing/required fields and the adapter still fills the
fields a partial producer omits.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 30, 2026
#19838 added ChatSessionSummary with a hand-written fromJson, which the
app-client schema inventory counts as a remaining manual DTO; main has
failed test_app_client_schema_inventory since (latent: that PR touched no
backend path, so the backend shard never ran).

- /v2/chat-sessions joins the app-client OpenAPI export; the spec and the
  Swift/TS generated clients are regenerated.
- New chat_sessions generator group -> chat_sessions_wire.g.dart
  (GeneratedChatSessionResponse).
- ChatSessionSummary.fromJson now decodes through the generated type,
  keeping the old tolerance: updated_at falls back to created_at, a
  mistyped/missing title or preview reads empty, a missing count 0, a
  missing star unstarred; an id and one parseable timestamp stay
  required; times are shown in local time. The new tests pass against
  both the old decoder and the new one.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR flutter flutter work needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Omi AI chat update on mobile: past chats, new chats, greeting and pull-to-close

2 participants