Skip to content

fix(mobile): let Usage filter an environment whose ID is all - #46736

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
saphid:hunter/c-ba384d3228
Dec 1, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
saphid:hunter/c-ba384d3228

Conversation

@saphid

@saphid saphid commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Problem

The server accepts any nonempty userdata/environment-id, including all. Mobile environment filters treat that value as their "All environments" action in two ways:

  • Usage: the row and the aggregate action share one string dispatcher where "all" means reset, so pressing the row for an all environment resets the filter to every environment.
  • Android menus: the row ID collides with the aggregate action's ID: all in Usage, and environment:all in the Threads and Archived threads filters. Android's AppBar dispatches presses with a first-match findAppBarMenuItem, so pressing the row runs the reset action.

Deterministic repro on origin/main (03e9365d37f4ca3bf90e73046b50dc63bc589345):

  1. Before the first boot of two task-isolated local servers, write all and lab to their userdata/environment-id files. Give both servers different nonzero usage.
  2. Pair both in the mobile app.
  3. Open Usage (by default every environment is selected), then press the all environment's row ("Alpha").
  4. On Android, also open the Threads filter and choose the all environment.

Observed (Usage):

  • The menu row IDs are ["all","all","lab"].
  • After the press selectedEnvironmentIds stays null, so useUsage keeps both environments and Cost/Tokens still include Alpha's usage.
  • Reopening the menu shows Alpha still checked.

Observed (Threads on Android): the press calls onEnvironmentChange(null).

Expected:

  • Usage: only Lab stays selected, its totals exclude Alpha, and Alpha is unchecked.
  • Threads: filters to the all environment.
  • Only the aggregate actions reset, and every menu action has a unique ID.

Change

  • Usage: the aggregate action now calls setSelectedEnvironmentIds(null) directly. Each row passes its branded ID straight to toggleUsageEnvironment through the existing functional updater, and row IDs are now environment:<id>.
  • Threads and Archived threads: the aggregate ID becomes all-environments, outside the row namespace.

iOS and Android both use these menus. Cost, Tokens and Limits follow the Usage selection.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • Threads regression test: new case in apps/mobile/src/features/home/home-list-filter-menu.test.ts, "filters to an environment whose ID is all instead of resetting on Android". It builds the real menu and resolves the press through Android's findAppBarMenuItem.
    • Base: AssertionError: expected [ null ] to deeply equal [ 'all' ].
    • Head: 2/2 pass.
  • Usage menu, before/after: I ran a verbatim copy of each revision's menu code against the real toggleUsageEnvironment and findAppBarMenuItem.
    • Base: IDs ["all","all","lab"]. Pressing Alpha leaves null, and findAppBarMenuItem(items,"all") returns All environments.
    • Head: IDs ["all","environment:all","environment:lab"]. Pressing Alpha leaves {lab}, the reopened checks are Alpha:false, Lab:true, and All environments still resets to null.
  • Downstream totals: in useUsage (apps/mobile/src/state/usage.ts), a null selection keeps every environment's summary; otherwise only the selected ones are kept. Cost, Tokens and Limits are built from those. So on base Alpha's usage stays in the totals, and on head only Lab's remains. I traced this in the source; I did not observe it on a device.
  • Checks: vp run check:changed exited 0 on head 709415f10d7 (format, lint, knip, typecheck, tests, React Compiler).
  • Transcript: https://gist.github.com/saphid/4d4cdb065684fea173fa98b5bd8d2927
  • Project filter: the Threads project filter's project:all is unchanged. Its rows use project group keys from buildProjectGroups, not raw environment IDs.

Not shown:

  • An on-device iOS or Android run with two paired servers.
  • A scenarios:prove run and before/after screenshots.
  • A unit test for the Usage screen's inline menu: it has no test seam, so its before/after evidence is the copied-wiring run above.

Authored by Claude Opus 5.5 (Model Hub); reviewed by GPT-6.2 Sol (Codex).

Not shown

  • apps/mobile/src/features/home/home-list-filter-menu.test.ts:38 — The linked gist still shows a superseded Usage test with a missing-function TypeError on base and a 5-test run on an earlier head. Replace those excerpts with the current Threads assertion failure and 2/2 pass, and attach the check:changed result for 709415f10d7; the draft currently reports the check but the linked evidence does not verify it.
  • apps/mobile/src/features/usage/UsageRouteScreen.tsx:223 — Usage proof exercises copied menu wiring, not the mounted screen. Add device before/after screenshots with distinct, non-deduplicated usage on both servers and verify that the displayed totals change; the draft already discloses this gap.
  • apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx:80 — The Android Threads/Archive repro is not scenario-ready: seed a visible live thread and an archived thread on each environment, then assert that only Alpha rows remain after choosing Alpha and that reset restores both environments.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Dec 1, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at c0e8c29

Macroscope's review found this PR approvable — Separates actual environment IDs from the “All environments” menu action across mobile filters. This is a limited UI selection correction with unchanged defaults and no changes to permissions or stored data.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c0e8c29 and c4667d9.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The “All environments” menu item now has a distinct identifier in the home, archive, and usage menus. The usage menu clears selected IDs directly for that action and toggles individual environments by their IDs. A test covers selecting an environment whose ID is “all.”

Changes: Environment filter menus

Layer / File(s) Summary
Menu identifiers and selection handling
apps/mobile/src/features/home/home-list-filter-menu.ts, apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx, apps/mobile/src/features/usage/UsageRouteScreen.tsx, apps/mobile/src/features/home/home-list-filter-menu.test.ts
The home and archive menus use all-environments for the “All environments” item. The usage menu clears selected IDs for that action and toggles individual environments using their IDs. The test checks selection of an environment with ID all.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: Minimal · previous review c0e8c

