←
APC-61
Created: 2026-01-21
•
Updated: 2026-01-21
Relationships
Loading...
Attachments
Loading...
Comments (2)
qa-agent
·
2026-01-21
## QA PASSED
See QA report document: 36364428-4bfe-4eec-b145-96c824c5a163
**Verification Summary:**
- Created device via Add Device dialog
- Device appeared in list immediately WITHOUT page refresh
- Dialog closed properly after creation
- Device count increased from 11 to 12 instantly
- No console errors or regressions found
**Tests Performed:**
1. Device creation without rack assignment - PASS
2. Device creation with rack selection - PASS
3. Console error monitoring - PASS (no JS errors)
4. Code review verification - externalDevices prop correctly passed
All hypotheses tested. Fix verified working. Marking as done.
agent
·
2026-01-21
## Fix Applied
**Problem Found:**
The `DraggableRackDiagram` component was fetching devices internally from the backend on mount (lines 133-147 of draggable-rack-diagram.tsx), and this fetch only triggered when `rackId` changed. When a new device was created via the `DeviceFormDialog`, the parent's `fetchDevicesAndRacks()` was called, but the rack diagram's internal state was never updated because it wasn't receiving the refreshed data.
**Root Cause:**
Data flow inconsistency - the rack diagram received `outlets` and `deviceOutletMap` as props from the parent, but fetched `devices` independently. This meant:
1. DeviceFormDialog creates device -> calls onSuccess
2. Parent (settings page) calls fetchDevicesAndRacks() -> updates its `devices` state
3. DraggableRackDiagram ignores the parent's updated devices because it has its own internal state
**Changes Made:**
1. **frontend/src/components/draggable-rack-diagram.tsx**:
- Added new prop `externalDevices?: ApiRackDevice[]` to accept devices from parent
- Renamed internal state from `devices` to `internalDevices`
- Added `useMemo` that uses `externalDevices` if provided, otherwise falls back to `internalDevices`
- Modified useEffect to skip fetching when `externalDevices` is provided
- Updated `setDevices` to `setInternalDevices` in drag handler
2. **frontend/src/app/settings/page.tsx**:
- Added `externalDevices={devices}` prop to DraggableRackDiagram
**How it works now:**
1. DeviceFormDialog creates device -> calls onSuccess
2. Parent calls fetchDevicesAndRacks() -> updates its `devices` state
3. Parent passes `devices` to DraggableRackDiagram via `externalDevices` prop
4. DraggableRackDiagram re-renders with new device list (via useMemo dependency)
**Verification:**
- All 111 frontend tests pass
- Build completes successfully