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.

fix(audit): treat blank snapshot display as absent, share empty-diff predicate

naveenkash385e0101f406
diff --git a/apps/erp/app/components/AuditLog/AuditLogDrawer.tsx b/apps/erp/app/components/AuditLog/AuditLogDrawer.tsx
index 38f7574bec..9c84ea3eca 100644
--- a/apps/erp/app/components/AuditLog/AuditLogDrawer.tsx
+++ b/apps/erp/app/components/AuditLog/AuditLogDrawer.tsx
@@ -35,6 +35,7 @@ import {
} from "~/components/UpgradeOverlay";
import { useDateFormatter, usePermissions, useRouteData } from "~/hooks";
import { path } from "~/utils/path";
+import { isEmptyDiffValue } from "./utils";
type AuditLogDrawerProps = {
isOpen: boolean;
@@ -331,19 +332,6 @@ function formatValue(value: unknown): string {
return JSON.stringify(value);
}
-/**
- * Whether a diff side holds no real value (null/undefined, empty string,
- * empty object/array). Rendered as a muted "Empty" pill instead of the
- * literal "null" — first-time sets read as "Empty → Net 15", not
- * "null → Net 15". Scalars like 0 and false are real values.
- */
-function isEmptyDiffValue(value: unknown): boolean {
- if (value === null || value === undefined || value === "") return true;
- if (Array.isArray(value)) return value.length === 0;
- if (typeof value === "object") return Object.keys(value).length === 0;
- return false;
-}
-
// Convert a column name into a Linear-style human label. When a snapshot
// exists, strip the trailing `Id` so a FK column reads as its referenced
// entity (e.g. `triggerProcessId` → `Trigger Process`). Without a
@@ -378,7 +366,11 @@ function ChangePill({
display?: unknown;
variant: "old" | "new";
}) {
- const hasDisplay = display !== undefined && display !== null;
+ // An empty-string display (e.g. a snapshot row whose name is blank) is no
+ // display at all — fall through so an empty value renders the "Empty" pill
+ // rather than a blank colored one.
+ const hasDisplay =
+ display !== undefined && display !== null && display !== "";
if (!hasDisplay && isEmptyDiffValue(value)) {
return (
<span className="px-2 py-0.5 rounded bg-muted text-muted-foreground italic">
diff --git a/apps/erp/app/components/AuditLog/index.ts b/apps/erp/app/components/AuditLog/index.ts
index 28ceec165f..da0a512546 100644
--- a/apps/erp/app/components/AuditLog/index.ts
+++ b/apps/erp/app/components/AuditLog/index.ts
@@ -1,2 +1,3 @@
export { default as AuditLogDrawer } from "./AuditLogDrawer";
export { useAuditLog } from "./useAuditLog";
+export { isEmptyDiffValue } from "./utils";
diff --git a/apps/erp/app/components/AuditLog/utils.ts b/apps/erp/app/components/AuditLog/utils.ts
new file mode 100644
index 0000000000..48271efb45
--- /dev/null
+++ b/apps/erp/app/components/AuditLog/utils.ts
@@ -0,0 +1,12 @@
+/**
+ * Whether a diff side holds no real value (null/undefined, empty string,
+ * empty object/array). Rendered as a muted "Empty" pill instead of the
+ * literal "null" — first-time sets read as "Empty → Net 15", not
+ * "null → Net 15". Scalars like 0 and false are real values.
+ */
+export function isEmptyDiffValue(value: unknown): boolean {
+ if (value === null || value === undefined || value === "") return true;
+ if (Array.isArray(value)) return value.length === 0;
+ if (typeof value === "object") return Object.keys(value).length === 0;
+ return false;
+}
diff --git a/apps/erp/app/modules/settings/ui/AuditLog/AuditLogTable.tsx b/apps/erp/app/modules/settings/ui/AuditLog/AuditLogTable.tsx
index de11c1e502..bf0e2fd4d1 100644
--- a/apps/erp/app/modules/settings/ui/AuditLog/AuditLogTable.tsx
+++ b/apps/erp/app/modules/settings/ui/AuditLog/AuditLogTable.tsx
@@ -12,6 +12,7 @@ import { memo, useCallback, useMemo } from "react";
import { LuFilePen, LuFilePlus, LuFileX } from "react-icons/lu";
import { Link } from "react-router";
import { EmployeeAvatar, Table } from "~/components";
+import { isEmptyDiffValue } from "~/components/AuditLog";
import { useDateFormatter } from "~/hooks";
import { path } from "~/utils/path";
@@ -50,18 +51,6 @@ function formatValue(value: unknown): string {
return JSON.stringify(value);
}
-/**
- * Whether a diff side holds no real value (null/undefined, empty string,
- * empty object/array). Rendered as a muted "Empty" pill instead of the
- * literal "null". Scalars like 0 and false are real values.
- */
-function isEmptyDiffValue(value: unknown): boolean {
- if (value === null || value === undefined || value === "") return true;
- if (Array.isArray(value)) return value.length === 0;
- if (typeof value === "object") return Object.keys(value).length === 0;
- return false;
-}
-
function DiffValue({
value,
variant