Preserve context edits when they exceed the size limit#138
Conversation
When an edited task context exceeds ContextMaxBytes (1 MiB), omm removed the temporary file before reporting the error, discarding the user's work. Move the size check before the file removal so the temp file is kept on the over-limit path, and surface its location in the error message so the user can recover and shorten the content. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
Summary
When a task's context is edited in an external editor and the saved content
exceeds
pers.ContextMaxBytes(1 MiB), thetextEditorClosedhandler ininternal/ui/update.goremoved the temporary file before the size check, sothe over-limit branch discarded the user's edits with no way to recover them.
This moves the size check ahead of the file removal. On the over-limit path the
temp file is now kept on disk, and the error message names its location so the
user can recover their text, shorten it, and re-open the editor. The success
path still removes the temp file exactly as before.
Why this matters
Issue #65 reports that editing a large context silently throws the work away.
As the issue puts it, "the main thing I would like is for work to not be lost."
The existing
// TODO: allow reopening the text editor with the same content againat the over-limit branch confirmed this was the intended direction. The1 MiB cap is unchanged; this is purely about not losing work.
Testing
go build ./...,go vet ./...,gofmt -l ./gofumpt -l .: cleango test ./...: all packages passFixes #65
AI was used for assistance.