Files
PaperClipAI/ui/src/components/TaskViewsMenu.tsx
T
TonioandPaperclip 4e1d49067c Align Inbox, Tasks and Audit toolbar controls (#22675)
## Thinking Path

> - Paperclip helps people manage agents and tasks.
> - Operators switch between Tasks, Inbox, and Audit to review work.
> - Inconsistent menus and shifting controls make those pages harder to
use.
> - Shared dropdown components keep the controls familiar.
> - This change aligns the menus and keeps room for both Audit
descriptions.

## Linked Issues or Issue Description

**What happened?**

Inbox used native dropdowns. Menus could touch the edge of a phone
screen. The Audit scope control moved when its description wrapped.

**Expected behavior**

Menus keep at least 8px of clearance. Switching Audit scope preserves
the control position.

**Steps to reproduce**

Open each Inbox filter and the Tasks view and filter menus at 320px and
390px. Switch between Activity and Agent Actions on Audit.

## What Changed

- Use Tasks-style menus and shorter filter labels in Inbox.
- Give Inbox and Tasks menus 8px of collision padding.
- Align Audit segments and reserve space for the taller scope
description.

## Verification

- All 129 tests across the Inbox, Audit feed, Tasks page and filter
suites passed after rebase at 88a68f9594.
- Before rebase, browser checks covered mobile menu clearance and Audit
scope switching at 320px and 390px.

## Risks

Inbox filters now use keyboard-navigable menu buttons. This changes how
assistive technology announces the controls.

## Model Used

OpenAI Codex (GPT-6), with local code execution and browser
verification.

## 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
- [ ] 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-23 13:32:14 -08:00

83 lines
3.1 KiB
TypeScript

import { Check, ChevronDown } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { TASK_VIEW_GROUPS, taskView, type TaskViewKey } from "@/lib/task-views";
import { cn } from "@/lib/utils";
/**
* The single control for Inbox views and task status presets (PAP-670).
* One menu, grouped by scope, so the
* nav does not have to grow a row every time a view is added.
*/
export function TaskViewsMenu({
value,
onChange,
badgeCount,
coordinator = false,
}: {
value: TaskViewKey;
onChange: (next: TaskViewKey) => void;
/** Unread count surfaced next to the My-work group, mirroring the nav badge. */
badgeCount?: number;
coordinator?: boolean;
}) {
const active = taskView(value);
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
size="sm"
variant="outline"
className="h-8 gap-1.5"
aria-label={`Change view — currently ${active.label}`}
>
<span className="max-w-(--sz-160px) truncate font-medium">{active.label}</span>
<ChevronDown aria-hidden="true" className="h-3.5 w-3.5 text-muted-foreground" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent collisionPadding={8} align="start" className="w-(--sz-260px)">
{TASK_VIEW_GROUPS.map((group, groupIndex) => (
<div key={group.label}>
{groupIndex > 0 ? <DropdownMenuSeparator /> : null}
<DropdownMenuLabel className="flex items-center justify-between gap-2">
<span>{group.label}</span>
{groupIndex === 0 && badgeCount != null && badgeCount > 0 ? (
<span className="rounded-full bg-primary px-1.5 text-(length:--text-nano) leading-tight text-primary-foreground">
{badgeCount > 99 ? "99+" : badgeCount}
</span>
) : null}
</DropdownMenuLabel>
{group.views.filter(view => coordinator || !view.coordinatorOnly).map((view) => {
const selected = view.key === value;
return (
<DropdownMenuItem
key={view.key}
onSelect={() => onChange(view.key)}
className="items-start gap-2"
aria-current={selected ? "true" : undefined}
>
<Check
aria-hidden="true"
className={cn("mt-0.5 size-3.5 shrink-0", selected ? "opacity-100" : "opacity-0")}
/>
<span className="min-w-0">
<span className={cn("block truncate", selected && "font-medium")}>{view.label}</span>
<span className="block text-(length:--text-nano) text-muted-foreground">{view.hint}</span>
</span>
</DropdownMenuItem>
);
})}
</div>
))}
</DropdownMenuContent>
</DropdownMenu>
);
}