Repository navigation
Browse and restore Trash in the TUI - #672
WhiskeyTuesday wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A pending Trash refresh can reinsert a restored topic after navigation because an early return skips request invalidation; the ordering needs a fix and regression test.
1 open issue
What changed in this PR
Adds Trash browsing and restoration to the TUI’s existing mail navigation, while keeping Trash topic IDs separate from posting IDs.
Changes:
- Adds a
0 Trashtab with pagination, thread reading, andito restore. - Blocks posting mutations in Trash and adds tests for restore outcomes, stale responses, and ID collisions.
- Documents the behavior and temporarily pins an SDK fork for pagination support; a published SDK release is required before merging.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
internal/tui/tui_test.go |
Updates source-count expectations for Trash. |
internal/tui/trash.go |
Implements restoration, mutation restrictions, and contextual help. |
internal/tui/trash_test.go |
Tests navigation, pagination, restoration, and identity safeguards. |
internal/tui/move.go |
Excludes Trash from move destinations. |
internal/tui/mail.go |
Integrates Trash navigation, reading, and action guards. |
internal/tui/mail_test.go |
Adjusts mail-source expectations for Trash. |
internal/tui/collections_test.go |
Accounts for Trash during collection discovery. |
internal/mail/source.go |
Adds the Trash source kind. |
internal/mail/page.go |
Adapts paginated Trash topics into list rows. |
go.sum |
Records checksums for the temporary SDK fork. |
go.mod |
Pins the SDK fork containing pagination support. |
docs/tui.md |
Documents Trash controls and restrictions. |
docs/architecture/mail-sources-and-paging.md |
Explains Trash identities and restore behavior. |
Review effort: Balanced
| if v.currentSourceKind() != mail.KindTrash { | ||
| return notify("Thread restored") | ||
| } | ||
| // A page or live head read begun before the restore may still contain this | ||
| // topic. Ignore those answers so they cannot resurrect the restored row. | ||
| v.moreRequestID++ | ||
| v.liveRequestID++ |
There was a problem hiding this comment.
Fixed in 8466640. Confirmed the reported ordering: A pre-restore Trash live refresh could still pass the request/source checks after a round trip through the Imbox: navigation invalidates paginated reads but does not change the live refresh generation.
The fix moves live-refresh invalidation ahead of the non-Trash early return, still after the restore error check. Paging invalidation remains scoped to Trash so a late restore does not interfere with the other source's page read.
The new regression holds an actual SDK refresh response from an offline test server, starts a restore with i, navigates to the Imbox, completes the successful restore, returns to a freshly read Trash list, and then delivers the old response. It reproduced the restored topic reappearing before the fix and now rejects that response. A separate test checks that a failed restore still allows an otherwise valid refresh.
TUI/mail tests, the targeted race check, and lint pass. The full test suite still hits the previously observed TestFindBareLinksPastRejectedPrefixesIsLinear timing failure; the new regressions pass.

The TUI can send mail to Trash but cannot browse it or restore a thread. Add a
0 Trashtab, with paginated browsing, thread reading, andito restore through HEY's normal topic restore operation.Trash returns topics rather than posting IDs. The adapter preserves that distinction, blocks posting mutations in Trash, and avoids marking a trashed topic as a seen posting. A restored row leaves the list only after success; earlier page reads cannot bring it back, and late responses cannot remove an unrelated row after switching sources.
Depends on basecamp/hey-sdk#314 or an equivalent SDK change that preserves Trash’s pagination cursor. This PR temporarily pins the exact helper commit in my public fork so it can be built and reviewed now. Before merging, that replacement needs to be removed and a published SDK release pinned. Feedback on the Trash UI and restore behavior is welcome while the SDK dependency is reviewed.
Tests cover navigation, opaque pagination, opening without a posting observation, restore success and failure, blocked mutations, stale reads, and topic/posting ID collisions.
Validation after rebasing onto f6244d7: TUI tests,
make lint, andmake buildpassed.make testfailed onlyTestFindBareLinksPastRejectedPrefixesIsLinear; the same five-second assertion fails on unchanged upstream on this machine. Focused live checks on combined build 9da3f57 passed in a real HEY account: trashing, browsing, reading, refusal of Move while trashed, and restoring the owned fixture with independent server readback.Summary by cubic
Adds a Trash tab (shortcut
0) to the TUI so trashed threads can be browsed, read, and restored withi. Previously Trash was write-only: mail could be sent there, but there was no way to browse or restore it.Trash serves topics rather than posting IDs. The adapter keeps that distinction — posting mutations are blocked in Trash, and a trashed topic is never observed as a seen posting. A successful restore removes the row and closes any open reader; a failed restore leaves the thread in place to retry. A restore also invalidates any read begun earlier, so a stale page or live response cannot resurrect the restored row even after the reader switches sources and back. Trash is excluded as a move destination. Tests cover navigation, opaque pagination, restore success and failure, blocked mutations, stale reads, and topic/posting ID collisions.
Dependencies
Topics.GetTrashPage; until it lands,go.modcarries a temporaryreplaceto a fork commit that must be removed before merging.Written for commit 8466640. Summary will update on new commits.