Skip to content

feat: booting indicator for async tool sources#22

Merged
StanAngeloff merged 10 commits intodevelopfrom
feature/booting-indicator
Mar 12, 2026
Merged

feat: booting indicator for async tool sources#22
StanAngeloff merged 10 commits intodevelopfrom
feature/booting-indicator

Conversation

@StanAngeloff
Copy link
Collaborator

Summary

When Flemma loads async tool sources (e.g. MCP servers, user-provided resolve functions), there's currently no way for users to know that tools are still loading. This PR adds visibility into the boot process through three surfaces:

  • Lualine #{booting} variable — a new resolver that returns truthy while async tool sources are pending, allowing users to show a loading indicator in their statusline format string (e.g. #{?#{booting},⏳ ,}#{model})
  • :Flemma status booting line — a ⏳ loading async tool sources… line appears in the Tools section while sources are still resolving
  • FlemmaBootComplete autocmd — a User autocmd that fires once all async tool sources have resolved, enabling downstream integrations (the lualine component uses this to auto-refresh)

Architecture

No new modules. This extends three existing files plus the syntax file:

lua/flemma/tools/init.lua

fire_ready_callbacks() now emits vim.api.nvim_exec_autocmds("User", { pattern = "FlemmaBootComplete" }) after draining the callback queue. This is the single event that signals boot completion.

lua/lualine/components/flemma.lua

  • New booting resolver in make_resolvers(): returns "1" while tools.is_ready() is false, "" when ready. This integrates with the existing conditional format system (#{?#{booting},true_branch,false_branch}).
  • New init() override: creates a User FlemmaBootComplete autocmd that calls lualine.refresh(), so the statusline updates automatically when boot finishes (no polling needed).

lua/flemma/status.lua

  • collect_tools() now includes booting = not tools_module.is_ready() in its return table.
  • format() conditionally inserts ⏳ loading async tool sources… after the Tools header when data.tools.booting is true.
  • The flemma.status.Data type annotation is updated to include booting: boolean on the tools field.

syntax/flemma_status.vim

  • New FlemmaStatusBooting match for ^\s\+⏳ .*$, linked to WarningMsg highlight group.

Testing

All changes are TDD — tests were written first, verified to fail, then implementation was added:

  • tests/flemma/tool_async_spec.lua — 1 new test: verifies FlemmaBootComplete autocmd fires when the last async source resolves
  • tests/flemma/lualine_spec.lua — 3 new tests: #{booting} truthy while pending, falsy when ready, and lualine refresh on FlemmaBootComplete. The lualine mock was also improved to support proper init() inheritance (added init method and setmetatable-based extend)
  • tests/flemma/status_spec.lua — 4 new tests: data.tools.booting true/false in collect(), and presence/absence in format()

Test plan

  • make qa passes (verified: qa: OK)
  • New lualine variable works in a format string: #{?#{booting},⏳ loading…,}#{model}
  • :Flemma status shows ⏳ loading async tool sources… while a slow async source is pending
  • :Flemma status omits the booting line once all sources resolve
  • Lualine auto-refreshes when boot completes (no manual refresh needed)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

StanAngeloff and others added 10 commits March 12, 2026 19:27
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…iness

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The default statusline format now shows ⏳ while async tool sources are
loading. Also removes the redundant DEFAULT_FORMAT local from the
lualine component — the single source of truth is config.lua.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The rebase onto develop introduced a policy field in sandbox status
data that the booting indicator test fixtures were missing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@StanAngeloff StanAngeloff force-pushed the feature/booting-indicator branch from d3bbfb6 to 6963630 Compare March 12, 2026 17:30
@StanAngeloff StanAngeloff merged commit 86d0405 into develop Mar 12, 2026
@StanAngeloff StanAngeloff deleted the feature/booting-indicator branch March 12, 2026 17:31
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