Files
PaperClipAI/ui/src/pages/AgentAdvancedTab.test.tsx
T
Dotta ffd8dcb4af fix(ui): clear mobile bottom nav on overlays and wrap mobile toolbars (#23045)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The board UI renders a fixed mobile bottom navigation bar
(`MobileBottomNav`, height `4rem` plus safe-area inset) and shared
collection toolbars on narrow viewports below `48rem`.
> - On mobile viewports (375px–390px), multi-control toolbars clip
actions off-screen, hidden org-chart controls reserve invisible width in
agent list view, and fixed or sticky footers and floating overlays
either hide behind `MobileBottomNav`, overlap it, or overflow the right
edge.
> - Operators on mobile cannot reach save, discard, retry, wizard
navigation, or toolbar filter controls when those surfaces collide with
the bottom navigation bar or clip off-screen.
> - This pull request adds shared mobile bottom-nav clearance tokens and
responsive rules in `ui/src/index.css`, lifts fixed/sticky footers and
floating overlays above `MobileBottomNav` on `< md` while constraining
horizontal fit at 375px+, wraps `.design-toolbar-actions` and collapses
hidden org-chart controls below `48rem`, and adds unit tests and mobile
Storybook stories.
> - The benefit is that every mobile toolbar, save bar, wizard footer,
bulk selection bar, toast, retry alert, and voice call panel stays fully
visible, reachable, and within the viewport width without changing
desktop layouts.

## Linked Issues or Issue Description

**What happened?**

On viewports narrower than `48rem` (such as 375px–390px mobile screens):
- `.design-toolbar-actions` did not wrap on mobile, pushing trailing
controls (such as Group by and View dropdowns in Coordinator Inbox)
off-screen into `overflow-x-clip`.
- `.agents-org-controls-reveal` reserved invisible `width: max-content`
space next to `New Agent` in mobile list view.
- `AgentAdvancedTab` (`sticky bottom-0 z-10`) and `ProfileWizard`
(`fixed inset-x-0 bottom-0 z-10`) footers sat behind `MobileBottomNav`
(`z-30`, `h-16`).
- `.agent-config-save-bar` (`bottom: 0; z-index: 40`) covered
`MobileBottomNav`, and `.agent-selection-bar` (`--selection-bar-bottom:
48px`) overlapped its top 16px.
- `ToastViewport` (`bottom-3 left-3 w-full max-w-sm`) overlapped
`MobileBottomNav` and overflowed the right edge by 12px at 375px.
- `IssueRowDetailsNotice` and `VoiceCallProvider` sat at `bottom-4` on
top of `MobileBottomNav` and lacked mobile horizontal containment /
viewport-safe max-height.

**Expected behavior**

- Multi-control toolbars wrap cleanly inside the mobile viewport, and
hidden org-chart controls occupy zero space in mobile list view.
- Fixed and sticky footers (`AgentConfigSaveBar`, `AgentAdvancedTab`,
`ProfileWizard`) and floating overlays (`.agent-selection-bar`,
`ToastViewport`, `IssueRowDetailsNotice`, `VoiceCallProvider`) clear
`MobileBottomNav` on `< md` viewports and stay within 375px–390px
horizontal bounds.
- Desktop (`>= 48rem`) layout and positioning remain unchanged.

**Steps to reproduce**

1. Open the Paperclip board UI at a `390x844` or `375x812` mobile
viewport.
2. Open Coordinator Inbox or Agents list view and inspect
`.design-toolbar-actions` and `.agents-org-controls-reveal`.
3. Open Agent settings (Identity/Runtime/Advanced), Tool Profile Wizard,
Agent bulk selection, or trigger a toast, row-details retry alert, or
active voice call panel while `MobileBottomNav` is visible.

**Paperclip version or commit**

`85ad16b47e` (`master`)

## What Changed

- **`ui/src/index.css`**:
- Added `--mobile-nav-overlay-bottom` (`calc(4rem + var(--spacing) * 3 +
var(--sz-safe-bottom))`) and `--mobile-nav-overlay-max-h` tokens for
floating overlays mounted outside `<main>`.
- Added `@media (width < 48rem)` rules to wrap `.design-toolbar-actions`
(`flex-wrap: wrap; min-width: 0; max-width: 100%`), expand
`[data-canonical-toolbar="inbox"] [data-toolbar-search]` to `width:
100%`, and collapse hidden
`.agents-org-controls-reveal:not([data-visible="true"])` (`display:
none`).
- Lifted `.agent-selection-bar` (`--selection-bar-bottom: calc(4rem +
var(--spacing) * 3)`) and `.agent-config-save-bar` (`bottom:
var(--tc-composer-bottom)`, `z-index: var(--z-20)`, mobile padding, full
slide-out transform when hidden, and matching
`.agent-settings-with-save-bar` bottom clearance) below `48rem` while
preserving cascade and `prefers-reduced-motion: reduce` ordering.
- **`ui/src/pages/AgentAdvancedTab.tsx`**: Updated the sticky save
footer to use `mobile-nav-composer`, `bottom-(--tc-composer-bottom)`,
`z-20`, `flex-wrap`, and `md:bottom-0`.
- **`ui/src/pages/tools/profiles/ProfileWizard.tsx`**: Updated the fixed
wizard footer to use `mobile-nav-composer`,
`bottom-(--tc-composer-bottom)`, `z-20`, `md:bottom-0`, and `flex-wrap`,
and increased mobile container bottom padding (`pb-36 md:pb-24`).
- **`ui/src/components/ToastViewport.tsx`**: Lifted toasts with
`bottom-(--mobile-nav-overlay-bottom) md:bottom-3` and replaced `left-3
w-full` with `inset-x-3 sm:inset-x-auto sm:left-3 sm:w-full` to
eliminate 375px right-edge overflow.
- **`ui/src/components/IssueRowDetailsNotice.tsx`**: Lifted above
`MobileBottomNav` with `bottom-(--mobile-nav-overlay-bottom)
md:bottom-4` and bounded mobile width with `inset-x-4 flex-wrap
sm:left-auto sm:right-4 sm:max-w-sm sm:flex-nowrap`.
- **`ui/src/components/voice/VoiceCallProvider.tsx`**: Lifted the active
voice panel with `bottom-(--mobile-nav-overlay-bottom)
max-h-(--mobile-nav-overlay-max-h) md:bottom-4 md:max-h-(--sz-calc-18)`.
- **Tests & Storybook**: Added `ui/src/index.mobile-overlays.test.ts`,
`ui/src/components/IssueRowDetailsNotice.test.tsx`,
`ui/src/components/voice/VoiceCallProvider.test.tsx`,
`ui/src/pages/AgentAdvancedTab.test.tsx`,
`ui/src/pages/tools/profiles/ProfileWizard.test.tsx`, expanded
`ui/src/components/ToastViewport.test.tsx`, and added catalog-compliant
mobile stories in
`ui/storybook/stories/navigation-preferences/mobile-overlays-clearance.stories.tsx`.

## Verification

- `pnpm --filter @paperclipai/ui exec vitest run
src/components/ToastViewport.test.tsx
src/components/IssueRowDetailsNotice.test.tsx
src/components/voice/VoiceCallProvider.test.tsx
src/pages/AgentAdvancedTab.test.tsx
src/pages/tools/profiles/ProfileWizard.test.tsx
src/index.mobile-overlays.test.ts` — 6 test files passed, 14/14 tests
passed.
- `pnpm --filter @paperclipai/ui exec vitest run
src/lib/analytics/replay-masking.test.tsx` — 220/220 tests passed.
- `pnpm --filter @paperclipai/ui typecheck` — passed with 0 errors.
- `pnpm check:token-gates` — all 4 token gates clean and `cliplab
character in sync`.
- `node scripts/storybook-catalog.mjs --check` — passed (373 files, 3491
stories).
- `node --test scripts/check-maps.test.mjs
scripts/storybook-catalog.test.mjs
scripts/storybook-feature-index.test.mjs` — 30/30 tests passed.
- Full-repo Vitest and browser E2E suites were not run locally; CI will
run the required repository checks on this PR.

## Risks

- Low risk. All positioning changes are scoped to `< md` / `< 48rem`
viewports using existing CSS custom property conventions
(`--tc-composer-bottom`, `--tc-composer-visible-nav-offset`,
`--sz-safe-bottom`), leaving desktop (`>= 48rem`) layouts unchanged.
- Floating overlays outside `<main>` (`ToastViewport`,
`IssueRowDetailsNotice`, `VoiceCallProvider`, `.agent-selection-bar`)
use the fixed `--mobile-nav-overlay-bottom` offset so they always clear
`MobileBottomNav` even when rendered in `document.body` portals; when
`MobileBottomNav` auto-hides on scroll, those overlays remain at the
safe clearance height rather than tracking `<main>`'s scroll state.

## Model Used

- Provider and model: Google Antigravity — Gemini 4 Neon (High)
- Capabilities: tool use, code editing, local terminal/test execution

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-11-27 13:41:39 +00:00

90 lines
3.2 KiB
TypeScript

// @vitest-environment jsdom
import { act } from "react";
import { createRoot } from "react-dom/client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { describe, expect, it, vi } from "vitest";
import type { Agent } from "@paperclipai/shared";
import { ToastProvider } from "../context/ToastContext";
import { AgentAdvancedTab } from "./AgentAdvancedTab";
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
vi.mock("@codemirror/view", () => {
class MockEditorView {
state = { doc: { toString: () => "name: Agent\n", length: 12 } };
static contentAttributes = { of: () => [] };
static editable = { of: () => [] };
static updateListener = { of: () => [] };
dispatch() {}
destroy() {}
}
return { EditorView: MockEditorView };
});
vi.mock("../lib/agent-configuration/load", () => ({
loadAgentConfiguration: vi.fn(async () => ({
agent: { id: "agent-1", companyId: "company-1", urlKey: "agent-1", name: "Agent" },
document: { apiVersion: "paperclip/v1", kind: "Agent", metadata: { name: "Agent" } },
})),
}));
vi.mock("../lib/agent-configuration/compact", () => ({
compactAgentConfiguration: (doc: unknown) => doc,
}));
vi.mock("../lib/agent-configuration-yaml", () => ({
serializeAgentConfigurationDocument: () => "name: Agent\n",
parseAgentConfigurationYaml: () => ({ metadata: { name: "Agent" } }),
}));
vi.mock("../lib/agent-configuration/save", () => ({
ConfigurationSaveInterrupted: class extends Error {},
planAgentConfiguration: () => [],
saveAgentConfiguration: vi.fn(),
}));
describe("AgentAdvancedTab", () => {
it("positions the sticky save footer above MobileBottomNav on mobile", async () => {
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false, staleTime: Infinity } },
});
const container = document.createElement("div");
const root = createRoot(container);
const agent = { id: "agent-1", companyId: "company-1", urlKey: "agent-1", name: "Agent" } as Agent;
queryClient.setQueryData(["agent-configuration-yaml", agent.companyId, agent.id], {
agent,
document: { apiVersion: "paperclip/v1", kind: "Agent", metadata: { name: "Agent" } },
});
try {
await act(async () => {
root.render(
<QueryClientProvider client={queryClient}>
<ToastProvider>
<AgentAdvancedTab
agent={agent}
onDirtyChange={vi.fn()}
onSaved={vi.fn()}
/>
</ToastProvider>
</QueryClientProvider>,
);
});
const footer = container.querySelector("footer");
expect(footer).not.toBeNull();
const classes = footer!.className.split(/\s+/);
expect(classes).toContain("sticky");
expect(classes).toContain("mobile-nav-composer");
expect(classes).toContain("bottom-(--tc-composer-bottom)");
expect(classes).toContain("md:bottom-0");
expect(classes).toContain("z-20");
expect(classes).toContain("flex-wrap");
expect(footer!.textContent).toContain("Reload saved");
expect(footer!.textContent).toContain("Save changes");
} finally {
act(() => root.unmount());
queryClient.clear();
}
});
});