Skip to content

fix(agenda): yield while preparing agenda entries - #1200

Open
dtvillafana wants to merge 1 commit into
nvim-orgmode:masterfrom
dtvillafana:uncapture-main-thread
Open

dtvillafana wants to merge 1 commit into
nvim-orgmode:masterfrom
dtvillafana:uncapture-main-thread

Conversation

@dtvillafana

@dtvillafana dtvillafana commented Oct 15, 2026 •

Copy link
Copy Markdown

Summary

Keep daily/weekly agenda preparation responsive when scanning many large Org files. All configured files and eligible headlines are processed to completion; the work budget controls when to yield, not which entries are included.

This follows the existing notification scanner’s Promise.async, Promise.yield, and OrgFile:parse_async patterns. It is cooperative scheduling, not background-thread processing. Buffer-backed parsing, the parser timeout fallback, and final rendering can still run synchronously.

Related Issues

None linked.

Changes

  • Prepare agenda data in an async coroutine, yielding after approximately 5 ms of scanning or date-matching work.
  • Use the existing incremental file parser before enumerating headlines, and skip archive files as before.
  • Reuse prepared results when rendering, including refresh and date navigation, while preserving agenda cursor/window restoration.
  • Avoid synchronous waits when loading custom agenda files, and return an existing search view when preparing it again.
  • Add Lua type annotations and six regression tests covering event-loop yielding, incremental parsing and archive exclusion, prepared-result reuse, 6,000 lines across two files, custom-file loading, and refresh/navigation.

The branch contains a single agenda-responsiveness commit on upstream master, without earlier fork-specific changes. No configuration options or user-facing commands change, so no user documentation update is needed.

Checklist

I confirm that I have:

  • Followed the Conventional Commits specification.
  • My PR title also follows the conventional commits specification.
  • Updated relevant documentation, if necessary. Added internal annotations; no user documentation changes are necessary.
  • Thoroughly tested my changes. Repository-wide stylua --check lua/ tests/ and git diff --check pass.
  • Added tests and verified existing tests pass with make test.
  • Checked for breaking changes and documented them, if any. None intended.

AI-assisted: OpenCode, GPT-6.1-sol

@dtvillafana
dtvillafana force-pushed the uncapture-main-thread branch from 9b2086c to 009e965 Compare October 15, 2026 18:43
@dtvillafana dtvillafana changed the title fix(agenda): yield during headline scanning and date matching fix(agenda): yield while preparing agenda entries Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant