Skip to content

feat(comments): delete .dunk/comments.json when the review is empty#12

Merged
amix merged 1 commit into
mainfrom
amix/delete-empty-comments-file
May 19, 2026
Merged

feat(comments): delete .dunk/comments.json when the review is empty#12
amix merged 1 commit into
mainfrom
amix/delete-empty-comments-file

Conversation

@amix
Copy link
Copy Markdown
Owner

@amix amix commented May 19, 2026

Context

Resolving the last comment left an empty { "schema": 1, "comments": [] } file behind — noise an agent or human reviewer still has to open and reason about.

What was changed

  • writeCommentsFile deletes .dunk/comments.json when the review has no comments instead of writing an empty array. Reads already treat a missing file as "no comments", so this round-trips cleanly (CLI resolve, TUI delete, drift clear).
  • Deletion is now a normal write path and the TUI/agent CLI ping-pong on the same review, so the read + fingerprint helpers do a single ENOENT-safe read instead of existsSync-then-read, closing a concurrent-deletion race.
  • One source of truth for the file path via commentsFilePath.
  • Tests: empty write deletes / is a no-op when absent, mutateCommentsFile and CLI resolve of the last comment delete the file, and a deterministic concurrent-deletion-mid-mutation regression test.

Reviewed with Doistbot (2 rounds): fixed the P1 ENOENT race, added the concurrent-deletion test and path helper.

Refs

CHANGELOG under ## [Unreleased].

🤖 Generated with Claude Code

Resolving the last comment left an empty `{ "schema": 1, "comments": [] }`
file that an agent or human reviewer still had to reason about. Reads
already treat a missing file as "no comments", so `writeCommentsFile`
now deletes the file on an empty review and round-trips cleanly.

Because deletion is now part of the normal write path and the TUI and
agent CLI ping-pong on the same review, a concurrent deletion could land
between an `existsSync` check and the read. The read/fingerprint helpers
now do a single ENOENT-safe read instead, and the comments-file path has
one source of truth via `commentsFilePath`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@amix amix marked this pull request as ready for review May 19, 2026 09:51
@amix amix merged commit 4bfd185 into main May 19, 2026
2 checks passed
@amix amix deleted the amix/delete-empty-comments-file branch May 19, 2026 09:51
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.

1 participant