Skip to content

feat(backend): per-day hidden-noise counts for the Home fold line - #23851

Merged
Git-on-my-level merged 3 commits into
mainfrom
lane/noise-hidden-counts
Oct 28, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
lane/noise-hidden-counts

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds GET /v1/conversations/hidden-noise-counts, an additive read-only endpoint. It gives the Home "N short clips hidden · Show" fold line a per-day count of the conversations that MEDIA_NOISE_MODE hides from Home. Under the 10-26 ruling, noise is hidden, the audio is kept, and the user can unhide it. The fold UI itself is a separate app lane; this PR is backend data only.

Contract (for the UI lane)

GET /v1/conversations/hidden-noise-counts?start_date=<ISO>&end_date=<ISO>&tz=<IANA> (Bearer user auth)

Param Rules
start_date Required, inclusive. A naive timestamp is read as UTC.
end_date Required, inclusive. Must be >= start_date; the window is at most 31 days.
tz Optional IANA zone, default UTC. Each row's created_at is bucketed by its local date in this zone.

Response 200:

{"tz":"America/Los_Angeles","start_date":"2026-10-21T07:00:00Z","end_date":"2026-10-28T06:59:59Z",
 "days":[{"date":"2026-10-26","count":2},{"date":"2026-10-27","count":5}],"total":7,"truncated":false}
  • start_date and end_date are echoed back normalized to UTC. days is sorted ascending and omits zero-count days.
  • At most 1000 discarded rows are scanned. If more exist, truncated is true and the counts are lower bounds.
  • 400: a reversed window, a window over 31 days, or an invalid tz. 422: a missing or unparseable date. 401: unauthenticated.

A row counts when all of these hold:

  • discarded == true and content_kind is media or noise;
  • status is completed or processing;
  • not deleted and not a sync merge donor (sync_merged_into).

User-kept rows (sync_relevance_user_kept) never count; unhiding sets discarded=false. Locked rows and Dream duplicates count, because the reveal list shows them. The endpoint does not check whether MEDIA_NOISE_MODE is on for the user: a user with nothing hidden gets days: [] and total: 0.

Reveal a day: use the existing GET /v1/conversations?include_discarded=true&start_date=<day start>&end_date=<day end> and keep rows where discarded == true && content_kind in (media, noise). That is the same predicate the count uses. content_kind is already on the list response and in the app-client OpenAPI, so no new list field is needed.

Cost and index

The endpoint runs one bounded query: users/{uid}/conversations with discarded == true, created_at within the window, ordered by created_at desc, an 8-field select, and limit(1001). The existing declared composite index conversations_discarded_created serves it, so there is no new index and no index run.

  • The query driver is registered in tests/support/firestore_query_driver_registry.py, and a router runtime witness is added.
  • The query reads no content: no transcript, no decryption.

Changes

  • backend/database/hidden_noise_counts.py: the query and the per-day bucketing.
  • backend/routers/conversations.py: the route, registered before /v1/conversations/{conversation_id}; route_policy_manifest.yaml gains its policy entry.
  • Tests: test_hidden_noise_counts.py (new); the runtime-witness test; a stub for the new module in test_conversation_events_bounds.py.
  • Contract: the app-client-openapi.json snapshot, plus regenerated Swift and TS DTOs. The generated DTOs only add the new endpoint's types.

Verification (layer: unit / contract, worktree at this PR head)

  • BACKEND_UNIT_TEST_FILE_LIST=<list> bash test.sh passed for:
    • test_hidden_noise_counts.py (16)
    • test_firestore_runtime_witnesses.py (25)
    • test_firestore_query_shapes.py and test_firestore_outside_query_contract.py
    • the 7-file Firestore guard set
    • the OpenAPI, compat and route-policy tests (75)
    • test_conversation_events_bounds.py, test_batch_pipeline_worker_io.py and test_generated_compute_caps.py
  • scripts/openapi_runner.sh scripts/export_openapi.py --check passed for the full, app-client and integration-public surfaces. check_app_client_openapi_compatibility.py --base-ref 08ff6c68a9dd passed.
  • generate_swift_openapi_types.py --check and the TS generator passed. scan_async_blockers.py --dirs routers utils reported no findings.
  • Not run: a live endpoint call against dev or prod. Deploy-layer behavior is unverified until the coordinator's train ships it.

Review: implementation by Sol (gpt-6.1-sol). GLM (zai/glm-5.3) found no P0 or P1. Its P2 (the count must match the reveal, which shows Dream duplicates) and P3 (truncated was set at exactly 1000 rows) are fixed in 02f3962. Its other P3 note is a design trade-off, not fixed: the 1000-row cap covers all discarded rows in the window, and making it noise-only would need a new composite index.

Line-Count-Exception: backend/routers/conversations.py | 2445 -> 2489 | new route and its response models belong beside the other /v1/conversations list routes; query logic lives in database/hidden_noise_counts.py

