chore: rebase fork onto upstream aerc master (0.22+) #2

Closed
jmz wants to merge 0 commits from sync/upstream-2026-10 into release/mirus
Owner

Rebases the fork onto upstream aerc master (0.22.0-34-g0d169b79, +228 commits over our 0.21.0 base).

Landing: this is a rebase, so the history is linear and does not share commits with the current release/mirus. Land it by fast-forwarding/force-updating release/mirus to this branch, not with a merge commit.

Kept (rebased)

  • AI assistant commands (:ai-summarize/ask/draft/translate/ai), CLI provider, result pager
  • undo-send / send-delay
  • Forgejo CI gate
  • new: refactor(ai) moves [ai] onto upstream's atomic config pattern and the new FetchBodyPart(ctx, …) API

Dropped (superseded upstream)

  • which-key popup → upstream keyhint (0d3d75cc), same # label annotations from binds.conf. Config: which-key-enabled/-delay → keyhint/keyhint-delay; styles whichkey_* → keyhint_* (dotfiles-local updated).
  • StyleSet nil-guard + IPC-on-UI-goroutine fix → upstream fixed the reload crash properly with atomic config (51fd25c0, todo #319).

Verification

  • go build ./..., go test -vet=off ./...: all pass
  • deployed on mba over the brew Cellar binary (backup: aerc.fork-0.21-whichkey)

🤖 Generated with Claude Code

https://claude.ai/code/session_012S3mRY7CzPt8r9zhPWBZjz

Rebases the fork onto upstream aerc `master` (0.22.0-34-g0d169b79, +228 commits over our 0.21.0 base). **Landing:** this is a rebase, so the history is linear and does not share commits with the current `release/mirus`. Land it by fast-forwarding/force-updating `release/mirus` to this branch, not with a merge commit. ## Kept (rebased) - AI assistant commands (`:ai-summarize/ask/draft/translate/ai`), CLI provider, result pager - undo-send / send-delay - Forgejo CI gate - new: `refactor(ai)` moves `[ai]` onto upstream's atomic config pattern and the new `FetchBodyPart(ctx, …)` API ## Dropped (superseded upstream) - which-key popup → upstream **keyhint** (0d3d75cc), same `# label` annotations from binds.conf. Config: `which-key-enabled/-delay` → `keyhint/keyhint-delay`; styles `whichkey_*` → `keyhint_*` (dotfiles-local updated). - StyleSet nil-guard + IPC-on-UI-goroutine fix → upstream fixed the reload crash properly with atomic config (51fd25c0, todo #319). ## Verification - `go build ./...`, `go test -vet=off ./...`: all pass - deployed on mba over the brew Cellar binary (backup: `aerc.fork-0.21-whichkey`) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012S3mRY7CzPt8r9zhPWBZjz
jmz added 236 commits 2026-10-06 23:27:41 +00:00
The uids slice used inside the worker action was mutated in the main
command loop. As a message was successfully processed, its uid was
removed from the slice in a way where the last item of the original
slice was getting duplicated at the end of the underlying array.
Depending on the scheduling of the concurrent messages processing, this
was sometimes leading to some messages being replaced in the export by
the last message.

This was apparently present since the introduction of this command in
commit 845763cb1f.

Link: https://lists.sr.ht/~rjarry/aerc-discuss/%[email protected]%3E
Changelog-fixed: Fixed occasional data loss in export result of
 `export-mbox`.
Signed-off-by: Damien Tardy-Panis <[email protected]>
Acked-by: Robin Jarry <[email protected]>
- easier to read
- less slice allocations and copies

Signed-off-by: Damien Tardy-Panis <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When reloading the configuration with :reload, global variables in the
config package are reset to their startup values and then, the config is
parsed from disk. While the parsing is done, these variables are
temporarily in an inconsistent and possibly invalid state.

When commands are executed interactively from aerc, they are handled by
the main goroutine which also deals with UI rendering. No UI render will
be done while :reload is in progress.

However, the IPC socket handler runs in an independent goroutine. This
has the unfortunate side effect to let the UI goroutine to run while
config parsing is in progress and causes crashes:

[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6bb142]

goroutine 1 [running]:
git.sr.ht/~rjarry/aerc/lib/log.PanicHandler()
	lib/log/panic-logger.go:51 +0x6cf
panic({0xc1d960?, 0x134a6e0?})
	/usr/lib/go/src/runtime/panic.go:783 +0x132
git.sr.ht/~rjarry/aerc/config.(*StyleConf).getStyle(0xc00038b908?, 0x4206b7?)
	config/style.go:386 +0x42
git.sr.ht/~rjarry/aerc/config.StyleSet.Get({0x0, 0x0, 0x0, {0x0, 0x0, 0x0}}, 0x421a65?, 0x0)
	config/style.go:408 +0x8b
git.sr.ht/~rjarry/aerc/config.(*UIConfig).GetStyle(...)
	config/ui.go:379
git.sr.ht/~rjarry/aerc/lib/ui.(*TabStrip).Draw(0xc000314700, 0xc000192230)
	lib/ui/tab.go:378 +0x15b
git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0xc000186fc0, 0xc0002c25f0)
	lib/ui/grid.go:126 +0x28e
git.sr.ht/~rjarry/aerc/app.(*Aerc).Draw(0x14b9f00, 0xc0002c25f0)
	app/aerc.go:192 +0x1fe
git.sr.ht/~rjarry/aerc/lib/ui.Render()
	lib/ui/ui.go:155 +0x16b
main.main()
	main.go:310 +0x997

Make the reload operation safe by changing how config objects are
exposed and updated. Change all objects to be atomic pointers. Expose
public functions to access their value atomically. Only update their
value after a complete and successful config parse. This way the UI
thread will always have access to a valid configuration.

NB: The account configuration is not included in this change since it
cannot be reloaded.

Fixes: https://todo.sr.ht/~rjarry/aerc/319
Reported-by: Anachron <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
When receiving the SIGHUP signal, reload all configuration.

Changelog-added: `:reload` is now invoked when `SIGHUP` is received
 by the `aerc` process.
Suggested-by: Anachron <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Change 'p' to 'N' for previous search result navigation to match actual
keybinding.

Signed-off-by: Yutaro Ohno <[email protected]>
Acked-by: Robin Jarry <[email protected]>
There is a race condition where a callback may never be called if the
worker finishes handling a message before the callback is registered.

In practice, with Go 1.25.0, I have not seen the callback lose this
race. However, adding an explicit runtime.Gosched() before registering
the callback does cause it to consistently lose the race. Therefore,
it's probably best to patch this as whether to yield the Goroutine is
outside our control.

