Summary
TerminalHistory.add() has an asymmetric capacity eviction policy compared to setMaxSize():
setMaxSize(Integer) — when trimming an oversized list, removes from the front (remove(0), oldest-first / FIFO).
add() — when the list is already at capacity (size == maxSize), appends the new entry then immediately removes from the back (removeLast()), silently discarding the newest command (LIFO-on-add).
This asymmetry is counterintuitive: users who set a max size would reasonably expect that older entries are evicted to make room for newer ones, consistent with how setMaxSize() itself trims the list.
Suggested Fix
In add(), replace the removeLast() call with a removeFirst() (or remove(0)) before appending the new entry, so that capacity eviction is consistently FIFO (oldest entry discarded). Update the add() JavaDoc to explicitly document the eviction policy and reference setMaxSize(Integer).
References
Summary
TerminalHistory.add()has an asymmetric capacity eviction policy compared tosetMaxSize():setMaxSize(Integer)— when trimming an oversized list, removes from the front (remove(0), oldest-first / FIFO).add()— when the list is already at capacity (size == maxSize), appends the new entry then immediately removes from the back (removeLast()), silently discarding the newest command (LIFO-on-add).This asymmetry is counterintuitive: users who set a max size would reasonably expect that older entries are evicted to make room for newer ones, consistent with how
setMaxSize()itself trims the list.Suggested Fix
In
add(), replace theremoveLast()call with aremoveFirst()(orremove(0)) before appending the new entry, so that capacity eviction is consistently FIFO (oldest entry discarded). Update theadd()JavaDoc to explicitly document the eviction policy and referencesetMaxSize(Integer).References