Skip to content

GH-105: add folder create, move and delete - #106

Merged
blainemotsinger merged 1 commit into
mainfrom
GH-105
Nov 15, 2026
Merged

blainemotsinger merged 1 commit into
mainfrom
GH-105

Conversation

@blainemotsinger

Copy link
Copy Markdown
Member

Summary

Adds folder management to the folder pane: create (nested), move (nested, after a
confirmation that names the destination), and delete (empty only, after a
confirmation). N / M / D are new and unbound before this change; they mirror
m / d — same letter, different pane.

Both the folder pane and the folders overlay own the keys, because the two-column
layout draws no folder pane and the overlay is the only folder access there.

Why chute does the parent and cascade work itself

The in-process IMAP server this package tests against does not create missing
parents for CREATE, does not rename inferior names on RENAME, and does not
refuse DELETE on a mailbox that still holds mail. RFC 3501 asks a server to do the
first two, so real servers differ. Assuming either would have shipped a nested create
that shows up as an orphan root, and a move that leaves its subtree behind.

  • create: one CREATE per missing level, shallowest first; levels already in the
    listing are skipped.
  • move: one RENAME, then LIST, then repair any descendant still under the old
    name (shallowest first). A server that already cascaded leaves nothing to repair, so
    the loop is a no-op there.
  • delete: the message count comes from STATUS, checked under the session mutex,
    so another client delivering mail between the interface's check and the delete is
    still refused. \Noselect containers skip the STATUS, which some servers refuse.

Every operation returns the listing the server reported. The UI draws that listing, never
a locally edited tree.

What changed

File Change
mail/folderops.go new: NewFolder, MoveFolder, DeleteFolder, FolderMessages, FolderConflict, FolderPath, IsBelow
mail/client.go CreateMailbox, RenameMailbox, DeleteMailbox, MailboxMessages
mail/errors.go six typed refusals; the not-empty and has-children ones carry a count
tui/folderops.go new: target resolution, guards, listing reconciliation, rename bookkeeping
tui/foldernew.go new: the create prompt with a live resolved-path preview
tui/foldermove.go new: the destination picker and its confirmation
tui/folderdelete.go new: the emptiness check before the confirmation
config/keys.go, tui/keys.go new_folder, move_folder, delete_folder
tui/{model,confirm,footer,help,client}.go wiring, two new confirmation kinds, footer and help entries
README.md the three key rows

Refusals

Case Message
INBOX, move or delete INBOX cannot be moved or deleted
A folder [accounts.imap] names "Trash" is set as trash in [accounts.imap]; change that setting first
Delete with mail Work has 12 messages; empty it first
Delete with subfolders Work has 3 folders below it; delete those first
Move into itself or a descendant a folder cannot move inside itself
Move onto a taken name that folder already exists
Move to the folder's current parent already there

A folder the server marks with \Sent / \Trash / etc. stays movable and deletable:
the attribute travels with the mailbox through a rename, so the role still resolves.
Only a literal config name breaks, and only that is refused.

Test changes outside the feature

Two behaviours changed deliberately, and the tests that encoded the old ones were
updated rather than worked around:

  • The folders pane now has its own footer (D:delete M:move N:new enter:open q:quit). It was advertising d:delete f:flag m:move, which do nothing in that
    pane. Six footer tests had been exercising the folder pane while claiming to test
    the message list; they now say which pane they mean.
  • M is bound again, to move_folder, not to actionMove. TestMoveAndReadBindings MatchTheIssue records both facts so bug fixes #88's alias cannot return as a side effect.

Verification

gofmt -l .                                      no output
go vet ./...                                    ok
go test -race -count=1 ./...                    ok  (4 packages)
golangci-lint v2.15.0 run                       0 issues
coverage: mail 84.2%, tui 88.6%

The new tests drive the real client against imapmemserver for the create/move/delete
paths, and the fake session client for the branch a cascading server takes (nothing to
repair) and the repair order. The TUI tests drive the whole flow through Update, and
TestFolderDialogsFitTheMinimumFrame holds all three dialogs inside the 60x20 floor —
it caught the picker title running to 93 cells before this PR was opened.

Closes #105

Create, move and delete mailboxes from the folder pane and the folders
overlay, on N, M and D.

The in-process test server creates no missing parents on CREATE, renames no
inferior names on RENAME, and deletes a non-empty mailbox without complaint,
so chute does that work itself: it creates every missing level, repairs any
descendant a rename left behind, and refuses to delete a folder that holds
mail or has folders below it. Every operation returns the listing the server
reported, so the tree never shows a locally invented name.

Move and delete refuse INBOX and any mailbox an [accounts.imap] override
names; a folder the server marks with an attribute stays editable, because
the attribute travels through a rename.

The folders pane also gets its own footer: it was advertising d, f and m,
which do nothing in that pane.
@blainemotsinger blainemotsinger self-assigned this Nov 15, 2026
@blainemotsinger
blainemotsinger merged commit 59cdcd7 into main Nov 15, 2026
5 checks passed
@blainemotsinger
blainemotsinger deleted the GH-105 branch November 15, 2026 19:35
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.

add folder functionality

1 participant