Skip to content

fix(chat): increment temp file suffix correctly - #326

Merged
xxynet merged 1 commit into
devfrom
fix/temp-file-name-increment
Sep 22, 2026
Merged

xxynet merged 1 commit into
devfrom
fix/temp-file-name-increment

Conversation

@xxynet

@xxynet xxynet commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

⚠️ Base branch must be dev. PRs targeting main will be rejected.

Summary

Fix temp-file collision numbering so repeated downloads keep a stable basename and increment numerically instead of accumulating suffixes such as _1_2_3.

Type of change

  • feat: New feature
  • fix: Bug fix
  • refactor: Code refactor (no functional change)
  • docs: Documentation update
  • chore: Build, CI, dependencies, or other maintenance
  • style: Code style / formatting (no logic change)
  • test: Adding or updating tests

Changes

  • Keep the original destination root and extension fixed while _move_no_clobber searches for an available numbered path.
  • Add a regression test covering collisions with both the base destination and its first numbered fallback while preserving existing file contents.

Screenshots / Logs

python -m pytest tests/ -q
575 passed, 1 skipped, 2 warnings in 29.68s

Checklist

  • I have tested these changes locally
  • I have updated documentation if needed
  • New dependencies have been added to requirements.txt (if applicable)
  • If this PR introduces new features, they have been discussed with the owner or maintainer
  • This PR does not introduce breaking changes

Summary by CodeRabbit

  • Bug Fixes

    • File moves now consistently select the next available numbered filename when multiple matching files already exist.
    • Existing files remain unchanged, while the source file is moved successfully.
  • Tests

    • Added coverage for filename selection when the original and first numbered filenames are already present.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 2004eea2-3eb7-4233-96ad-2ba23eeed55f

📥 Commits

Reviewing files that changed from the base of the PR and between 5d6c9a7 and 78195ee.

📒 Files selected for processing (2)
  • core/chat/message_elements.py
  • tests/test_message_elements.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The move helper now derives numbered fallback names once from the original candidate path. A regression test verifies that existing candidates remain unchanged and the source moves to the next available name.

Changes

Non-clobbering file move

Layer / File(s) Summary
Move retry and regression coverage
core/chat/message_elements.py, tests/test_message_elements.py
_move_no_clobber computes the candidate root and extension before the retry loop. The test verifies that the source moves to download_2.png while existing files remain unchanged.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 78195

Downloads now retain a stable basename and select the next numbered filename without overwriting existing files. The change is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: correcting temporary-file suffix increments in chat downloads.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each filename twice
Existing bytes stay snug and nice
The source hops to number two
No clobbering breaks the queue
Tests guard the burrow too

Comment @coderabbitai help to get the list of available commands.

@xxynet
xxynet merged commit cd6ef61 into dev Sep 22, 2026
4 checks passed
@xxynet
xxynet deleted the fix/temp-file-name-increment branch September 22, 2026 14:15
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