Skip to content

Fix mobile settings and live provider usage#854

Merged
arul28 merged 2 commits into
mainfrom
ade/ok-start-skill-pass-two-ac43c8e6
Jul 18, 2026
Merged

Fix mobile settings and live provider usage#854
arul28 merged 2 commits into
mainfrom
ade/ok-start-skill-pass-two-ac43c8e6

Conversation

@arul28

@arul28 arul28 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • add Settings access to mobile Work and return user-triggered machine transitions to Hub before transport changes
  • align mobile Claude/Codex usage cards, external links, refresh behavior, and percent semantics with desktop
  • make the desktop header and full usage panel consume the same authoritative binding-scoped snapshots
  • preserve valid Claude quota data during non-interactive refreshes and clear only the legacy false auth error

Validation

  • desktop typecheck
  • targeted desktop usage/preload suites (260 tests)
  • affected desktop CI shards 1, 2, and 4 (3,069 tests)
  • ADE CLI typecheck and 1,970 tests
  • ADE TUI typecheck and 924 tests
  • five targeted iOS simulator tests

Summary by CodeRabbit

  • New Features

    • Added an optional Settings shortcut to the iOS top toolbar.
    • Improved usage quota displays with provider labels, clearer window names, reset countdowns, and spending-cap messaging.
    • Usage activity refreshes automatically after manual quota updates.
  • Bug Fixes

    • Prevented stale or out-of-order usage data from replacing newer information.
    • Preserved valid usage details when provider credentials cannot be refreshed.
    • Improved connection transitions so the project home view remains available during reconnects and disconnects.
    • Clamped quota percentages to valid 0–100% values.

Greptile Summary

This PR aligns desktop and iOS usage surfaces around live, binding-scoped quota snapshots. The main changes are:

  • Desktop usage polling now preserves valid Claude quota data during non-interactive refreshes.
  • Desktop preload and renderer usage components now ignore stale snapshots and reset state on project binding changes.
  • iOS Work and Settings screens now show usage percentages, provider labels, links, reset timing, and spend-cap state consistently.
  • iOS connection changes now return the UI to the Hub before reconnect, disconnect, pairing, or handoff transitions.
  • Tests and docs were updated for the usage refresh and mobile connection flows.

Confidence Score: 5/5

Safe to merge with low risk.

The changes are focused on usage snapshot routing, quota preservation, and mobile UI state transitions, with tests covering the main stale-snapshot and binding-change paths.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The desktop typecheck step was killed (exit code 137) as shown in the desktop-typecheck.log.
  • The targeted Vitest run for desktop usage preload completed with exit code 0, showing Test Files 3 passed (3) and Tests 263 passed (263).
  • iOS simulator validation was intentionally not attempted because the Linux sandbox lacks xcodebuild.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
apps/desktop/src/main/services/usage/usageTrackingService.ts Carries forward valid provider windows and extra usage when a non-interactive provider poll requests preservation.
apps/desktop/src/preload/preload.ts Routes usage events by binding state so local snapshots are used only when unbound and remote/local-runtime events when bound.
apps/desktop/src/renderer/components/usage/HeaderUsageControl.tsx Resets and guards header usage state across binding changes and stale snapshot arrivals.
apps/desktop/src/renderer/components/usage/UsageQuotaPanel.tsx Applies the same snapshot ordering and binding-generation protections to the full quota panel.
apps/ios/ADE/Services/SyncService.swift Returns the iOS UI to the Hub before user-triggered machine reconnect, disconnect, pairing, and handoff transitions.
apps/ios/ADE/Views/Settings/ConnectionSettingsView.swift Updates mobile settings usage cards with provider branding, used-percent semantics, links, reset labels, and spend-cap messaging.
apps/ios/ADE/Views/Work/WorkUsageActivityCarousel.swift Aligns compact mobile usage limits with desktop provider labels, used percentages, clamping, and refresh revisions.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
  participant Provider as Claude/Codex provider
  participant Machine as Machine usage tracker
  participant Runtime as Runtime event pump
  participant Preload as Desktop preload bridge
  participant UI as Header/Quota panel
  participant iOS as iOS usage surfaces

  Provider->>Machine: Poll quota windows
  alt Non-interactive Claude cannot verify credentials
    Machine->>Machine: Preserve previous unexpired windows
  else Fresh provider result
    Machine->>Machine: Merge fresh windows/status
  end
  Machine->>Runtime: Emit usage snapshot event
  Runtime->>Preload: Stream binding-scoped usage event
  Preload->>UI: Dispatch only events matching binding state
  UI->>UI: Ignore older snapshots and reset on binding change
  iOS->>Machine: Refresh quota / request usage stats
  Machine-->>iOS: Return live quota/activity snapshots
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
  participant Provider as Claude/Codex provider
  participant Machine as Machine usage tracker
  participant Runtime as Runtime event pump
  participant Preload as Desktop preload bridge
  participant UI as Header/Quota panel
  participant iOS as iOS usage surfaces

  Provider->>Machine: Poll quota windows
  alt Non-interactive Claude cannot verify credentials
    Machine->>Machine: Preserve previous unexpired windows
  else Fresh provider result
    Machine->>Machine: Merge fresh windows/status
  end
  Machine->>Runtime: Emit usage snapshot event
  Runtime->>Preload: Stream binding-scoped usage event
  Preload->>UI: Dispatch only events matching binding state
  UI->>UI: Ignore older snapshots and reset on binding change
  iOS->>Machine: Refresh quota / request usage stats
  Machine-->>iOS: Return live quota/activity snapshots