Product invariants affected

none

Failure class (fixes)

Failure-Class: none

UI-Evidence: none -- backend endpoint; desktop, windows and web changes are generated DTOs only, with no rendered UI

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Git-on-my-level and others added 3 commits October 28, 2026 10:22
Expose authenticated, timezone-aware counts over a projected 1000-row scan
within a required 31-day window, reusing the existing discarded/created_at
index. Exclude user-kept rows, non-noise discards, tombstones and duplicate
links while retaining Home's completed/processing and locked-row semantics.

Register the query driver and named route witness, cover the endpoint with
fake Firestore tests, and refresh the additive app-client OpenAPI contract.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Count Dream duplicates (the reveal list shows them), report truncated only
when rows were actually cut (read cap+1), and stub the new database module
in the router bounds test. GLM review P2/P3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Oct 28, 2026, 4:20 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T04:23:09.241917Z 02f3962 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level merged commit 6dafa9d into main Oct 28, 2026
67 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/noise-hidden-counts branch October 28, 2026 04:35
Git-on-my-level added a commit that referenced this pull request Oct 28, 2026
## What this does

On Home, each day's noise and junk clips (lone "ừ", "Mm-", 2-second
fragments) fold into one quiet line at the end of that day: "4 short
clips hidden · Show". Tapping it reveals the clips in place, in time
order, and "Hide 4 short clips" folds them back. David approved this
from real-app renders on 10-28.

Depends on **#23851**, which adds `GET
/v1/conversations/hidden-noise-counts`. **Merge this after #23851 is
deployed.** Until then the count request fails, and the app keeps
showing nothing extra.

## How it works

- **Counts:** `ConversationProvider.refreshFoldedNoiseCounts` runs after
the initial load. It asks for counts over the loaded days (newest 31 at
most) in the device time zone. A failed read keeps what was shown and is
never treated as "nothing hidden". With "Show discarded" on, nothing
folds, because those rows are already listed.
- **Reveal:** fetches that day's `include_discarded=true` rows and keeps
`discarded && content_kind in (media, noise)`, the same rule the server
count uses. A clip discarded by hand never appears.
- **Revealed rows:** they read like ordinary rows, with their title or
transcript and the emoji, instead of the "Discarded · 1m 8s" style.
- **Rebuilds:** Home's page snapshot includes the fold state. Without
it, tapping never redrew the list; a test caught this.
- **Model:** `ServerConversation` now carries `contentKind`, which was
already on the wire.
- **Copy:** three new strings, translated for all locales.

## Review follow-up (GLM, FIX-FIRST round 1)

All fixed, with tests:
- **Sign-out and account switch:** these reset the fold, and an
in-flight reply for the old account is dropped, so another account's
rows can never appear.
- **Show discarded:** with it on, nothing folds and no folded rows merge
in. Before, toggling it caused duplicate rows.
- **Filtered views:** search, folder and selection never draw the line
or merge revealed rows.
- **Delete and restore:** deleting on the phone removes the clip from
the fold. A refresh drops cached rows, so a clip unhidden or deleted
elsewhere doesn't come back on the next reveal.
- **Load-more:** refreshes counts.
- **Double-tap Show:** fetches once.
- **Fetch failures:** stay silent and keep what's shown.

Not changed: a day whose only content is folded noise still has no row
of its own. That's a follow-up if it matters.

## UI evidence

| Folded | Revealed |
|---|---|
|
![Folded](https://raw.githubusercontent.com/BasedHardware/omi/7dd3d2c587c534338af5de33c34f3cbc68a7e157/.agent-artifacts/ui-evidence/home-noise-fold/001-mobile-ios-home-noise-folded.png)
|
![Revealed](https://raw.githubusercontent.com/BasedHardware/omi/7dd3d2c587c534338af5de33c34f3cbc68a7e157/.agent-artifacts/ui-evidence/home-noise-fold/002-mobile-ios-home-noise-revealed.png)
|

## Verification

- `test/widgets/home_noise_fold_test.dart`, 5 cases:
  - fold, reveal in time order, and fold back;
  - only noise/media rows reveal;
  - tap target is 44pt or more;
  - count parsing;
  - a failed read keeps the counts;
  - Show discarded folds nothing.
- 81 related Home, conversation and provider test files: 946 passed, 7
skipped.
- Not verified on a phone. TestFlight follows the merge.

Line-Count-Exception: app/lib/providers/conversation_provider.dart |
2401 -> 2410 | the fold logic lives in its own mixin; the provider keeps
only its import, the mixin clause, two @OverRide markers, and the
reset/refresh/delete hooks at its existing sign-out, toggle, delete and
load paths

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)

This branch was successfully deployed

1 active deployment
staging - docs — 02f39622 Deployed Oct 28, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant