feat: per-account cancel + folder message-count progress in log

- orchestrator: per-account cancellable context registry + CancelAccount;
  on cancel, close IMAP connections to unblock in-flight FETCH; account ends
  in 'cancelled' status with a cancelled event
- imapx: CopyDeps.OnFolder callback fires after EXAMINE with the folder's
  message count (before the long fetch) for visibility
- httpapi: POST /tasks/{id}/accounts/{accountId}/cancel
- web: per-row cancel button while running, folder event shows N messages,
  cancelled/done_with_errors status badges

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMHQTtnQtQqL8muAXHr9kd
This commit is contained in:
2026-07-02 12:47:07 +07:00
parent 1ed150382e
commit f024f329fc
7 changed files with 133 additions and 16 deletions
+7
View File
@@ -19,6 +19,10 @@ type CopyDeps struct {
IsMigrated func(key string) (bool, error)
MarkMigrated func(folder, key string) error
OnProgress func(copied, skipped int)
// OnFolder is called once per folder right after EXAMINE, before the
// (potentially long) envelope fetch, with the message count in the source
// folder — for progress visibility.
OnFolder func(srcFolder, dstFolder string, total int64)
}
// CopyResult summarizes the outcome of one CopyFolder run.
@@ -42,6 +46,9 @@ func CopyFolder(ctx context.Context, src, dst *imapclient.Client, srcFolder, dst
if err != nil {
return res, fmt.Errorf("examine src %q: %w", srcFolder, err)
}
if deps.OnFolder != nil {
deps.OnFolder(srcFolder, dstFolder, int64(sel.NumMessages))
}
if sel.NumMessages == 0 {
return res, nil
}