fix(cli): drive mm index bar length from engine discovery event (#743)#748
Merged
fix(cli): drive mm index bar length from engine discovery event (#743)#748
Conversation
fd34e31 to
e63f1f3
Compare
PR #741 reused the wizard helper _collect_seed_scale (a .md-only rglob) to pre-compute the progress-bar length for `mm index`. Two consequences: - `mm index ./src/` (Python project, no .md files) → bar length 0 → no bar rendered. Long indexing runs looked hung. - Duplicate I/O: helper rglobs the tree once for the bar length, engine rglobs it again via _discover_files for the actual indexing. Have IndexEngine.index_path_stream emit a `discovery` event right after _discover_files runs, carrying the engine's actual files_total. The helper consumes it to lazy-create (and, for multi-path runs, grow) the click.progressbar. Bar length now reflects what the engine plans to process — including non-.md corpora — and there is no duplicate walk. The wizard's _collect_seed_scale stays in place: _maybe_seed_initial_index still uses it for the seed-or-skip threshold gate (file-count + size). Only the bar-length pre-compute path moves to the streaming source. Helper return adds bar_rendered (bool) so `mm index` can gate its trailing newline on whether the bar actually appeared, replacing the old `expected_total > 0` gate that itself counted .md only. Closes #743. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
e63f1f3 to
138cbbe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IndexEngine.index_path_streamnow emits adiscoveryevent with the engine's actualfiles_totalright after_discover_filesruns.cli/_index_progress.run_with_progressconsumesdiscoveryto lazy-create (and, for multi-path runs, grow) theclick.progressbar. Theexpected_totalparameter is gone.mm indexand the wizard's_seed_with_progressno longer pre-compute via_collect_seed_scale— bar length comes from the stream.Why
Pre-#743
mm index ./src/(Python project, no.mdfiles) showed no progress bar because_collect_seed_scaleonly counted.md. Long runs looked hung. The pre-compute also duplicated therglobwalk that the engine itself does in_discover_files.Notes
_collect_seed_scalestays in place for_maybe_seed_initial_index's seed-or-skip threshold gate (file-count + size axis), per the issue's acceptance.bar_rendered(bool);mm indexuses it to gate the trailing newline that the legacyexpected_total > 0check used to gate.discoveryevent as the firstindex_path_streamyield.Test plan
uv run pytest packages/memtomem/tests -m \"not ollama\"— 3996 passed, 7 skippeduv run ruff check packages/memtomem/src packages/memtomem/tests— cleanuv run ruff format --check ...— cleantest_index_path_stream_emits_discovery_first(engine emits discovery first)test_index_path_stream_discovery_for_non_md_corpus(.py file counted; the cli: use engine discovery count for mm index bar length (replace _collect_seed_scale .md-only walk) #743 reproducer)test_index_path_stream_no_discovery_for_invalid_path(no spurious 0-length bar)test_no_collect_seed_scale_call_during_index(no duplicate rglob)test_bar_renders_for_non_md_corpus(bar appears formm index ./src/)Closes #743.
🤖 Generated with Claude Code