The dangerous implementation is not one that never works. It is one that works in a demo and loses its boundaries under real networks and real data volume. A global showModal and currentRequest lets a second request replace the first, so approval targets the wrong peer. Requests are queued entities; the modal renders the head.
Frontend architecture is about state ownership, repeatable events, invalidation of stale async work, and cleanup after unmount—not the shape of the source directory.
Engineering boundaries and tradeoffs
List non-negotiable invariants before selecting performance knobs. Tuning can roll out gradually; identity, permission, and terminal-state rules cannot drift at runtime.
- Every request has a stable ID, type, source, creation time, expiry, and terminal state.
- First-contact security can outrank files while every queue retains fairness and abuse limits.
- Approval carries the current request ID and locks only that entity until response.
A modal is not state storage. Identity and terminal state belong to queued request entities so consent always applies to the visible item.
How it fails in production
Failure and success must share one state model. An error toast that neither releases resources nor propagates a terminal state leaves dirty work for the next recovery attempt.
- Closing one modal rejects every pending request.
- An expired request remains visible and approval can never complete.
- A new modal steals focus and never restores it for keyboard and screen-reader users.
Turn testing into a closed loop
Do not stop verification when the final action succeeds. Count side effects, measure wait time, inspect privacy, and prove the next run begins from a clean baseline.
- Inject ten mixed requests and independently accept, reject, expire, and dismiss them.
- Delay the first response while new requests arrive; entities and queue remain usable.
- Test focus trap and restoration with keyboard, Escape, and a screen reader.
A capability becomes maintainable when it degrades safely, repetition adds no side effects, and its signals reveal a fault before user reports do.