c0daa1901b
* feat(ui): add responsive layouts to swimlane kanban content Mobile gets swipeable columns with tab navigation and touch-friendly drag sensors. Tablet gets 2-column horizontal scroll with snap. Desktop keeps the existing CSS grid layout. * feat(ui): add mobile task sheet and search bar components Bottom sheet (vaul Drawer) for task preview with Edit/Delete/Open Session actions. Compact search bar component for filtering tasks on mobile. * feat(ui): wire mobile components into kanban board Integrate MobileFab, MobileSearchBar, and MobileTaskSheet into the kanban board. Skip desktop preview panel on mobile — card taps open a bottom sheet instead of navigating directly. * refactor(ui): optimize swimlane container for mobile Hide swimlane headers for single workflow on mobile, remove horizontal padding on small screens. Extract filterTasks and WorkflowItem to keep the main component under the line limit. * test: add mobile kanban E2E tests 8 Playwright tests covering mobile layout, FAB, search, column tabs, bottom sheet, preview panel suppression, and swimlane header hiding. Adds mobile-chrome project (Pixel 5) to playwright config. * fix(ui): fix mobile E2E test failures in CI Exclude mobile tests from chromium project (wrong viewport), add startIndex to Embla carousel to fix initial scroll race condition, fix strict locator for menu heading, use first step for swimlane test. * fix(ui): fix create task dialog button layout on mobile Make StartTaskSplitButton full-width on mobile, hide dropdown chevron on small screens, and show a visible "Create only" button instead. * fix(ui): match header button sizes and add icon to create-only action Align hamburger menu button with changelog/health buttons by removing explicit h-10 w-10 override. Add IconPlus to "Create without starting agent" in both the desktop dropdown and mobile button. * fix(ui): address code review feedback for mobile kanban - Base hideHeaders on workflowFilter/total count, not filtered result - Clamp mobile column index via useMemo when steps change - Fix wrong assertion in preview panel test (was checking toBeVisible) - Separate altDisabled from splitDisabled (no agent needed for create-only) - Add visible plan mode button on mobile (was hidden behind dropdown) - Wait for mobile-kanban-layout in page object goto() - Extract computeBaseDisabled to reduce complexity * fix(test): fix flaky mobile E2E tests in headless Chrome - Use instant jump (scrollTo with jump=true) for tab-triggered carousel navigation instead of animated scroll that doesn't complete in headless - Add data-testid to swimlane header to avoid ambiguous Badge locator matching column tab buttons - Add timeout to viewport assertion for resilience * fix(ui): address review feedback and fix carousel reinitialization - Stabilize Embla options to prevent carousel reinit on tab change (startIndex was causing re-initialization, resetting scroll position) - Guard programmatic scrolls from triggering select callback revert - Remove PointerSensor from mobile DnD sensors (conflicts with touch) - Fix plan mode button using wrong disabled prop on mobile - Use literal name matching in columnTab locator (avoid regex injection) - Use toHaveCount(0) for stricter preview panel absence assertion * fix(ui): use pointerDown gating for carousel swipe sync Embla's scrollTo doesn't work in headless Chrome, causing the select event to fire with index 0 and reset the active tab. Fix by only syncing Embla→tabs on user-initiated pointer interactions (swipes), not on programmatic scrollTo calls. Update E2E test to verify tab active state instead of carousel viewport positions, which are unreliable in headless environments. * fix(test): add data-testid and data-active to column tabs Use explicit data attributes for more reliable test targeting instead of getByRole and CSS class assertions. * refactor(ui): use touch sensors for tablet and deduplicate getTasksForStep * fix(ui): improve spacing for stats and settings buttons in mobile menu
343 lines
9.7 KiB
TypeScript
343 lines
9.7 KiB
TypeScript
"use client";
|
|
|
|
import { memo } from "react";
|
|
import {
|
|
IconLoader2,
|
|
IconFileInvoice,
|
|
IconSend,
|
|
IconChevronDown,
|
|
IconPlus,
|
|
} from "@tabler/icons-react";
|
|
import { Button } from "@kandev/ui/button";
|
|
import { DialogClose } from "@kandev/ui/dialog";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "@kandev/ui/dropdown-menu";
|
|
import { SHORTCUTS } from "@/lib/keyboard/constants";
|
|
import { KeyboardShortcutTooltip } from "@/components/keyboard-shortcut-tooltip";
|
|
|
|
type UpdateButtonProps = {
|
|
isCreatingTask: boolean;
|
|
hasTitle: boolean;
|
|
onUpdate: () => void;
|
|
};
|
|
|
|
function UpdateButton({ isCreatingTask, hasTitle, onUpdate }: UpdateButtonProps) {
|
|
return (
|
|
<Button
|
|
type="button"
|
|
variant="default"
|
|
className="w-full h-10 cursor-pointer sm:w-auto sm:h-7 gap-1.5"
|
|
disabled={isCreatingTask || !hasTitle}
|
|
onClick={onUpdate}
|
|
>
|
|
{isCreatingTask ? (
|
|
<>
|
|
<IconLoader2 className="h-3.5 w-3.5 animate-spin" />
|
|
Updating...
|
|
</>
|
|
) : (
|
|
"Update"
|
|
)}
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
type StartTaskSplitButtonProps = {
|
|
isCreatingTask: boolean;
|
|
disabled: boolean;
|
|
altDisabled: boolean;
|
|
isEditMode: boolean;
|
|
onAltAction: () => void;
|
|
onPlanModeAction?: () => void;
|
|
};
|
|
|
|
function StartTaskSplitButton({
|
|
isCreatingTask,
|
|
disabled,
|
|
altDisabled,
|
|
isEditMode,
|
|
onAltAction,
|
|
onPlanModeAction,
|
|
}: StartTaskSplitButtonProps) {
|
|
const altLabel = isEditMode ? "Update task" : "Create only";
|
|
|
|
return (
|
|
<div className="flex flex-col w-full sm:w-auto gap-2 sm:gap-0">
|
|
<div className="flex w-full sm:inline-flex sm:w-auto rounded-md border border-border overflow-hidden sm:h-7 h-10">
|
|
<Button
|
|
type="submit"
|
|
variant="default"
|
|
className="rounded-none border-0 cursor-pointer gap-1.5 h-full flex-1"
|
|
disabled={disabled}
|
|
data-testid="submit-start-agent"
|
|
>
|
|
{isCreatingTask ? (
|
|
<IconLoader2 className="h-3.5 w-3.5 animate-spin" />
|
|
) : (
|
|
<IconSend className="h-3.5 w-3.5" />
|
|
)}
|
|
{isCreatingTask ? "Starting..." : "Start task"}
|
|
</Button>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
type="button"
|
|
variant="default"
|
|
className="rounded-none border-0 border-l border-primary-foreground/20 px-2 cursor-pointer h-full hidden sm:flex"
|
|
disabled={disabled}
|
|
data-testid="submit-start-agent-chevron"
|
|
>
|
|
<IconChevronDown className="h-3.5 w-3.5" />
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-auto min-w-max">
|
|
{onPlanModeAction && (
|
|
<DropdownMenuItem
|
|
onClick={onPlanModeAction}
|
|
className="cursor-pointer whitespace-nowrap focus:bg-muted/80 hover:bg-muted/80"
|
|
data-testid="submit-plan-mode"
|
|
>
|
|
<IconFileInvoice className="h-3.5 w-3.5 mr-1.5" />
|
|
Start task in plan mode
|
|
</DropdownMenuItem>
|
|
)}
|
|
<DropdownMenuItem
|
|
onClick={onAltAction}
|
|
className="cursor-pointer whitespace-nowrap focus:bg-muted/80 hover:bg-muted/80"
|
|
>
|
|
<IconPlus className="h-3.5 w-3.5 mr-1.5" />
|
|
{isEditMode ? "Update task" : "Create without starting agent"}
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
{/* Mobile-only: visible buttons for plan mode and creating without agent */}
|
|
{onPlanModeAction && (
|
|
<Button
|
|
type="button"
|
|
variant="outline"
|
|
className="w-full h-10 cursor-pointer gap-1.5 sm:hidden"
|
|
disabled={altDisabled}
|
|
onClick={onPlanModeAction}
|
|
data-testid="mobile-plan-mode"
|
|
>
|
|
<IconFileInvoice className="h-3.5 w-3.5" />
|
|
Plan mode
|
|
</Button>
|
|
)}
|
|
<Button
|
|
type="button"
|
|
variant="outline"
|
|
className="w-full h-10 cursor-pointer gap-1.5 sm:hidden"
|
|
disabled={altDisabled}
|
|
onClick={onAltAction}
|
|
>
|
|
<IconPlus className="h-3.5 w-3.5" />
|
|
{altLabel}
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
type DefaultSubmitButtonProps = {
|
|
isCreatingSession: boolean;
|
|
isCreatingTask: boolean;
|
|
isSessionMode: boolean;
|
|
isCreateMode: boolean;
|
|
isEditMode: boolean;
|
|
hasDescription: boolean;
|
|
isPassthroughProfile: boolean;
|
|
disabled: boolean;
|
|
};
|
|
|
|
function DefaultSubmitButton({
|
|
isCreatingSession,
|
|
isCreatingTask,
|
|
isSessionMode,
|
|
isCreateMode,
|
|
isEditMode,
|
|
hasDescription,
|
|
isPassthroughProfile,
|
|
disabled,
|
|
}: DefaultSubmitButtonProps) {
|
|
const planModeStyle =
|
|
isCreateMode && !hasDescription
|
|
? "bg-blue-600 border-blue-500 text-white hover:bg-blue-700 hover:text-white"
|
|
: "";
|
|
|
|
return (
|
|
<Button
|
|
type="submit"
|
|
variant="default"
|
|
className={`w-full h-10 cursor-pointer sm:w-auto sm:h-7 gap-1.5 ${planModeStyle}`}
|
|
disabled={
|
|
disabled ||
|
|
isCreatingSession ||
|
|
isCreatingTask ||
|
|
(isSessionMode ? !hasDescription && !isPassthroughProfile : false)
|
|
}
|
|
>
|
|
{(() => {
|
|
if (isCreatingSession || isCreatingTask) {
|
|
return (
|
|
<>
|
|
<IconLoader2 className="h-3.5 w-3.5 animate-spin" />
|
|
{isEditMode ? "Updating..." : "Starting..."}
|
|
</>
|
|
);
|
|
}
|
|
if (isSessionMode) return "Create Session";
|
|
if (isCreateMode) {
|
|
return (
|
|
<>
|
|
<IconFileInvoice className="h-3.5 w-3.5" />
|
|
Start Plan Mode
|
|
</>
|
|
);
|
|
}
|
|
return "Update task";
|
|
})()}
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
export type TaskCreateDialogFooterProps = {
|
|
isSessionMode: boolean;
|
|
isCreateMode: boolean;
|
|
isEditMode: boolean;
|
|
isTaskStarted: boolean;
|
|
isPassthroughProfile: boolean;
|
|
isCreatingSession: boolean;
|
|
isCreatingTask: boolean;
|
|
hasTitle: boolean;
|
|
hasDescription: boolean;
|
|
hasRepositorySelection: boolean;
|
|
branch: string;
|
|
agentProfileId: string;
|
|
workspaceId: string | null;
|
|
effectiveWorkflowId: string | null;
|
|
executorHint: string | null;
|
|
onCancel: () => void;
|
|
onUpdateWithoutAgent: () => void;
|
|
onCreateWithoutAgent: () => void;
|
|
onCreateWithPlanMode?: () => void;
|
|
};
|
|
|
|
function isMissingWorkflowCtx(
|
|
isCreateMode: boolean,
|
|
workspaceId: string | null,
|
|
effectiveWorkflowId: string | null,
|
|
) {
|
|
return isCreateMode && (!workspaceId || !effectiveWorkflowId);
|
|
}
|
|
|
|
function computeBaseDisabled(props: TaskCreateDialogFooterProps) {
|
|
const missingCtx = isMissingWorkflowCtx(
|
|
props.isCreateMode,
|
|
props.workspaceId,
|
|
props.effectiveWorkflowId,
|
|
);
|
|
return (
|
|
props.isCreatingTask ||
|
|
!props.hasTitle ||
|
|
!props.hasRepositorySelection ||
|
|
!props.branch ||
|
|
missingCtx
|
|
);
|
|
}
|
|
|
|
function computeFooterState(props: TaskCreateDialogFooterProps) {
|
|
const showStartTask =
|
|
(props.isCreateMode && (props.hasDescription || props.isPassthroughProfile)) ||
|
|
Boolean(props.isEditMode && props.agentProfileId);
|
|
const altDisabled = computeBaseDisabled(props);
|
|
const splitDisabled = altDisabled || !props.agentProfileId;
|
|
const defaultDisabled = props.isSessionMode ? !props.agentProfileId : altDisabled;
|
|
|
|
return { showStartTask, splitDisabled, altDisabled, defaultDisabled };
|
|
}
|
|
|
|
export const TaskCreateDialogFooter = memo(function TaskCreateDialogFooter(
|
|
props: TaskCreateDialogFooterProps,
|
|
) {
|
|
const {
|
|
isSessionMode,
|
|
isCreateMode,
|
|
isEditMode,
|
|
isTaskStarted,
|
|
isPassthroughProfile,
|
|
isCreatingSession,
|
|
isCreatingTask,
|
|
hasTitle,
|
|
hasDescription,
|
|
executorHint,
|
|
onCancel,
|
|
onUpdateWithoutAgent,
|
|
onCreateWithoutAgent,
|
|
onCreateWithPlanMode,
|
|
} = props;
|
|
const { showStartTask, splitDisabled, altDisabled, defaultDisabled } = computeFooterState(props);
|
|
|
|
return (
|
|
<>
|
|
{!isSessionMode && !isTaskStarted && executorHint && (
|
|
<div className="flex flex-1 items-center gap-3 text-sm text-muted-foreground">
|
|
<span className="text-xs text-muted-foreground">{executorHint}</span>
|
|
</div>
|
|
)}
|
|
<DialogClose asChild>
|
|
<Button
|
|
type="button"
|
|
variant="outline"
|
|
onClick={onCancel}
|
|
disabled={isCreatingSession || isCreatingTask}
|
|
className="w-full h-10 border-0 cursor-pointer sm:w-auto sm:h-7 sm:border"
|
|
>
|
|
Cancel
|
|
</Button>
|
|
</DialogClose>
|
|
<KeyboardShortcutTooltip shortcut={SHORTCUTS.SUBMIT}>
|
|
{(() => {
|
|
if (isTaskStarted) {
|
|
return (
|
|
<UpdateButton
|
|
isCreatingTask={isCreatingTask}
|
|
hasTitle={hasTitle}
|
|
onUpdate={onUpdateWithoutAgent}
|
|
/>
|
|
);
|
|
}
|
|
if (showStartTask) {
|
|
return (
|
|
<StartTaskSplitButton
|
|
isCreatingTask={isCreatingTask}
|
|
disabled={splitDisabled}
|
|
altDisabled={altDisabled}
|
|
isEditMode={isEditMode}
|
|
onAltAction={isEditMode ? onUpdateWithoutAgent : onCreateWithoutAgent}
|
|
onPlanModeAction={onCreateWithPlanMode}
|
|
/>
|
|
);
|
|
}
|
|
return (
|
|
<DefaultSubmitButton
|
|
isCreatingSession={isCreatingSession}
|
|
isCreatingTask={isCreatingTask}
|
|
isSessionMode={isSessionMode}
|
|
isCreateMode={isCreateMode}
|
|
isEditMode={isEditMode}
|
|
hasDescription={hasDescription}
|
|
isPassthroughProfile={isPassthroughProfile}
|
|
disabled={defaultDisabled}
|
|
/>
|
|
);
|
|
})()}
|
|
</KeyboardShortcutTooltip>
|
|
</>
|
|
);
|
|
});
|