Signed-off-by: Marco Munizaga <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
This is basically an 'æ' character enclosed in a '@' character followed
by a '_' character. An icon version is enclosed in a mini terminal.

                    .@@@@@@@@@@@@@@@@@@@.
                @@@@@@@@.              @@@@@@@
             @@@@@@                        @@@@@%
           @@@@&    .-@@@@%.       @@@@@.     @@@@@
         @@@@    @@@@@@@@@@@@*  @@@@@@@@@@     @@@@.
        @@@@     `@        ,@@@@@@      @@@.     @@@&
       @@@*                 .@@@@        @@@      @@@.
      @@@@                   @@@          @@@     @@@@
     /@@@                    @@@          @@@     (@@@
     @@@@         @@@@@@@@@@@@@@@@@@@@@@@@@@@     &@@@
     @@@@       @@@@@        @@@                  @@@@
     *@@@      @@@@          @@@                 @@@@
      @@@@     @@@@         @@@@,               @@@@
       @@@#    @@@@        %@@@@@/           .@@@@.
        @@@@    @@@@@   .@@@,  @@@@@/     &@@@@@
         @@@@/    @@@@@@@@       @@@@@@@@@@@
           @@@@@
             @@@@@@                        @@@@
                &@@@@@@@&            &@@@@@@@
                     @@@@@@@@@@@@@@@@@@@          @@@@@@@@@

Install the icon and reference it in the XDG .desktop file. Reference
the logo in README.md for maximum enjoyment.

Signed-off-by: Robin Jarry <[email protected]>
Acked-by: Moritz Poldrack <[email protected]>
I noticed that clicking on a message in the message list only opens that
message after I've navigated to another folder and came back.

The problem is that we store the number of UIDs in the list in an
attribute and screw up :-)

It's easier to simply ask the store for the number of UIDs it has when
needed, and it *also* makes clicks work on the initial message list
load.

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
If you start aerc with mouse mode activated and you happen to touch the
mouse, you might encounter this crash [1].

The problem is that if the grid has not been drawn yet, reflow has not
been called, hence {row,column}Layout is nil, and we crash accessing
their elements.

There might be ways to better synchronize things (?), but the easiest is
to simply ignore mouse events if {row,column}Layout is nil; this is what
this patch does.

[1] panic: runtime error: slice bounds out of range [:2] with capacity 0
goroutine 1 [running]:
git.sr.ht/~rjarry/aerc/lib/log.PanicHandler()
        git.sr.ht/~rjarry/aerc/lib/log/panic-logger.go:51 +0x6cf
panic({0xc8c660?, 0xc001914000?})
        runtime/panic.go:792 +0x132
git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).MouseEvent(0xc000162090, 0x63, 0x16, {0xc9ac60?, 0xc000414440?})
        git.sr.ht/~rjarry/aerc/lib/ui/grid.go:144 +0x5a6
git.sr.ht/~rjarry/aerc/app.(*AccountView).MouseEvent(0x142db50?, 0xcd1640?, 0xc0000478f0?, {0xc9ac60?, 0xc000414440?})
        git.sr.ht/~rjarry/aerc/app/account.go:192 +0x25
[...]

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
This fixes a systematic crash when typing ctrl+w in a list box when no
entry matches the typed filter, due to an unchecked access to the
(empty) selected line.

Reported-by: Mariano Casco <[email protected]>
Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
I've setup aerc to use a message split and display the Message-Id
header, and have been experiencing a few crashes upon (I think) opening
new messages.

Here's an excerpt of the associated stack trace:
  [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x10967aa01]

  goroutine 1 [running]:
  git.sr.ht/~rjarry/aerc/lib/log.PanicHandler()
          git.sr.ht/~rjarry/aerc/lib/log/panic-logger.go:51 +0x6cf
  panic({0x10994e6c0?, 0x10a072b40?})
          runtime/panic.go:792 +0x132
  git.sr.ht/~rjarry/aerc/app.fmtHeader(0xc0045ab130, {0xc00011ee8c, 0xa}, {0x109952f40, 0x1b}, {0x0, 0x0}, {0x0, 0x0}, {0x0, ...})
          git.sr.ht/~rjarry/aerc/app/msgviewer.go:193 +0x381

The problem is that we happily dereference msg.RFC822Headers in
fmtHeaders, that happens to be nil. While it's not clear why that
happens (it could be linked to the fact we're working on a message we're
fetching (?)), we should definitely check RFC822Headers against nil
before dereferencing it.

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Currently, the aerc icon is installed to:

  /usr/share/icons/hicolor/scalable/apps/aerc.svg/icon.svg
                                        ^^^^^^^^^

The install_file macro expects an installation directory, not file path.

Rename the source file so that the target install path is correct.

Fixes: 29413dc783 ("contrib: add application icon and logos")
Reported-by: Matěj Cepl <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Matěj Cepl <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
If check-mail is not set up to run on startup (for example when the sync
is done externally), the new messages were not displayed in the dirlist
until one would switch to each of the directories.

We're now running the SyncNewMail in handleListDirectories on all
directories, the same way it's done at the end of handleCheckMail. This
registers all the new messages before the dirlist gets rendered.

Fixes: https://todo.sr.ht/~rjarry/aerc/185
Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CCSLCE7V6PBJA.THVFF075ARCT%40walnut%3E
Signed-off-by: Damien Tardy-Panis <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When fetching message headers in a large folder, aerc could enter an
infinite loop, repeatedly fetching the same message metadata. This was
caused by a bug in the JMAP worker's message fetching logic.

The `handleFetchMessageHeaders` function in `worker/jmap/fetch.go`
iterates over a slice of emails (`currentEmails`) to identify threads
that need to be fetched. If a thread was already cached, the code would
then iterate over all emails within that thread and append them to the
`currentEmails` slice.

Appending to a slice while iterating over it is a classic Go pitfall
that can lead to unexpected behavior. In this case, it caused the loop
to re-process the same emails repeatedly, leading to an infinite loop of
`Email/get` requests for the same message ID.

This patch fixes the bug by removing the line that appends to the
`currentEmails` slice inside the loop. The UI is still updated with the
information about the emails in the cached thread, but the main loop
does not grow and the infinite loop is avoided.

Signed-off-by: Matěj Cepl <[email protected]>
Tested-by: Tristan Partin <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Some of my folders contain accents, e.g. "Télécom". I'm using fuzzy
matching for autocomplete, and this folder is not proposed if I type,
say, ":mv tele", while I expected it would.

We use fuzzy.RankFindFold, and this patch leverages instead the Unicode
normalized fuzzy.RandFindNormalizedFold, making fuzzy search work better
with accents and friends.

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Bence Ferdinandy <[email protected]>
Acked-by: Robin Jarry <[email protected]>
go-jmap v0.5.2 was not a signed tag. Update to v0.5.3 which is signed,
and makes packagers' lives easier. No changes were made between 0.5.2
and 0.5.3.

Signed-off-by: Tim Culverhouse <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Just as prior to this commit, the GMail extension for labels is used
towards servers where the X-GM-EXT-1 capability is available. For other
servers, this commit adds storing labels using keyword flags, if
PERMANENTFLAGS is either empty or allows `\*`, in accordance with
section 6.3.2 of rfc9051.

No feature validation has been done with either GMail nor Proton, as I
don't have accounts setup for either of those providers.

Labels are not visible by default. Taking inspiration from something
like these lines and adding to the appropriate sections of the
configuration can make them show up in the UI:

column-subject = {{if .Labels}}{{.Labels | join " "}}|{{ end }}{{.Subject}}
header-layout = From|To,Cc|Bcc,Date,Subject,Labels

Existing unit test coverage for imap is sparse. This commit does not
change that fact, as it is hard do see test cases which might be
meaningful to add.

Implements: https://todo.sr.ht/~rjarry/aerc/320
Changelog-added: Add support for Labels when using imap.
Signed-off-by: cos <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Add a configuration option to specify a directory where all temporary
files are saved.

Changelog-added: A custom directory can now be specified for temporary
 files.
Signed-off-by: inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Instead of creating new mail files in the general temporary directory,
where they might be erased upon system restart, create them in
${XDG_STATE_HOME:-~/.local/state}/aerc/compose. Adjust :recover to find
those files automatically.

Changelog-changed: Temporary files for messages being composed now
 reside in the system's proper state home directory.
Signed-off-by: inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
This allows setting viewer options for specific message senders or
subjects via conditional `viewer` blocks in the main configuration file,
similar to contextual UI configuration.  Each block can target the
envelope sender and the From/Subject headers, as either an exact match
with `=` (on the email address for sender/from) or a regex with `~` (on
the full "$name <$email>" string representation).

For example, some senders like to include a useless plain text part in
their alternatives, telling you that your client doesn't support HTML.
The documented example would prefer plain text where present by default,
but switch to the HTML part for such senders.

Signed-off-by: Terrance <[email protected]>
Reviewed-by: Julio B <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Fix the following error on startup:

 error: ~/.config/aerc/aerc.conf: [general].temporary-directory:
   stat "": no such file or directory

When the setting is empty, use the platform default temp directory.

Fixes: 05ec40d81d ("config: allow specifying the temporary directory")
Reported-by: Jon Fineman <[email protected]>
Reported-by: Julio B <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Instead of requiring the directory to be created by the user. Let aerc
create it if necessary with restrictive permissions.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Some linters seem to have been enabled by default, and they point out
issues in the codebase, so I have disabled them. They can be enabled at
a later point.

Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
As reported by bonswouar on IRC, the mail received hook is not invoked
when a new mail is received on an account that's not currently active,
only when that account is activated.

This is due to a bug in MessageStore.Update, that wrongly assumes that
messages in a directory are displayed in increasing UID order - this is
only the case when reverse-msglist-order (that defaults to false) is
true. So unless there's less than one page worth of messages in a
directory or reverse-msglist-order is true, MessageStore.Update will
think that new messages are outside of the current page, and not fetch
their headers (this is what might trigger the mail received hook).

This patch ensures that the order is properly taken into account, and
makes the mail received hook be invoked whether the account is active or
not.

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
I noticed that changing labels does not show the "labels updated"
message in the status bar while it should. The problem is that we don't
report a "Done" in handleModifyLabels, and the callback updating the
status bar is never invoked.

This patch fixes this, along with two missing or misplaced return-s in
handleModifyLabels.

Fixes: 8f9cd5c0 ("imap: store and retrieve labels")
Fixes: 96ed6a95 ("imap: add support for :modify-labels / :tag for gmail and proton")
Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Previously, commands.Register allowed using pointers to new command,
e.g.:

    commands.Register(&Prefetch{})

which however made aerc crash later when some methods (e.g., Aliases,
Execute) got double pointer instead of the simple pointer they expected.

Signed-off-by: Matěj Cepl <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Since go-opt v2, the flags from subcommands are not interpreted
properly. This has been reported on several occasions.

go-opt now supports sub-commands natively. Update the code accordingly.

Link: https://lists.sr.ht/~rjarry/aerc-devel/%[email protected]%3E
Link: https://lists.sr.ht/~rjarry/aerc-discuss/%[email protected]%3E
Reported-by: Antonin Godard <[email protected]>
Reported-by: Mervyn Fox <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Antonin Godard <[email protected]>
Instead of printing completion items for patch sub commands in a random
order (depending on whatever go hash table seed is used), sort the
completion items using standard ASCII order.

Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Antonin Godard <[email protected]>
Instead of duplicating commands.QuoteSpace almost everywhere, make it
the default value for the post processing function of FilterList.

Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Antonin Godard <[email protected]>
go-opt v2.2.0 now supports providing individual descriptions for
completion items by appending a newline character to the completion item
followed by its description.

Do that for patch sub commands. Here's what it looks like:

       apply    (Apply the selected message(s) to the current project.)
       cd       (Change aerc's working directory to the current project.)
       drop     (Drop a patch from the repository.)
       find     (Search for applied patches.)
       init     (Create a new project.)
       list     (List the current project with the tracked patch sets.)
       ls       (List the current project with the tracked patch sets.)
       rebase   (Rebase the patch data.)
       switch   (Switch context to the specified project.)
       term     (Open a shell or run a command in the current project's directory.)
       unlink   (Delete all patch tracking data for the specified project.)
:patch

Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Antonin Godard <[email protected]>
I have tried hooks from `aerc-config` examples and noticed I keep
getting errors when they were supposed to be run. I checked the logs and
noticed that they were parsed only up to the end of if statement
(up to the ;).

Investigating further, I found that `;` is treated as a
comment in INI file format and found examples in the library used by
aerc (go-ini), showing that value needs to be wrapped in backticks to
use semicolons in it.

I have updated the config documentation to match that. I have also
tested it and it works as expected.

Link: b2f570e5b5/testdata/full.ini (L71)
Signed-off-by: Ensar Sarajčić <[email protected]>
Acked-by: Robin Jarry <[email protected]>
This is an optimization. It makes no sense to request emails if there
are none to fetch.

Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Somehow one of my accounts' cache was locked, and I noticed the
following error in the logs:
  ERROR 2025/11/21 10:30:54.006464 cache.go:57: [GMail] failed opening
  cache db: resource temporarily unavailable

It's not super useful, since in particular it does not tell where it
tried to find the cache. This patch adds this location, making the error
log a bit more actionable (e.g. I know what to go `rm -rf` :-)):
  ERROR 2025/11/21 10:32:43.520762 cache.go:57: [GMail] failed opening
  cache db at /home/simon/.cache/aerc/GMail: resource temporarily
  unavailable

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The Reply-To field does not currently receive autocompletion
support, and some users seem to use this field via `abook`.

This is reported in the Debian Bug report #1042578.

Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1042578
Signed-off-by: Nilesh Patra <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The `restrict-deletes` functionality only partially worked on IMAP
except for Proton Mail, because the Junk and Trash folders are not
properly detected.

Angel Sartonev found out that they are when using LIST instead of
LIST-STATUS to discover the list of directories, which makes sense: LIST
is about directories, LIST-STATUS about their contents.

We must use LIST to discover that list, even if the IMAP provider
supports LIST-STATUS. The performance impact for correctness, if any, is
minimal (and if present, likely an improvement) since we do CheckMail
right after, hence we turn two consecutive calls to LIST-STATUS into one
call to LIST followed by one to LIST-STATUS.

Fixes: de2006bb ("config: allow controlling whether :delete is allowed from any folder")
Reported-by: Angel Sartonev <[email protected]>
Reported-by: bonswouar (IRC)
Co-authored-by: Angel Sartonev <[email protected]>
Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
I thought several times in the past that it'd be great to see how
go-imap and a given IMAP server interact, and it turns out that there's
a easy way to do it. This patch adds an option to control this.

I have validated that this logging works fine when the target path
exists and is writable to, and that we simply ignore the option
otherwise, logging something like:
  TRACE 2025/11/21 14:49:41.924753 connect.go:127: [ProtonMail] Not
  logging IMAP debug logs: open ./idontexist/imap_debug_ProtonMail.log:
  no such file or directory

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Add a command to toggle the sidebar visibility at runtime.

- Add sidebarHidden field to AccountView
- Add hasSidebar() helper and buildGrid() method
- Update Split() and Vsplit() to respect sidebar state
- Works with all view layouts (basic, hsplit, vsplit)

Changelog-added: New `:toggle-sidebar` command to hide/show the
 sidebar.
Signed-off-by: Matthew Phillips <[email protected]>
Acked-by: Robin Jarry <[email protected]>
In order to load message parts for rendering html emails, we need to
know the parts Content-ID header values (if any). Add this field to the
BodyStructure type and initialize it in all workers.

Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Bence Ferdinandy <[email protected]>
Tested-by: Inwit <[email protected]>
Tested-by: Matthew Phillips <[email protected]>
Add a new html-inline-images option in the [viewer] section that enables
inlining of images referenced by <img> tags with cid: URLs in HTML emails.

When enabled, aerc will parse HTML content to find <img src="cid:...">
references, fetch the corresponding image parts using their Content-ID
and use base64 encoding to embed images directly in HTML using data:
URLs.

This allows HTML emails with embedded images to be properly viewed in
w3m and other browsers that support data: URLs. The implementation uses
asynchronous callbacks to fetch all images in parallel without blocking.

The feature works with all aerc commands that fetch message parts (:save,
:open, :pipe, and viewing). Updated the filters/html script to enable
w3m image support with sixel graphics when img2sixel is available.

Add documentation for the new html-inline-images viewer option in both
the default aerc.conf and the aerc-config(5) man page.

Implements: https://todo.sr.ht/~rjarry/aerc/252
Changelog-added: New `[viewer].html-inline-images` option to replace
 `<img src="cid:...">` tags in `text/html` parts with their related
 `image/*` part data encoded in base64. For this to work with sixel
 compatible terminals, you need to update your filters with `text/html =
 ! html -sixel` and install `img2sixel`.
Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Bence Ferdinandy <[email protected]>
Tested-by: Inwit <[email protected]>
Tested-by: Matthew Phillips <[email protected]>
Currently, the address book command is executed with exec. This prevents
from having shell markup like in all other commands.

Run the address book command with sh -c "<command>" to allow constructs
like:

  address-book-cmd = maddr -h to ~/Maildir/Sent | sort -u | grep %s

Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Paul W. Rankin <[email protected]>
After 4f7f5d40, trailing spaces after empty headers are removed when
edit-headers is true. Since this change was intended for users of
format-flowed, restrict that behavior to when format-flowed is true.

Fixes: 4f7f5d40
Signed-off-by: inwit <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
updateSplitView() used hardcoded grid positions that assumed the
sidebar was always visible, causing a crash when opening a split
view with the sidebar hidden.

closeSplit() also ignored the sidebar visibility state, causing
the sidebar to reappear when closing a split.

Fix both by checking hasSidebar() for correct column positions
and reusing buildGrid() in closeSplit().

Fixes: 66cf16c4 ("commands: add :toggle-sidebar command")
Signed-off-by: Matthew Phillips <[email protected]>
Tested-by: Julio B <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Ctrl-left and ctrl-right can be used to navigate per word in all input
boxes but these bindings get shadowed by the default switch-account
bindings of the composer.

These can cause silent and unintended account changes when composing.

Reported-by: Gregory Dushkin <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Acked-by: Inwit <[email protected]>
Instead of having a hard-coded list of help topics, change the :help
command completion to list available man pages as listed by:

	man -k aerc

Append each man page short description to the completion choices.

In case mandb isn't up to date, or if running aerc without installing
it, fallback to a hard-coded list. I didn't try to walk the "doc" folder
since the working directory isn't guaranteed.

Also, in order for this to work properly, mandb must be executed after
installing the man pages. This isn't part of the makefile since it would
cause issues in downstream builds which install in staging directories.

Add a mention of mandb in the installation instructions.

Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Antonin Godard <[email protected]>
This is the result of the following command:

go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./...

Signed-off-by: Robin Jarry <[email protected]>
At times messages from the message store may be incomplete and not
contain the sender. This is unexpected, but should not crash the
application.

[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x55f3cee9b99e]

panic({0x55f3cf118720?, 0x55f3cf72e6f0?})
	runtime/panic.go:783 +0x132
git.sr.ht/~rjarry/aerc/commands/msg.Mark.Execute.senderFilter.func2({0xc0019c4000, 0x801, 0x0?})
	git.sr.ht/~rjarry/aerc/commands/msg/mark.go:180 +0x1fe
git.sr.ht/~rjarry/aerc/commands/msg.Mark.Execute({0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, {0xc00190eb70, 0x7}}, {0xc001542810, ...})
	git.sr.ht/~rjarry/aerc/commands/msg/mark.go:106 +0x68c
git.sr.ht/~rjarry/aerc/commands.ExecuteCommand({0x55f3cf21c8f0, 0x55f3cf8cd220?}, {0xc00190ea90?, 0x500c000fb2300?})
	git.sr.ht/~rjarry/aerc/commands/commands.go:221 +0x4d3

Fixes: 6baffcda ("mark: add filter-based marking")
Signed-off-by: Moritz Poldrack <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Clarifies usage of check-mail-cmd in doc/aerc-notmuch.5.scd
to make explicit the need to update the notmuch database with 'notmuch new'.
Additionally provides an additional example for check-mail-cmd.

The fact that the notmuch database must be explicitly updated
was not mentioned in this documentation prior,
with the provided example being potentially confusing to new users
who were not already using and familiar with notmuch before coming to aerc:
https://lists.sr.ht/~rjarry/aerc-discuss/%[email protected]%3E

Signed-off-by: Aedin Joseph <[email protected]>
Reviewed-by: Inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Correct various typos and grammatical issues across man pages. Fix "an
popover" to "a popover", "exists" to "exist", "froma" to "from a", and
similar errors. Standardize IMAP capitalization throughout. Fix
punctuation in command descriptions and ensure consistent sentence
structure.

Also fix missing space in aerc.conf comment formatting.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Bence Ferdinandy <[email protected]>
The TemplateData interface was missing HasNew, Bell, and Title methods
that are implemented by the concrete type. Add these methods to the
interface and corresponding stub implementations in dummyData used for
template validation during config parsing.

Also document the Number template field and the ThreadContext and
ThreadOrphan threading attributes that were previously undocumented.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Bence Ferdinandy <[email protected]>
The contextual UI section regex pattern included "subject" as a valid
context type, but the switch statement in parseUi never handled it. Any
[ui:subject=...] sections would silently be parsed as folder contexts
due to the missing case branch.

Remove "subject" from the regex since the feature was never implemented.
Update documentation to reflect that only account and folder contexts
are supported.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Bence Ferdinandy <[email protected]>
Fix several documentation errors where stated defaults did not match
the actual code defaults:

The outgoing-cred-cmd-cache option defaults to false, not true. The
border-char-vertical and border-char-horizontal options default to
box-drawing characters, not spaces. The dialog-width and dialog-height
descriptions incorrectly mentioned percentage signs in the value range.

Update aerc.conf icon examples to show actual ASCII defaults instead of
UTF-8 symbols that suggested different defaults. Document the [default]
binding context. Fix deprecated index-format references to use
index-columns.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Bence Ferdinandy <[email protected]>
Add SORT and THREAD (RFC 5256) to the list of supported IMAP extensions
since aerc implements server-side sorting and threading when available.

Document the imaps+login scheme which uses the LOGIN authentication
mechanism as a fallback when PLAIN is not available on the server.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Bence Ferdinandy <[email protected]>
Add missing key name aliases and special keys to aerc-binds(5):

Document <cr> as alias for <enter>, <del> as alias for <delete>, the
<clear> key, and function keys <f1> through <f63>. Add the
view::passthrough folder-specific binding context that was missing from
the list.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Bence Ferdinandy <[email protected]>
Fix several command signatures and flag descriptions in aerc(1):

The :forward command uses -x for account selection, not -a. Add the
missing -f flag to :flag and :unflag for marking messages as forwarded.
Add the missing -V flag to :mark for visual mark mode without clearing.
Document the -r, -R, and --dsn flags for :send that were added but never
documented. Fix :unflag signature to match :flag.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Bence Ferdinandy <[email protected]>
Document AERC_STYLESET and AERC_OSC8_URLS environment variables that
are available in filter commands. AERC_STYLESET contains the path to
the active styleset and AERC_OSC8_URLS is set to 1 when OSC 8 hyperlink
support is enabled.

Fix tag-modified hook documentation: remove the non-existent
AERC_ACCOUNT_BACKEND variable and add AERC_TAG_TOGGLED which contains
tags that were toggled rather than explicitly added or removed.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Bence Ferdinandy <[email protected]>
Both set_attr() handlers for "bg" and "default" attributes incorrectly
operated on s->fg instead of s->bg. This caused bg = <color> to change
the foreground instead, leaving backgrounds unchanged. The "default"
attribute would also fail to reset background colors since it cleared fg
twice.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The DEFAULT cases (both fg and bg) and the bg PALETTE case were missing
the sep = ";" assignment after emitting their escape codes. This caused
malformed sequences when these color types preceded other attributes,
e.g. fg=default with bg=red produced \x1b[3941m instead of \x1b[39;41m.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The 256-color palette uses indices 0-255. The upper bound check was
incorrectly accepting 256 as valid.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Good practice to only close what we explicitly opened.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Appears to be a typo, as it had no practical effect.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Colorize the diffstat output that appears before patches, showing
per-file change summaries like:

 README.md        |  6 ++++--

The +/- characters use diff_add/diff_del styles. Binary file stats (Bin
X -> Y bytes) colorize the old size as deletion and new size as
addition. Matches git log --stat.

Changelog-added: Diffstat summary lines before patches are now
 highlighted similar to git diff --stat.
Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Render trailing spaces and tabs in diff additions, deletions, and
context lines with a red background by default, similar to git's
diff.wsErrorHighlight = all (old,new,context). See git-diff(1).

The style is configurable with the diff_whitespace styleset option.

Changelog-added: Trailing whitespace in diff addition, deletion
 and context lines are now highlighted with a red background by
 default, similar to git's `diff.wsErrorHighlight` option set to
 `all`. Configurable with `[viewer].diff_whitespace` styleset option.
Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
If compilation failed, the uninitialized regex structures would silently
be passed to regexec(), resulting in undefined behavior.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The lib/auth package parses Authentication-Results email headers, not
general authentication mechanisms. Rename it to lib/authres to better
reflect its purpose and avoid confusion with SASL/OAuth authentication
code. This also aligns with the go-msgauth/authres library it wraps.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
SASL and OAuth2 authentication logic was duplicated across the IMAP
worker and the SMTP sender code. Both implementations handled XOAUTH2,
OAUTHBEARER, and token caching independently, making maintenance
difficult and bug fixes error-prone.

Move this shared logic into lib/auth where it can be reused by all
backends. The IMAP worker no longer needs its own OAuth structs and
configuration parsing since it can now rely on the common
implementation also used by the SMTP sender.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
When a message is deleted, it is completely removed from store.Messages.
When the store "knows" about the UID but does not have any header
information about it, there will be a "nil" entry in the store.Messages
map.

Take that into account in MessageList.Draw to avoid fetching headers for
messages that are being deleted.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Move the cancellation context from individual message types to the base
Message struct. Previously, only a few message types (OpenDirectory,
FetchDirectoryContents, FetchDirectoryThreaded, SearchDirectory,
FetchMessageHeaders, FetchMessageFlags) had a Context field, requiring
special handling in workers.

Now all worker messages carry a context through the base Message type,
set via PostAction's new first parameter. Workers access it uniformly
via the Context() method which returns context.Background() when unset.

Add a Close() method to MessageStoreView that cancels pending fetch
operations when the message viewer is closed, preventing wasted work on
messages the user is no longer viewing.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Pass the message context to Do() and Download() methods so that JMAP
requests can be cancelled when the user navigates away or closes a
message view. This builds on the previous commit that added context to
all worker messages.

Handle context.Canceled errors in the Run() loop by sending a Cancelled
response instead of treating it as a regular error.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Configure the HTTP client transport with TCP keepalive settings to
detect dead connections more quickly. Set dial timeout to 30 seconds
and keepalive interval to 15 seconds.

This helps detect stale connections when the network changes or the
server becomes unreachable, allowing the worker to trigger reconnection
sooner rather than waiting for TCP timeouts.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Store mailboxes in an in-memory map during ListDirectories instead of
relying solely on the cache. This fixes a bug where MailboxPath would
fail to resolve parent mailbox names when the cache was disabled,
because it tried to look up parents from a non-existent cache.

Simplify addMbox by having it compute the directory path internally
via MailboxPath, removing the need for callers to pass the path.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Extract common email fetching logic into a getEmails helper function.
The helper first checks the local cache for each requested email, then
fetches any missing ones from the server. Fetched emails are stored in
the cache for subsequent requests.

Refactor handleFetchMessageHeaders, handleFetchMessageBodyPart and
handleFetchFullMessages to use this helper. This ensures consistent
cache-then-fetch behavior across all message retrieval operations,
fixing cases where body part and full message fetches would fail if
the email was not already cached.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Move the exponential backoff reconnection logic from the IMAP worker's
observer to the account view. This centralizes reconnection handling
in the UI layer where it can be applied consistently across all worker
backends.

Add a reconnect-maxwait configuration option in accounts.conf that
controls the maximum delay between reconnection attempts. The backoff
starts with an immediate retry, then increases delays using 1.8^n
seconds until reaching the configured maximum.

Remove the reconnect-maxwait parameter from IMAP source options since
it is now an account-level setting. The IMAP observer no longer manages
auto-reconnect state or delayed reconnection; it simply emits ConnError
when the connection is lost.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Change NewWorker to accept the UI message channel as a parameter instead
of using a package-level global variable. This makes the dependency
explicit and allows different accounts to potentially use different
channels in the future.

Move the WorkerMessages channel from worker/types to app package where
it is created and consumed. Increase the channel buffer from 50 to 2048
to handle bursts of messages during sync operations. Also increase the
actions channel buffer from unbuffered to 32 and remove the action queue
mechanism since the buffered channel provides sufficient decoupling.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Add defer log.PanicHandler() to the Run method of all worker backends:
IMAP, JMAP, maildir, mbox, and notmuch. This ensures that any panic in
a worker goroutine is logged with a stack trace before the goroutine
terminates, making debugging easier.

Previously, a panic in a worker would silently kill the goroutine,
leaving the account in an unresponsive state with no indication of what
went wrong.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Refactor all IMAP message handlers to return errors instead of posting
Done or Error messages directly. The main Run loop now handles all
response posting in a single location, reducing code duplication and
ensuring consistent error handling across all operations.

Introduce two sentinel errors: ErrUnsupported for operations not
implemented by a backend and ErrNoop for operations that completed
without effect and should not trigger a Done message. Use
context.Canceled for cancelled operations.

Move connection timeout management from handleMessage to the
stopIdler/startIdler functions where it is more logically placed. Set
timeout before stopping IDLE when real commands execute, and clear it
when starting IDLE to allow indefinite waiting.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Move the Gmail X-GM-EXT-1 extension handling from the middleware layer
directly into the IMAP worker. This simplifies the architecture by
removing the gmailWorker middleware wrapper and its associated locking.

The XGMExtClient is now a field of the IMAP client struct, initialized
alongside other extension clients. Gmail-specific search and filter
operations are handled by dedicated methods in xgmext.go that are called
directly from the message handlers when the extension is available.

Rename xgmext types to be exported (XGMExtClient, ThreadIDSearch,
RawSearch) and simplify their methods to work with uint32 UIDs directly,
avoiding unnecessary type conversions.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Create the idler and observer at worker construction time instead of
deferring to Configure. This ensures they are always available and
removes the need for nil checks throughout the code.

Move idle_timeout and idle_debounce configuration directly to the idler
struct instead of storing them in imapConfig. The idler now uses
sensible defaults (10s timeout, 10ms debounce) that can be overridden
during configuration.

Remove the conditional nil checks when setting the client on idler and
observer since they are now guaranteed to exist.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Change the UID format from a simple numeric string to include the
directory name and UIDVALIDITY value in the format "dir:validity:uid".
This makes UIDs globally unique across the entire account rather than
just within a single mailbox.

The new format allows the UI and offline cache to unambiguously identify
messages even when switching between directories. It also provides
automatic cache invalidation when UIDVALIDITY changes, as the UID
prefix will differ.

Move the UID conversion functions from the models package to IMAPWorker
methods since they now depend on the selected mailbox state.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Rename the private fields and methods in WorkerMessage interface and
Message struct to be exported: getId/setId become GetId/SetId, id
becomes Id, acct becomes Acct, and setAccount becomes SetAccount.

This prepares for external code that needs to inspect or construct
worker messages, such as the offline worker that needs to serialize
messages to a queue.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Call SetAccount in PostAction to populate the account name on action
messages, matching the behavior of PostMessage. This ensures action
messages can be properly attributed to their source account when
processed by middleware or logged.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Add a Uid field to Directory and DirectoryInfo that stores a unique
identifier which changes when the directory contents become invalid.
For IMAP, this is the UIDVALIDITY value; other backends leave it empty.

Fetch UIDVALIDITY during directory listing when LIST-STATUS is
available, otherwise fetch it during CheckMail status queries. Include
the validity in Directory messages sent to the UI.

Refactor handleListDirectories to collect all mailboxes and statuses
before sending Directory messages, allowing the validity to be included
from the status response.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Previously, worker action messages did not specify which directory they
targeted. Workers implicitly assumed operations applied to the currently
selected folder. This assumption breaks when the UI needs to perform
operations on a folder different from the one currently open, such as
when fetching messages from a background account or handling move/copy
operations across folders.

Add Directory field to FetchDirectoryContents, FetchDirectoryThreaded,
SearchDirectory, FetchMessageHeaders, FetchFullMessages,
FetchMessageBodyPart, FetchMessageFlags, DeleteMessages, FlagMessages,
AnsweredMessages, and ForwardedMessages. Add Source field to
CopyMessages and MoveMessages to specify the origin folder.

The message store now populates these fields with its directory name.
Each worker backend validates the directory and switches context when
necessary. For IMAP, this means issuing a SELECT command when the
requested directory differs from the currently selected mailbox.

Update the foldermapper middleware to translate the new Directory and
Source fields between external and internal folder names in both
ProcessAction and PostMessage.

In the maildir backend, pass the resolved directory to search and
msgInfoFromUid instead of relying on the selected folder state. This
ensures FetchMessageHeaders and SearchDirectory operate on the correct
directory when it differs from the currently selected one.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Add Directory and Filter fields to DirectoryContents, DirectoryThreaded,
SearchResults, MessageInfo, and FullMessage response types. Workers now
populate these fields so the UI knows which directory and filter context
each response belongs to.

This metadata allows the message store to correctly associate incoming
messages with their source context, which is essential for the offline
worker to cache messages by directory and for proper handling of
concurrent operations across multiple folders.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Add an Index field to MessageInfo that indicates the message's position
in the current view. This allows workers to send incremental updates
with position information, enabling the UI to insert new messages at the
correct location without requiring a full refresh.

The JMAP push handler now includes index information when sending
unsolicited message updates, allowing the message list to stay
synchronized with server-side changes in real time.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Process JMAP state changes synchronously in handleChange instead of
sending them through a channel to be processed in the Run loop. This
simplifies the worker's main loop to only handle UI actions, while
push notifications are handled directly by the EventSource callback.

Change refresh and refreshQueriesAndThreads to log errors directly
rather than returning them, since there is no longer a caller that
needs to handle the error.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Remove per-email cache lookups and patch generation. Compute a single
patch from source and destination mailboxes and apply it to all
messages in one request.

Remove the email destruction logic that was triggered when moving
messages from certain virtual mailbox configurations. Messages are now
always moved by updating their mailbox associations, never destroyed.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Replace hardcoded "Mailbox", "Email" and "Thread" strings with named
constants when accessing JMAP state change maps. This avoids typos and
makes the state type references easier to identify.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Rename parseEnvelope to ParseEnvelope to make it available for use by
other packages. The cache worker will need this function to reconstruct
envelope data from stored headers.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Refactor notmuch message handlers to return errors instead of posting
Done or Error messages directly. The main Run loop now handles all
response posting, matching the pattern established in other worker
backends.

Remove the done() and err() helper methods and use the standard
ErrUnsupported and ErrNoop sentinel errors. Change flag and delete
handlers to return on first error instead of continuing to process
remaining UIDs.

Changelog-changed: `:flag` and `:delete` on multiple messages now
 stop on the first error on `notmuch` accounts.
Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Have individual message handlers return errors to the central
handleAction switch instead of posting Done or Error messages
themselves. The switch now dispatches the appropriate response based
on the return value: Done for nil, Error for regular errors,
Unsupported or Cancelled for the respective sentinel errors.

Add support for types.ErrNoop to signal that an operation had no
effect and should not produce a Done response. Replace the local
errUnsupported variable with the standard types.ErrUnsupported
sentinel.

In flag and mark handlers (handleAnsweredMessages,
handleForwardedMessages, handleFlagMessages), return immediately on
error instead of continuing the loop. This lets the central handler
report the error consistently.

Remove the currentSortCriteria field since it is no longer used.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Refactor mbox message handlers to return errors instead of posting Done
or Error messages directly. The main Run loop now handles all response
posting, matching the pattern established in other worker backends.

This reduces code duplication and ensures consistent error handling
across all operations.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
The IMAP connection observer emitted a synthetic Done response to
a fabricated Disconnect action when detecting a connection loss.
This was unnecessary since the ConnError message that follows
already handles the involuntary disconnect path: it sets the
disconnected status, notifies the user, and triggers reconnection
with exponential backoff.

Remove the fake Done/Disconnect from the observer. This also
prevents the UI from clearing the directory list and message store
on connection loss, allowing users to continue reading cached
messages while waiting for reconnection.

Signed-off-by: Robin Jarry <[email protected]>
Show it in wizard's help and make the shortcut consistent with the
default $ex = <C-x> in the view section.

Signed-off-by: Francesc Elies <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When GPG operations fail (e.g. password prompt is cancelled), empty
emails were being sent to the recipients. This occurred because the SMTP
transaction started via NewSender() before message validation was
complete.

Fix it by building and buffering the complete message before creating
the mail sender. This ensures that any validation errors (including GPG
failures) are caught before the SMTP DATA command is issued, preventing
empty or partial emails from reaching recipients.

Fixes: https://todo.sr.ht/~rjarry/aerc/290
Signed-off-by: Markus Schneider-Pargmann <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The archive() function calls newHelper() which relies on
app.SelectedTabContent() to determine the current context. When called
from an OnClose callback after sending a reply with archive-on-reply
configured, the composer tab is already closed and the user may have
switched accounts, causing a crash.

Pass the account and store directly to archive() from the calling
context instead of querying the current UI state.

Changelog-fixed: Crash when switching accounts quickly after sending
 a reply with archive-on-reply enabled.
Signed-off-by: Bence Ferdinandy <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Before, the two examples would be rendered in one line. In the future,
maybe it would be good define one way to specify multiple examples for
consistency. Currently, they are sometimes formatted as bullet lists,
sometimes as multiple raw lines (```) and sometimes as multiple
paragraphs.

Signed-off-by: laalsaas <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Noticed a missing space and missing information for the log to be
reliable when testing rjarry's IMAP cache patch series.

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Since stores now drop messages linked to other directories, the
MessageInfo coming from the header cache need to have their directory
information properly set.

Fixes: e324fa24 ("worker: add directory and filter metadata to response messages")
Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Currently the `QuickTerm` output will be gone after any event,
including mouse event. It should only be removed on key events.

Changelog-fixed: Quick terminal outputs (e.g. from pipe command)
 will no longer disappear on a mouse event. They will only disappear
 on a keypress as described in the status bar.
Signed-off-by: Gary Guo <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Previously, the notmuch worker's sort() method was using
rfc822.MessageInfo() in order to retrieve info about each message for
sorting. This method seems to parse the entire body of the message, so
it does much more work than needed for sorting. In contrast, the maildir
worker's sort() method uses rfc822.MessageHeaders(), which only parses
the headers, and is much faster. I noticed that on a large mailbox with
~60k messages, the maildir backend loads in a few seconds, whereas the
notmuch backend takes half a minute.

This patch switches the notmuch worker's sort() method to use
rfc822.MessageHeaders(). It also includes logic to skip sorting if the
sort criterion matches that of the notmuch results.

Signed-off-by: Rex Fernando <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Set up locale at startup to enable proper handling of multibyte UTF-8
characters. This is a prerequisite for correct column width calculation
with wcwidth() in subsequent changes.

Try LC_ALL from environment first, fall back to C.UTF-8, then UTF-8 for
LC_CTYPE as a last resort.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Tabs move the cursor to the next 8-column boundary, not 8 spaces
unconditionally. The old code replaced all tabs with 8 spaces regardless
of position, breaking alignment when tabs appeared mid-line.

  "x\ty" (x at col 0, tab, y):
    terminal: y appears at column 8
    old filter: "x        y"        y at column 9
    new filter: "x       y"         y at column 8 (7 spaces)

  "abcd\ty" (4 chars, tab, y):
    terminal: y appears at column 8
    old filter: "abcd        y"     y at column 12
    new filter: "abcd    y"         y at column 8 (4 spaces)

Also handle multibyte characters via mbtowc/wcwidth for correct column
width calculation with UTF-8. A 2-column wide character (like CJK or
some emoji) followed by a tab needs 6 spaces to reach column 8, not 7.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The diffstat regex was more permissive than necessary, matching any line
starting with space containing " | " followed by a number.

Add end-of-line anchor and require the full diffstat format:
  - Binary: "Bin <num> -> <num> bytes" at end
  - Regular: number followed by optional +/- characters at end

Valid diffstat lines:
  " file.c | 10 +++---"
  " renamed.txt | 0"
  " image.png | Bin 0 -> 1234 bytes"

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Check for diff meta lines before +/- diff content when rendering quoted
text. The "+++ b/file" line was incorrectly rendered as a diff addition
because startswith("+") matched before the diff_meta_re check.

Previously in a quoted diff:
  > --- a/file.c     rendered with quote style + bold (correct)
  > +++ b/file.c     rendered as diff addition (wrong, green)

Now both render as bold with the quote color, same as unquoted diff
meta lines.

Fixes: c0e1bb1e0b ("colorize: highlight diffstat summary lines")
Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Using (v)split on Darwin suffers from frequent rerendering of message
content [1] due to repeated fsevent notifications. Prior to this patch aerc
subscribes to fsevents at a file level granularity (fsevents.FileEvents
flag).

Apple warns that setting this flag "will generate significantly more
events" [2]. The Go fsnotify/fsevents package speculates that this is
due to file events "don't coalesce as easily as directory-level events"
[3], which is the default.

This patch removes the fsevents.FileEvents flag when setting up fsevent
monitoring, which returns to the default behaviour of subscribing to
events at the directory granularity level.

[1] https://lists.sr.ht/~rjarry/aerc-discuss/%[email protected]%3E
[2] https://developer.apple.com/documentation/coreservices/1455376-fseventstreamcreateflags/kfseventstreamcreateflagfileevents
[3] https://pkg.go.dev/github.com/fsnotify/fsevents#readme-file-events

Signed-off-by: Maarten Aertsen <[email protected]>
Acked-by: Robin Jarry <[email protected]>
On wide screens, it is common to have aerc running in a wide window. In
that case, the message viewer and the composer aligned to the left leave
the user looking at the side of the window for long periods of time,
which can be tiresome if the window sits on a side of the screen.
Introduce an option to allow the message viewer and the composer to be
centered on the window by setting a fixed width for them and padding
both sides with empty space.

Changelog-added: The editor and the message viewer can now be centered
 on screen using a fixed width.
Signed-off-by: inwit <[email protected]>
Tested-by: Antonin Godard <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Since commit 64a2dd30ba ("compose: validate message before starting
SMTP transaction"), the message is first written into a bytes.Buffer
before being sent. The buffer contents are then sent via io.Copy to the
SMTP sender and subsequently copied again to the copy-to-folder buffer.

However, bytes.Buffer is a stream: io.Copy drains it entirely when
sending to SMTP. The second io.Copy then reads from an already-empty
buffer, resulting in an empty message being appended to the sent folder.

Use msgBuf.Bytes() to populate the copy buffer before draining it into
the SMTP sender. bytes.Buffer.Bytes() returns the unread data as a slice
without consuming it, so the buffer remains intact for the subsequent
io.Copy.

Fixes: 64a2dd30ba ("compose: validate message before starting SMTP transaction")
Reported-by: Bence Ferdinandy <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Bence Ferdinandy <[email protected]>
newSmtpSender() returned the io.WriteCloser from conn.Data() instead of
the smtpSender wrapper. Callers would only close the data writer without
ever calling Quit() or Close() on the underlying SMTP connection,
leaking it.

Return the smtpSender object so that its Close() method properly
terminates the SMTP session. Also send QUIT before closing since some
servers hang when the client disconnects without it. If Quit() fails,
fall back to a raw Close().

Fixes: 67923707ff ("Refactor send command")
Signed-off-by: Robin Jarry <[email protected]>
Tested-by: septante <[email protected]>
Acked-by: septante <[email protected]>
The deferred w.w.Close() caused the underlying writer to always be
closed twice: once via defer and again with the explicit return at
the end. For the SMTP sender this results in calling Quit() on an
already-closed connection.

Remove the defer and instead call w.w.Close() explicitly in each
error path so that the connection is closed exactly once.

Also fix a write error that was silently discarded (return nil instead
of return err).

Fixes: cb1c4c9c62 ("send: ensure crlf line endings")
Signed-off-by: Robin Jarry <[email protected]>
Tested-by: septante <[email protected]>
Acked-by: septante <[email protected]>
Without this, timezones written in UTC time with the Z suffix appear
with no timezone at all, and therefore show misleading information.

Signed-off-by: Lydia Sobot <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Per https://pubs.opengroup.org/onlinepubs/9799919799/functions/fscanf.html:

  If a '-' is in the scanlist and is not the first character, nor the
  second where the first character is a '^', nor the last character, the
  behavior is implementation-defined.

The scanset [_-*] places a hyphen between '_' and '*', which POSIX
treats as a character range. Since '_' (0x5F) > '*' (0x2A), the range is
implementation-defined; glibc and musl seem to silently accept it, while
macOS libc matches nothing. This breaks parsing of style names
containing '_' or '*', causing silent fallbacks to compiled-in defaults.

Fix by reordering the scanset to [*?_-], placing the hyphen last where
POSIX guarantees it is treated literally.

Fixes: c156b255fc ("colorize: accept wildcards in styles")
Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
MB_CUR_MAX is correctly defined as size_t on Linux but is defined as an
int on macOS. Cast to size_t to silence -Wsign-conversion warning in the
mbtowc call.

Fixes: 1e5a3097f8 ("colorize: fix tab expansion to respect column position")
Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The URL regex was not matching email addresses containing '=' in the
local part. Only the portion after '=' was being colorized.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Use cat -vte to reveal non-printing characters, tabs, and line endings
in diff output when a test fails. This makes it much easier to diagnose
issues with invisible whitespace or control characters in filter output.
Also colorize the diff (red/green/cyan).

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The draw function takes x and y as the position to start drawing from.
The previous variable was named `size` and it's value was the
size of the header drawn before the value eg. "From:", "To:" etc.

More appropriate name would be `xpos` as that's what the variable really
represents, it just happens to be size when we initialize it. This makes
the code much more readable as we change it to draw the 'Real Names' and
'Emails' with different colors/styles.

Signed-off-by: Sahil Gautam <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Now the user is able to customize the recipients name, email, subject
and date headers style in the message viewer's header by customizing the
'realname', 'email', 'subject' and 'date' style objects respectively.

Draw individual components of header fields according to the configured
styleset.

Changelog-added: New styleset objects available to customize special
 headers in the message viewer.
Signed-off-by: Sahil Gautam <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Avoids showing dynamic folder when using <tab> to autocomplete folder
name. In the UI the dynamic folder is indistinguishable from the desired
folder as it has a space appended to it.

Signed-off-by: Peter Sanchez <[email protected]>
Acked-by: Robin Jarry <[email protected]>
I am using a split for my GMail account, and can super easily get the
UI to be unresponsive by aggressively scrolling down the message list.

The problem is that if FetchBodyPart's context gets cancelled in the
middle of processing, the UI will never get a MessageInfo, and be stuck
forever.

This patch makes sure that the context we pass to FetchBodyPart is not
cancellable.

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Some emails contain malformed MIME parts with invalid content
disposition headers or broken nested structures. Previously,
ParseEntityStructure would fail the entire parsing operation when
encountering such issues, making the whole message unreadable.

Instead of returning an error, log a warning and continue parsing
the remaining parts. This allows users to still read the valid
portions of a message even when some parts are malformed. Only
propagate MultipartError which indicates a fundamental structural
issue that cannot be recovered from.

Signed-off-by: Robin Jarry <[email protected]>
This allows links to be selected using e.g. fzf:
:menu -lc fzf :open-link

Changelog-added: `:menu` commands within a message view can be supplied
 with the links extracted from the message using the `-l` flag.
Signed-off-by: Luke Adams <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Add a new :repeat command that will:

- Repeat the last executed command (:)
- If last command was :repeat, it will continue searching for the
  last non :repeat command, to avoid getting caught in an infinite loop.
- It won't repeat commands executed via keybinds defined in `binds.conf`

Changelog-added: New `:repeat` command.
Signed-off-by: Francesc Elies <[email protected]>
Tested-by: Inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Add a new :toggle-folder command that toggles the expand/collapse state
of a folder in the directory tree view. This provides a convenient
single command alternative to using :expand-folder and :collapse-folder
separately.

The toggle behavior is consistent with existing commands:
- For folders with children: toggles the folder's own hidden state
- For leaf nodes: toggles the parent folder (same as collapse)
- For root nodes without children: no-op (nothing to toggle)

Also add comprehensive unit tests for collapse, expand, and toggle
folder operations covering top-level, nested, and deeply nested folders.

Changelog-added: `:toggle-folder` command to toggle directory tree
 expand/collapse state.
Signed-off-by: Arjuna Del Toso <[email protected]>
Tested-by: Inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Since glibc 2.43, strchr is a const-preserving macro when building in
C23 mode. It returns a const pointer when given a const input, which
causes a type mismatch when assigning the result to a non-const pointer.

This was introduced in glibc commit cd748a63ab1a ("Implement C23
const-preserving standard library macros") where strchr, along with
other standard library functions, gained _Generic-based macro wrappers
that preserve const-qualification of the input pointer.

Replace the manual strchr/null-terminate/advance pattern with strtok
which handles comma-delimited tokenization directly and avoids the
const-correctness issue.

Link: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cd748a63ab1a
Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
This is a redo of 194365b9, that uses LIST (not LIST-STATUS) to properly
discover the list of mailboxes. The goal was to properly get the role of
each mailbox, and fully support the `restrict-deletes` functionality
(incidentally it also fixes mailbox listing for Strato); it was lost via
8a151bac.

This patch reinstates this and then uses LIST-STATUS (if it's supported)
to get each mailbox's UIDVALIDITY.

Fixes: 8a151bac ("models: add validity identifier to Directory structs")
Reported-by: post <[email protected]>
Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Take into account the fact that names can have Unicode characters wider
than one cell and that they can be 1-4 bytes wide. So instead of using
the byte position, move `xpos` forward by the cell width of the rendered
character.

Fixes: cb2ea2be ("viewer: add support for special headers styling")
Signed-off-by: Sahil Gautam <[email protected]>
Tested-by: Inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Replace the explicit database path and config file in the source URL
with automatic discovery via libnotmuch (environment variables
NOTMUCH_CONFIG, NOTMUCH_DATABASE, NOTMUCH_PROFILE and XDG conventions).
The source URL hostname is now interpreted as an optional profile name:

    source = notmuch://
    source = notmuch://work

Replace the maildir-store path option with an enable-maildir boolean
(default: true). The maildir root is now always obtained from the
notmuch API via notmuch_config_get(NOTMUCH_CONFIG_MAIL_ROOT) instead
of being specified manually.

Deprecation warnings are emitted when old-style source URLs with
database paths or the maildir-store option are detected in
accounts.conf. Legacy database paths are identified by checking if
the URL hostname+path resolves to an existing file or directory on
disk; if it does not exist, it is treated as a profile name.

The account wizard no longer shells out to "notmuch config get" to
pre-fill the database path. The server field now accepts an optional
profile name instead.

Remove dead code from lib/notmuch/ related to database and config paths.

Implements: https://todo.sr.ht/~rjarry/aerc/325
Changelog-changed: The notmuch maildir-store option has been replaced
 by enable-maildir (default: true). The maildir root is always obtained
 from the notmuch database configuration.
Changelog-changed: The notmuch source URL no longer accepts an explicit
 database path or config query parameter. Database and configuration
 are now discovered automatically. An optional profile name can be
 specified as the URL hostname.
Changelog-deprecated: The notmuch maildir-store option and explicit
 database paths in the source URL now emit deprecation warnings.
Signed-off-by: Robin Jarry <[email protected]>
Tested-by: septante <[email protected]>
Acked-by: septante <[email protected]>
Do not assume "plain" is the default authentication mechanism. If no
mechanism is explicitly set in the connection URI, return an empty
string. The IMAP worker already falls back to "login" if "plain" is not
supported by the server.

Fix the "login" fallback in the IMAP worker to issue an IMAP LOGIN [1]
command instead of a SASL AUTHENTICATE [2] command. This is necessary
because the server may not advertise LOGIN as a separate AUTH
capability.
If, however, the server explicitly advertises the LOGINDISABLED
capability do not fall back to LOGIN, because [1] states:

  A client implementation MUST NOT send a LOGIN command if the
  LOGINDISABLED capability is advertised.

[1]: https://www.rfc-editor.org/rfc/rfc3501#section-6.2.3
[2]: https://www.rfc-editor.org/rfc/rfc3501#section-6.2.2

Fixes: 018e6f81f4 ("lib: consolidate SASL authentication code")
Signed-off-by: Folker Schwesinger <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The fix in a14dacb36f needs to be made in more places, so that we don't
cancel the context used when accessing the IMAP server (even for
instance if the user views another folder).

Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When vaxis receives SIGTERM, it posts a QuitEvent via a non-blocking
send which can be silently dropped if the event queue is full. Even when
delivered, aerc's HandleEvent never matches QuitEvent so the signal is
ignored. The main loop stays stuck in its select forever.

This was lost in the tcell to vaxis migration. With tcell,
ChannelEvents() was tied to the Quit channel and signals caused aerc to
exit properly.

Register SIGTERM and SIGINT directly and call Exit() to close the Quit
channel, allowing the main loop to break out and perform a clean
shutdown (closing backends, running the aerc-shutdown hook, restoring
the terminal).

Fixes: 0fd5f41157 ("ui: initialize vaxis directly, drop tcell.Screen initialization")
Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
The :tag/:modify-labels command produces a terse message in the status
bar ("labels updated"). Change that message to inform the user not only
that the tags have been changed but also about the specific changes
performed. Use the alias "tag" or "label" in accordance to the user's
choice.

Signed-off-by: inwit <[email protected]>
Tested-by: Simon Martin <[email protected]>
Reviewed-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Re-add leading zeroes to message UIDs to fix sorting for the IMAP
backend.

Fixes: e9852a2558 ("imap: include directory and validity in message UIDs"
Reported-by: Jens Grassel <[email protected]>
Reported-by: Terrance <[email protected]>
Signed-off-by: Folker Schwesinger <[email protected]>
Tested-by: Jens Grassel <[email protected]>
Tested-by: Terrance <[email protected]>
Valgrind is rather pedantic about what it considers memory "leaks". On
exit, even memory chunks that were allocated with malloc and are still
referenced by static symbols are considered leaked.

Free every regex and dynamically allocated escape sequence.

Link: https://builds.sr.ht/~rjarry/job/1713008#task-validate-85
Reported-by: Julio B <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Julio B <[email protected]>
This mirrors imaps+insecure:// by making the SMTP connection with
TLS/SSL but skipping certificate verification.

Signed-off-by: Terrance <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The "Checking for new mail..." status message is visible for a split
second and then it disappears. Don't send the default Done message for
CheckMail actions. When the command exits a message is sent by
handleCheckMail().

Fixes: e54ba517 ("notmuch: centralize error and response handling")
Signed-off-by: Julio B <[email protected]>
Tested-by: Inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
As discussed in the following ML thread:

https: //lists.sr.ht/~rjarry/aerc-discuss/%[email protected]%3E
Signed-off-by: Josh Holland <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
`:archive month` fails when used with maildir protocol if parent dirs
missing:

 ERROR [...] worker.go:629: could not create directory Archive/2026/01: mkdir [...]/Archive/2026/01: no such file or directory
 ERROR [...] account.go:523: unexpected error: mkdir [...]/Archive/2026/01: no such file or directory

This could have been solved in go-maildir directly but the maintainer
doesn't seem sure about it.

Link: https://github.com/emersion/go-maildir/issues/27
Signed-off-by: Francesc Elies <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Make it possible to bind dash ("-", aka hyphen-minus) to a function

Signed-off-by: Daniel Lublin <[email protected]>
Tested-by: Francesc Elies <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Unfold RFC 6350 continuation lines before parsing. Without this,
properties with long parameter lists like EMAIL are split across
lines and fail to match. Also handle FN fields with parameters
(e.g. FN;DERIVED=TRUE:Name) which were previously skipped by the
exact "FN:" prefix check.

For example, the following vCard was not parsed correctly:

    BEGIN:VCARD
    EMAIL;PROP-ID=364320a92d58a502b191d9f8430d0ffacb471a24;PREF=1;
     TYPE=HOME,PREF:[email protected]
    FN;DERIVED=TRUE:Joe Smith
    END:VCARD

The EMAIL line is folded (continuation line starts with a space) and
the FN line has a parameter. Both were silently ignored.

Changelog-fixed: `carddav-query` now correctly parses vCard contacts
 with folded lines and parameterized properties.
Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Increase the version to check for potential new findings. There were
none.

Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
In the previous template, having a body with no signature causes
the body to be inserted directly after the headers, causing it to be
interpreted as a header itself. This could be a security concern, as a
malicious mailto link could try to set arbitrary mail headers. From a
usability vantage point, it causes the first line of the body to not be
visible or editable as part of the body.

Multiple body parts are now joined with CRLF.

The body is now available in TemplateData, and is inserted above the
signature rather than below it.

Signed-off-by: Taylor C. Richberger <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Marking read and unread mail currently involves manual filtering, which
can be a quite bothersome approach when working with large amounts of
mail. Add new -u (unread) and -U (read) flags to filter by. These can
be combined with -r, -s, and subject-based filtering allowing for calls
like:

    :mark -U -s bence

To mark all read messages from Bence.

Changelog-added: Added `-u` and `-U` to the mark command to mark
 messages based on read-status.
Suggested-by: andyrtr
Signed-off-by: Moritz Poldrack <[email protected]>
Tested-by: Andreas Radke <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Since the iterator pattern was still new at the time, the filtering was
implemented "incorrectly", as it did not follow the proper™ way it was
intended to be used, leading to unnecessary overhead. Apply the correct
pattern to the functions and simplify the command code.

Signed-off-by: Moritz Poldrack <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Update the default config comments.

Fixes: f0769d3309 ("compose: read VISUAL before EDITOR")
Signed-off-by: Erin John <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Generative AI is a technical, ethical, and political nightmare and its
use directly supports the growing tide of fascism worldwide. I don't use
slopware and it'd be a shame if aerc went down that path.

Signed-off-by: Drew DeVault <[email protected]>
Acked-by: Jens Grassel <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Some minor proofreading.

Fixes: 6ea0856404 ("doc: improve aerc-templates examples")
Fixes: d7954c2ba6 ("style: add back support for valid header patterns")
Signed-off-by: septante <[email protected]>
Reviewed-by: Inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The first line under the heading 'commenting' should talk about
comments, not functions.

Signed-off-by: Sahil Gautam <[email protected]>
Reviewed-by: Inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Looks like this has been busted since the scrollbar patch in 2023-10.
That patch short-circuited most of the computation in PartSwitcher.Draw
for the easy case of single-part messages (when the switcher is not
forced), but in so doing left the switcher properties "height" and
"offset" at their default zero values.  Since "offset" (from the top) is
later used to decide to which widget (part or switcher) mouse events
should be routed, the result was that, when the switcher was not shown,
mouse events would be always considered to fall in the (non-existent)
switcher and never routed to the part viewer/terminal (e.g. the pager).

Make the "offset" equal the full height of the subwindow in those cases
so all events fall into the part viewer.

Fixes: 14baf17f4b ("switcher: add scrollbar")
Changelog-fixed: Mouse works again in the message viewer when the
 switcher is not shown.
Signed-off-by: septante <[email protected]>
Acked-by: Robin Jarry <[email protected]>
In vim/neovim, the default keybind to accept a completion is <C-y>.
aerc seems to use keybinds similar to vim, and being able to scroll
through completion suggestions with <C-n> and <C-p> but not being able
to accept them with vim standard <C-y> feels inconsistent. This change
addresses the inconsistent behavior and adds <C-y> to accept completion.

Changelog-added: In addition of `<Enter>`, `<C-y>` now validates
 completion choices.
Signed-off-by: Sarah H. McGrath <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Pass template environment variables to pager commands, matching the
existing filter behavior.

This enables MIME-aware pager integrations, such as selecting different
Neovim filetypes or rendering pipelines depending on the current message
part.

Signed-off-by: luca <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Add a new `-v` option to :filter and :search, inverting the search
expression and excluding messages which match.  When multiple filters
are applied, each one can be inverted or not.

Search criteria are combined in two halves, Match and Exclude, with
each worker translating those as needed:

- IMAP searches use `NOT` expressions for excluded terms.

- JMAP isn't currently implemented and searches including any exclude
  components will return an error.  From reading the search spec, it
  looks like only keywords can be flipped, rather than headers etc.

- Gmail extension searches use a `-` prefix on each excluded term.

- Notmuch searches use a `not` prefix on each excluded term.

- Raw message searches just apply excludes followed by matches.

Signed-off-by: Terrance <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Maildir flags after the "2," info prefix must be kept in ASCII order.

splitMaildirFile sorted using indexes into the original info string
instead of the parsed flags. Sort the parsed flags directly.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Convert most straightforward sort.Strings, sort.Slice and
sort.SliceStable calls to the slices equivalents.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When piping git patches, messages are sorted by Subject so patch series
are applied in order.

The comparator returned false whenever either side lacked envelope
metadata, leaving those messages in an arbitrary position. Put them
after messages with metadata, and treat two metadata-less messages as
equal.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
ByUID existed only to sort threads by their highest UID. Make that a
method on Thread and sort with slices.SortFunc directly.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Replace sort.Slice with slices.SortFunc and adapt the comparator to the
three-way form.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The local slice goes out of scope right after, there is no point in
clearing it.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Replace sort.Slice with slices.SortFunc and adapt ThreadLess to the
three-way comparator form.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Replace sort.SliceStable with slices.SortStableFunc and adapt callers to
the three-way comparator form.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Sort messages by UID before applying the requested sort criteria.

The later sorting passes are stable, so messages with equal sort keys
keep a deterministic order instead of shuffling between refreshes.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Build the temporary sort-key slices with values instead of pointers, and
keep the helper structs local to the functions that use them.

This avoids one small allocation per message and keeps the data together
while sorting.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Building MessageInfo looks up the same maildir message several times.
Resolve it lazily with loadMsg and keep it on Message instead.

Clear the cache after SetFlags and Remove, since they rename or delete
the file.

Reported-by: septante <[email protected]>
Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
maildir(5) documents the file modification time as the message delivery
date, and files moved from new to cur keep the same mtime, so the
timestamp remains available after the message has been read:
https://manpages.debian.org/stretch/qmail/maildir.5.en.html

Use it as MessageInfo.InternalDate so arrival-based sorting follows the
local delivery time instead of falling back to the Date header. This
also matches some IMAP sync tools, which preserve the IMAP INTERNALDATE
in the file mtime.

Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Add a WorkerInteractor field to the notmuch worker struct, initialized
from the concrete *types.Worker. This allows wrapping the worker to
apply folder name translations during configuration.

All ProcessAction and PostMessage calls are routed through the new field
so that a folder mapper can intercept them. Logging and Actions() remain
on the concrete *types.Worker field since those do not require
translation.

Signed-off-by: inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Allow users to remap physical maildir directory names to custom
display names in the notmuch backend, using the same folder-map
mechanism as imap and maildir.

The folder-map applies only to physical maildir directories. Query-map
and dynamic query folders pass through the folder mapper unchanged:
the middleware skips directory translation for entries with QueryRole.
If a maildir display name collides with an existing query folder name,
the maildir entry takes precedence in the directory store.

Changelog-added: Add `folder-map` support for the notmuch backend.
Signed-off-by: inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Add diff_whitespace background colors to bundled stylesets using each
theme's diff_del color.

Changelog-changed: Bundled stylesets now highlight diff whitespace.
Signed-off-by: Fredrik Foss-Indrehus <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Acked-by: septante <[email protected]>
See [section 4.4.2 of RFC 8621, in particular the documentation for
`hasKeyword` and the example below the section.

Changelog-fixed: Fixed sorting flagged and read messages to the top
 for JMAP.
Signed-off-by: Greenscreener <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Update vaxis from v0.15.0 to v0.16.0. The resize API changed: the
application must now call vx.Resize(ev) when handling a vaxis.Resize
event to resize internal screen buffers.

Fixes: https://todo.sr.ht/~rjarry/aerc/343
Signed-off-by: inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When a JMAP folder has no active search filter, the cached
FolderContents.Filter is nil. Since the SearchCriteria type was
refactored into a pointer, translateSearch dereferences it without
a nil check, causing a panic on every push update.

Add a nil guard before accessing the Exclude field.

Fixes: d9ff08b05f ("search: add option to invert filters/searches")
Signed-off-by: Robin Jarry <[email protected]>
It's possible that we add a very empty MessageInfo to the store in case
of unsolicited messages, with the expectation that it will be enriched
when the message is actually fetched (see comment in msgstore.go:360).

It means that merge() should also merge RFC822Headers, which this patch
does.

Signed-off-by: Simon Martin <[email protected]>
Tested-by: septante <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Acked-by: septante <[email protected]>
When a key is pressed that starts a multi-key binding, show a
floating popover listing possible continuations and their
descriptions. Bindings with annotations display the annotation
text; others fall back to showing the command.

Disabled by default, configurable via keyhint in [ui] section
of aerc.conf. Three new styleset objects are added for theming:
keyhint_default, keyhint_key, keyhint_desc.

Changelog-added: Show a keyhint popup with available keybinding
 continuations when a multi-key binding prefix is pressed.
Signed-off-by: Johnathan <[email protected]>
Tested-by: Inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Introduce WithCenteredGrid struct with methods for reuse in composer and
msgviewer. Extract the grid creation logic into a dedicated buildGrid()
method to prepare for dynamic layout adjustments. Exclude the reviewer
from the centering, since it is in a nested grid.

Reported-by: Antonin Godard <[email protected]>
Co-authored-by: septante <[email protected]>
Signed-off-by: inwit <[email protected]>
Tested-by: Antonin Godard <[email protected]>
Acked-by: Robin Jarry <[email protected]>
If centered-layout-width is bigger than the actual dynamic width of the
window, the message viewer, the composer and the review screen are
currently not shown at all. Properly show all of them also when the
window width is small.

Fixes: 741f93d991 ("ui: allow centering the message viewer and composer")
Changelog-fixed: When centered-layout-width is on and the window
 is too small, the msgviewer, the composer and the reviewer are now
 properly shown.
Reported-by: Antonin Godard <[email protected]>
Signed-off-by: inwit <[email protected]>
Tested-by: Antonin Godard <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When message headers are updated, the message flags (like \Seen) can be
overwritten with empty flags, causing messages to appear as unread even
when they were read.

This is because the merge function in the message store is
unconditionally replacing the flags.

Modify the merge function to no longer handle flag updates.

Introduce new logic in the Update function to handle flags based on
the ReplaceFlags field in the MessageInfo update.

*  If ReplaceFlags is true, replace flags.
*  If ReplaceFlags is false, merge the new flags using a bitwise OR to
   prevent overwriting existing flags.

Add a new test case to verify the correctness of the new flag handling
logic and prevent future regressions.

Signed-off-by: Matěj Cepl <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When recalling a draft without a compose template configured, the
recalled body passed to NewComposer was discarded because addTemplate()
returned early when there were no template readers. Write the body to
the temp file via setContents() so the editor is populated correctly.

Rename addTemplate() to setUpFields() since it no longer always adds
a template.

Remove the readers slice and MultiReader in setUpFields(),
because there is at most one reader.

Rearrange template empty check in setUpFields() to improve readability.

Log a warning for processing old templates that don't parse as an
email.

Changelog-fixed: Fix missing body in the editor when using `:recall`.
Signed-off-by: Bowen Ho <[email protected]>
Acked-by: Robin Jarry <[email protected]>
These tests had drifted significantly and the master branch was
modified. Fix the tests to work with the current master branch.

Fixes: 5f91f4ff7d ("msgstore: preserve message flags on header updates")
Signed-off-by: Robin Jarry <[email protected]>
go get -u -t ./...
	go mod tidy

golang.org/x/* modules all jumped to go 1.25. Bump the min version for
aerc as well. Update CI to run with 1.25.

Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Inwit <[email protected]>
When deleting multiple messages, the IMAP worker posts individual
MessagesDeleted for each ExpungeUpdate from the server. This causes
messages to visibly disappear one by one instead of all at once.

Suppress individual MessagesDeleted posts when the expunge handler is
for a delete operation and post a single batched notification after all
updates have been processed. Make drainCloser wait for its goroutine to
fully exit before returning, ensuring no updates are lost.

Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Inwit <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Appending CRLF bufio.Scanner.Bytes() is not reliable at all. This
function returns a slice to an internal buffer that may contain the rest
of the message (following lines). Appending things to it may modify the
internal buffer, corrupting the rest of it.

Write scan.Bytes() directly without any modification and append the CRLF
line ending in a separate Write call.

Fixes: cb1c4c9c62 ("send: ensure crlf line endings")
Co-authored-by: jp39 <[email protected]>
Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
pruneEmptyContainers recurses into a container's children (case 3) but
never re-checks the container afterwards. If the container is
a placeholder (threadable == nil) and the recursion clears all its
children, it becomes an empty node that remains in the root set.
gatherSubjects then crashes accessing c.child.threadable.

Fix by checking after the recursive call: if the container now has no
threadable and no children, remove it from the parent's list using the
same pattern as case 1.

Fixes: https://todo.sr.ht/~rjarry/aerc/353
Changelog-fixed: Crash when threading maildir messages with references
 that create empty dummy containers in the root set.
Reported-by: Robert Vojta <[email protected]>
Signed-off-by: inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Add support for fenced code blocks (``` delimited) and inline `code`
spans. Fenced blocks switch to a CODE_BLOCK state that applies the code
style to all lines until the closing fence. Inline backtick pairs are
detected in print_inline_code() which is called from urls() for
non-URL text segments, preserving URL detection within code spans.

Add the "code" style object configurable via stylesets, defaulting to
palette index 5. Update all bundled stylesets accordingly.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
The "submissions" service is defined as an alias of "smtps". Add support
for it in the DNS SRV config discovery.

Link: https://www.rfc-editor.org/rfc/rfc8314#section-7.3
Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Markdown allows any number of consecutive backtick characters to
delimit inline code spans, so that literal backticks can appear
inside them. Count the opening backtick sequence length and search
for a closing sequence of exactly the same length.

Also use a proper regex to detect fenced code block start lines and
fix the closing check to require an exact match instead of a prefix
match.

Signed-off-by: Robin Jarry <[email protected]>
Tested-by: Diederik de Haas <[email protected]>
Issue Email/queryChanges calls for all mailboxes as part of the main
handleChange JMAP request instead of in a separate
refreshQueriesAndThreads round trip. This reduces the number of JMAP
calls when processing push notifications.

Move the QueryChangesResponse handler and its associated
MessageInfo/MessagesDeleted posting into handleChange as well. Flush
folder contents from cache on Email/queryChanges errors.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Process mailbox renames, creations and count updates directly inside the
mailbox.GetResponse case instead of collecting IDs and post-processing
them after the response loop. Remove the mboxes map that was populated
from cache before the request.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Populate addedEmails and removedEmails maps from QueryChanges responses
to distinguish genuinely new messages from those that simply changed
within a folder. Use these maps in the email.GetResponse handler to set
the correct Index and RecentFlag on new messages, skip re-posting
messages that were just removed and re-added, and detect messages
removed from mailboxes by comparing old and new MailboxIDs.

Drop the separate emailUpdated/emailCreated call ID tracking since both
cases are now handled uniformly.

This also prepares for eagerly fetching newly added messages in the same
request batch, avoiding an extra round-trip where the UI would have to
discover new UIDs first and then request their headers separately.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Pass the addedEmails map into refreshQueriesAndThreads and fetch all
added emails (from QueryChanges) alongside thread emails in a single
Email/get call. This saves the UI round trip to fetch message headers
from new IDs.

Apply the same MailboxIDs-comparison and Index/RecentFlag logic as in
handleChange so that newly added messages are posted with correct
metadata.

Remove the HasEmail cache check that skipped already-cached emails since
added emails need to be re-fetched to get their current state.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Log mailbox deletions, message deletions, message updates and message
additions at info level to aid debugging of push notifications.

Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
The query builder is copied from translate() to translatePart(), meaning
all the query construction happens on a copy which is thrown away.

Pass a pointer to the builder so that changes are actually applied, and
add some basic tests for a couple of queries.

Fixes: d9ff08b05f ("search: add option to invert filters/searches")
Signed-off-by: Terrance <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Remove legacy mailing list. It is probably time to do so. Do not leak
local hostname in message ID.

Signed-off-by: Robin Jarry <[email protected]>
The vaxis module path changed from git.sr.ht/~rockorager/vaxis to
go.rockorager.dev/vaxis starting with v0.17.0. Update all imports
accordingly.

Signed-off-by: inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When inherit-host-tty-features is enabled in [general], the embedded
terminal is initialized with a reference to the host vaxis instance.
This enables the embedded terminal to negotiate advanced keyboard
protocols with child processes, allowing disambiguation of modified keys
(e.g. Ctrl+Backspace is no longer aliased to C-h). It also enables
hyperlink support (OSC 8), clipboard integration (OSC 52), inline image
display, and foreground/background color queries (OSC 10/11) for child
processes. This only has an effect when the host terminal supports the
relevant protocols.

Changelog-added: New `[general].inherit-host-tty-features` config
 option enabling advanced keyboard protocol negotiation, hyperlink
 support (OSC 8), clipboard integration (OSC 52), inline image display,
 and color queries (OSC 10/11) for embedded terminal child processes.
Changelog-deprecated: The `[general].enable-osc8` config option has
 been superseded by `[general].inherit-host-tty-features`.
Signed-off-by: inwit <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Add -l flag to extract the List-Post header to use as the recipient.

Changelog-added: Added `-l` switch to `reply` for replying to a
 mailing list address.
Signed-off-by: Andrew Kloet <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Let's change that so that contrib/check-patches is happy.

Signed-off-by: Robin Jarry <[email protected]>
~$ contrib/git-stats.sh 0.21.0..0.22.0
Author                     Commits  Changed Files  Insertions  Deletions
Robin Jarry                     76            383       +3734      -2967
Fredrik Foss-Indrehus           29             65        +498       -286
Simon Martin                    16             19        +110        -72
Inwit                           13             81        +519       -332
Sahil Gautam                     4              6         +67        -13
Terrance                         4             22        +430        -55
Tristan Partin                   4              5         +29        -13
Damien Tardy-Panis               3              3         +26        -14
Francesc Elies                   3             11         +78         -1
Matěj Cepl                       3              4         +75         -2
Moritz Poldrack                  3              4        +174       -175
Folker Schwesinger               2              4         +38        -13
Matthew Phillips                 2              4        +143        -48
septante                         2              4          +5         -4
Aedin Joseph                     1              1          +5         -2
Andrew Kloet                     1              3         +18         -1
Arjuna Del Toso                  1              6        +596         -8
Bence Ferdinandy                 1              3         +11        -12
Bowen Ho                         1              1         +17        -16
Daniel Lublin                    1              2          +5         +0
Drew DeVault                     1              1         +14         +0
Ensar Sarajčić                   1              1          +2         -2
Erin John                        1              1          +1         -1
Gary Guo                         1              1          +6         -2
Greenscreener                    1              1          +4         +0
Johnathan                        1              8        +508        -16
Josh Holland                     1              2          +5         -4
Julio B                          1              1          +3         +0
Luke Adams                       1              2         +17         -1
Lydia Sobot                      1              2          +5         -2
Maarten Aertsen                  1              1          +1         -1
Marco Munizaga                   1              2         +47         -4
Markus Schneider-Pargmann        1              1         +21         -8
Nilesh Patra                     1              1          +1         -1
Peter Sanchez                    1              1          +2         +0
Rex Fernando                     1              3         +56        -19
Sarah H. McGrath                 1              1          +1         -1
Taylor C. Richberger             1              8         +37        -11
Tim Culverhouse                  1              2          +3         -3
Yutaro Ohno                      1              1          +1         -1
cos                              1              5         +72        -19
laalsaas                         1              1          +2         -2
luca                             1              2         +20         +0

Reviewer/Tester   Commits
Robin Jarry           115
Simon Martin           35
Tristan Partin         16
Inwit                  13
Bence Ferdinandy       12
Antonin Godard          8
septante                5
Julio B                 3
Jens Grassel            2
Matthew Phillips        2
Andreas Radke           1
Diederik de Haas        1
Francesc Elies          1
Matěj Cepl              1
Moritz Poldrack         1
Paul W. Rankin          1
Terrance                1

Signed-off-by: Robin Jarry <[email protected]>
Debian passes CPPFLAGS to the build and not adding them causes blhc
checks to fail.

Current CPPFLAGS passed are:

$ dpkg-buildflags --get CPPFLAGS
-Wdate-time -D_FORTIFY_SOURCE=2

Signed-off-by: Nilesh Patra <[email protected]>
Acked-by: Robin Jarry <[email protected]>
This will make future changes easier to review.

Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
In a few places around the codebase, we had the same pattern of creating
a slice of paths pointing to specific resource directories. Let's use
a function to encapsulate the logic.

Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
We described filter execution differently than hook execution in the
documentation. Let's rectify that to make it easier for users to
understand.

Changelog-fixed: Clean up hook execution documentation.
Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
When executing filters, we add the various filters subdirectories of our
search directories. However, we were not doing the same for hooks. By
searching for hooks in the subdirectories, users can keep their `PATH`
a bit cleaner and hook can be looked up by name without the user needing
to do their own `PATH` manipulation.

Changelog-added: Hooks are now also searched in
 `${XDG_CONFIG_HOME:-~/.config}/aerc/hooks`,
 `~/.local/libexec/aerc/hooks`,
 `${XDG_DATA_HOME:-~/.local/share}/aerc/hooks`,
 `$PREFIX/libexec/aerc/hooks`, `$PREFIX/share/aerc/hooks`,
 `/usr/libexec/aerc/hooks`, `/usr/share/aerc/hooks`.
Co-authored-by: Robin Jarry <[email protected]>
Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
This style of code was suggested by Robin, and it does seem to clean
things up.

Co-authored-by: Robin Jarry <[email protected]>
Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The codeset pointer returned by nl_langinfo_l() may be invalidated by
freelocale(). Evaluate the result before freeing the locale object.

Fixes: d3288e6359 ("wrap: use nl_langinfo to get locale codeset")
Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
wcwidth() and wcswidth() return -1 when encountering non-printable
wide characters. Casting that to size_t wraps to SIZE_MAX, breaking
all margin arithmetic. Use wrapper functions that clamp negative
return values to zero.

Fixes: 99bc69918e ("wrap: fix wide CJK characters support")
Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
The filter Env is no longer initialized with the parent process
environment. This causes filter subprocesses to run without essential
variables like LANG or LC_*, breaking locale detection.

Fixes: 2aeb43e190 ("filters: match PATH manipulation with similar hook execution code")
Signed-off-by: Robin Jarry <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
The mbox search helpers SearchMessage and GetRequiredParts receive a nil
SearchCriteria when no filter is active, but don't check for this before
trying to access the inner SearchCriteriaPart fields.

Add further nil checks against the top-level criteria.

Fixes: d9ff08b05f ("search: add option to invert filters/searches")
Signed-off-by: Terrance <[email protected]>
Acked-by: Robin Jarry <[email protected]>
golangci-lint needed a new release for Go 1.27, which Alpine Edge now
ships.

Signed-off-by: Tristan Partin <[email protected]>
Tested-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
aerc ended up in an infinite loop trying to fetch the headers for a
message that somehow confused go-imap.

While I can't reproduce, it looks like 6dc701a2a introduced a regression
in case of error when fetching any message's headers: we used to still
post a MessageInfo for all messages (possibly reporting an error), while
we don't anymore... and will retry right away.

This patch fixes this.

Fixes: 6dc701a2a ("imap: centralize error and response handling in Run loop")
Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The bot is now denied anonymous access to the /raw endpoint of
lists.sr.ht with a "418 I'm a teapot" error, so it can no longer
download the raw message to find the applied patch subject and
submitter.

Include the thread root headers directly in the EMAIL_RECEIVED webhook
GraphQL query. The message-id, subject and sender are then read from the
payload without any extra HTTP round trip.

Signed-off-by: Robin Jarry <[email protected]>
In `73a9eaa3bdacf576895ee536a69f98c6b8c84cc8`[0], we started making the
pager environment an alias to the filter environment when the pager was
not the same as the filter. Later on, we append `COLUMNS`/`LINES` to
`filter.Env`.

Because `os.Environ()` typically leaves spare capacity in the backing
array, appending `COLUMNS` and then `LINES` onto `filter.Env` usually
does not need to reallocate; it writes in place into the same backing
array that `pager.Env` still points to, just past `pager.Env`'s own
length. When the pager is later started via `term.Model.StartWithSize()`,
vaxis appends[1] `TERM` to the pager's environment. Since `pager.Env`'s
length was never updated to account for the later `filter.Env` appends,
that `TERM` append lands in the exact same backing array slot as the
`COLUMNS` entry, silently overwriting it. `LINES`, appended one slot
further, is unaffected, which is why only `COLUMNS` went missing.

Fix this by clamping `pager.Env`'s capacity to its current length with a
three-index slice expression, so that any later append to `pager.Env`
is forced to allocate a new backing array instead of writing into
`filter.Env`'s reserved space.

Link: 73a9eaa3bd [0]
Link: 08d2ed0bce/widgets/term/term.go (L214-L218) [1]
Changelog-fixed: The COLUMNS shell variable is now consistently
 available for use in filters. This was a regression in 0.22.0.
Signed-off-by: Tristan Partin <[email protected]>
Tested-by: Marco van Hulten <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Notmuch is not picky about what characters it allows in the names of
profiles, but URL parsing is picky. For example, my notmuch profiles
include the @ symbol, which causes the URL parser to split them into the
user and host portion of the URL.

Skip the parsing for notmuch account source strings and simply treat
everything after "notmuch://" as the profile name instead, matching what
the docs say.

Changelog-fixed: Allow any character in the name of a notmuch profile.
Signed-off-by: Jason Cox <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The update makes the maildir backend automatically refresh the current
message list after checking the mail. Without the patch, the message
counter is updated in the top bar, but the list stays intact and doesn't
show the new messages. The patch aligns the maildir backend with the
other ones that do the same.

Changelog-fixed: Messages are displayed immediately when manually
 checking a maildir mailbox.
Signed-off-by: Vitaly Ovchinnikov <[email protected]>
Acked-by: Robin Jarry <[email protected]>
`set_stdio_encoding()` assumed `setlocale(LC_ALL, "")` returns NULL when
`LANG`/`LC_ALL` are unset, and only fell back to "C.UTF-8"/"UTF-8" in
that case. In practice, POSIX libc implementations return the non-NULL
string "C" in that situation, so the fallback was never taken. "C"'s
codeset is US-ASCII, so wrap exited with:

	error: locale 'C' is not UTF-8

Add `locale_supports_utf8()` to check the actual codeset instead of just
checking for NULL, and use it to gate every step of the fallback chain,
including the final result. This also fixes the same failure when `LANG`
names a real but non-UTF-8 locale (e.g. `LANG=en_US.ISO8859-1`), which
previously skipped the fallback entirely instead of trying
"C.UTF-8"/"UTF-8".

Changelog-fixed: Fix wrap filter when `LANG` or `LC_ALL` are
 unset. Previously it would error out.
Signed-off-by: Tristan Partin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
This change joins the folder name with the maildir root before creating
the parents.

Fixes: 90c0cd1519 ("maildir: fix error when using archive month")
Fixes: https://todo.sr.ht/~rjarry/aerc/354
Link: https://github.com/emersion/go-maildir/issues/27
Changelog-fixed: Folders are no longer created in aerc's current
 working directory when using `copy-to` or `:archive`.
Signed-off-by: Markus Unkel <[email protected]>
Acked-by: Robin Jarry <[email protected]>
The Item* event flags are only reported by fsevents when the stream is
created with the FileEvents flag. Since that flag was removed, macOS
delivers directory granularity events with none of those flags set, and
the switch dropped every single one of them. No watcher event ever
reached the maildir and notmuch workers, so new mail only showed up
after reopening a folder or restarting aerc.

Report a change for every event and only refine the operation when the
Item* flags are present. Both consumers use the event as a rescan
trigger and ignore its contents, and they debounce for 50ms, so the
coalescing gained by dropping FileEvents is preserved.

Fixes: e4586b7910 ("watchers: remove fsevents.FileEvents flag on Darwin")
Changelog-fixed: New messages are detected again on macOS without
 reopening the folder.
Signed-off-by: Micah Duke <[email protected]>
Tested-by: Maarten Aertsen <[email protected]>
Tested-by: Micah Duke <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Do not use go-message functions to parse Message-ID, References and
In-Reply-To headers. These functions are very pedantic about RFC
compliance which leads to insane slowdowns when aerc deals with non
RFC-compliant emails.

Use a broad regular expression to match anything that looks like
a message ID. The added lenient functions cannot fail.

Signed-off-by: Robin Jarry <[email protected]>
Simon has been a consistent and reliable contributors for the last few
releases and I could really use the help :)

Signed-off-by: Robin Jarry <[email protected]>
Acked-by: Inwit <[email protected]>
Acked-by: Simon Martin <[email protected]>
Casing of the format=flowed parameter is ambiguous. Even on the RFC3676,
we can see it being referred to as both Format=Flowed and format=flowed
in multiple places. This probably means that the parameter is case
insensitive and it shouldn't really matter, but for aesthetic purposes
it is proposed to be changed to lowercase. This is a bit more common for
the values/parameters of MIME Content-Type headers.

This will also match the implementation of other MUAs like mutt,
thunderbird and mblaze. The current test data that come with aerc all of
them seem to use the lowercase variant too.

Link: https://www.rfc-editor.org/rfc/rfc3676.txt
Signed-off-by: Loukas Agorgianitis <[email protected]>
Acked-by: Simon Martin <[email protected]>
Supported source types include mbox files, but this isn't documented
outside of reading a mailbox file from the command line.

Add man page aerc-mbox with a brief summary, and references to it in
other relevant man pages.

Signed-off-by: Terrance <[email protected]>
Reviewed-by: septante <[email protected]>
Acked-by: Simon Martin <[email protected]>
He uses Proton, that strips all but a handful of headers, so his emails
will never have X-Sourcehut-Patchset-Update.

Signed-off-by: Simon Martin <[email protected]>
Normalize several configuration comments to a common format.
The proposed format is the following:

    # This is the description of an option that can be arbitrarily long
    # and for readability purposes can span multiple lines or paragraphs
    #
    # Default: foo
    #sample-option=foo

Most of the configuration comments already conform to the above format,
empty comment lines are trimmed/added for the ones that don't.
Alignment for some example values is also normalized to be consistent.
Casing mismatch for default configuration keys in templates section is
also fixed.

Signed-off-by: Loukas Agorgianitis <[email protected]>
Acked-by: Simon Martin <[email protected]>
With 5f91f4ff7d, message flags are essentially only updated in the
message store if the ReplaceFlags field is set. The IMAP backend sets
this flag correctly when `:flag` triggers a flag update, but all other
backends relied on the old behavior where flags were unconditionally
updated. This caused a regression where these backends no longer update
the UI correctly after running `:flag` and friends.

Set the ReplaceFlags field in these cases, which should be safe for both
mbox and maildir. The JMAP backend also only triggers the MessageInfo
update once it *knows* that the operation succeeded (just as IMAP does
based on 4cfc71b1be), so the change should be safe for JMAP as well.

Fixes: 5f91f4ff7d ("msgstore: preserve message flags on header updates")
Link: https://lists.sr.ht/~rjarry/aerc-discuss/%[email protected]%3E
Changelog-fixed: Flag changes through `:flag` et. al. are now correctly
 reflected in the UI again for non-IMAP backends.
Reported-by: Philippe SWARTVAGHER <[email protected]>
Co-authored-by: Jason Cox <[email protected]>
Signed-off-by: Simon Sigurdhsson <[email protected]>
Acked-by: Simon Martin <[email protected]>
The notmuch worker applies flag and tag changes to the database but
never tells the UI about them. The message store keeps the MessageInfo
it cached when the message was first listed, so a message that has just
been read keeps its unread styling and a message that has just been
tagged keeps its old labels, until aerc is restarted. Re-opening the
folder does not help either, since the cache is keyed by uid and
survives a new query.

Post the updated MessageInfo from handleFlagMessages() and
handleModifyLabels(), as the imap worker already does. ReplaceFlags is
set when reporting flags so that clearing one works: the store ORs
flags together otherwise, which would make setting a flag work while
clearing it silently did nothing.

Changing tags can also take a message out of the current query. Adding
one listed in exclude-tags is the obvious case, but removing a tag the
query selects on does it just as well, and folder queries are arbitrary
notmuch queries. Testing only the added tags against exclude-tags would
therefore miss removals, so after modifying tags the folder query is
re-run restricted to the affected messages and MessagesDeleted is
posted for those that no longer match. The query is batched so that
tagging a large selection stays a handful of queries rather than one
per message.

Changelog-fixed: Messages in the `notmuch` backend now update
 immediately when they are read or when their tags change, instead of
 keeping their previous appearance until aerc is restarted.
Signed-off-by: Jérémy Pagé <[email protected]>
Acked-by: Simon Martin <[email protected]>
Tested-by: Inwit <[email protected]>
Commit 6052a2f785 ("maildir: cache message lookups") introduces a message
lookup cache after a Message object is created. However, the cache is
ineffective because each c.Message() invocation creates a new object.

Add an another cache that maps UID to Message objects at the Container
level. The cache is built both when calling Message() and when calling
UIDs(). The latter results in key performance improvement, as both
MessageFromKey() and Messages() require walking the maildir directory and
are O(n), so by populating the cache in UIDs(), the total complexity is
reduced from O(n^2) to O(n).

Signed-off-by: Gary Guo <[email protected]>
Acked-by: Simon Martin <[email protected]>
When sorting happens, message info is needed for all messages in the
directory. This can be an expensive operation as it would need to read all
messages. This information is immutable (unlike flags), so it can be easily
cached.

Signed-off-by: Gary Guo <[email protected]>
Acked-by: Simon Martin <[email protected]>
In 5f91f4ff7d ("msgstore: preserve message flags on header updates")
it became required to pass ReplaceFlags: true to worker MessageInfo
messages in order to fully set the flags provided instead of merging
them.

This causes a bug for maildir: once aerc observes a maildir message has
the Seen flag set, then the effect of unsetting it (whether manually by
the user within aerc or by manipulation external to aerc) will never be
visible within the message list: the message remains Seen, though the
directory list will update its unread count. This bug is not unique to
the Seen flag; any flag will exhibit this stuck-on behavior.

Maildir is different from IMAP in that the flags of each message are
always known, so it is best to always replace the flags rather than
attempting to merge them.

Fixes: 5f91f4ff7d ("msgstore: preserve message flags on header updates")
Signed-off-by: Max Rees <[email protected]>
Acked-by: Simon Martin <[email protected]>
The workaround was looking at the root email's subject and sender, while
we need to look at the current email's. This patch fixes this.

Fixes: 39041fd9f ("ircbot: workaround to detect patch applications by simartin")
Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
Commit d1854702d4 slightly modified the way a reconnection backoff was
calculated replacing an issue where aerc would stop trying after a while
with one where it will eventually start to issue reconnection attempts
with no delay in between, causing a high CPU usage.

This is because the backoff would eventually reach a value that cannot
be represented by time.Duration leading to negative and eventually zero
wait time.

Put a hard limit on the backoff so that it can be safely represented by
time.Duration. While at it, also simplify the code.

Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/66028
Fixes: d1854702d4 ("account: move reconnection backoff logic to UI layer")
Changelog-fixed: Repeated reconnection failures will no longer cause
 aerc to start spinning the CPU.
Changelog-changed: A hard maximum of one day is now enforced for
 reconnection attempt delay, setting reconnect-maxwait to a higher value
 thus has no effect.
Signed-off-by: Karel Balej <[email protected]>
Acked-by: Simon Martin <[email protected]>
Container objects can be accessed concurrently, so operations on their
map attributes need to be synchronized.

Fixes: 5fcc95197 ("maildir: actually cache message lookups")
Link: https://lists.sr.ht/~rjarry/aerc-devel/%[email protected]%3E
Reported-by: Jens Grassel <[email protected]>
Signed-off-by: Simon Martin <[email protected]>
Tested-by: Jens Grassel <[email protected]>
Reviewed-by: Gary Guo <[email protected]>
The workaround was still not working; rjarry provided logs showing that
a bunch of `self`s were missing (https://f.jarry.cc/p/UWjql.txt)

Fixes: 87876556a ("ircbot: fix detection of patch applications by simartin")
Signed-off-by: Simon Martin <[email protected]>
Acked-by: Robin Jarry <[email protected]>
OpenAI-compatible [ai] endpoint (local Ollama or cloud). Acts on selected/marked
messages; non-blocking (worker body-fetch + goroutine HTTP, result via ui.QueueFunc);
confirm-gate before sending message text; result shown in a pager tab; draft/translate/
freeform prompts ported from the iamb AI design. Disabled until endpoint+model set.
New [ai] command option: when set, :ai-* write the combined system+user prompt
to the command's stdin and use stdout as the response (takes precedence over
endpoint/model; no API key). Enables using the Claude Code CLI ('claude -p')
via its subscription, or 'ollama run', etc. aiCheckConfigured/confirm-prompt
updated to accept either provider.
A short AI response fits one screen, so with $LESS containing F the pager exited
immediately and the result tab vanished. Append -+F for less so the tab stays
until dismissed.
AI responses are markdown; add an [ai] pager option so they render with a
markdown pager, independent of the [viewer] (email) pager.
[compose] send-delay holds :send behind a cancellable timer (composer stays
open); :undo-send cancels it, :abort also cancels. send-delay=0 = immediate.
refactor(ai): adapt fork commands to upstream atomic config + context APIs
Some checks failed
check / check (pull_request) Failing after 5s
becb062231
Upstream made config objects atomic pointers behind accessor functions
(fixing the IPC :reload crash, todo #319) and added a context argument
to MessageStore.FetchBodyPart. Move the [ai] section onto the same
pattern (parse into a local, store atomically with the rest) and update
the AI and undo-send commands to the new accessors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012S3mRY7CzPt8r9zhPWBZjz
keyhint: group continuations by next key and lay out in columns
Some checks failed
check / check (pull_request) Failing after 5s
check / check (push) Failing after 4s
dd987afb4c
With leader-key setups (e.g. dozens of <Space> chords), the keyhint
popup listed every full continuation in a single column, which quickly
grew taller than the screen and was cut off.

Group continuations by their next keystroke: when several bindings share
the same next key, show one "+N…" entry for that key; the group expands
once the key is pressed. A key with a single binding below it still
shows that binding's full key sequence and description.

Add KeyHint.Layout() to arrange entries in a grid: a single column when
they fit, otherwise flowing into as many columns as needed (and fit).
The popup is capped at 40% of the screen height. If entries still do not
fit, the last cell shows "+K more".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012S3mRY7CzPt8r9zhPWBZjz
Author
Owner

Landed by force-updating release/mirus to this branch (dd987afb), as agreed (rebase landing, linear history). The previous line is preserved at tag archive/release-mirus-pre-0.22.

Landed by force-updating `release/mirus` to this branch (`dd987afb`), as agreed (rebase landing, linear history). The previous line is preserved at tag `archive/release-mirus-pre-0.22`.
jmz closed this pull request 2026-10-07 12:45:20 +00:00
Some checks failed
check / check (pull_request) Failing after 5s
Required
Details
check / check (push) Failing after 4s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
public/aerc!2
No description provided.