Skip to content

fix(cli): drive mm index bar length from engine discovery event (#743)#748

Merged
memtomem merged 1 commit intomainfrom
fix/743-mm-index-discovery-bar-length
May 3, 2026
Merged

fix(cli): drive mm index bar length from engine discovery event (#743)#748
memtomem merged 1 commit intomainfrom
fix/743-mm-index-discovery-bar-length

Conversation

@pandas-studio
Copy link
Copy Markdown
Collaborator

Summary

  • IndexEngine.index_path_stream now emits a discovery event with the engine's actual files_total right after _discover_files runs.
  • cli/_index_progress.run_with_progress consumes discovery to lazy-create (and, for multi-path runs, grow) the click.progressbar. The expected_total parameter is gone.
  • mm index and the wizard's _seed_with_progress no longer pre-compute via _collect_seed_scale — bar length comes from the stream.

Why

Pre-#743 mm index ./src/ (Python project, no .md files) showed no progress bar because _collect_seed_scale only counted .md. Long runs looked hung. The pre-compute also duplicated the rglob walk that the engine itself does in _discover_files.

Notes

  • _collect_seed_scale stays in place for _maybe_seed_initial_index's seed-or-skip threshold gate (file-count + size axis), per the issue's acceptance.
  • Helper return now includes bar_rendered (bool); mm index uses it to gate the trailing newline that the legacy expected_total > 0 check used to gate.
  • 3 existing engine tests updated to skip-past or accept the new discovery event as the first index_path_stream yield.

Test plan

  • uv run pytest packages/memtomem/tests -m \"not ollama\" — 3996 passed, 7 skipped
  • uv run ruff check packages/memtomem/src packages/memtomem/tests — clean
  • uv run ruff format --check ... — clean
  • New: test_index_path_stream_emits_discovery_first (engine emits discovery first)
  • New: 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)
  • New: test_index_path_stream_no_discovery_for_invalid_path (no spurious 0-length bar)
  • New: test_no_collect_seed_scale_call_during_index (no duplicate rglob)
  • New: test_bar_renders_for_non_md_corpus (bar appears for mm index ./src/)

Closes #743.

🤖 Generated with Claude Code

Copy link
Copy Markdown
Owner

@memtomem memtomem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@memtomem memtomem force-pushed the fix/743-mm-index-discovery-bar-length branch from fd34e31 to e63f1f3 Compare May 3, 2026 10:39
Copy link
Copy Markdown
Owner

@memtomem memtomem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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]>
@memtomem memtomem force-pushed the fix/743-mm-index-discovery-bar-length branch from e63f1f3 to 138cbbe Compare May 3, 2026 10:48
@memtomem memtomem merged commit dd96ae0 into main May 3, 2026
9 checks passed
@memtomem memtomem deleted the fix/743-mm-index-discovery-bar-length branch May 3, 2026 10:52
@github-actions github-actions Bot locked and limited conversation to collaborators May 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli: use engine discovery count for mm index bar length (replace _collect_seed_scale .md-only walk)

2 participants