Skip to content

TerminalHistory: inconsistent eviction policy between setMaxSize() and add() #115

@coderabbitai

Description

@coderabbitai

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions