Skip to content

fix(input): cap console history growth (B3)#42

Open
Vadim1987 wants to merge 2 commits into
aldum:devfrom
Vadim1987:fix/b3-history-cap
Open

fix(input): cap console history growth (B3)#42
Vadim1987 wants to merge 2 commits into
aldum:devfrom
Vadim1987:fix/b3-history-cap

Conversation

@Vadim1987

Copy link
Copy Markdown

Console history grows for the whole session: History:remember only ever appends, and nothing evicts, so on a long session every entered command accumulates in memory (each entry is a string[] of lines).
The fix caps history at 100 entries: after an append, _trim evicts from the front while over the limit. Since the backing store is a plain array, eviction shifts indices, so _trim also shifts self.index when arrow-key navigation is active — the position keeps pointing at the same entry — and resets it if the navigated-to entry itself was evicted.
The limit is a named constant; 100 entries comfortably covers a session on the device while keeping the worst case bounded.

@dsent dsent requested a review from aldum July 2, 2026 19:59
@dsent

dsent commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

@aldum What is our policy on tests? Do we add extensive automated tests like there are in the last few Vadim's PRs or not? I remember @nagydani being sceptical of extensive automated testing.

@aldum

aldum commented Jul 4, 2026

Copy link
Copy Markdown
Owner

My opinion is, short of a compiler, static checks and tests are the only thing standing between us and pervasive bugs. And we still get bugs.

@dsent

dsent commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

@aldum do you approve this PR, then?

@aldum

aldum commented Jul 4, 2026

Copy link
Copy Markdown
Owner

@dsent Not as such, no. I'd like to see a config option, at least in-code.
0 should mean unlimited history, and I think the default should be a tad higher, it's just plaintext after all

@aldum aldum left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

@Vadim1987

Copy link
Copy Markdown
Author

Done: the limit is a constructor parameter fed from the config ("input_history" in baseconf, in-code as suggested), 0 means unlimited, default raised to 1000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants