Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

src/reports.ts keeps chat reports under FORGE_APP_DATA: one per person per line, at most 20 per reporter, newest 200 - module and test only #321

Parked opened this
Closed without merging

I added src/reports.ts and src/reports.test.ts and pushed them. Nothing else is wired. I did not touch lobby.ts, the page or forge.json.

Notes

stopped parked by the crew deploy 99a0b51

opened this

I added src/reports.ts and src/reports.test.ts and pushed them. Nothing else is wired. I did not touch lobby.ts, the page or forge.json.

The six new tests pass. I could not run the type check: bun x tsc --noEmit failed in this sandbox with "bun is unable to write files to tempdir". I also did not run the full bun --cwd Software/so101 test, so the forge's check will be the first full run. Commit a39fdbe from pull #299 wasn't in this clone, so I wrote the module fresh rather than reusing it.

  • Store: new Reports(file) takes the JSON path from the caller. add({id, text, author, reporter, at}) returns false for a repeat of the same reporter and line id. list() returns newest first.
  • Caps: 200 overall, with the oldest dropped first. 20 per reporter, with that reporter's oldest dropped first.
  • Persistence: every add writes the file by temp file and rename, so a restart restores the list. A missing file starts empty without a log line. An unreadable or malformed file starts empty with one console.error line.
  • Tests: they cover a duplicate being ignored, newest-first order, both caps, a restart restoring the list, and a corrupt file.

One thing to check: entries in the file that lack the expected fields are dropped when it loads. The file itself isn't rewritten until the next add.

🤖 Generated with Claude Code

Closes #316

commented

I added src/reports.ts and src/reports.test.ts and pushed them. Nothing else is wired. I did not touch lobby.ts, the page or forge.json.

The six new tests pass. I could not run the type check: bun x tsc --noEmit failed in this sandbox with "bun is unable to write files to tempdir". I also did not run the full bun --cwd Software/so101 test, so the forge's check will be the first full run. Commit a39fdbe from pull #299 wasn't in this clone, so I wrote the module fresh rather than reusing it.

  • Store: new Reports(file) takes the JSON path from the caller. add({id, text, author, reporter, at}) returns false for a repeat of the same reporter and line id. list() returns newest first.
  • Caps: 200 overall, with the oldest dropped first. 20 per reporter, with that reporter's oldest dropped first.
  • Persistence: every add writes the file by temp file and rename, so a restart restores the list. A missing file starts empty without a log line. An unreadable or malformed file starts empty with one console.error line.
  • Tests: they cover a duplicate being ignored, newest-first order, both caps, a restart restoring the list, and a corrupt file.

One thing to check: entries in the file that lack the expected fields are dropped when it loads. The file itself isn't rewritten until the next add.

🤖 Generated with Claude Code

commented

Parked by the crew: the preview's deploy failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs