Skip to content

feat(cli): show chunk progress in mm init wizard's _seed_with_progress #655

@memtomem

Description

@memtomem

Context

PR #653 added per-chunk SSE progress and surfaced it in the web Index tab. The mm init wizard's seed-index path (packages/memtomem/src/memtomem/cli/init_cmd.py:_seed_with_progress, line 1496-) consumes the same index_path_stream but ignores the new chunk_progress events. PR #653 left this out deliberately — see PR description "Out of scope" and the docstring note in the code.

Why this needs design

_seed_with_progress uses click.progressbar configured for file-unit length with this item_show_func:

click.progressbar(
    length=expected_total,                            # files
    label="  Seeding",
    item_show_func=lambda item: (item or "").rsplit("/", 1)[-1][:40],
)

Two problems:

  1. The item_show_func extracts the path tail and truncates to 40 chars. Passing a free-form "file (32/250)" works for "/"-less inputs but the chunk count gets eaten by the truncate.
  2. The bar's length is in files, so chunk_progress events have no natural advance unit. Just calling bar.update(0, label) works (advance=0, label refresh) but the wizard's UX tone is "minimal CLI noise" — fast-firing chunk labels may feel busy.

Options

  1. Refresh sub-label without advancebar.update(0, f"{file} {done}/{total}") and a wider item_show_func that handles both formats. Simplest. Risk: noisy on fast files.
  2. Switch bar length to chunk unitslength=expected_chunks instead of expected_total files; advance per chunk. Requires pre-counting chunks (currently only files are pre-counted). Cost-heavy.
  3. Two-bar layout — outer file-bar, inner per-file chunk-bar shown only when chunks_total > N. Most informative but click.progressbar doesn't compose well.

Acceptance criteria

  • Wizard seed run shows chunk-level progress for files producing more than progress_threshold chunks (default 32).
  • Small files (under threshold) stay quiet — match the web Index tab behavior.
  • KeyboardInterrupt cleanup still works (test: ^C mid-seed prints the resume hint, _close_bar runs).
  • No regression in the multi-path aggregation summary line at the end.

Files likely touched

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions