Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

refactor([issue-2844]): replace @dnd-kit/utilities with an owned dndTransformToCss helper

[._.]/ Adam Eivy4d1a9ffc90af
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 92512b37b2..24b29ea9d1 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -56,3 +56,4 @@
- **Apply the mergeable Dependabot bumps in one commit** — server `vitest`/`@vitest/coverage-v8` 4.1.9→4.1.10 and `node-pty` 1.2.0-beta.10→beta.14; client `react`/`react-dom` 19.2.7→19.2.8, `vite` 8.0.16→8.1.5, and `@tailwindcss/postcss` 4.3.1→4.3.3. Applied together with regenerated lockfiles because the individual PRs predate lockfile tracking and each ERESOLVE'd in isolation: the two vitest packages must move in lockstep, `@tailwindcss/postcss` was stranded a patch behind the already-merged `tailwindcss` 4.3.3, and Dependabot's `react-dom` PR would have left `react` mismatched at 19.2.7. Holding back `undici` 8 (breaks the DNS-rebinding connect-time IP pinning in `safeUrlFetch.js`, #1859) and `eslint`/`@eslint/js` 10 (`[email protected]` peers at `^9.7`).
- **[issue-2845] Standardize the `loraTraining` sample 404 error envelope** — new `sendErrorResponse`/`buildErrorEnvelope` helpers in `server/lib/errorHandler.js` build the shared `{ error, code, timestamp }` body in one place; `asyncHandler`, `errorMiddleware`, the `res.sendFile` 404 callback in `server/routes/loraTraining.js`, and the `authGate` 401/403 short-circuits now all route through it, so responses raised outside a handler's catch no longer omit `code`/`timestamp`. Mid-response failures (SSE/streaming routes) now delegate to Express's finalhandler so the socket is destroyed instead of the request hanging.
- **[issue-2837] Break the agent-lifecycle circular-dependency cluster** — `finalizeAgent`/`releaseAgentLane` (plus the success-criteria + output-hook helpers) move to `server/services/agentFinalization.js`, the summary extractors to `agentSummaryExtraction.js`, runner recovery to `agentRunnerSync.js`, and the runner output batchers to `agentRunnerOutputBatchers.js`. With those leaves in place the two static cycles (`agentLifecycle` ↔ `agentCliSpawning`, `agentLifecycle` ↔ `agentTuiSpawning`) are gone, and three `await import()` cycle-dodges — `handleOrphanedTask`, the spawner's init-time lifecycle/management lookups, and `flushRunnerOutputBatcher` — become plain static imports. `agentLifecycle.js` still re-exports every moved symbol, so no import path changes for callers. New `agentImportCycles.test.js` re-derives the static import graph and fails if a cycle is reintroduced.
+- **[issue-2844] Drop the `@dnd-kit/utilities` dependency** — the package was pulled in only for `CSS.Transform.toString()` at three drag-and-drop sites (influence chips, CoS sortable tasks, video timeline blocks). A ~10-line owned helper, `dndTransformToCss` in `client/src/lib/dndTransform.js`, replaces it with byte-identical output (rounded `translate3d` + verbatim `scaleX`/`scaleY`, `undefined` for a null transform), and the direct dependency is removed from `client/package.json` and its lockfile. It remains in the tree only as a transitive peer of `@dnd-kit/core`/`sortable`, which stay.
diff --git a/client/package-lock.json b/client/package-lock.json
index c4ed05e1a8..8cf300a8aa 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -10,7 +10,6 @@
"dependencies": {
"@dnd-kit/core": "6.3.1",
"@dnd-kit/sortable": "10.0.0",
- "@dnd-kit/utilities": "3.2.2",
"@react-three/drei": "10.7.7",
"@react-three/fiber": "9.6.1",
"@xterm/addon-fit": "0.11.0",
diff --git a/client/package.json b/client/package.json
index ab9d3348e3..ed7e35cc30 100644
--- a/client/package.json
+++ b/client/package.json
@@ -15,7 +15,6 @@
"dependencies": {
"@dnd-kit/core": "6.3.1",
"@dnd-kit/sortable": "10.0.0",
- "@dnd-kit/utilities": "3.2.2",
"@react-three/drei": "10.7.7",
"@react-three/fiber": "9.6.1",
"@xterm/addon-fit": "0.11.0",
diff --git a/client/src/components/cos/tabs/SortableTaskItem.jsx b/client/src/components/cos/tabs/SortableTaskItem.jsx
index abf7910384..40c11c9d09 100644
--- a/client/src/components/cos/tabs/SortableTaskItem.jsx
+++ b/client/src/components/cos/tabs/SortableTaskItem.jsx
@@ -1,6 +1,6 @@
import { useState } from 'react';
import { useSortable } from '@dnd-kit/sortable';
-import { CSS } from '@dnd-kit/utilities';
+import { dndTransformToCss } from '../../../lib/dndTransform';
import TaskItem from './TaskItem';
export default function SortableTaskItem({ task, onRefresh, providers, durations, apps }) {
@@ -15,7 +15,7 @@ export default function SortableTaskItem({ task, onRefresh, providers, durations
} = useSortable({ id: task.id, disabled: isEditing });
const style = {
- transform: CSS.Transform.toString(transform),
+ transform: dndTransformToCss(transform),
transition,
opacity: isDragging ? 0.5 : 1,
zIndex: isDragging ? 1000 : 'auto',
diff --git a/client/src/components/universeBuilder/InfluenceChipsInput.jsx b/client/src/components/universeBuilder/InfluenceChipsInput.jsx
index bde0d024e1..fd3162b904 100644
--- a/client/src/components/universeBuilder/InfluenceChipsInput.jsx
+++ b/client/src/components/universeBuilder/InfluenceChipsInput.jsx
@@ -15,7 +15,7 @@ import {
sortableKeyboardCoordinates,
useSortable,
} from '@dnd-kit/sortable';
-import { CSS } from '@dnd-kit/utilities';
+import { dndTransformToCss } from '../../lib/dndTransform';
import { WORLD_INFLUENCE_ENTRY_MAX, WORLD_INFLUENCES_PER_LIST_MAX } from '../../services/api';
const TONE_CLASS = {
@@ -162,7 +162,7 @@ export default function InfluenceChipsInput({
function SortableChip({ token, toneClass, onRemove }) {
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: token });
const style = {
- transform: CSS.Transform.toString(transform),
+ transform: dndTransformToCss(transform),
transition,
opacity: isDragging ? 0.5 : 1,
zIndex: isDragging ? 10 : 'auto',
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index c300758a59..e2c16418b7 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -84,6 +84,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `consoleFilters.js` | `installConsoleFilters()` — drops a small allow-list of known-noise console strings (THREE.js `Clock` deprecation, expected WebGL `Context Lost.`) from `console.{warn,log,debug}`. Idempotent; auto-installed on import. Imported for its side effect from `main.jsx`. |
| `diffLines.js` | `diffLineBlocks(oldText, newText)` → `{ blocks }` (`{ type: 'same', lines }` / `{ type: 'change', oldLines, newLines }`) — line-level Myers LCS with common prefix/suffix trim and a 4M-cell `LINE_DIFF_CELL_CAP` guard. The structural layer behind `HunkDiff` (collapse same-blocks to context, word-diff each change-block). |
| `diffWords.js` | `diffWords(oldText, newText)` → `{ tooLarge, oldRuns, newRuns }` — word-level Myers LCS core (tokenize on whitespace, common prefix/suffix trim, collapse to `{ text, changed }` runs, 4M-cell `DIFF_CELL_CAP` guard on the trimmed middle). Shared by `InlineDiff` (stacked), `SideBySideDiff` (columnar), and `HunkDiff`'s change blocks. |
+| `dndTransform.js` | `dndTransformToCss(transform)` — render a dnd-kit `useSortable` transform (`{ x, y, scaleX, scaleY }` or `null`) as a CSS `transform` string. Owned replacement for `@dnd-kit/utilities`' `CSS.Transform.toString()`; use it in every `useSortable` style object instead of re-adding that dependency. |
| `downloadBlob.js` | `downloadBlob(data, filename, type?)` — trigger a browser "Save as…" for a Blob / ArrayBuffer / typed array / string, with object-URL + temporary `<a>` cleanup. Use instead of inlining `URL.createObjectURL` + `<a download>`. |
| `extensionErrors.js` | `isExtensionError(payload)` — true when an error report came from a browser extension's injected content script rather than from PortOS, so `clientErrorReporter` can drop it instead of spending its 1/sec throttle slot on an error we can't fix. Client mirror of the authoritative `server/lib/extensionErrors.js` (parity enforced by `server/lib/extensionErrors.mirror.test.js`); the server re-checks, since a long-lived tab can still be running an old bundle. |
| `genUtils.js` | Shared bits between Image Gen and Video Gen pages. |
diff --git a/client/src/lib/dndTransform.js b/client/src/lib/dndTransform.js
new file mode 100644
index 0000000000..f8ea2d4293
--- /dev/null
+++ b/client/src/lib/dndTransform.js
@@ -0,0 +1,20 @@
+// Owned replacement for `@dnd-kit/utilities`' `CSS.Transform.toString()`.
+// dnd-kit's `useSortable` hands back a `{ x, y, scaleX, scaleY }` transform (or
+// `null` when the node isn't being dragged); every PortOS call site feeds that
+// straight into a `style.transform`. That one call shape was the only reason the
+// package was a dependency, so we own the ~10 lines instead.
+//
+// Behavior matches @dnd-kit/utilities 3.2.2 exactly: `undefined` for a nullish
+// transform (so React omits the property), translations rounded to whole pixels,
+// scales emitted verbatim.
+
+/**
+ * Render a dnd-kit transform as a CSS `transform` value.
+ * @param {{x: number, y: number, scaleX: number, scaleY: number}|null|undefined} transform
+ * @returns {string|undefined} e.g. `translate3d(4px, 0px, 0) scaleX(1) scaleY(1)`
+ */
+export function dndTransformToCss(transform) {
+ if (!transform) return undefined;
+ const { x, y, scaleX, scaleY } = transform;
+ return `translate3d(${x ? Math.round(x) : 0}px, ${y ? Math.round(y) : 0}px, 0) scaleX(${scaleX}) scaleY(${scaleY})`;
+}
diff --git a/client/src/lib/dndTransform.test.js b/client/src/lib/dndTransform.test.js
new file mode 100644
index 0000000000..a4cdc74aa3
--- /dev/null
+++ b/client/src/lib/dndTransform.test.js
@@ -0,0 +1,29 @@
+import { describe, it, expect } from 'vitest';
+import { dndTransformToCss } from './dndTransform.js';
+
+describe('dndTransformToCss', () => {
+ it('renders a full translate + scale string', () => {
+ expect(dndTransformToCss({ x: 12, y: -4, scaleX: 1, scaleY: 1 }))
+ .toBe('translate3d(12px, -4px, 0) scaleX(1) scaleY(1)');
+ });
+
+ it('rounds fractional pixel offsets', () => {
+ expect(dndTransformToCss({ x: 12.4, y: -4.6, scaleX: 1, scaleY: 1 }))
+ .toBe('translate3d(12px, -5px, 0) scaleX(1) scaleY(1)');
+ });
+
+ it('emits 0px for zero/NaN offsets instead of "NaNpx"', () => {
+ expect(dndTransformToCss({ x: 0, y: NaN, scaleX: 1, scaleY: 1 }))
+ .toBe('translate3d(0px, 0px, 0) scaleX(1) scaleY(1)');
+ });
+
+ it('passes non-unit scales through verbatim', () => {
+ expect(dndTransformToCss({ x: 0, y: 0, scaleX: 1.5, scaleY: 0.5 }))
+ .toBe('translate3d(0px, 0px, 0) scaleX(1.5) scaleY(0.5)');
+ });
+
+ it('returns undefined for a nullish transform so React omits the property', () => {
+ expect(dndTransformToCss(null)).toBeUndefined();
+ expect(dndTransformToCss(undefined)).toBeUndefined();
+ });
+});
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index 1b8cbac28e..1e0021649a 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -58,6 +58,7 @@ export * from './compareHelpers.js';
export * from './consoleFilters.js';
export * from './diffLines.js';
export * from './diffWords.js';
+export * from './dndTransform.js';
export * from './downloadBlob.js';
export * from './extensionErrors.js';
export * from './genUtils.js';
diff --git a/client/src/pages/VideoTimelineEditor.jsx b/client/src/pages/VideoTimelineEditor.jsx
index 21b635737e..7b2c296a6b 100644
--- a/client/src/pages/VideoTimelineEditor.jsx
+++ b/client/src/pages/VideoTimelineEditor.jsx
@@ -13,7 +13,7 @@ import {
horizontalListSortingStrategy,
useSortable,
} from '@dnd-kit/sortable';
-import { CSS } from '@dnd-kit/utilities';
+import { dndTransformToCss } from '../lib/dndTransform';
import {
Play, Pause, Plus, Trash2, X, Save, Film, Loader2, ArrowLeft, Volume2, VolumeX,
} from 'lucide-react';
@@ -49,7 +49,7 @@ export function TimelineBlock({ clip, clipMeta, isSelected, isMissing, pxPerSec,
const removeLabel = isMissing ? 'missing clip' : clipMeta?.prompt?.trim().slice(0, 40) || 'clip';
const width = Math.max(60, dur * pxPerSec);
const style = {
- transform: CSS.Transform.toString(transform),
+ transform: dndTransformToCss(transform),
transition,
width: `${width}px`,
opacity: isDragging ? 0.4 : 1,