feat(schedules): add month sort toggle, compact pull-down card, and year day popover

- Add persisted time/priority sort toggle to Month swimlane lane header
- Support pull-down / click-to-expand compact floating detail cards (320px) on Month lanes and timeline bars
- Replace Year view direct day-jump with an interactive floating day agenda popover and double-click Day view shortcut
This commit is contained in:
ji ruo committed 2026-12-03 22:28:34 +08:00
1 parent 73e51e4658
commit be2fff5561
3 files changed
+850 -161

No files matched your search

@@ -2,11 +2,34 @@
import * as React from "react";
import { ChevronDownIcon, ChevronRightIcon, PlusIcon } from "lucide-react";
import Link from "next/link";
import {
ChevronDownIcon,
ChevronRightIcon,
HistoryIcon,
ListChecksIcon,
PauseIcon,
PencilIcon,
PlayIcon,
PlusIcon,
RouteIcon,
ZapIcon,
} from "lucide-react";
import { formatProxyRouteSummary } from "@/components/proxy-route-selector";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { useLiveTranslation } from "@/i18n/use-live-translation";
import { type CalendarEventOccurrence, makeDateKey, parseDateKey, weekdayOfDateKey } from "@/lib/schedule-calendar";
import type { TaskSchedule } from "@/lib/types";
import {
type CalendarEventOccurrence,
makeDateKey,
parseClockMinutes,
parseDateKey,
weekdayOfDateKey,
} from "@/lib/schedule-calendar";
import { scheduleDisplay } from "@/lib/schedule-display";
import type { ProxyPoolEntry, Task, TaskSchedule } from "@/lib/types";
import { cn } from "@/lib/utils";
interface StatusVisual {
@@ -15,6 +38,7 @@ interface StatusVisual {
bar: string;
barOnce: string;
barSelected: string;
pill: string;
}
const LANE_STATUS_VISUAL: Record<TaskSchedule["status"], StatusVisual> = {
@@ -24,6 +48,7 @@ const LANE_STATUS_VISUAL: Record<TaskSchedule["status"], StatusVisual> = {
bar: "bg-emerald-500/16 border-emerald-500/35 text-emerald-950 dark:bg-emerald-500/22 dark:border-emerald-400/40 dark:text-emerald-100",
barOnce: "bg-emerald-500/90 border-emerald-600 text-white dark:bg-emerald-600 dark:border-emerald-400",
barSelected: "ring-2 ring-emerald-500 ring-offset-1 ring-offset-background",
pill: "border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300",
},
waiting: {
dot: "bg-blue-500",
@@ -31,6 +56,7 @@ const LANE_STATUS_VISUAL: Record<TaskSchedule["status"], StatusVisual> = {
bar: "bg-blue-500/12 border-blue-500/30 text-blue-950 dark:bg-blue-500/20 dark:border-blue-400/35 dark:text-blue-100",
barOnce: "bg-indigo-500/90 border-indigo-600 text-white dark:bg-indigo-600 dark:border-indigo-400",
barSelected: "ring-2 ring-blue-500 ring-offset-1 ring-offset-background",
pill: "border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800 dark:bg-blue-950/50 dark:text-blue-300",
},
outside: {
dot: "bg-orange-500",
@@ -38,6 +64,7 @@ const LANE_STATUS_VISUAL: Record<TaskSchedule["status"], StatusVisual> = {
bar: "bg-orange-500/14 border-orange-500/35 text-orange-950 dark:bg-orange-500/20 dark:border-orange-400/40 dark:text-orange-100",
barOnce: "bg-orange-500/90 border-orange-600 text-white dark:bg-orange-600 dark:border-orange-400",
barSelected: "ring-2 ring-orange-500 ring-offset-1 ring-offset-background",
pill: "border-orange-200 bg-orange-50 text-orange-700 dark:border-orange-800 dark:bg-orange-950/50 dark:text-orange-300",
},
completed: {
dot: "bg-sky-500",
@@ -45,6 +72,7 @@ const LANE_STATUS_VISUAL: Record<TaskSchedule["status"], StatusVisual> = {
bar: "bg-sky-500/14 border-sky-500/30 text-sky-950 dark:bg-sky-500/20 dark:border-sky-400/35 dark:text-sky-100",
barOnce: "bg-sky-600/90 border-sky-700 text-white dark:bg-sky-600 dark:border-sky-400",
barSelected: "ring-2 ring-sky-500 ring-offset-1 ring-offset-background",
pill: "border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-800 dark:bg-sky-950/50 dark:text-sky-300",
},
paused: {
dot: "bg-slate-400",
@@ -52,6 +80,7 @@ const LANE_STATUS_VISUAL: Record<TaskSchedule["status"], StatusVisual> = {
bar: "bg-slate-400/15 border-slate-400/35 text-slate-700 dark:bg-slate-500/20 dark:border-slate-500/40 dark:text-slate-300",
barOnce: "bg-slate-500/80 border-slate-600 text-white",
barSelected: "ring-2 ring-slate-400 ring-offset-1 ring-offset-background",
pill: "border-slate-200 bg-slate-100 text-slate-700 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300",
},
error: {
dot: "bg-rose-500",
@@ -59,6 +88,7 @@ const LANE_STATUS_VISUAL: Record<TaskSchedule["status"], StatusVisual> = {
bar: "bg-rose-500/16 border-rose-500/40 text-rose-950 dark:bg-rose-500/24 dark:border-rose-400/45 dark:text-rose-100",
barOnce: "bg-rose-600/90 border-rose-700 text-white dark:bg-rose-600 dark:border-rose-400",
barSelected: "ring-2 ring-rose-500 ring-offset-1 ring-offset-background",
pill: "border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-800 dark:bg-rose-950/50 dark:text-rose-300",
},
};
@@ -71,6 +101,28 @@ const STATUS_SORT_RANK: Record<TaskSchedule["status"], number> = {
paused: 5,
};
type MonthLaneSortMode = "time" | "priority";
const MONTH_SORT_STORAGE_KEY = "artex.schedules.monthSortMode";
const LANE_ROW_HEIGHT = 46;
const INACTIVE_HEADER_HEIGHT = 30;
const EXPANDED_CARD_WIDTH = 320;
interface ExpandedLaneCardState {
scheduleId: number;
anchorLeft: number;
openAbove: boolean;
}
interface LanePullDragState {
scheduleId: number;
originY: number;
deltaY: number;
wasExpanded: boolean;
anchorLeft: number;
openAbove: boolean;
}
export interface MonthSlideBinding {
containerRef: React.RefObject<HTMLDivElement | null>;
viewportRef: React.MutableRefObject<HTMLDivElement | null>;
@@ -114,6 +166,17 @@ function formatScheduleWindow(schedule: TaskSchedule): string {
return `${start}–${schedule.end_time.slice(0, 5)}`;
}
function scheduleStartMinutes(schedule: TaskSchedule): number {
return parseClockMinutes(schedule.start_time) ?? 0;
}
function scheduleEndMinutes(schedule: TaskSchedule): number {
const end = parseClockMinutes(schedule.end_time);
if (end === null) return Number.MAX_SAFE_INTEGER;
const start = scheduleStartMinutes(schedule);
return end <= start ? end + 1440 : end;
}
function buildRowSpans(
schedule: TaskSchedule,
scheduleOccs: CalendarEventOccurrence[],
@@ -213,10 +276,14 @@ export function MonthSwimlaneView({
anchorDateKey,
schedules,
occurrences,
taskById,
proxyPool,
selectedOccurrenceId,
onSelectOccurrence,
onSelectDay,
onCreateAtSlot,
onEdit,
onAction,
}: {
slide: MonthSlideBinding;
trackDateKeys: string[];
@@ -228,13 +295,91 @@ export function MonthSwimlaneView({
anchorDateKey: string;
schedules: TaskSchedule[];
occurrences: CalendarEventOccurrence[];
taskById: Map<number, Task>;
proxyPool: ProxyPoolEntry[];
selectedOccurrenceId: string | null;
onSelectOccurrence: (occ: CalendarEventOccurrence) => void;
onSelectDay: (dateKey: string) => void;
onCreateAtSlot: (dateKey: string, startMin: number, endMin: number) => void;
onEdit: (item: TaskSchedule) => void;
onAction: (id: number, type: "pause" | "resume" | "run") => Promise<void>;
}) {
const { t: translate } = useLiveTranslation();
const { t: translate, i18n, isEn } = useLiveTranslation();
const { statusText, timezoneLabel, windowLabel } = scheduleDisplay(translate, i18n.resolvedLanguage ?? "zh-CN");
const [sortMode, setSortMode] = React.useState<MonthLaneSortMode>("time");
const [showInactive, setShowInactive] = React.useState(false);
const [expandedCard, setExpandedCard] = React.useState<ExpandedLaneCardState | null>(null);
const [pullDrag, setPullDrag] = React.useState<LanePullDragState | null>(null);
const bodyScrollRef = React.useRef<HTMLDivElement | null>(null);
React.useEffect(() => {
if (!pullDrag) return;
const handleMove = (e: PointerEvent) => {
const dy = e.clientY - pullDrag.originY;
setPullDrag((prev) => (prev ? { ...prev, deltaY: dy } : null));
};
const handleUp = (e: PointerEvent) => {
const dy = e.clientY - pullDrag.originY;
const { scheduleId, wasExpanded, anchorLeft, openAbove } = pullDrag;
setPullDrag(null);
if (Math.abs(dy) < 6) {
setExpandedCard((prev) => (prev?.scheduleId === scheduleId ? null : { scheduleId, anchorLeft, openAbove }));
return;
}
if (!wasExpanded && dy >= 24) {
setExpandedCard({ scheduleId, anchorLeft, openAbove });
} else if (wasExpanded && dy <= -24) {
setExpandedCard(null);
}
};
window.addEventListener("pointermove", handleMove);
window.addEventListener("pointerup", handleUp, { once: true });
window.addEventListener("pointercancel", handleUp, { once: true });
return () => {
window.removeEventListener("pointermove", handleMove);
window.removeEventListener("pointerup", handleUp);
window.removeEventListener("pointercancel", handleUp);
};
}, [pullDrag]);
React.useEffect(() => {
if (!expandedCard) return;
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === "Escape") {
setExpandedCard(null);
}
};
const onPointerDown = (e: PointerEvent) => {
const target = e.target as HTMLElement | null;
if (target?.closest('[data-month-expand-card="true"], [data-month-expand-handle="true"]')) return;
setExpandedCard(null);
};
window.addEventListener("keydown", onKeyDown);
window.addEventListener("pointerdown", onPointerDown);
return () => {
window.removeEventListener("keydown", onKeyDown);
window.removeEventListener("pointerdown", onPointerDown);
};
}, [expandedCard]);
React.useEffect(() => {
try {
const saved = window.localStorage.getItem(MONTH_SORT_STORAGE_KEY);
if (saved === "time" || saved === "priority") {
setSortMode(saved);
}
} catch {
// ignore storage errors
}
}, []);
const changeSortMode = React.useCallback((next: MonthLaneSortMode) => {
setSortMode(next);
try {
window.localStorage.setItem(MONTH_SORT_STORAGE_KEY, next);
} catch {
// ignore storage errors
}
}, []);
const [hoveredInfo, setHoveredInfo] = React.useState<{
schedule: TaskSchedule;
occ: CalendarEventOccurrence;
@@ -312,13 +457,23 @@ export function MonthSwimlaneView({
}
const compareRows = (a: SwimlaneRowData, b: SwimlaneRowData) => {
const rankDiff = (STATUS_SORT_RANK[a.schedule.status] ?? 9) - (STATUS_SORT_RANK[b.schedule.status] ?? 9);
if (rankDiff !== 0) return rankDiff;
const typeDiff = (a.schedule.schedule_type === "once" ? 0 : 1) - (b.schedule.schedule_type === "once" ? 0 : 1);
if (typeDiff !== 0) return typeDiff;
const timeDiff = a.schedule.start_time.localeCompare(b.schedule.start_time);
if (timeDiff !== 0) return timeDiff;
return a.schedule.name.localeCompare(b.schedule.name);
if (sortMode === "priority") {
const rankDiff = (STATUS_SORT_RANK[a.schedule.status] ?? 9) - (STATUS_SORT_RANK[b.schedule.status] ?? 9);
if (rankDiff !== 0) return rankDiff;
const typeDiff = (a.schedule.schedule_type === "once" ? 0 : 1) - (b.schedule.schedule_type === "once" ? 0 : 1);
if (typeDiff !== 0) return typeDiff;
}
const startDiff = scheduleStartMinutes(a.schedule) - scheduleStartMinutes(b.schedule);
if (startDiff !== 0) return startDiff;
const endDiff = scheduleEndMinutes(a.schedule) - scheduleEndMinutes(b.schedule);
if (endDiff !== 0) return endDiff;
if (sortMode === "time") {
const rankDiff = (STATUS_SORT_RANK[a.schedule.status] ?? 9) - (STATUS_SORT_RANK[b.schedule.status] ?? 9);
if (rankDiff !== 0) return rankDiff;
}
const nameDiff = a.schedule.name.localeCompare(b.schedule.name);
if (nameDiff !== 0) return nameDiff;
return a.schedule.id - b.schedule.id;
};
active.sort(compareRows);
@@ -332,7 +487,7 @@ export function MonthSwimlaneView({
maxDayLoad: Math.max(...visibleLoads, 1),
totalVisibleRuns: runs,
};
}, [trackDays, trackDateKeys, occurrences, schedules, visibleStartIdx, visibleEndIdx]);
}, [trackDays, trackDateKeys, occurrences, schedules, visibleStartIdx, visibleEndIdx, sortMode]);
const todayIdx = trackDays.findIndex((d) => d.isToday);
const trackWidthPct = (totalCols / Math.max(visibleCount, 1)) * 100;
@@ -378,60 +533,169 @@ export function MonthSwimlaneView({
});
};
const startPullDrag = (scheduleId: number, e: React.PointerEvent, source: "label" | "bar" | "card") => {
if (e.button !== 0) return;
e.stopPropagation();
const wasExpanded = expandedCard?.scheduleId === scheduleId;
let anchorLeft = expandedCard?.scheduleId === scheduleId ? expandedCard.anchorLeft : 8;
let openAbove = expandedCard?.scheduleId === scheduleId ? expandedCard.openAbove : false;
if (source !== "card") {
const scrollEl = bodyScrollRef.current;
const bodyRect = scrollEl?.getBoundingClientRect();
const targetRect = (e.currentTarget as HTMLElement).getBoundingClientRect();
const containerW = bodyRect?.width ?? EXPANDED_CARD_WIDTH + 16;
if (source === "bar" && bodyRect) {
const centerX = targetRect.left + targetRect.width / 2 - bodyRect.left;
anchorLeft = Math.round(centerX - EXPANDED_CARD_WIDTH / 2);
} else {
anchorLeft = 8;
}
anchorLeft = Math.max(8, Math.min(anchorLeft, Math.max(8, containerW - EXPANDED_CARD_WIDTH - 8)));
if (bodyRect) {
const spaceBelow = bodyRect.bottom - targetRect.bottom;
const spaceAbove = targetRect.top - bodyRect.top;
openAbove = spaceBelow < 220 && spaceAbove >= 220;
} else {
openAbove = false;
}
}
setPullDrag({
scheduleId,
originY: e.clientY,
deltaY: 0,
wasExpanded,
anchorLeft,
openAbove,
});
};
const activeCard = React.useMemo(() => {
const isPulling = Boolean(pullDrag);
const targetId = pullDrag?.scheduleId ?? expandedCard?.scheduleId ?? null;
if (targetId === null) return null;
let previewHeight: number | null = null;
if (pullDrag) {
if (!pullDrag.wasExpanded) {
if (pullDrag.deltaY < 14) return null;
previewHeight = Math.max(56, Math.min(260, pullDrag.deltaY + 28));
} else {
const shrunk = 210 + pullDrag.deltaY;
previewHeight = Math.max(48, Math.min(280, shrunk));
}
}
const anchorLeft = pullDrag?.anchorLeft ?? expandedCard?.anchorLeft ?? 8;
const openAbove = pullDrag?.openAbove ?? expandedCard?.openAbove ?? false;
const activeIdx = activeRows.findIndex((r) => r.schedule.id === targetId);
if (activeIdx >= 0) {
return {
row: activeRows[activeIdx],
rowTopPx: activeIdx * LANE_ROW_HEIGHT,
anchorLeft,
openAbove,
previewHeight,
isPulling,
};
}
if (showInactive) {
const inactiveIdx = inactiveRows.findIndex((r) => r.schedule.id === targetId);
if (inactiveIdx >= 0) {
return {
row: inactiveRows[inactiveIdx],
rowTopPx: activeRows.length * LANE_ROW_HEIGHT + INACTIVE_HEADER_HEIGHT + inactiveIdx * LANE_ROW_HEIGHT,
anchorLeft,
openAbove,
previewHeight,
isPulling,
};
}
}
return null;
}, [activeRows, inactiveRows, showInactive, expandedCard, pullDrag]);
const renderLeftLabel = (row: SwimlaneRowData, muted = false) => {
const { schedule } = row;
const vis = LANE_STATUS_VISUAL[schedule.status] ?? LANE_STATUS_VISUAL.waiting;
const isOnce = schedule.schedule_type === "once";
const cadenceLabel = translate(cadenceKey(schedule));
const windowText = formatScheduleWindow(schedule);
const isExpanded = expandedCard?.scheduleId === schedule.id;
return (
<button
<div
key={schedule.id}
type="button"
onClick={() => openScheduleDetail(row)}
className={cn(
"flex h-[46px] w-full items-center gap-2 border-border/50 border-b bg-background px-3 text-left transition-colors hover:bg-muted/30",
"group/lane relative h-[46px] border-border/50 border-b bg-background transition-colors",
isExpanded && "bg-muted/35",
muted && "opacity-55",
)}
title={`${schedule.name} · ${windowText}`}
>
<span className="relative flex size-2 shrink-0 items-center justify-center">
{schedule.status === "running" && (
<span className="absolute inline-flex size-2.5 animate-ping rounded-full bg-emerald-400 opacity-60" />
)}
<span className={cn("relative size-2 rounded-full", vis.dot)} />
</span>
<button
type="button"
onClick={() => openScheduleDetail(row)}
className="flex h-[46px] w-full items-center gap-2 px-3 pb-1 text-left transition-colors hover:bg-muted/30"
title={`${schedule.name} · ${windowText}`}
>
<span className="relative flex size-2 shrink-0 items-center justify-center">
{schedule.status === "running" && (
<span className="absolute inline-flex size-2.5 animate-ping rounded-full bg-emerald-400 opacity-60" />
)}
<span className={cn("relative size-2 rounded-full", vis.dot)} />
</span>
<div className="min-w-0 flex-1">
<div className="flex items-center justify-between gap-1.5">
<span className="truncate font-medium text-xs leading-tight">{schedule.name}</span>
{row.visibleDayCount > 0 && (
<span className="shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums">
{translate("schedule.month.runDays", { count: row.visibleDayCount })}
</span>
)}
</div>
<div className="mt-0.5 flex items-center gap-1.5 text-[10px] text-muted-foreground">
<span
className={cn(
"shrink-0 rounded px-1 py-0 font-medium text-[9px]",
isOnce
? "bg-indigo-500/12 text-indigo-600 dark:bg-indigo-500/20 dark:text-indigo-300"
: "bg-muted text-muted-foreground",
<div className="min-w-0 flex-1">
<div className="flex items-center justify-between gap-1.5">
<span className="truncate font-medium text-xs leading-tight">{schedule.name}</span>
{row.visibleDayCount > 0 && (
<span className="shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums">
{translate("schedule.month.runDays", { count: row.visibleDayCount })}
</span>
)}
>
{cadenceLabel}
</span>
<span className="truncate font-mono tabular-nums">{windowText}</span>
{schedule.task_ids.length > 0 && (
<span className="ml-auto shrink-0 font-mono text-[9px] tabular-nums opacity-75">
#{schedule.task_ids.length}
</div>
<div className="mt-0.5 flex items-center gap-1.5 text-[10px] text-muted-foreground">
<span
className={cn(
"shrink-0 rounded px-1 py-0 font-medium text-[9px]",
isOnce
? "bg-indigo-500/12 text-indigo-600 dark:bg-indigo-500/20 dark:text-indigo-300"
: "bg-muted text-muted-foreground",
)}
>
{cadenceLabel}
</span>
)}
<span className="truncate font-mono tabular-nums">{windowText}</span>
{schedule.task_ids.length > 0 && (
<span className="ml-auto shrink-0 font-mono text-[9px] tabular-nums opacity-75">
#{schedule.task_ids.length}
</span>
)}
</div>
</div>
</div>
</button>
</button>
{/* Pull-down handle matching Week/Day cards */}
<button
type="button"
tabIndex={-1}
data-no-calendar-swipe="true"
data-month-expand-handle="true"
aria-expanded={isExpanded}
title={
isExpanded ? translate("schedule.calendar.collapseDetails") : translate("schedule.calendar.expandDetails")
}
onPointerDown={(e) => startPullDrag(schedule.id, e, "label")}
className={cn(
"absolute inset-x-0 bottom-0 z-10 flex h-2.5 cursor-ns-resize items-center justify-center transition-opacity hover:bg-muted/40",
isExpanded ? "opacity-90" : "opacity-30 group-hover/lane:opacity-100",
)}
>
<span className="h-0.5 w-6 rounded-full bg-muted-foreground/60" />
</button>
</div>
);
};
@@ -441,116 +705,137 @@ export function MonthSwimlaneView({
const isOnce = schedule.schedule_type === "once";
const windowText = formatScheduleWindow(schedule);
const shortStart = schedule.start_time.slice(0, 5);
const isExpanded = expandedCard?.scheduleId === schedule.id;
return (
<div
key={schedule.id}
className={cn(
"relative h-[46px] border-border/50 border-b transition-colors hover:bg-muted/15",
"group/row relative h-[46px] border-border/50 border-b transition-colors hover:bg-muted/15",
isExpanded && "bg-muted/20",
muted && "opacity-55",
)}
>
{/* Background clickable day cells */}
<div className="grid h-full" style={dayGridColsStyle}>
{trackDays.map((d) => (
<button
key={d.dateKey}
type="button"
aria-label={translate("schedule.month.createAtDay", { date: d.dateKey })}
onClick={() => onCreateAtSlot(d.dateKey, 9 * 60, 10 * 60)}
className={cn(
"group/cell relative border-border/25 border-r transition-colors last:border-r-0 hover:bg-accent/35",
d.isMonthStart && "border-l border-l-border/80",
d.isWeekend && "bg-muted/20",
d.isToday && "bg-blue-500/[0.045]",
)}
>
<PlusIcon className="pointer-events-none absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 text-muted-foreground/40 opacity-0 transition-opacity group-hover/cell:opacity-100" />
</button>
))}
</div>
<div className="relative h-full">
<div className="grid h-full" style={dayGridColsStyle}>
{trackDays.map((d) => (
<button
key={d.dateKey}
type="button"
aria-label={translate("schedule.month.createAtDay", { date: d.dateKey })}
onClick={() => onCreateAtSlot(d.dateKey, 9 * 60, 10 * 60)}
className={cn(
"group/cell relative border-border/25 border-r transition-colors last:border-r-0 hover:bg-accent/35",
d.isMonthStart && "border-l border-l-border/80",
d.isWeekend && "bg-muted/20",
d.isToday && "bg-blue-500/[0.045]",
)}
>
<PlusIcon className="pointer-events-none absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 text-muted-foreground/40 opacity-0 transition-opacity group-hover/cell:opacity-100" />
</button>
))}
</div>
{/* Continuous merged horizontal bars */}
{row.spans.length > 0 && (
<div className="pointer-events-none absolute inset-0 grid items-center py-2" style={dayGridColsStyle}>
{row.spans.map((span) => {
const anySelected = span.occurrences.some((o) => o.id === selectedOccurrenceId);
const barLabel = span.spanDays >= 2 ? windowText : shortStart;
{/* Continuous merged horizontal bars */}
{row.spans.length > 0 && (
<div className="pointer-events-none absolute inset-0 grid items-center py-2" style={dayGridColsStyle}>
{row.spans.map((span) => {
const anySelected = span.occurrences.some((o) => o.id === selectedOccurrenceId);
const barLabel = span.spanDays >= 2 ? windowText : shortStart;
return (
<div
key={span.key}
style={{ gridColumn: `${span.startIdx + 1} / span ${span.spanDays}` }}
className="pointer-events-auto flex h-full items-center px-[2px]"
>
return (
<div
className={cn(
"relative flex h-6 w-full items-center overflow-hidden border transition-all",
span.continuesBeforeTrack ? "rounded-l-none border-l-dashed" : "rounded-l-[5px]",
span.continuesAfterTrack ? "rounded-r-none border-r-dashed" : "rounded-r-[5px]",
isOnce ? vis.barOnce : vis.bar,
anySelected && vis.barSelected,
)}
key={span.key}
style={{ gridColumn: `${span.startIdx + 1} / span ${span.spanDays}` }}
className="pointer-events-auto flex h-full items-center px-[2px]"
>
{/* Crisp left accent edge for recurring bars */}
{!isOnce && (
<span
aria-hidden="true"
className={cn("pointer-events-none absolute inset-y-0 left-0 w-[3px]", vis.accent)}
/>
)}
{/* Per-day interactive slices inside the continuous bar */}
<div
className="grid h-full w-full divide-x divide-current/10"
style={{ gridTemplateColumns: `repeat(${span.spanDays}, minmax(0, 1fr))` }}
>
{span.occurrences.map((occ) => {
const dateLabel =
span.spanDays > 1 && isOnce ? `${span.startDateKey} → ${span.endDateKey}` : occ.dateKey;
const titleText = `${schedule.name}\n${dateLabel} · ${occ.displayTimeRange}${
span.overnight ? ` (${translate("schedule.month.overnight")})` : ""
}`;
return (
<button
key={occ.id}
type="button"
title={titleText}
onMouseEnter={() => setHoveredInfo({ schedule, occ, span })}
onMouseLeave={() => setHoveredInfo((cur) => (cur?.occ.id === occ.id ? null : cur))}
onClick={(e) => {
e.stopPropagation();
onSelectOccurrence(occ);
}}
className="h-full w-full cursor-pointer transition-colors hover:bg-current/10"
/>
);
})}
</div>
{/* Centered readable time window label (no mystery dots) */}
<span
className={cn(
"pointer-events-none absolute inset-0 flex items-center justify-center truncate px-1.5 font-medium font-mono tracking-tight",
span.spanDays >= 2 ? "text-[10px]" : "text-[9px]",
"group/bar relative flex h-6 w-full items-center overflow-hidden border transition-all",
span.continuesBeforeTrack ? "rounded-l-none border-l-dashed" : "rounded-l-[5px]",
span.continuesAfterTrack ? "rounded-r-none border-r-dashed" : "rounded-r-[5px]",
isOnce ? vis.barOnce : vis.bar,
anySelected && vis.barSelected,
)}
>
{barLabel}
</span>
{/* Crisp left accent edge for recurring bars */}
{!isOnce && (
<span
aria-hidden="true"
className={cn("pointer-events-none absolute inset-y-0 left-0 w-[3px]", vis.accent)}
/>
)}
{/* Subtle right edge indicator for overnight runs */}
{span.overnight && (
{/* Per-day interactive slices inside the continuous bar */}
<div
className="grid h-full w-full divide-x divide-current/10"
style={{ gridTemplateColumns: `repeat(${span.spanDays}, minmax(0, 1fr))` }}
>
{span.occurrences.map((occ) => {
const dateLabel =
span.spanDays > 1 && isOnce ? `${span.startDateKey} → ${span.endDateKey}` : occ.dateKey;
const titleText = `${schedule.name}\n${dateLabel} · ${occ.displayTimeRange}${
span.overnight ? ` (${translate("schedule.month.overnight")})` : ""
}`;
return (
<button
key={occ.id}
type="button"
title={titleText}
onMouseEnter={() => setHoveredInfo({ schedule, occ, span })}
onMouseLeave={() => setHoveredInfo((cur) => (cur?.occ.id === occ.id ? null : cur))}
onClick={(e) => {
e.stopPropagation();
onSelectOccurrence(occ);
}}
className="h-full w-full cursor-pointer transition-colors hover:bg-current/10"
/>
);
})}
</div>
{/* Centered readable time window label (no mystery dots) */}
<span
aria-hidden="true"
className="pointer-events-none absolute inset-y-0 right-0 w-[3px] bg-current opacity-35"
/>
)}
className={cn(
"pointer-events-none absolute inset-0 flex items-center justify-center truncate px-1.5 font-medium font-mono tracking-tight",
span.spanDays >= 2 ? "text-[10px]" : "text-[9px]",
)}
>
{barLabel}
</span>
{/* Subtle right edge indicator for overnight runs */}
{span.overnight && (
<span
aria-hidden="true"
className="pointer-events-none absolute inset-y-0 right-0 w-[3px] bg-current opacity-35"
/>
)}
{/* Bottom pull-to-expand handle directly on bar (matching Week/Day event cards) */}
<button
type="button"
tabIndex={-1}
data-no-calendar-swipe="true"
data-month-expand-handle="true"
aria-expanded={isExpanded}
title={
isExpanded
? translate("schedule.calendar.collapseDetails")
: translate("schedule.calendar.expandDetails")
}
onPointerDown={(e) => startPullDrag(schedule.id, e, "bar")}
className="absolute inset-x-0 bottom-0 z-10 flex h-2 cursor-ns-resize items-center justify-center opacity-0 transition-opacity group-hover/bar:opacity-100"
>
<span className="h-[2px] w-5 rounded-full bg-current opacity-55" />
</button>
</div>
</div>
</div>
);
})}
</div>
)}
);
})}
</div>
)}
</div>
</div>
);
};
@@ -568,16 +853,36 @@ export function MonthSwimlaneView({
className="grid shrink-0 border-b bg-background/95 backdrop-blur-xs"
style={{ gridTemplateColumns: "236px minmax(0, 1fr)" }}
>
<div className="flex flex-col justify-center border-r px-3 py-2">
<div className="flex items-center justify-between gap-2">
<div className="flex flex-col justify-between gap-1.5 border-r px-3 py-2">
<div className="flex items-center justify-between gap-2" title={translate("schedule.month.laneHint")}>
<span className="font-semibold text-xs">{translate("schedule.month.laneTitle")}</span>
<span className="rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground tabular-nums">
{activeRows.length}/{schedules.length}
</span>
</div>
<span className="mt-0.5 truncate text-[10px] text-muted-foreground">
{translate("schedule.month.laneHint")}
</span>
<fieldset
aria-label={translate("schedule.month.sortLabel")}
data-no-calendar-swipe="true"
className="grid grid-cols-2 rounded-md border bg-muted/45 p-0.5 text-[10px]"
>
{(["time", "priority"] as const).map((mode) => {
const active = sortMode === mode;
return (
<button
key={mode}
type="button"
aria-pressed={active}
onClick={() => changeSortMode(mode)}
className={cn(
"cursor-pointer truncate rounded-[4px] px-1.5 py-0.5 font-medium transition-colors",
active ? "bg-background text-foreground shadow-xs" : "text-muted-foreground hover:text-foreground",
)}
>
{translate(mode === "time" ? "schedule.month.sortByTime" : "schedule.month.sortByPriority")}
</button>
);
})}
</fieldset>
</div>
<div ref={slide.viewportRef} className="min-w-0 overflow-hidden">
@@ -655,8 +960,8 @@ export function MonthSwimlaneView({
{translate("schedule.month.empty")}
</div>
) : (
<div className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden">
<div className="grid min-h-full" style={{ gridTemplateColumns: "236px minmax(0, 1fr)" }}>
<div ref={bodyScrollRef} className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden">
<div className="relative grid min-h-full" style={{ gridTemplateColumns: "236px minmax(0, 1fr)" }}>
{/* Left column: pinned schedule labels */}
<div className="flex flex-col border-r bg-background">
{activeRows.map((row) => renderLeftLabel(row, false))}
@@ -723,6 +1028,178 @@ export function MonthSwimlaneView({
)}
</div>
</div>
{/* Compact floating detail card anchored to the pulled lane/bar (matching Week/Day pull-down) */}
{activeCard &&
(() => {
const { row, rowTopPx, anchorLeft, openAbove, previewHeight, isPulling } = activeCard;
const { schedule } = row;
const vis = LANE_STATUS_VISUAL[schedule.status] ?? LANE_STATUS_VISUAL.waiting;
const windowText = formatScheduleWindow(schedule);
const linkedTasks = schedule.task_ids.map((id) => ({ id, task: taskById.get(id) }));
const posStyle: React.CSSProperties = {
left: `${anchorLeft}px`,
...(openAbove && !isPulling
? { bottom: `calc(100% - ${rowTopPx + 2}px)` }
: { top: `${rowTopPx + LANE_ROW_HEIGHT - 2}px` }),
...(previewHeight !== null ? { height: `${previewHeight}px` } : {}),
};
return (
<div
data-month-expand-card="true"
data-no-calendar-swipe="true"
style={posStyle}
className={cn(
"absolute z-30 flex max-h-[300px] w-[320px] max-w-[calc(100%-16px)] flex-col overflow-hidden rounded-lg border bg-popover/98 text-popover-foreground shadow-lg ring-1 ring-border/75 backdrop-blur-xs",
!isPulling && "transition-[height] duration-150 ease-out",
)}
>
<div className="flex min-h-0 flex-1 flex-col gap-1.5 overflow-y-auto px-3 pt-2.5 pb-2 text-[11px]">
{/* Header: status dot + title + status badge */}
<div className="flex items-start justify-between gap-2">
<div className="flex min-w-0 items-center gap-1.5">
<span className={cn("size-2 shrink-0 rounded-full", vis.dot)} />
<span className="break-words font-semibold text-xs leading-snug">{schedule.name}</span>
</div>
<Badge variant="outline" className={cn("h-4 shrink-0 px-1.5 text-[10px]", vis.pill)}>
{statusText(schedule)}
</Badge>
</div>
{/* Time window, rule & timezone */}
<div className="flex flex-wrap items-center gap-1 font-mono text-[10px] text-muted-foreground">
<span>{windowText}</span>
<span>·</span>
<span>{windowLabel(schedule)}</span>
</div>
<div className="text-[10px] text-muted-foreground">{timezoneLabel(schedule)}</div>
{/* Proxy route if configured */}
{schedule.proxy_mode && schedule.proxy_mode !== "inherit" ? (
<div className="flex items-center gap-1 text-[10px] text-muted-foreground">
<RouteIcon className="size-3 shrink-0" />
<span className="truncate font-mono">
{formatProxyRouteSummary(
{
mode: schedule.proxy_mode,
proxy_pool_id: schedule.proxy_pool_id,
proxy_url: schedule.proxy_url,
effective_proxy: schedule.effective_proxy,
},
isEn,
proxyPool,
)}
</span>
</div>
) : null}
{/* Remark */}
{schedule.remark ? (
<p className="rounded bg-muted/45 px-2 py-1 text-[10px] text-muted-foreground leading-relaxed">
{schedule.remark}
</p>
) : null}
{/* Linked tasks */}
<div className="space-y-0.5 border-t pt-1.5">
<div className="flex items-center gap-1 font-medium text-[10px] text-muted-foreground">
<ListChecksIcon className="size-3 shrink-0" />
<span>
{linkedTasks.length > 0
? translate("schedule.calendar.boundTasksCount", { count: linkedTasks.length })
: translate("schedule.calendar.noBoundTasks")}
</span>
</div>
{linkedTasks.length > 0 ? (
<div className="space-y-0.5">
{linkedTasks.slice(0, 4).map(({ id, task }) => (
<Link
key={id}
href={`/function/tasks/detail?id=${encodeURIComponent(String(id))}`}
className="flex items-center justify-between gap-2 rounded px-1.5 py-0.5 text-[10px] hover:bg-muted"
>
<span className="truncate font-medium">
#{id} {task?.name?.trim() || task?.description || ""}
</span>
{task?.status ? (
<span className="shrink-0 text-[9px] text-muted-foreground">{task.status}</span>
) : null}
</Link>
))}
</div>
) : null}
</div>
</div>
{/* Compact inline action bar */}
<div className="flex flex-wrap items-center gap-1 border-t bg-muted/20 px-2.5 py-1.5">
<Button
type="button"
size="xs"
className="h-6 rounded-full bg-blue-600 px-2 text-[10px] text-white hover:bg-blue-700"
onClick={() => void onAction(schedule.id, "run")}
>
<ZapIcon className="mr-0.5 size-3" />
{translate("schedule.runNow")}
</Button>
<Button
type="button"
size="xs"
variant="outline"
className="h-6 rounded-full px-2 text-[10px]"
onClick={() => void onAction(schedule.id, schedule.enabled ? "pause" : "resume")}
>
{schedule.enabled ? (
<PauseIcon className="mr-0.5 size-3" />
) : (
<PlayIcon className="mr-0.5 size-3" />
)}
{schedule.enabled ? translate("schedule.pause") : translate("schedule.enable")}
</Button>
<Button
type="button"
size="xs"
variant="ghost"
className="h-6 px-1.5 text-[10px]"
onClick={() => {
setExpandedCard(null);
onEdit(schedule);
}}
>
<PencilIcon className="mr-0.5 size-3" />
{translate("schedule.edit")}
</Button>
<Button
type="button"
size="xs"
variant="ghost"
className="ml-auto h-6 px-1.5 text-[10px] text-muted-foreground"
onClick={() => {
setExpandedCard(null);
openScheduleDetail(row);
}}
>
<HistoryIcon className="mr-0.5 size-3" />
{translate("schedule.calendar.fullDetails")}
</Button>
</div>
{/* Bottom pull-up / click-to-collapse handle */}
<button
type="button"
tabIndex={-1}
data-no-calendar-swipe="true"
data-month-expand-handle="true"
aria-expanded={true}
title={translate("schedule.calendar.collapseDetails")}
onPointerDown={(e) => startPullDrag(schedule.id, e, "card")}
className="flex h-3.5 shrink-0 cursor-ns-resize items-center justify-center border-t bg-muted/35 transition-colors hover:bg-muted/65"
>
<span className="h-0.5 w-7 rounded-full bg-muted-foreground/55" />
</button>
</div>
);
})()}
</div>
</div>
)}
@@ -50,6 +50,7 @@ import {
formatMinutesAsClock,
layoutDayTimedEvents,
makeDateKey,
parseClockMinutes,
parseDateKey,
resolveDisplayOffsetMinutes,
startOfWeekDateKey,
@@ -727,6 +728,11 @@ export function ScheduleCalendarWorkspace({
const [dragState, setDragState] = React.useState<DragState | null>(null);
const [expandedOccId, setExpandedOccId] = React.useState<string | null>(null);
const [expandDrag, setExpandDrag] = React.useState<ExpandDragState | null>(null);
const [yearDayPopover, setYearDayPopover] = React.useState<{
dateKey: string;
left: number;
top: number;
} | null>(null);
const [gridDensity, setGridDensity] = React.useState<"fit" | "comfortable">("fit");
const [sidebarOpen, setSidebarOpen] = React.useState(true);
React.useEffect(() => {
@@ -859,6 +865,13 @@ export function ScheduleCalendarWorkspace({
monthYearLongFmt: new Intl.DateTimeFormat(locale, { year: "numeric", month: "long", timeZone: "UTC" }),
monthYearShortFmt: new Intl.DateTimeFormat(locale, { year: "numeric", month: "short", timeZone: "UTC" }),
weekdayShortFmt: new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: "UTC" }),
dayLongFmt: new Intl.DateTimeFormat(locale, {
year: "numeric",
month: "short",
day: "numeric",
weekday: "short",
timeZone: "UTC",
}),
}),
[locale],
);
@@ -956,9 +969,13 @@ export function ScheduleCalendarWorkspace({
}
const occs = expandSchedulesForDateKeys(visibleSchedules, Array.from(allDaysSet), displayOffset, serverOffset);
const dayCounts = new Map<string, number>();
const dayOccurrences = new Map<string, CalendarEventOccurrence[]>();
const monthScheduleIds = new Map<string, Set<number>>();
for (const o of occs) {
dayCounts.set(o.dateKey, (dayCounts.get(o.dateKey) ?? 0) + 1);
const list = dayOccurrences.get(o.dateKey);
if (list) list.push(o);
else dayOccurrences.set(o.dateKey, [o]);
const p = parseDateKey(o.dateKey);
if (p) {
const ymKey = `${p.year}-${p.month}`;
@@ -967,12 +984,31 @@ export function ScheduleCalendarWorkspace({
monthScheduleIds.set(ymKey, set);
}
}
for (const list of dayOccurrences.values()) {
list.sort((a, b) => {
const sa = parseClockMinutes(a.schedule.start_time) ?? a.startMin;
const sb = parseClockMinutes(b.schedule.start_time) ?? b.startMin;
if (sa !== sb) return sa - sb;
return a.schedule.name.localeCompare(b.schedule.name);
});
}
return cols.map((col) => ({
...col,
dayCounts,
dayOccurrences,
monthScheduleIds,
}));
}, [viewMode, yearStartQuarter.year, yearStartQuarter.month, yearVisibleCols, yearBufferCols, visibleSchedules, displayOffset, serverOffset, dateFormatters]);
}, [
viewMode,
yearStartQuarter.year,
yearStartQuarter.month,
yearVisibleCols,
yearBufferCols,
visibleSchedules,
displayOffset,
serverOffset,
dateFormatters,
]);
const upcomingItems = React.useMemo(() => {
return visibleSchedules
.filter((s) => s.enabled && s.status !== "completed" && (s.status === "running" || s.next_start))
@@ -1078,6 +1114,7 @@ export function ScheduleCalendarWorkspace({
const shiftYearQuarters = React.useCallback((deltaQuarters: number) => {
if (deltaQuarters === 0) return;
setExpandedOccId(null);
setYearDayPopover(null);
setYearStartQuarter((prev) => {
const next = addYearMonth(prev.year, prev.month, deltaQuarters * 3);
const nextAnchor = makeDateKey(next.year, next.month, 1);
@@ -1180,6 +1217,7 @@ export function ScheduleCalendarWorkspace({
const selectViewMode = React.useCallback(
(mode: CalendarViewMode) => {
setExpandedOccId(null);
setYearDayPopover(null);
if (mode === "month") {
const p = parseDateKey(anchorDateKey);
if (p) setMonthStartDateKey(makeDateKey(p.year, p.month, 1));
@@ -1275,6 +1313,11 @@ export function ScheduleCalendarWorkspace({
) {
return;
}
if (e.key === "Escape" && yearDayPopover) {
e.preventDefault();
setYearDayPopover(null);
return;
}
if (e.key === "Escape" && expandedOccId) {
e.preventDefault();
setExpandedOccId(null);
@@ -1290,8 +1333,18 @@ export function ScheduleCalendarWorkspace({
};
window.addEventListener("keydown", onKeyDown);
return () => window.removeEventListener("keydown", onKeyDown);
}, [viewMode, selectedOccurrence, expandedOccId, navigatePeriod]);
}, [viewMode, selectedOccurrence, expandedOccId, yearDayPopover, navigatePeriod]);
React.useEffect(() => {
if (!yearDayPopover) return;
const onPointerDown = (e: PointerEvent) => {
const target = e.target as HTMLElement | null;
if (target?.closest('[data-year-day-popover="true"], [data-year-day-cell="true"]')) return;
setYearDayPopover(null);
};
window.addEventListener("pointerdown", onPointerDown);
return () => window.removeEventListener("pointerdown", onPointerDown);
}, [yearDayPopover]);
const miniYearBlockStart = Math.floor(miniMonth.year / 12) * 12;
const shortMonthNames = React.useMemo(
() =>
@@ -2250,14 +2303,39 @@ export function ScheduleCalendarWorkspace({
const p = parseDateKey(dk);
const inMonth = p?.month === m;
const isToday = dk === todayKey;
const isSelected = dk === anchorDateKey;
const isSelected = dk === (yearDayPopover?.dateKey ?? anchorDateKey);
const dayCount = inMonth ? (col.dayCounts.get(dk) ?? 0) : 0;
const dayTitle =
dayCount > 0
? `${translate("schedule.calendar.dayEventCount", { count: dayCount })} · ${translate("schedule.year.dayHint")}`
: translate("schedule.year.dayHint");
return (
<button
key={dk}
type="button"
title={dayCount > 0 ? translate("schedule.calendar.dayEventCount", { count: dayCount }) : undefined}
onClick={() => {
data-year-day-cell="true"
title={dayTitle}
onClick={(e) => {
setAnchorDateKey(dk);
if (yearDayPopover?.dateKey === dk) {
setYearDayPopover(null);
return;
}
const rect = e.currentTarget.getBoundingClientRect();
const cardW = 304;
const cardH = 330;
const vw = window.innerWidth;
const vh = window.innerHeight;
const rawLeft =
rect.right + 10 + cardW <= vw - 12
? rect.right + 10
: rect.left - cardW - 10;
const left = Math.max(12, Math.min(rawLeft, vw - cardW - 12));
const top = Math.max(12, Math.min(rect.top - 16, vh - cardH - 12));
setYearDayPopover({ dateKey: dk, left, top });
}}
onDoubleClick={() => {
setYearDayPopover(null);
jumpToDateKey(dk);
selectViewMode("day");
}}
@@ -2265,7 +2343,9 @@ export function ScheduleCalendarWorkspace({
"flex aspect-square h-[calc(100%-2px)] max-h-8 min-h-5 items-center justify-center rounded-full text-[11px] transition-colors",
!inMonth && "text-muted-foreground/30",
isToday && "bg-blue-600 font-semibold text-white hover:bg-blue-700",
!isToday && isSelected && "bg-accent font-semibold text-foreground ring-1 ring-border",
!isToday &&
isSelected &&
"bg-accent font-semibold text-foreground ring-1 ring-blue-500/60",
!isToday &&
!isSelected &&
inMonth &&
@@ -2288,6 +2368,132 @@ export function ScheduleCalendarWorkspace({
})}
</div>
</div>
{/* Floating Day Agenda Popover for Year view */}
{yearDayPopover && (() => {
const dk = yearDayPopover.dateKey;
const p = parseDateKey(dk);
const dayDate = p ? new Date(Date.UTC(p.year, p.month - 1, p.day)) : null;
const dayOccs = yearTrackColumns[0]?.dayOccurrences.get(dk) ?? [];
const isTodayPop = dk === todayKey;
return (
<div
data-year-day-popover="true"
data-no-calendar-swipe="true"
style={{ left: `${yearDayPopover.left}px`, top: `${yearDayPopover.top}px` }}
className="fixed z-40 flex w-[304px] max-h-[330px] flex-col overflow-hidden rounded-xl border bg-popover/98 text-popover-foreground shadow-xl ring-1 ring-border/60 backdrop-blur-xs"
>
<div className="flex items-center justify-between gap-2 border-b px-3 py-2.5">
<div className="flex min-w-0 items-center gap-1.5">
<span className="truncate font-semibold text-xs">
{dayDate ? dateFormatters.dayLongFmt.format(dayDate) : dk}
</span>
{isTodayPop ? (
<span className="shrink-0 rounded-full bg-blue-600 px-1.5 py-0.5 font-medium text-[9px] text-white">
{translate("schedule.calendar.today")}
</span>
) : null}
</div>
<div className="flex shrink-0 items-center gap-1">
{dayOccs.length > 0 ? (
<span className="rounded-full bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground tabular-nums">
{translate("schedule.calendar.monthSchedulesCount", { count: dayOccs.length })}
</span>
) : null}
<Button
type="button"
size="icon-xs"
variant="ghost"
className="size-6"
onClick={() => setYearDayPopover(null)}
>
<XIcon className="size-3.5" />
</Button>
</div>
</div>
<div className="min-h-0 flex-1 overflow-y-auto p-2">
{dayOccs.length === 0 ? (
<div className="py-6 text-center text-muted-foreground text-xs">
{translate("schedule.year.dayEmpty")}
</div>
) : (
<div className="space-y-1">
{dayOccs.map((occ) => {
const st = STATUS_STYLE[occ.schedule.status] ?? STATUS_STYLE.waiting;
return (
<button
key={occ.id}
type="button"
onClick={() => {
setYearDayPopover(null);
setPopoverTimelineOpen(false);
setSelectedOccurrence(occ);
}}
className="flex w-full items-center gap-2 rounded-lg border border-transparent px-2 py-1.5 text-left transition-colors hover:border-border/70 hover:bg-muted/50"
>
<span className={cn("size-2 shrink-0 rounded-full", st.dot)} />
<div className="min-w-0 flex-1">
<div className="truncate font-medium text-xs leading-tight">{occ.schedule.name}</div>
<div className="mt-0.5 flex items-center gap-1.5 font-mono text-[10px] text-muted-foreground tabular-nums">
<span>{occ.displayTimeRange}</span>
<span>·</span>
<span className="truncate">{statusText(occ.schedule)}</span>
</div>
</div>
<ChevronRight className="size-3.5 shrink-0 text-muted-foreground/60" />
</button>
);
})}
</div>
)}
</div>
<div className="flex items-center justify-between gap-1.5 border-t bg-muted/20 px-2.5 py-2">
<div className="flex items-center gap-1">
<Button
type="button"
size="xs"
variant="outline"
className="h-6 px-2 text-[11px]"
onClick={() => {
setYearDayPopover(null);
jumpToDateKey(dk);
selectViewMode("day");
}}
>
{translate("schedule.year.openDayView")}
</Button>
<Button
type="button"
size="xs"
variant="outline"
className="h-6 px-2 text-[11px]"
onClick={() => {
setYearDayPopover(null);
jumpToDateKey(dk);
selectViewMode("month");
}}
>
{translate("schedule.year.openMonthView")}
</Button>
</div>
<Button
type="button"
size="xs"
className="h-6 rounded-full bg-blue-600 px-2.5 text-[11px] text-white hover:bg-blue-700"
onClick={() => {
setYearDayPopover(null);
onCreateAtSlot(dk, 9 * 60, 10 * 60);
}}
>
<Plus className="mr-0.5 size-3" />
{translate("schedule.year.quickCreate")}
</Button>
</div>
</div>
);
})()}
</div>
) : viewMode === "month" ? (
<MonthSwimlaneView
@@ -2301,6 +2507,8 @@ export function ScheduleCalendarWorkspace({
anchorDateKey={anchorDateKey}
schedules={visibleSchedules}
occurrences={occurrences}
taskById={taskById}
proxyPool={proxyPool}
selectedOccurrenceId={selectedOccurrence?.id ?? null}
onSelectOccurrence={(occ) => {
setPopoverTimelineOpen(false);
@@ -2311,6 +2519,8 @@ export function ScheduleCalendarWorkspace({
selectViewMode("day");
}}
onCreateAtSlot={onCreateAtSlot}
onEdit={onEdit}
onAction={onAction}
/>
) : (
/* Week & Day Time Grid View: 64px time axis stays fixed while adjacent day columns glide smoothly */
+10 -8
View File
@@ -151,10 +151,7 @@ export const scheduleMessages = {
"此前已执行过,当前不在执行时段内,等下次到点自动继续",
"Previously ran; currently outside the scheduled hours and waiting for the next run",
],
"schedule.statusHint.paused": [
"计划已手动关闭,到点不会自动执行",
"Manually disabled; will not run automatically",
],
"schedule.statusHint.paused": ["计划已手动关闭,到点不会自动执行", "Manually disabled; will not run automatically"],
"schedule.statusHint.completed": [
"一次性计划已过结束时间,不会再重复执行",
"One-time schedule has finished and will not repeat",
@@ -227,10 +224,7 @@ export const scheduleMessages = {
"Demo mode does not execute schedules. Run this schedule in a deployed instance.",
],
"schedule.proxy": ["出口代理 / 代理池", "Egress Proxy / Proxy Pool"],
"schedule.proxyInherit": [
"保持任务自身 / 全局代理设置(不覆盖)",
"Keep task / global proxy (do not override)",
],
"schedule.proxyInherit": ["保持任务自身 / 全局代理设置(不覆盖)", "Keep task / global proxy (do not override)"],
"schedule.proxyHelp": [
"设为直连、代理池或指定代理后,保存与计划触发时会自动应用到所有关联任务的容器。",
"When set to direct, proxy pool, or specific proxy, bound tasks automatically apply this route on save and when the schedule runs.",
@@ -307,6 +301,14 @@ export const scheduleMessages = {
],
"schedule.month.createAtDay": ["在 {{date}} 新建计划", "Create schedule on {{date}}"],
"schedule.month.overnight": ["跨夜", "Overnight"],
"schedule.month.sortLabel": ["排序方式", "Sort order"],
"schedule.month.sortByTime": ["按时间", "By time"],
"schedule.month.sortByPriority": ["按优先级", "By priority"],
"schedule.year.dayEmpty": ["当天暂无排期", "No schedules on this day"],
"schedule.year.openDayView": ["日视图", "Day view"],
"schedule.year.openMonthView": ["月视图", "Month view"],
"schedule.year.quickCreate": ["新建", "New"],
"schedule.year.dayHint": ["点击预览当日排期 · 双击进入日视图", "Click to preview day · Double-click for Day view"],
"schedule.calendar.expandDetails": ["下拉或点击展开详情", "Pull down or click to expand details"],
"schedule.calendar.collapseDetails": ["上拉或点击收起详情", "Pull up or click to collapse details"],
"schedule.calendar.fullDetails": ["更多详情", "Full details"],