Skip to content

fix: progress bar, console output, and interactive mode improvements - #2

Merged
FaZeTitans merged 5 commits into
mainfrom
fix/progress-output-interactive
Mar 6, 2026
Merged

FaZeTitans merged 5 commits into
mainfrom
fix/progress-output-interactive

Conversation

@FaZeTitans

@FaZeTitans FaZeTitans commented Mar 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Paginated document fetching — transferCollection now fetches documents page-by-page (batchSize per page) using startAfter pagination instead of loading the entire collection with query.get(). This distributes network I/O evenly, making the progress bar advance linearly instead of stalling during a long initial fetch then jumping.
  • Fix counting with maxDepth — countSubcollectionsForDoc now respects maxDepth to match transfer behavior. Previously the total was too high when using --max-depth, causing the progress bar to never reach 100% naturally.
  • Improved console output during counting — Each top-level collection is clearly separated, subcollection names are displayed (so you can verify what's being scanned), excluded subcollections are shown explicitly, and process.stdout.write calls are guarded against JSON mode.
  • Full interactive mode — All transfer configuration options (where filters, exclude patterns, parallel, merge, clear, delete-missing, transform, rename, ID prefix/suffix, webhook, rate limit, max depth, etc.) are now available via an "additional options" checkbox prompt. CLI-only behavioral flags (resume, json output, quiet, log file, yes) are excluded as they don't apply to interactive configuration. At the end of the session, the user can choose to execute the transfer or save the configuration as an INI or JSON file for later use with fscopy -f.
  • Fix config file values ignored — Removed yargs defaults for options that support file config override (retries, verify, rateLimit, etc.) so ?? fallback works correctly. Fixed INI parsing of 0 values being dropped by parseInt(...) || undefined.

- transferCollection now fetches documents page-by-page (page size =
  batchSize) using startAfter pagination instead of loading the entire
  collection at once with query.get(). This distributes network I/O
  evenly across the transfer, making the progress bar advance linearly
  instead of stalling during a long initial fetch then jumping.

- Fix counting bug: countSubcollectionsForDoc now respects maxDepth to
  match transfer behavior. Previously, the count included docs beyond
  maxDepth that would never be transferred, causing the progress bar
  total to be too high.
- Separate each top-level collection with clear formatting
- Show unique subcollection names found per collection (e.g. orders,
  reviews, settings) so user can verify what's being scanned
- Show excluded subcollection names so user can verify --exclude works
- Show subcollection document counts per collection
- Show live "Scanning <collection>..." indicator during counting
- Guard all process.stdout.write calls against JSON mode to prevent
  garbled output when using --json
- Add onSubcollectionExcluded callback to CountProgress interface
Interactive mode now includes all options available in CLI/config modes:
- After basic prompts (source, dest, collections, subcollections, dry
  run, merge), offers "Configure additional options?" with a checkbox
  of all available options grouped logically
- Each selected option gets its appropriate prompt type (input, number,
  confirm, etc.)
- Available options: exclude patterns, where filters, parallel, batch
  size, document limit, max depth, rate limit, clear destination,
  delete missing, transform file, rename collections, ID prefix/suffix,
  webhook, skip oversized, detect conflicts, verify counts, verify
  integrity, retries

At the end of the interactive session, user can choose to:
- Execute transfer (existing behavior)
- Save as INI config file
- Save as JSON config file

Config serialization generates proper INI (with sections and commented
defaults for unset options) or JSON format. The saved file can then be
used with `fscopy -f <file>`.

Also updates cli.ts to handle the new InteractiveResult return type
and exit gracefully when saving instead of executing.
Copilot AI review requested due to automatic review settings March 5, 2026 15:46
@FaZeTitans FaZeTitans self-assigned this Mar 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Firestore transfer CLI’s user experience and correctness by making transfer progress more linear (via paginated reads), aligning document counting with transfer behavior (notably maxDepth), and expanding interactive mode to configure and persist more options.

Changes:

  • Implement paginated document fetching in transferCollection to avoid loading entire collections at once and to make progress advance steadily.
  • Fix counting logic to respect maxDepth, and enhance counting console output (including excluded subcollections) while guarding live output for non-interactive modes.
  • Expand interactive mode to cover advanced options and allow “execute vs save config” at the end, with CLI support for the new return type.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/transfer/transfer.ts Switches to page-by-page query pagination for transfer reads and moves limit handling into pagination.
src/transfer/count.ts Makes subcollection counting respect maxDepth and adds a callback for excluded subcollections.
src/orchestrator.ts Improves counting/deletion progress output and adds helpers for live progress rendering.
src/interactive.ts Implements full interactive flow including advanced options and config save (INI/JSON) paths.
src/cli.ts Adapts CLI to the new interactive return type and exits early on “save”.
src/tests/interactive.test.ts Updates interactive tests for new prompts and return shape.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/orchestrator.ts Resolved
Comment thread src/orchestrator.ts Resolved
Comment thread src/transfer/transfer.ts Resolved
Comment thread src/transfer/count.ts Resolved
Comment thread src/__tests__/interactive.test.ts Resolved
Comment thread src/interactive.ts Resolved
Comment thread src/interactive.ts Resolved
- Gate progressBar.start() with canWriteProgress check
- Use process.stdout.columns + isTTY in clearLine
- Extend INI/JSON parsers and mergeConfig for advanced fields
- Include advanced fields in INI serialization
- Use explicit confirm queue in interactive tests
- Add pagination boundary tests for transfer
- Add maxDepth + onSubcollectionExcluded tests for count

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/config/parser.ts Resolved
Comment thread src/config/parser.ts Resolved
Comment thread src/__tests__/transfer.test.ts Resolved
Comment thread src/__tests__/count.test.ts Resolved
…rops 0 values

- Remove yargs defaults for retries, verify, rateLimit, skipOversized,
  detectConflicts, maxDepth, verifyIntegrity so file config values are
  actually used when CLI args are not explicitly passed
- Replace Number.parseInt(...) || undefined with parseIntOption() helper
  to preserve valid 0 values in INI config parsing

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/interactive.ts Resolved
@FaZeTitans
FaZeTitans merged commit 523c093 into main Mar 6, 2026
5 checks passed
@FaZeTitans
FaZeTitans deleted the fix/progress-output-interactive branch March 6, 2026 02:07
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.

2 participants