Loading

Reviews (2): Last reviewed commit: "ship: iteration 1 — harden usage refresh..." | Re-trigger Greptile

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored Preview Jul 18, 2026 2:23am

@arul28 arul28 changed the title mobile-settings-and-usage-sync -> Primary Fix mobile settings and live provider usage Jul 18, 2026
@arul28

arul28 commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

@copilot review but do not make fixes

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR changes desktop usage polling ownership, provider-state reconciliation, binding-aware snapshot handling, and event routing. It also updates iOS connection transition state, toolbar settings access, quota presentation, usage refresh behavior, and related tests.

Changes

Desktop usage synchronization

Layer / File(s) Summary
Provider polling reconciliation
apps/desktop/src/main/services/usage/*
Provider polls now distinguish fresh results from preserve_previous results and carry forward prior provider state when polling is unavailable.
Runtime usage event ownership
apps/desktop/src/main/main.ts, apps/desktop/src/preload/*
Runtime-backed contexts stop local usage polling, while preload events are forwarded according to project binding state.
Snapshot ordering and binding changes
apps/desktop/src/renderer/components/usage/*
Usage components share snapshot ordering rules, reset state on binding changes, reject stale async results, and restart status checks.
Polling and snapshot validation
apps/desktop/src/main/services/usage/usageTrackingService.test.ts, apps/desktop/src/preload/preload.test.ts, apps/desktop/src/renderer/components/usage/usage.test.tsx
Tests cover preserved Claude state, authentication errors, backoff, event bridging, and snapshot ordering.

iOS connection and settings controls

Layer / File(s) Summary
User connection transition helpers
apps/ios/ADE/Services/SyncService.swift
User-triggered connection paths now restore project-home presentation state before disconnect or reconnect work.
Settings toolbar wiring
apps/ios/ADE/Views/Components/ADEDesignSystem.swift, apps/ios/ADE/Views/Work/WorkRootScreen.swift
Root toolbar APIs support an optional Settings button, which is hidden during Work selection mode.
Connection settings integration
apps/ios/ADE/Views/Settings/ConnectionSettingsView.swift, apps/ios/ADETests/ADETests.swift
Connection settings use the new transition-aware methods, with tests covering project-home state behavior.

iOS usage quota presentation

Layer / File(s) Summary
Quota data and settings presentation
apps/ios/ADE/Models/RemoteModels.swift, apps/ios/ADE/Views/Settings/ConnectionSettingsView.swift
Quota percentages are clamped and settings cards display provider details, spending-cap state, usage progress, status text, and reset countdowns.
Usage activity refresh flow
apps/ios/ADE/Views/Work/*
Manual quota refreshes increment a revision used to reload activity data, with provider-specific quota labels and percentages.
Quota value validation
apps/ios/ADETests/ADETests.swift
Tests verify percentage clamping.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • arul28/ADE#276: Overlaps the desktop usage snapshot and polling pipeline changes.
  • arul28/ADE#327: Also changes header usage snapshot ordering and refresh behavior.
  • arul28/ADE#813: Overlaps the iOS reconnect and connection settings flow.

Suggested labels: desktop, ios, docs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.65% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and matches the main themes of the changes: mobile settings UI and live usage/provider syncing.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade/ok-start-skill-pass-two-ac43c8e6

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/desktop/src/renderer/components/usage/HeaderUsageControl.tsx (1)

172-177: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Guard explicit refreshes against project-binding changes.

Both refresh handlers can apply an old project’s response after rebinding. Promote the binding generation to a ref shared with these callbacks, capture it before the request, and discard the result if it changed.

  • apps/desktop/src/renderer/components/usage/HeaderUsageControl.tsx#L172-L177: generation-guard the result of window.ade.usage.refresh().
  • apps/desktop/src/renderer/components/usage/UsageQuotaPanel.tsx#L287-L292: apply the same guard in refreshNow and add a binding-during-refresh regression test.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/renderer/components/usage/HeaderUsageControl.tsx` around
lines 172 - 177, Promote the project-binding generation to a shared ref used by
both refresh callbacks. In
apps/desktop/src/renderer/components/usage/HeaderUsageControl.tsx lines 172-177,
capture the generation before window.ade.usage.refresh() and applySnapshot only
when it is unchanged; make the same change in
apps/desktop/src/renderer/components/usage/UsageQuotaPanel.tsx lines 287-292
within refreshNow, and add a regression test covering rebinding during refresh.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/desktop/src/main/services/usage/usageTrackingService.ts`:
- Around line 2673-2689: The skipped-provider handling around carriedWindows and
providerStatus must not restore a previous “ok” status when all carried windows
have expired. Only preserve the previous status while carriedWindows remains
valid; otherwise retain the stale-status fallback when lastSuccessAt exists or
clear/downgrade the status. Add a test covering expiration of the final carried
window and the resulting non-ok status.

---

Outside diff comments:
In `@apps/desktop/src/renderer/components/usage/HeaderUsageControl.tsx`:
- Around line 172-177: Promote the project-binding generation to a shared ref
used by both refresh callbacks. In
apps/desktop/src/renderer/components/usage/HeaderUsageControl.tsx lines 172-177,
capture the generation before window.ade.usage.refresh() and applySnapshot only
when it is unchanged; make the same change in
apps/desktop/src/renderer/components/usage/UsageQuotaPanel.tsx lines 287-292
within refreshNow, and add a regression test covering rebinding during refresh.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c05f0c70-b659-42f4-8c85-98b44132a8b2

📥 Commits

Reviewing files that changed from the base of the PR and between 2cc83ee and 755205d.

⛔ Files ignored due to path filters (3)
  • docs/ARCHITECTURE.md is excluded by !docs/**
  • docs/features/onboarding-and-settings/README.md is excluded by !docs/**
  • docs/features/sync-and-multi-device/ios-companion.md is excluded by !docs/**
📒 Files selected for processing (18)
  • apps/desktop/src/main/main.ts
  • apps/desktop/src/main/services/usage/usageProviderStrategies.ts
  • apps/desktop/src/main/services/usage/usageTrackingService.test.ts
  • apps/desktop/src/main/services/usage/usageTrackingService.ts
  • apps/desktop/src/preload/preload.test.ts
  • apps/desktop/src/preload/preload.ts
  • apps/desktop/src/renderer/components/usage/HeaderUsageControl.tsx
  • apps/desktop/src/renderer/components/usage/UsageQuotaPanel.tsx
  • apps/desktop/src/renderer/components/usage/usage.test.tsx
  • apps/desktop/src/renderer/components/usage/usageSnapshotOrdering.ts
  • apps/ios/ADE/Models/RemoteModels.swift
  • apps/ios/ADE/Services/SyncService.swift
  • apps/ios/ADE/Views/Components/ADEDesignSystem.swift
  • apps/ios/ADE/Views/Settings/ConnectionSettingsView.swift
  • apps/ios/ADE/Views/Work/WorkNewChatScreen.swift
  • apps/ios/ADE/Views/Work/WorkRootScreen.swift
  • apps/ios/ADE/Views/Work/WorkUsageActivityCarousel.swift
  • apps/ios/ADETests/ADETests.swift

Comment thread apps/desktop/src/main/services/usage/usageTrackingService.ts
@arul28

arul28 commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 6e6ce047f1

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@arul28
arul28 merged commit fd18074 into main Jul 18, 2026
35 checks passed
@arul28
arul28 deleted the ade/ok-start-skill-pass-two-ac43c8e6 branch July 18, 2026 03:46
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