This change fixes the mobile environment filter so a server whose environment ID is "all" can be selected without resetting the filter. No concrete merge-blocking risk was found, and the change is small and easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(mobile): let Usage filter an environment whose ID is all" follows the conventional commit style and matches the main change. The PR fixes Usage so an environment whose ID is "all" filte…
Description check Passed The description follows the repository template. It has Problem, Change, Scope, and Verification sections. The Problem section gives a reproduction and expected behavior. The Change section explains t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(mobile): let Usage filter an environment whose ID is all" follows the conventional commit style and matches the main change. The PR fixes Usage so an environment whose ID is "all" filters correctly instead of acting as the reset action. The title is specific to the changeset. It also omits the Android Threads and Archived threads menu ID change, which is a secondary part of the fix.

Full details: Description check

Explanation

The description follows the repository template. It has Problem, Change, Scope, and Verification sections. The Problem section gives a reproduction and expected behavior. The Change section explains the Usage and Threads/Archived threads fixes. The Scope section explains why no issue is needed. The Verification section lists a Threads regression test, a copied-wiring Usage check, and a check run, and it states what was not shown. Remaining gaps: the linked transcript still contains superseded excerpts, and there are no device screenshots or on-device runs. The template requires before/after screenshots for UI changes, and the description does not include them. The reviewer comments in the description also list open items.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ed721f7 and c0e8c29.

Files selected for processing: 4

  • apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx
  • apps/mobile/src/features/home/home-list-filter-menu.test.ts
  • apps/mobile/src/features/home/home-list-filter-menu.ts
  • apps/mobile/src/features/usage/UsageRouteScreen.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 1, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Native Android dev client on Pixel 9, Android 16/API 36, 1080×2424, light theme. Separate checkouts, Metro bundles, and fresh server databases for each commit; Alpha has ID all, Lab has ID lab. Threads use the repository's Replay (dev) recordings. Usage scans the same two isolated, real Pi sessions on both sides (340 Alpha + 371 Lab = 711 tokens).

Steps: select Alpha in Threads and Archive, use Lab as the control, switch back to Alpha, then restore All environments. In Usage → Tokens, tap Alpha off from all selected; restore all, tap Lab off, then Alpha off; restore all again. The recordings show these same scripted interactions on both commits.

Before After
facc02ea36 c4667d9e7e
Threads → Alpha: both Alpha-live and Lab-live remain. Before: Alpha filter leaves both environments visible Threads recording Threads → Alpha: only Alpha rows remain; Lab control and All environments restore work. After: Alpha filter shows only Alpha threads Threads recording
Archive → Alpha: both archived rows remain; the check stays on All environments. Before: Alpha archive filter leaves both archived rows Archive recording Archive → Alpha: only Alpha-archived remains; the check moves to Alpha. After: Alpha archive filter shows only Alpha-archived Archive recording
Usage → tap Alpha off: remains 711 tokens / 2 sessions. Before: toggling Alpha leaves aggregate usage Usage recording Usage → tap Alpha off: 371 tokens / 1 session, Lab only. Lab off yields Alpha's 340; Alpha off then clears selection; All environments restores 711 / 2. After: toggling Alpha excludes its usage Usage recording
Usage selection after tapping Alpha: all three items remain checked. Before: All environments, Alpha and Lab remain checked Usage selection after tapping Alpha: only Lab is checked. After: only Lab remains selected

The duplicate-key warning toasts in the base captures are produced by this defect (environment:all in Threads/Archive and all in Usage); they do not appear during the head flows. Stills were taken after two byte-identical screenshots at least 500 ms apart. Recordings and selected captures were visually inspected before upload.

Drivers and setup: run instructions, environment setup, thread seed, archive setup, real usage seed, Threads driver, Archive driver, Usage driver.

Not shown:

  • iOS was not separately exercised; this proof covers the reported Android Threads and Archive flows and Usage on Android.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 1, 2026
@juliusmarminge
juliusmarminge merged commit 7cf7446 into pingdotgg:main Dec 1, 2026
58 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 1, 2026
imetn added a commit to imetn/t4code that referenced this pull request Dec 2, 2026
…ce-control & server fixes)

Ported 15 commits from 772e3d4..1e6e7d7:
- ff548ac (pingdotgg#46552), 4025a2f (pingdotgg#46733), abf106f (pingdotgg#46759), c4f3661 (pingdotgg#46960), 5cac91c (pingdotgg#47138)
- 7cf7446 (pingdotgg#46736 mobile Usage filter env 'all', Lock pingdotgg#5 icons preserved)
- 0a5e0e3 (pingdotgg#46848 Android saved route priority)
- b6ac305 (pingdotgg#47096 mobile Git branch grapheme/flag cuts)
- 946d88b (pingdotgg#47098 mobile SVG pixel dimensions)
- c3faadd (pingdotgg#45111 mobile confirm stop once per run)
- a32c694 (pingdotgg#43968 PR Author menu replaces typed author qualifier)
- 6baa47d (pingdotgg#46934 preserve repeated JSON keys in tool output)
- aef9eb9 (pingdotgg#46497 Forgejo PR org labels)
- c57dd42 (pingdotgg#47143 Forgejo issue detail newest comments)
- a7256d6 (pingdotgg#46622 GitLab multiline issue titles)
(Note: pingdotgg#46702 8184b93 already functionally present via useOpenOrReturnToThread.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants