nanocoder
nanocoder copied to clipboard
[Bug] A truncated prompt-history file is wiped on the next prompt
Description
loadHistory in source/prompt-history.ts treats any read or parse error the same as a missing file and sets this.history = []. saveHistory writes that array with fs.writeFile, which truncates the file in place. A crash during an earlier save leaves a file that starts with ---JSON_FORMAT--- and then broken JSON.
Steps to Reproduce
- Take
.nano-coder-history, keep the JSON marker, and cut the JSON off mid-value. - Start nanocoder and submit one prompt.
Expected Behavior
The bad file is left alone, or the previous entries are kept.
Actual Behavior
The parse throws, history becomes empty, and the next save replaces the file with that empty history plus the new prompt.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
@addyCooks should i take this one?
Go ahead @Vishesh-Verma-07 !