Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat(production): compact work-center layout for the schedule forecast (#1944)

Brad Barbin31371c3d1807
diff --git a/apps/erp/app/components/Gantt/Gantt.tsx b/apps/erp/app/components/Gantt/Gantt.tsx
index 026623e4c8..1f0dffbdd5 100644
--- a/apps/erp/app/components/Gantt/Gantt.tsx
+++ b/apps/erp/app/components/Gantt/Gantt.tsx
@@ -62,6 +62,7 @@ import {
runStatusClassNameColor
} from "./components/GanttTaskStatus";
import { eventBackgroundClassName, SpanTitle } from "./components/SpanTitle";
+import { assignTracks } from "./tracks";
/** The tree list's default width, in px — the timeline takes the remainder. */
const TREE_DEFAULT_WIDTH = 360;
@@ -182,6 +183,25 @@ const Gantt = ({
const timelineScrollRef = useRef<HTMLDivElement>(null);
const panelGroupRef = useRef<HTMLDivElement>(null);
+ // An inline bar (`data.items`) is not a tree node, so the tree cannot hold
+ // its selection — the Gantt does. Selecting a row clears it and vice versa.
+ // Seeded once from `selectedId`, like the tree's own selection.
+ const [selectedItemId, setSelectedItemId] = useState<string | undefined>(
+ () =>
+ selectedId &&
+ events.some((event) =>
+ event.data.items?.some((item) => item.id === selectedId)
+ )
+ ? selectedId
+ : undefined
+ );
+ const onTreeSelectedIdChanged = (id: string | undefined) => {
+ // The tree letting go because an inline bar took the selection.
+ if (id === undefined && selectedItemId) return;
+ setSelectedItemId(undefined);
+ onSelectedIdChanged(id);
+ };
+
// The tree defaults to a fixed pixel width; react-resizable-panels only takes
// percentages, so convert once the group's width is known (and gate the group
// on it, since defaultSize is read only at mount). The timeline gets the rest.
@@ -202,6 +222,7 @@ const Gantt = ({
getTreeProps,
getNodeProps,
toggleNodeSelection,
+ deselectAllNodes,
toggleExpandNode,
expandAllBelowDepth,
toggleExpandLevel,
@@ -213,27 +234,40 @@ const Gantt = ({
tree: events,
selectedId,
collapsedIds,
- onSelectedIdChanged,
+ onSelectedIdChanged: onTreeSelectedIdChanged,
estimatedRowHeight: () => 32,
parentRef,
filter: {
value: { text: filterText, wipOnly },
fn: (value, node) => {
- const isWIP = (value.wipOnly && node.data.isPartial) || !value.wipOnly;
+ const isWIP =
+ !value.wipOnly ||
+ node.data.isPartial ||
+ !!node.data.items?.some((item) => item.data.isPartial);
if (!isWIP) return false;
if (value.text === "") return true;
- if (
- node.data.message.toLowerCase().includes(value.text.toLowerCase())
- ) {
- return true;
- }
- return false;
+ // A row also matches on its inline bars — a job search finds the lane
+ // it runs on.
+ return [node, ...(node.data.items ?? [])].some((event) =>
+ matchesFilterText(event, value.text)
+ );
}
}
});
+ const selectItem = (id: string) => {
+ if (id === selectedItemId) {
+ setSelectedItemId(undefined);
+ onSelectedIdChanged(undefined);
+ return;
+ }
+ setSelectedItemId(id);
+ deselectAllNodes();
+ onSelectedIdChanged(id);
+ };
+
// Defined once: desktop puts these in resizable panels, phones in a fixed row.
const treePanel = (
<div className="grid h-full grid-rows-[2rem_1fr] overflow-hidden">
@@ -359,6 +393,9 @@ const Gantt = ({
treeScrollRef={treeScrollRef}
virtualizer={virtualizer}
toggleNodeSelection={toggleNodeSelection}
+ selectedItemId={selectedItemId}
+ onItemSelected={selectItem}
+ filterText={filterText}
/>
);
@@ -500,8 +537,15 @@ type GanttTimelineProps = Pick<
toggleNodeSelection: UseTreeStateOutput["toggleNodeSelection"];
showDurations: boolean;
treeScrollRef: React.RefObject<HTMLDivElement>;
+ selectedItemId: string | undefined;
+ onItemSelected: (id: string) => void;
+ filterText: string;
};
+function matchesFilterText(event: GanttEvent, text: string) {
+ return event.data.message.toLowerCase().includes(text.toLowerCase());
+}
+
const TICK_COUNT = 5;
/**
@@ -554,7 +598,10 @@ const GanttTimeline = ({
getTreeProps,
toggleNodeSelection,
showDurations,
- treeScrollRef
+ treeScrollRef,
+ selectedItemId,
+ onItemSelected,
+ filterText
}: GanttTimelineProps) => {
const timelineContainerRef = useRef<HTMLDivElement>(null);
// Live width (ResizeObserver) so the timeline reflows to fill the panel when
@@ -868,7 +915,15 @@ const GanttTimeline = ({
toggleNodeSelection(node.id);
}}
>
- {node.data.level === "TRACE" ? (
+ {node.data.items ? (
+ <LaneItems
+ items={node.data.items}
+ selectedItemId={selectedItemId}
+ onItemSelected={onItemSelected}
+ filterText={filterText}
+ nonWorkingOffsets={nonWorkingOffsets}
+ />
+ ) : node.data.level === "TRACE" ? (
<>
{node.data.wait && node.data.wait.duration > 0 && (
<WaitSpan wait={node.data.wait} />
@@ -1220,6 +1275,150 @@ function SpanWithDuration({
);
}
+/**
+ * An inline bar's colors: a light fill with dark text in light mode, the
+ * reverse in dark mode. Solid, not translucent, so gridlines and the shaded
+ * non-working time never show through. Same meaning as the solid bars —
+ * red conflict, amber maintenance, blue in progress, neutral scheduled.
+ */
+function laneItemClassName(
+ data: Pick<
+ GanttEvent["data"],
+ "isError" | "isCancelled" | "isPartial" | "style"
+ >
+) {
+ if (data.isError) {
+ return "border-red-300 bg-red-50 text-red-900 hover:border-red-500 dark:border-red-800 dark:bg-red-950 dark:text-red-100 dark:hover:border-red-600";
+ }
+ if (data.isCancelled) {
+ return "border-border bg-muted text-muted-foreground";
+ }
+ if (data.style.variant === "maintenance") {
+ return "border-amber-300 bg-amber-50 text-amber-900 hover:border-amber-500 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-100 dark:hover:border-amber-600";
+ }
+ if (data.isPartial) {
+ return "border-blue-300 bg-blue-50 text-blue-900 hover:border-blue-500 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100 dark:hover:border-blue-600";
+ }
+ return "border-zinc-300 bg-zinc-100 text-zinc-900 hover:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-100 dark:hover:border-zinc-500";
+}
+
+/**
+ * A row's inline bars (`data.items`), each labelled and selectable. Bars that
+ * overlap in time stack into tracks so none hides another; a row with no
+ * overlap stays one line. Like any bar, each is split on non-working time,
+ * with its label on the widest piece.
+ */
+function LaneItems({
+ items,
+ selectedItemId,
+ onItemSelected,
+ filterText,
+ nonWorkingOffsets
+}: {
+ items: GanttEvent[];
+ selectedItemId: string | undefined;
+ onItemSelected: (id: string) => void;
+ filterText: string;
+ nonWorkingOffsets: { start: number; end: number }[] | null;
+}) {
+ const visible = items.filter((item) => item.data.duration > 0);
+ const { tracks, trackCount } = assignTracks(visible.map((item) => item.data));
+ const showLabels = trackCount <= 2;
+ // A search that matches some bar dims the rest; one that only matches the
+ // row's own name leaves every bar lit.
+ const dimUnmatched =
+ filterText !== "" &&
+ visible.some((item) => matchesFilterText(item, filterText));
+
+ return (
+ <div className="pointer-events-none absolute inset-x-0 inset-y-0.5">
+ {visible.map((item, index) => {
+ const { offset, duration } = item.data;
+ const pieces = nonWorkingOffsets
+ ? splitWorkingSegments(offset, duration, nonWorkingOffsets)
+ : [{ startMs: offset, durationMs: duration }];
+ let labelIndex = 0;
+ for (let i = 1; i < pieces.length; i++) {
+ if (
+ (pieces[i]?.durationMs ?? 0) > (pieces[labelIndex]?.durationMs ?? 0)
+ ) {
+ labelIndex = i;
+ }
+ }
+ const isSelected = item.id === selectedItemId;
+ const isDimmed = dimUnmatched && !matchesFilterText(item, filterText);
+ const title = `${item.data.message} · ${formatDurationMilliseconds(
+ duration,
+ { style: "short", maxDecimalPoints: 1 }
+ )}`;
+ const track = tracks[index] ?? 0;
+
+ return (
+ <div
+ key={item.id}
+ className="absolute inset-x-0"
+ style={{
+ top: `${(track / trackCount) * 100}%`,
+ height: `${100 / trackCount}%`
+ }}
+ >
+ {pieces.map((piece, i) => (
+ <Timeline.Span
+ key={`${piece.startMs}:${piece.durationMs}`}
+ startMs={piece.startMs}
+ durationMs={piece.durationMs}
+ className="h-full px-px py-px"
+ >
+ <button
+ type="button"
+ title={title}
+ aria-label={title}
+ aria-pressed={isSelected}
+ onClick={(e) => {
+ e.stopPropagation();
+ onItemSelected(item.id);
+ }}
+ className={cn(
+ "pointer-events-auto relative flex h-full w-full min-w-[2px] items-center gap-1 overflow-hidden rounded-sm border px-1.5 text-left font-medium transition-[opacity,border-color]",
+ trackCount === 1 ? "text-xs" : "text-xxs",
+ laneItemClassName(item.data),
+ isSelected &&
+ "ring-2 ring-foreground ring-offset-1 ring-offset-background",
+ isDimmed && "opacity-30"
+ )}
+ >
+ {(item.data.isPartial || item.data.isEstimated) && (
+ <span
+ className={cn(
+ "absolute inset-0 opacity-15",
+ item.data.isPartial && "animate-tile-scroll"
+ )}
+ style={{
+ backgroundImage: `url(${tileBgPath})`,
+ backgroundSize: "8px 8px"
+ }}
+ />
+ )}
+ {showLabels && i === labelIndex && (
+ <>
+ {item.data.isUnschedulable && (
+ <LuBan className="relative size-3 shrink-0" />
+ )}
+ <span className="relative truncate">
+ {item.data.message}
+ </span>
+ </>
+ )}
+ </button>
+ </Timeline.Span>
+ ))}
+ </div>
+ );
+ })}
+ </div>
+ );
+}
+
const edgeBoundary = 0.05;
function CurrentTimeIndicator({ totalDuration }: { totalDuration: number }) {
diff --git a/apps/erp/app/components/Gantt/tracks.test.ts b/apps/erp/app/components/Gantt/tracks.test.ts
new file mode 100644
index 0000000000..7c61fb570a
--- /dev/null
+++ b/apps/erp/app/components/Gantt/tracks.test.ts
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { describe, expect, it } from "vitest";
+import { assignTracks } from "./tracks";
+
+describe("assignTracks", () => {
+ it("keeps back-to-back bars on one track", () => {
+ expect(
+ assignTracks([
+ { offset: 0, duration: 10 },
+ { offset: 10, duration: 5 },
+ { offset: 20, duration: 5 }
+ ])
+ ).toEqual({ tracks: [0, 0, 0], trackCount: 1 });
+ });
+
+ it("opens a second track only for an overlap", () => {
+ expect(
+ assignTracks([
+ { offset: 0, duration: 10 },
+ { offset: 5, duration: 10 },
+ { offset: 10, duration: 5 }
+ ])
+ ).toEqual({ tracks: [0, 1, 0], trackCount: 2 });
+ });
+
+ it("reports tracks in input order regardless of start order", () => {
+ expect(
+ assignTracks([
+ { offset: 5, duration: 10 },
+ { offset: 0, duration: 10 }
+ ])
+ ).toEqual({ tracks: [1, 0], trackCount: 2 });
+ });
+
+ it("uses one track for an empty row", () => {
+ expect(assignTracks([])).toEqual({ tracks: [], trackCount: 1 });
+ });
+});
diff --git a/apps/erp/app/components/Gantt/tracks.ts b/apps/erp/app/components/Gantt/tracks.ts
new file mode 100644
index 0000000000..46f96f4556
--- /dev/null
+++ b/apps/erp/app/components/Gantt/tracks.ts
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+/**
+ * Pack bars that share one row into tracks: each bar takes the first track
+ * whose last bar has ended by the time it starts. Bars that never overlap all
+ * land on track 0, so a row of back-to-back work stays a single line; only an
+ * overlap opens a second track. Returns each bar's track (input order) and
+ * the number of tracks used.
+ */
+export function assignTracks(bars: { offset: number; duration: number }[]): {
+ tracks: number[];
+ trackCount: number;
+} {
+ const order = bars
+ .map((bar, index) => ({ ...bar, index }))
+ .sort((a, b) => a.offset - b.offset || b.duration - a.duration);
+ const trackEnds: number[] = [];
+ const tracks = new Array<number>(bars.length).fill(0);
+
+ for (const bar of order) {
+ let track = trackEnds.findIndex((end) => end <= bar.offset);
+ if (track === -1) {
+ track = trackEnds.length;
+ trackEnds.push(0);
+ }
+ trackEnds[track] = bar.offset + bar.duration;
+ tracks[bar.index] = track;
+ }
+
+ return { tracks, trackCount: Math.max(trackEnds.length, 1) };
+}
diff --git a/apps/erp/app/components/Gantt/types.ts b/apps/erp/app/components/Gantt/types.ts
index e6fca42aa8..3dd88cea87 100644
--- a/apps/erp/app/components/Gantt/types.ts
+++ b/apps/erp/app/components/Gantt/types.ts
@@ -57,6 +57,14 @@ export type GanttEvent = {
* ms relative to the timeline window, like the bar's.
*/
conflictSegments?: { offset: number; duration: number }[];
+ /**
+ * Bars drawn side by side INSIDE this row instead of as child rows — e.g. a
+ * work-center lane carrying every operation it runs on one line. Each is
+ * labelled with its `message` and selectable by its `id`. When set, the
+ * row's own bar is not drawn. Bars that overlap in time share the row in
+ * stacked tracks.
+ */
+ items?: GanttEvent[];
};
};
diff --git a/apps/erp/app/modules/production/ui/Schedule/ForecastHeader.tsx b/apps/erp/app/modules/production/ui/Schedule/ForecastHeader.tsx
index 6d5ce20041..0086914fa4 100644
--- a/apps/erp/app/modules/production/ui/Schedule/ForecastHeader.tsx
+++ b/apps/erp/app/modules/production/ui/Schedule/ForecastHeader.tsx
@@ -17,6 +17,9 @@ import {
Popover,
PopoverContent,
PopoverTrigger,
+ Tabs,
+ TabsList,
+ TabsTrigger,
Tooltip,
TooltipContent,
TooltipTrigger,
@@ -51,6 +54,13 @@ import { path } from "~/utils/path";
export type ForecastRange = "day" | "week" | "shift";
+/**
+ * How the board lays out work: "compact" is one row per work center with its
+ * operations side by side; "detailed" is the tree with a row per operation and
+ * the people who staffed it.
+ */
+export type ForecastView = "compact" | "detailed";
+
/** Which date control the in-flight navigation belongs to, so only it spins. */
type PendingNav = "prev" | "next" | "today" | "date";
@@ -62,6 +72,8 @@ type ForecastHeaderProps = {
shiftId: string | null;
departments: { value: string; label: string }[];
shifts: { id: string; name: string }[];
+ view: ForecastView;
+ onViewChange: (view: ForecastView) => void;
};
/**
@@ -76,7 +88,9 @@ export function ForecastHeader({
departmentId,
shiftId,
departments,
- shifts
+ shifts,
+ view,
+ onViewChange
}: ForecastHeaderProps) {
const { t } = useLingui();
const { locale } = useLocale();
@@ -123,8 +137,17 @@ export function ForecastHeader({
// cannot queue up navigations the user then has to step back through.
const isNavigating = pendingParams !== null;
+ // The view switch only replaces the URL (no reload), so the router's search
+ // params can be behind on it — carry the current view into every navigation.
+ const currentParams = () => {
+ const params = new URLSearchParams(searchParams);
+ if (view === "detailed") params.set("view", view);
+ else params.delete("view");
+ return params;
+ };
+
const setParam = (mutate: (params: URLSearchParams) => void) => {
- const newParams = new URLSearchParams(searchParams);
+ const newParams = currentParams();
mutate(newParams);
navigate(`?${newParams.toString()}`);
};
@@ -223,7 +246,7 @@ export function ForecastHeader({
options={locations}
onChange={(selected) => {
if (!selected) return;
- const newParams = new URLSearchParams(searchParams);
+ const newParams = currentParams();
newParams.set("location", selected);
window.location.href = `${path.to.scheduleForecast}?${newParams.toString()}`;
}}
@@ -282,6 +305,21 @@ export function ForecastHeader({
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
+ <Tabs
+ value={view}
+ onValueChange={(value) =>
+ onViewChange(value === "detailed" ? "detailed" : "compact")
+ }
+ >
+ <TabsList>
+ <TabsTrigger value="compact">
+ <Trans>Compact</Trans>
+ </TabsTrigger>
+ <TabsTrigger value="detailed">
+ <Trans>Detailed</Trans>
+ </TabsTrigger>
+ </TabsList>
+ </Tabs>
</HStack>
<HStack className="flex-wrap gap-y-2">
diff --git a/apps/erp/app/modules/production/ui/Schedule/resourceTimeline.test.ts b/apps/erp/app/modules/production/ui/Schedule/resourceTimeline.test.ts
index 00ea7a08bf..fc5be03b03 100644
--- a/apps/erp/app/modules/production/ui/Schedule/resourceTimeline.test.ts
+++ b/apps/erp/app/modules/production/ui/Schedule/resourceTimeline.test.ts
@@ -4,7 +4,7 @@
import { describe, expect, it } from "vitest";
import type { ResourceTimelineReservation } from "./resourceTimeline";
-import { buildResourceTimeline } from "./resourceTimeline";
+import { buildResourceTimeline, collapseToLanes } from "./resourceTimeline";
const HOUR = 3_600_000;
@@ -400,3 +400,91 @@ describe("buildResourceTimeline", () => {
expect(detail.durationMs).toBe(10 * HOUR);
});
});
+
+describe("collapseToLanes", () => {
+ const timeline = () =>
+ buildResourceTimeline({
+ locationName: "Austin Plant",
+ reservations: [
+ reservation({
+ id: "res-machine",
+ operationId: "op-clean",
+ startAt: "2026-07-14T10:00:00.000Z",
+ endAt: "2026-07-14T12:00:00.000Z"
+ }),
+ reservation({
+ id: "res-emp",
+ resourceKind: "Employee",
+ resourceId: "emp-1",
+ resourceName: "Brad Barbin",
+ operationId: "op-clean"
+ }),
+ reservation({ id: "res-a" }),
+ reservation({
+ id: "res-drill",
+ resourceId: "wc-2",
+ resourceName: "Drill Press"
+ })
+ ],
+ workCenters: [{ id: "wc-3", name: "Saw" }],
+ maintenance: [
+ {
+ id: "maint-1",
+ workCenterId: "wc-2",
+ name: "MAIN000001",
+ startAt: "2026-07-14T12:00:00.000Z",
+ endAt: "2026-07-14T13:00:00.000Z"
+ }
+ ]
+ });
+
+ it("keeps the root and one childless row per lane", () => {
+ const lanes = collapseToLanes(timeline().events);
+
+ expect(lanes.map((e) => e.id)).toEqual([
+ "resources-root",
+ "lane:WorkCenter:wc-1",
+ "lane:WorkCenter:wc-2",
+ "lane:WorkCenter:wc-3"
+ ]);
+ for (const lane of lanes.slice(1)) {
+ expect(lane.children).toEqual([]);
+ expect(lane.hasChildren).toBe(false);
+ }
+ expect(lanes[0]?.children).toEqual([
+ "lane:WorkCenter:wc-1",
+ "lane:WorkCenter:wc-2",
+ "lane:WorkCenter:wc-3"
+ ]);
+ });
+
+ it("puts a lane's operations and maintenance on its row in start order", () => {
+ const lanes = collapseToLanes(timeline().events);
+ const cnc = lanes.find((e) => e.id === "lane:WorkCenter:wc-1")!;
+ const drill = lanes.find((e) => e.id === "lane:WorkCenter:wc-2")!;
+ const saw = lanes.find((e) => e.id === "lane:WorkCenter:wc-3")!;
+
+ expect(cnc.data.items?.map((i) => i.id)).toEqual(["res-a", "res-machine"]);
+ expect(cnc.data.items?.[1]?.data.offset).toBe(2 * HOUR);
+ expect(cnc.data.items?.[1]?.data.duration).toBe(2 * HOUR);
+ expect(drill.data.items?.map((i) => i.id)).toEqual([
+ "res-drill",
+ "maint-1"
+ ]);
+ // An idle station still gets its (empty) row.
+ expect(saw.data.items).toEqual([]);
+ });
+
+ it("drops operator segments and leaves the input untouched", () => {
+ const events = timeline().events;
+ const snapshot = JSON.stringify(events);
+ const lanes = collapseToLanes(events);
+
+ const allIds = lanes.flatMap((lane) => [
+ lane.id,
+ ...(lane.data.items ?? []).map((item) => item.id)
+ ]);
+ expect(allIds).not.toContain("res-emp");
+ expect(JSON.stringify(events)).toBe(snapshot);
+ });
+});
diff --git a/apps/erp/app/modules/production/ui/Schedule/resourceTimeline.ts b/apps/erp/app/modules/production/ui/Schedule/resourceTimeline.ts
index 88bb602724..6f47322a0b 100644
--- a/apps/erp/app/modules/production/ui/Schedule/resourceTimeline.ts
+++ b/apps/erp/app/modules/production/ui/Schedule/resourceTimeline.ts
@@ -630,3 +630,35 @@ function makeRootEvent(
}
};
}
+
+/**
+ * The compact layout of a resource timeline: one row per resource lane, its
+ * operations (and maintenance) drawn side by side on that row as `items`
+ * instead of one row each. Operator segments are dropped — the detailed tree
+ * shows who worked what. Pure: the input is left untouched, and every item
+ * keeps its id, so the same `detailsById` serves both layouts.
+ */
+export function collapseToLanes(events: GanttEvent[]): GanttEvent[] {
+ const byId = new Map(events.map((event) => [event.id, event]));
+ const lanes: GanttEvent[] = [];
+ let root: GanttEvent | undefined;
+
+ for (const event of events) {
+ if (event.level === 0) {
+ root = event;
+ } else if (event.level === 1) {
+ const items = event.children
+ .map((id) => byId.get(id))
+ .filter((child): child is GanttEvent => child !== undefined)
+ .map((child) => ({ ...child, children: [], hasChildren: false }));
+ lanes.push({
+ ...event,
+ children: [],
+ hasChildren: false,
+ data: { ...event.data, items }
+ });
+ }
+ }
+
+ return root ? [root, ...lanes] : lanes;
+}
diff --git a/apps/erp/app/routes/x+/scheduling+/forecast.tsx b/apps/erp/app/routes/x+/scheduling+/forecast.tsx
index fa04e6c25c..e9ff8ddd5b 100644
--- a/apps/erp/app/routes/x+/scheduling+/forecast.tsx
+++ b/apps/erp/app/routes/x+/scheduling+/forecast.tsx
@@ -34,10 +34,14 @@ import {
} from "~/modules/production";
import { getForecastNonWorkingIntervals } from "~/modules/production/forecast.server";
import ForecastUpgradeOverlay from "~/modules/production/ui/ForecastUpgradeOverlay";
-import type { ForecastRange } from "~/modules/production/ui/Schedule/ForecastHeader";
+import type {
+ ForecastRange,
+ ForecastView
+} from "~/modules/production/ui/Schedule/ForecastHeader";
import { ForecastHeader } from "~/modules/production/ui/Schedule/ForecastHeader";
import {
buildResourceTimeline,
+ collapseToLanes,
workCenterIdFromLaneId
} from "~/modules/production/ui/Schedule/resourceTimeline";
import { TimelineDetail } from "~/modules/production/ui/Schedule/TimelineDetail";
@@ -556,6 +560,11 @@ function getSpanId(location: Location<any>): string | undefined {
return search.get("span") ?? undefined;
}
+function getView(location: Location<any>): ForecastView {
+ const search = new URLSearchParams(location.search);
+ return search.get("view") === "detailed" ? "detailed" : "compact";
+}
+
export default function ResourceGanttView() {
const {
locationId,
@@ -586,6 +595,20 @@ export default function ResourceGanttView() {
const navigate = useNavigate();
const { location, replaceSearchParam } = useReplaceLocation();
const selectedSpanId = getSpanId(location);
+ const view = getView(location);
+
+ // Compact (the default) puts each work center on one row with its operations
+ // side by side; detailed is the full Location > Work Center > Operation >
+ // People tree. Switched in the browser — both come from the same events.
+ const events = useMemo(
+ () =>
+ trace
+ ? view === "compact"
+ ? collapseToLanes(trace.events)
+ : trace.events
+ : [],
+ [trace, view]
+ );
// Axis labels are 24-hour clock times for a day/shift and dates for a week,
// both in the plant's timezone (the company fallback is resolved server-side).
@@ -670,6 +693,13 @@ export default function ResourceGanttView() {
shiftId={shiftId}
departments={departments}
shifts={shifts}
+ view={view}
+ onViewChange={(nextView) =>
+ replaceSearchParam(
+ "view",
+ nextView === "detailed" ? nextView : undefined
+ )
+ }
/>
{reservationCount === 0 && (
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-border bg-muted/40 px-4 py-2.5">
@@ -744,8 +774,8 @@ export default function ResourceGanttView() {
<div className="min-w-0 flex-1">
<Gantt
selectedId={selectedSpanId}
- key={trace.events[0]?.id ?? "-"}
- events={trace.events}
+ key={`${view}:${events[0]?.id ?? "-"}`}
+ events={events}
onSelectedIdChanged={(selectedSpan) => {
if (!selectedSpan) {
replaceSearchParam("span");
diff --git a/docs/content/docs/reference/scheduling.mdx b/docs/content/docs/reference/scheduling.mdx
index cfb6fb1413..1bda374b41 100644
--- a/docs/content/docs/reference/scheduling.mdx
+++ b/docs/content/docs/reference/scheduling.mdx
@@ -59,7 +59,9 @@ You can **pin** an operation's due date from the date picker on the bill of proc
<PlanBadge plan="Business" />
-The **Forecast** page renders the schedule the engine actually booked: a lane per work center (idle stations included), operation bars labeled with the job and operation, and operator segments underneath showing who is reserved. Every bar is a stored <Term>capacity reservation</Term>, so what you see is exactly what the engine committed, not a redraw from dates. Amber maintenance bars show downtime in the same lanes.
+The **Forecast** page renders the schedule the engine actually booked: a lane per work center (idle stations included) with operation bars labeled with the job and part. Every bar is a stored <Term>capacity reservation</Term>, so what you see is exactly what the engine committed, not a redraw from dates. Amber maintenance bars show downtime in the same lanes.
+
+The page opens in the **Compact** layout: each work center is one row, with its operations side by side in time order. Switch to **Detailed** to give each operation its own row, with operator segments underneath showing who is reserved. Click any bar to open its explanation.
Click any bar and a side panel explains its timing. A **schedule note** answers "why does this start when it does" in plain language, for example *"Waited 14h for the work center — queued behind J000001 (3 ops)"* or *"Waited 2d 3h for a qualified operator to be available"*. The panel also separates **work** from **span**: an operation stretched across shift boundaries might show 6 hours of work across a 22-hour span, which is honest rather than alarming. A popover on each lane, *"How are these hours calculated?"*, shows which rung of the availability ladder is in use and what downtime and staffing subtract from it.
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index 4954c286e7..d61f8e5bbb 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -5136,6 +5136,9 @@ msgstr "Bestätigung eines Wareneingangs, einer Lieferung oder einer Rechnung: M
msgid "Community support"
msgstr "Community-Unterstützung"
+msgid "Compact"
+msgstr "Kompakt"
+
msgid "Companies"
msgstr "Unternehmen"
@@ -7685,6 +7688,9 @@ msgstr "Problembeschreibung"
msgid "Detail"
msgstr "Detail"
+msgid "Detailed"
+msgstr "Detailliert"
+
msgid "Details"
msgstr "Details"
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index de0e193a7d..eafa9b2832 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -5136,6 +5136,9 @@ msgstr "Committing a receipt, shipment, or invoice: quantities move, journal ent
msgid "Community support"
msgstr "Community support"
+msgid "Compact"
+msgstr "Compact"
+
msgid "Companies"
msgstr "Companies"
@@ -7685,6 +7688,9 @@ msgstr "Description of Issue"
msgid "Detail"
msgstr "Detail"
+msgid "Detailed"
+msgstr "Detailed"
+
msgid "Details"
msgstr "Details"
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index 0ecb5520fc..665988b145 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -5136,6 +5136,9 @@ msgstr "Confirmar un recibo, envío o factura: las cantidades se mueven, los asi
msgid "Community support"
msgstr "Soporte comunitario"
+msgid "Compact"
+msgstr "Compacto"
+
msgid "Companies"
msgstr "Empresas"
@@ -7685,6 +7688,9 @@ msgstr "Descripción del Problema"
msgid "Detail"
msgstr "Detalle"
+msgid "Detailed"
+msgstr "Detallado"
+
msgid "Details"
msgstr "Detalles"
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index 9b973a6c3c..71293be0a0 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -5136,6 +5136,9 @@ msgstr "Comptabilisation d'une réception, d'une expédition ou d'une facture :
msgid "Community support"
msgstr "Support communautaire"
+msgid "Compact"
+msgstr "Compact"
+
msgid "Companies"
msgstr "Entreprises"
@@ -7685,6 +7688,9 @@ msgstr "Description du problème"
msgid "Detail"
msgstr "Détail"
+msgid "Detailed"
+msgstr "Détaillé"
+
msgid "Details"
msgstr "Détails"
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index 31554122f7..d02b3c0232 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -5136,6 +5136,9 @@ msgstr "एक प्राप्ति, शिपमेंट या चाल
msgid "Community support"
msgstr "सामुदायिक समर्थन"
+msgid "Compact"
+msgstr "कॉम्पैक्ट"
+
msgid "Companies"
msgstr "कंपनियां"
@@ -7685,6 +7688,9 @@ msgstr "समस्या का विवरण"
msgid "Detail"
msgstr "विवरण"
+msgid "Detailed"
+msgstr "विस्तृत"
+
msgid "Details"
msgstr "विवरण"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index 4581612957..70bd144e23 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -5136,6 +5136,9 @@ msgstr "Registrazione di un'entrata merci, spedizione o fattura: le quantità si
msgid "Community support"
msgstr "Supporto della comunità"
+msgid "Compact"
+msgstr "Compatto"
+
msgid "Companies"
msgstr "Aziende"
@@ -7685,6 +7688,9 @@ msgstr "Descrizione del Problema"
msgid "Detail"
msgstr "Dettagli"
+msgid "Detailed"
+msgstr "Dettagliato"
+
msgid "Details"
msgstr "Dettagli"
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index 3926ed656a..ba4fb5a848 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -5136,6 +5136,9 @@ msgstr "領収書、出荷、または請求書のコミット: 数量が移動
msgid "Community support"
msgstr "コミュニティサポート"
+msgid "Compact"
+msgstr "コンパクト"
+
msgid "Companies"
msgstr "企業"
@@ -7685,6 +7688,9 @@ msgstr "問題の説明"
msgid "Detail"
msgstr "詳細"
+msgid "Detailed"
+msgstr "詳細"
+
msgid "Details"
msgstr "詳細"
diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.po
index b7fbaa960b..0436e6057c 100644
--- a/packages/locale/locales/ko/erp.po
+++ b/packages/locale/locales/ko/erp.po
@@ -5136,6 +5136,9 @@ msgstr "입고, 출하 또는 송장을 커밋하면: 수량이 이동하고,
msgid "Community support"
msgstr "커뮤니티 지원"
+msgid "Compact"
+msgstr "간략"
+
msgid "Companies"
msgstr "회사"
@@ -7685,6 +7688,9 @@ msgstr "이슈 설명"
msgid "Detail"
msgstr "상세"
+msgid "Detailed"
+msgstr "상세"
+
msgid "Details"
msgstr "상세 정보"
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index 5063092d01..b487812b57 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -5136,6 +5136,9 @@ msgstr "Potwierdzenie przyjęcia, wysyłki lub faktury: ilości się przesuwają
msgid "Community support"
msgstr "Wsparcie społeczności"
+msgid "Compact"
+msgstr "Kompaktny"
+
msgid "Companies"
msgstr "Firmy"
@@ -7685,6 +7688,9 @@ msgstr "Opis problemu"
msgid "Detail"
msgstr "Szczegóły"
+msgid "Detailed"
+msgstr "Szczegółowy"
+
msgid "Details"
msgstr "Szczegóły"
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 887b8b9c7e..690b2a93bc 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -5136,6 +5136,9 @@ msgstr "Confirmar um recibo, remessa ou fatura: as quantidades se movem, os lan
msgid "Community support"
msgstr "Suporte comunitário"
+msgid "Compact"
+msgstr "Compacto"
+
msgid "Companies"
msgstr "Empresas"
@@ -7685,6 +7688,9 @@ msgstr "Descrição do Problema"
msgid "Detail"
msgstr "Detalhe"
+msgid "Detailed"
+msgstr "Detalhado"
+
msgid "Details"
msgstr "Detalhes"
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index e7ee673ba3..a62dcfc61d 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -5136,6 +5136,9 @@ msgstr "Проведение поступления, отгрузки или с
msgid "Community support"
msgstr "Поддержка сообщества"
+msgid "Compact"
+msgstr "Компактный"
+
msgid "Companies"
msgstr "Компании"
@@ -7685,6 +7688,9 @@ msgstr "Описание проблемы"
msgid "Detail"
msgstr "Подробности"
+msgid "Detailed"
+msgstr "Подробный"
+
msgid "Details"
msgstr "Детали"
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index 207424e70a..4e61b645c2 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -5136,6 +5136,9 @@ msgstr "Mal kabul, Sevkiyat veya Fatura muhasebeleştirildiğinde: miktarlar har
msgid "Community support"
msgstr "Topluluk desteği"
+msgid "Compact"
+msgstr "Kompakt"
+
msgid "Companies"
msgstr "Şirketler"
@@ -7685,6 +7688,9 @@ msgstr "Sorun Açıklaması"
msgid "Detail"
msgstr "Detay"
+msgid "Detailed"
+msgstr "Ayrıntılı"
+
msgid "Details"
msgstr "Detaylar"
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index a3d311104d..a7fe72ec00 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -5136,6 +5136,9 @@ msgstr "提交收货、发货或发票:数量变动,凭证条目进入分类
msgid "Community support"
msgstr "社区支持"
+msgid "Compact"
+msgstr "紧凑"
+
msgid "Companies"
msgstr "公司"
@@ -7685,6 +7688,9 @@ msgstr "问题描述"
msgid "Detail"
msgstr "详情"
+msgid "Detailed"
+msgstr "详细"
+
msgid "Details"
msgstr "详情"