Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions cuprum-ui/src/components/drill/DrillPlanInspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { SegmentedControl } from "@/components/ui/SegmentedControl";
import { formatXYViolations } from "@/lib/xyGate";
import { formatZReasons } from "@/lib/zGate";
import { useUnitFormat } from "@/i18n/useUnitFormat";
import { useFlag } from "@/hooks/useFlag";
import { getRegistrationHoles } from "@/lib/fiducialRegistration";

export interface DrillPlanInspectorProps {
Expand Down Expand Up @@ -168,13 +169,20 @@ export function DrillPlanInspector({
useEffect(() => {
if (isRunActive) setPanelMode("plan");
}, [isRunActive]);

// Registration mode toggle: "corner" (classic datum bind) or "fiducial".
// Persisted only for the session (ephemeral state). Defaults to "corner".
const [registrationMode, setRegistrationMode] = useState<"corner" | "fiducial">("corner");

// Detect whether the panel has any registration holes so the toggle can be shown.
const hasRegistrationHoles = getRegistrationHoles(toolingHoles).length > 0;
// Feature flag: fiducial registration is still rough — hide behind an explicit opt-in.
const fiducialRegistrationEnabled = useFlag("fiducialRegistration");

// When the fiducial-registration flag is turned off, reset any stale "fiducial"
// registrationMode so the corner-based flow is always used.
useEffect(() => {
if (!fiducialRegistrationEnabled) setRegistrationMode("corner");
}, [fiducialRegistrationEnabled]);

// Gate: the footer start button is disabled when any of these conditions hold.
const startDisabled =
Expand Down Expand Up @@ -344,8 +352,8 @@ export function DrillPlanInspector({
{/* Work zero — compact status card-button (opens the zero-binding mode).
Shows a registration-mode toggle when the panel has registration holes. */}
<div className="border-t border-border">
{/* Registration mode toggle (shown only when registration holes exist) */}
{hasRegistrationHoles && (
{/* Registration mode toggle (shown only when flag + registration holes are present) */}
{fiducialRegistrationEnabled && hasRegistrationHoles && (
<div className="flex items-center gap-2 px-4 pt-3 pb-1">
<span className="text-[11px] font-medium text-muted-foreground">
{t("workzero.title")}
Expand All @@ -362,7 +370,7 @@ export function DrillPlanInspector({
</div>
)}

{registrationMode === "fiducial" && hasRegistrationHoles ? (
{fiducialRegistrationEnabled && registrationMode === "fiducial" && hasRegistrationHoles ? (
/* Fiducial mode: compact status card-button opens fiducial panel */
<div className="px-4 py-2">
<button
Expand Down
3 changes: 2 additions & 1 deletion cuprum-ui/src/lib/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Flag labels are plain strings (NOT i18n): these are transient internal toggles,
* not worth the en/ru parity-gate churn. See the design spec. */
export type FlagKey = "uvExposure" | "cncMilling";
export type FlagKey = "uvExposure" | "cncMilling" | "fiducialRegistration";

export interface FlagDef {
/** Label shown in the experimental panel. Plain string, not localized. */
Expand All @@ -20,6 +20,7 @@ export interface FlagDef {
export const FLAGS: Record<FlagKey, FlagDef> = {
uvExposure: { label: "UV-засветка", description: "Засветка медной графики через UV-LCD" },
cncMilling: { label: "CNC-фрезеровка", description: "Изоляционная фрезеровка меди" },
fiducialRegistration: { label: "Центровка по реперам", description: "Привязка сверловки к реперным отверстиям (в разработке)", defaultDev: false, defaultProd: false },
};

/** Effective default for the current build mode, ignoring any override. */
Expand Down
Loading