Skip to content

Restore Agent Tank Model Usage Block in Mobile Bottom Navigation More Sheet #2060

Closed

Description

@propr-dev

Context

Following the PWA and mobile layout migration (Issue #1726, PR #1940), the application shell replaced the legacy top navigation bar with a dedicated mobile bottom navigation bar (MobileBottomNavigation) on viewports under 768px (md). As part of this responsive redesign, GlobalHeader was updated to hidden md:flex, hiding the mobile hamburger menu toggle on small screens.

Prior to this change, mobile users accessed the navigation drawer by tapping the hamburger menu. At the bottom of that sidebar sat <AgentTankSidebar>, which displays real-time subscription usage and rate limits (e.g., Claude Code Pro/Max 5-hour session and weekly quotas, Codex session/weekly limits, Antigravity Gemini model tiers). However, when the mobile navigation was refactored into the bottom navigation bar and the expandable "More" bottom sheet, the model usage block (AgentTankSidebar) was not included in MobileBottomNavigation. Because the desktop sidebar is permanently off-canvas (-translate-x-full) on mobile viewports without any toggle button, the model usage block became completely invisible and inaccessible to mobile users.

This issue restores the Agent Tank model usage block to the mobile UI by embedding it directly into the MobileBottomNavigation "More" sheet, alongside system health and account controls, ensuring that mobile and PWA users can monitor their model capacity and rate limits on any device.


Requirements

  1. Surface Model Usage in Mobile UI: Embed the Agent Tank usage component into the MobileBottomNavigation "More" bottom sheet, positioning it directly after <HealthDetails> and before the user identity/logout section.
  2. Permission Gating: Guard the usage block so that it only renders if the user has instance.manage_agents permission or if the application is running in read-only demo mode (isDemoMode). This matches the backend authorization requirement (requireAgentTankUsageAccess on /api/config/agent-tank/usage) and mirrors the desktop sidebar behavior in Layout.tsx.
  3. Demo Mode Handling: When in demo mode, suppress the manual refresh button (allowManualRefresh={!isDemoMode}) to prevent unauthorized mutating requests while still displaying the synthetic usage feed.
  4. Container Theming and Spacing: Add an optional className prop to AgentTankSidebarProps to allow containers like the mobile bottom sheet to supply border colors (e.g., border-slate-100) that match the surrounding sheet theme instead of being locked to border-gray-200.
  5. Keyboard and Screen-Reader Accessibility: Enhance multi-metric agent rows in AgentTankSidebar with role="button", tabIndex={0}, aria-expanded, and keyboard handlers (Enter / Space) so mobile and desktop keyboard/screen-reader users can toggle metric breakdowns.
  6. Export Semantic Alias: Export AgentTankSidebar as AgentTankUsage alongside the default export so that call sites outside the desktop sidebar context can refer to the component with semantic clarity.
  7. Graceful Degradation: Ensure that when Agent Tank is disabled, unconfigured, or unreachable, the component returns null and takes up 0px without rendering orphaned borders or empty cards in the More sheet.
  8. Automated Unit Testing: Add unit test coverage in MobileBottomNavigation.test.tsx verifying:
    • The usage block renders when enabled and the user possesses instance.manage_agents.
    • The usage block is hidden when the user lacks instance.manage_agents (in non-demo mode).
    • The usage block renders in demo mode with the manual refresh button hidden.
    • Tapping an agent row with multiple metrics toggles the sub-metric breakdown display.

Implementation Specification

1. propr-ui/src/components/AgentTankSidebar.tsx

  • Extend AgentTankSidebarProps with an optional className?: string.
  • Update AgentTankSidebar's root element to use border-t ${className || 'border-gray-200'} to allow custom borders.
  • In AgentRow, add role="button", tabIndex={0}, aria-expanded={expanded}, and an onKeyDown handler listening for Enter and Space when hasMultipleMetrics is true.
  • Add export { AgentTankSidebar as AgentTankUsage }; before export default AgentTankSidebar;.

2. propr-ui/src/components/MobileBottomNavigation.tsx

  • Import AgentTankSidebar from ./AgentTankSidebar.
  • Inside the "More" bottom sheet modal, insert <AgentTankSidebar allowManualRefresh={!isDemoMode} className="border-slate-100" /> immediately after <HealthDetails systemHealth={systemHealth} />, wrapped in the permission check (isDemoMode || userHasPermission(user, 'instance.manage_agents')).

3. propr-ui/src/components/MobileBottomNavigation.test.tsx

  • Mock ../api/revertApi using Vitest (getAgentTankUsage and refreshAgentTank).
  • In beforeEach, default getAgentTankUsage to { enabled: false } so that existing navigation tests are not impacted.
  • Add test cases covering permission gating, demo mode refresh suppression, and metric row expansion in the More sheet.

Acceptance Criteria

  1. When viewing the application on a mobile viewport (< 768px) with Agent Tank configured, tapping "More" in the bottom navigation bar reveals the "Usage" block showing provider icons, provider names, and usage progress bars.
  2. Clicking or tapping a provider row with multiple metrics (e.g. Claude session and weekly metrics) toggles the expanded detail view showing individual sub-metrics and reset countdowns.
  3. Keyboard users can focus and toggle multi-metric provider rows using Enter or Space.
  4. Users without instance.manage_agents permission (and not in demo mode) do not see the Usage block in the More sheet.
  5. In demo mode, the Usage block is visible, but the manual refresh button (title="Refresh usage") is omitted.
  6. When Agent Tank is disabled or unreachable, no empty space or orphaned divider line appears in the More sheet.
  7. On desktop viewports (>= 1024px), AgentTankSidebar continues to render in the left sidebar as before with no regression.
  8. Running npm test -- src/components/MobileBottomNavigation.test.tsx passes cleanly with all new and existing tests.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Sep 2, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    This implementation restores the Agent Tank model usage block to mobile users by integrating AgentTankSidebar directly into the MobileBottomNavigation "More" bottom sheet. The "More" sheet was established during the PWA mobile redesign as the unified mobile container for all secondary navigation and system health utilities (such as HealthDetails and user profile actions). Embedding the usage block here ensures it is always accessible from any page on mobile with a single tap, without cluttering the primary 5-icon bottom bar or requiring a redundant secondary drawer.

    Alternatives Considered

    • Adding an Agent Tank destination to the primary bottom bar: Rejected because 5 destinations (Inbox, Activity, New Plan, Repositories, More) is the widely accepted ergonomic maximum for mobile bottom bars (WCAG & mobile HIG). Adding a 6th destination would shrink touch targets below 44px, cause label truncation on narrower mobile screens (such as 375px viewports), and disrupt established navigation patterns.
    • Reintroducing the hamburger menu toggle on mobile headers: Rejected because the mobile PWA shell deliberately eliminated the desktop header in favor of bottom-oriented navigation for better one-handed reachability. Reintroducing a top menu button would create conflicting navigation pathways and inconsistent mental models between desktop and mobile.
    • Placing Agent Tank usage solely on the Dashboard page: Rejected because desktop users have continuous visibility into Agent Tank across every page via the sidebar. Restricting mobile visibility to the dashboard would degrade the mobile experience, preventing operators from checking quota pressure while reviewing tasks, reading logs, or managing plans.

    Key Architectural Decisions

    • Reuse Existing Component: We reuse AgentTankSidebar rather than creating a separate mobile usage component. This avoids duplicating polling intervals, provider ranking, percentage color coding, Antigravity label formatting, and data-fetching logic.
    • Flexible Border Theming via className: We add a className prop to AgentTankSidebarProps to allow the mobile sheet to specify border-slate-100, aligning seamlessly with the surrounding slate borders in MobileBottomNavigation while preserving the default border-gray-200 in the desktop sidebar.
    • Consistent Permission & Demo Gating: We enforce (isDemoMode || userHasPermission(user, 'instance.manage_agents')) and allowManualRefresh={!isDemoMode}, strictly mirroring Layout.tsx and preventing unauthorized 403 network requests against the backend.

    File: propr-ui/src/components/AgentTankSidebar.tsx

    Why this file: This file contains the core rendering logic for the model usage block. We need to: (1) allow the parent container to customize border styling so it matches the mobile sheet's slate palette, (2) enhance keyboard accessibility on collapsible agent rows for screen readers and keyboard navigation, and (3) export a semantic alias (AgentTankUsage) so call sites outside the desktop sidebar can reference it intuitively.

    --- a/propr-ui/src/components/AgentTankSidebar.tsx
    +++ b/propr-ui/src/components/AgentTankSidebar.tsx
    @@ -203,6 +203,16 @@
             className={`flex items-center justify-between ${hasMultipleMetrics ? 'cursor-pointer hover:bg-gray-50 -mx-1 px-1 rounded' : ''}`}
             onClick={hasMultipleMetrics ? onToggle : undefined}
    +        // Enable keyboard activation (Enter or Space) to toggle metric breakdown,
    +        // ensuring complete accessibility for keyboard-only and screen-reader users.
    +        onKeyDown={hasMultipleMetrics ? (e) => {
    +          if (e.key === 'Enter' || e.key === ' ') {
    +            e.preventDefault();
    +            onToggle();
    +          }
    +        } : undefined}
    +        role={hasMultipleMetrics ? 'button' : undefined}
    +        tabIndex={hasMultipleMetrics ? 0 : undefined}
    +        aria-expanded={hasMultipleMetrics ? expanded : undefined}
           >
             <div className="flex items-center gap-1.5 text-gray-600">
    @@ -242,7 +252,14 @@
     interface AgentTankSidebarProps {
       allowManualRefresh?: boolean;
    +  // Optional custom className to allow host containers (such as the mobile More sheet)
    +  // to provide specific border/padding styles (e.g. border-slate-100) matching their palette.
    +  className?: string;
     }
     
    -const AgentTankSidebar: React.FC<AgentTankSidebarProps> = ({ allowManualRefresh = true }) => {
    +const AgentTankSidebar: React.FC<AgentTankSidebarProps> = ({
    +  allowManualRefresh = true,
    +  className = '',
    +}) => {
       const [data, setData] = useState<AgentTankUsageResponse | null>(null);
       const [loading, setLoading] = useState(true);
    @@ -298,7 +315,9 @@
       return (
    -    <div className="px-4 py-3 border-t border-gray-200">
    +    // Use custom border class if provided to match host container styling (e.g., mobile bottom sheet),
    +    // falling back to the standard sidebar border-gray-200.
    +    <div className={`px-4 py-3 border-t ${className || 'border-gray-200'}`}>
           <div className="flex items-center justify-between mb-2">
             <span className="text-[10px] font-semibold uppercase tracking-wider text-gray-400">
               Usage
             </span>
    @@ -328,2 +347,5 @@
     
    +// Export a semantic alias for use outside the desktop sidebar context (e.g. mobile bottom sheet),
    +// while maintaining the default export for full backwards compatibility.
    +export { AgentTankSidebar as AgentTankUsage };
     export default AgentTankSidebar;

    File: propr-ui/src/components/MobileBottomNavigation.tsx

    Why this file: This is the mobile navigation controller that renders the persistent bottom tab bar and the "More" bottom sheet on viewports < md. By rendering AgentTankSidebar inside the More sheet directly beneath HealthDetails, we restore model usage observability to mobile users with appropriate permission and demo-mode guards.

    --- a/propr-ui/src/components/MobileBottomNavigation.tsx
    +++ b/propr-ui/src/components/MobileBottomNavigation.tsx
    @@ -23,6 +23,8 @@
     import { userHasPermission } from '../contexts/AuthContext';
    +// Import the model usage component to restore capacity monitoring in the mobile navigation shell
    +import AgentTankSidebar from './AgentTankSidebar';
     
     interface MobileBottomNavigationProps {
       user: CurrentUser | null;
       onLogout: () => void;
    @@ -259,6 +261,16 @@
                 <HealthDetails systemHealth={systemHealth} />
     
    +            {/* Model usage block (Agent Tank) - surfaced in the mobile More sheet so capacity
    +                and rate limits remain accessible after the removal of the desktop sidebar on mobile.
    +                Guarded by instance.manage_agents or demo mode to align with backend authorization
    +                and desktop Layout behavior. Manual refresh is suppressed in demo mode. */}
    +            {(isDemoMode || userHasPermission(user, 'instance.manage_agents')) && (
    +              <AgentTankSidebar
    +                allowManualRefresh={!isDemoMode}
    +                className="border-slate-100"
    +              />
    +            )}
    +
                 {user && (
                   <div className="border-t border-slate-100 p-4">
                     <div className="flex items-center gap-3">

    File: propr-ui/src/components/MobileBottomNavigation.test.tsx

    Why this file: This file tests MobileBottomNavigation. We add unit test coverage to ensure that the usage block is properly rendered when authorized, hidden when unauthorized, rendered in demo mode without the refresh button, and expandable on mobile tap interactions.

    --- a/propr-ui/src/components/MobileBottomNavigation.test.tsx
    +++ b/propr-ui/src/components/MobileBottomNavigation.test.tsx
    @@ -1,6 +1,6 @@
    -import { fireEvent, render, screen, within } from '@testing-library/react';
    +import { fireEvent, render, screen, within } from '@testing-library/react';
     import { MemoryRouter, useLocation } from 'react-router-dom';
    -import { describe, expect, it, vi } from 'vitest';
    +import { beforeEach, describe, expect, it, vi } from 'vitest';
     import type { CurrentUser } from '../api/proprTypes';
     import type { HeaderStats } from '../hooks/useHeaderStats';
     import MobileBottomNavigation from './MobileBottomNavigation';
    +import { getAgentTankUsage } from '../api/revertApi';
    +
    +// Mock revertApi to isolate navigation tests from network requests and allow
    +// deterministic simulation of enabled, disabled, and multi-metric usage states.
    +vi.mock('../api/revertApi', () => ({
    +  getAgentTankUsage: vi.fn(),
    +  refreshAgentTank: vi.fn().mockResolvedValue({ success: true }),
    +}));
     
     const user: CurrentUser = {
    @@ -58,4 +68,9 @@
     describe('MobileBottomNavigation', () => {
    +  beforeEach(() => {
    +    // Default to disabled so existing navigation tests without mock setup don't render unexpected usage UI
    +    vi.mocked(getAgentTankUsage).mockResolvedValue({ enabled: false });
    +  });
    +
       it('renders all five destinations in order with the unread count and route active state', () => {
         renderNavigation();
    @@ -145,2 +160,94 @@
         expect(onLogout).toHaveBeenCalledOnce();
       });
    +
    +  it('renders Agent Tank usage in the More sheet when enabled and user has manage_agents permission', async () => {
    +    // Provide mock subscription usage data to verify usage rendering in the sheet
    +    vi.mocked(getAgentTankUsage).mockResolvedValue({
    +      enabled: true,
    +      agents: {
    +        claude: {
    +          name: 'claude',
    +          usage: {
    +            session: { percent: 45, resetsIn: '2h' },
    +            weeklyAll: { percent: 70, resetsIn: '3d' },
    +          },
    +        },
    +      },
    +    });
    +
    +    renderNavigation();
    +    const moreButton = screen.getByRole('button', { name: 'More' });
    +    fireEvent.click(moreButton);
    +
    +    // Verify that the Usage section header, provider name, and primary usage percentage are visible
    +    expect(await screen.findByText('Usage')).toBeInTheDocument();
    +    expect(screen.getByText('Claude')).toBeInTheDocument();
    +    expect(screen.getByText('45%')).toBeInTheDocument();
    +  });
    +
    +  it('hides Agent Tank usage in the More sheet when user lacks manage_agents permission and is not in demo mode', () => {
    +    vi.mocked(getAgentTankUsage).mockResolvedValue({
    +      enabled: true,
    +      agents: {
    +        claude: {
    +          name: 'claude',
    +          usage: { session: { percent: 45 } },
    +        },
    +      },
    +    });
    +
    +    // Render navigation with user lacking manage_agents permission
    +    renderNavigation('/tasks', vi.fn(), {
    +      ...user,
    +      permissions: ['instance.manage_members'],
    +    });
    +
    +    fireEvent.click(screen.getByRole('button', { name: 'More' }));
    +
    +    // Usage section must be omitted to prevent unauthorized API calls
    +    expect(screen.queryByText('Usage')).not.toBeInTheDocument();
    +  });
    +
    +  it('renders Agent Tank usage in demo mode and suppresses the manual refresh button', async () => {
    +    vi.mocked(getAgentTankUsage).mockResolvedValue({
    +      enabled: true,
    +      agents: {
    +        claude: {
    +          name: 'claude',
    +          usage: { session: { percent: 30 } },
    +        },
    +      },
    +    });
    +
    +    // Render navigation in demo mode with empty user permissions
    +    render(
    +      <MemoryRouter initialEntries={['/tasks']}>
    +        <MobileBottomNavigation
    +          user={{ ...user, permissions: [] }}
    +          onLogout={vi.fn()}
    +          isDemoMode={true}
    +          unreadCount={0}
    +          systemHealth={systemHealth}
    +        />
    +      </MemoryRouter>
    +    );
    +
    +    fireEvent.click(screen.getByRole('button', { name: 'More' }));
    +
    +    expect(await screen.findByText('Usage')).toBeInTheDocument();
    +    expect(screen.getByText('Claude')).toBeInTheDocument();
    +    // Refresh button must be omitted in demo mode to prevent mutating actions
    +    expect(screen.queryByRole('button', { name: 'Refresh usage' })).not.toBeInTheDocument();
    +  });
    +
    +  it('toggles metric breakdown when clicking an agent row with multiple metrics in the More sheet', async () => {
    +    vi.mocked(getAgentTankUsage).mockResolvedValue({
    +      enabled: true,
    +      agents: {
    +        claude: {
    +          name: 'claude',
    +          usage: {
    +            session: { percent: 45, resetsIn: '2h' },
    +            weeklyAll: { percent: 70, resetsIn: '3d' },
    +          },
    +        },
    +      },
    +    });
    +
    +    renderNavigation();
    +    fireEvent.click(screen.getByRole('button', { name: 'More' }));
    +
    +    expect(await screen.findByText('Claude')).toBeInTheDocument();
    +    // Sub-metric labels are collapsed initially
    +    expect(screen.queryByText('Weekly')).not.toBeInTheDocument();
    +
    +    // Click Claude agent row to expand metrics breakdown
    +    fireEvent.click(screen.getByText('Claude'));
    +
    +    // Expanded sub-metrics should now be visible
    +    expect(screen.getByText('Weekly')).toBeInTheDocument();
    +    expect(screen.getByText('70%')).toBeInTheDocument();
    +  });
     });
  2. propr-dev commented on Sep 2, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using codex agent with gpt-5.6-sol model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: codex
    • Model: gpt-5.6-sol
    • Branch: 2060/gpt-5.6-sol-restore-agent-tank-model--20260902-0626-pse
    • Base Branch: main
    • Worktree: issue-2060-20260902-0626-gpt-5.6-sol-pse

    🔍 Track Task Execution

  3. added a commit that references this issue on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions