Repository navigation
feat(backend): per-day hidden-noise counts for the Home fold line - #23851
Merged
Merged
Conversation
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]>
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]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
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 | |---|---| |  |  | ## 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thatMEDIA_NOISE_MODEhides 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)start_dateend_date>= start_date; the window is at most 31 days.tzUTC. Each row'screated_atis 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_dateandend_dateare echoed back normalized to UTC.daysis sorted ascending and omits zero-count days.truncatedistrueand the counts are lower bounds.400: a reversed window, a window over 31 days, or an invalidtz.422: a missing or unparseable date.401: unauthenticated.A row counts when all of these hold:
discarded == trueandcontent_kindismediaornoise;statusiscompletedorprocessing;deletedand not a sync merge donor (sync_merged_into).User-kept rows (
sync_relevance_user_kept) never count; unhiding setsdiscarded=false. Locked rows and Dream duplicates count, because the reveal list shows them. The endpoint does not check whetherMEDIA_NOISE_MODEis on for the user: a user with nothing hidden getsdays: []andtotal: 0.Reveal a day: use the existing
GET /v1/conversations?include_discarded=true&start_date=<day start>&end_date=<day end>and keep rows wherediscarded == true && content_kind in (media, noise). That is the same predicate the count uses.content_kindis 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}/conversationswithdiscarded == true,created_atwithin the window, ordered bycreated_atdesc, an 8-fieldselect, andlimit(1001). The existing declared composite indexconversations_discarded_createdserves it, so there is no new index and no index run.tests/support/firestore_query_driver_registry.py, and a router runtime witness is added.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.yamlgains its policy entry.test_hidden_noise_counts.py(new); the runtime-witness test; a stub for the new module intest_conversation_events_bounds.py.app-client-openapi.jsonsnapshot, 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.shpassed for:test_hidden_noise_counts.py(16)test_firestore_runtime_witnesses.py(25)test_firestore_query_shapes.pyandtest_firestore_outside_query_contract.pytest_conversation_events_bounds.py,test_batch_pipeline_worker_io.pyandtest_generated_compute_caps.pyscripts/openapi_runner.sh scripts/export_openapi.py --checkpassed for the full, app-client and integration-public surfaces.check_app_client_openapi_compatibility.py --base-ref 08ff6c68a9ddpassed.generate_swift_openapi_types.py --checkand the TS generator passed.scan_async_blockers.py --dirs routers utilsreported no findings.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 (
truncatedwas 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