Skip to content

Recursive suggestCommand() on regenerate causes stack overflow and duplicate UI banners #124

@404-Page-Found

Description

@404-Page-Found

Bug Description

Selecting "Regenerate suggestions" in the suggest action menu recursively calls suggestCommand(), causing unbounded call stack growth and printing a new intro() banner each time.

Steps to Reproduce

  1. Run commit-echo suggest
  2. When presented with the action menu, select "Regenerate suggestions"
  3. Repeat selecting "Regenerate suggestions" 10-20 times

Expected Behavior

Suggestions are regenerated in-place without growing the call stack or printing duplicate intro banners.

Actual Behavior

  1. Stack growth: Each call adds a frame to the call stack. After enough regenerations (hundreds), this causes RangeError: Maximum call stack size exceeded.
  2. UI pollution: Each recursive call invokes intro(pc.bold(pc.cyan("commit-echo"))) at src/commands/suggest.ts:87, printing a new clack intro banner on every regeneration.

Root Cause

src/commands/suggest.ts:267 — the "regenerate" action handler calls await suggestCommand(options) recursively instead of using a loop.

Suggested Fix

Refactor the suggestion flow into a loop:

while (true) {
  // ... generate and display suggestions ...
  const action = await select({ ... });
  if (action === "regenerate") continue;
  break;
}

Environment

  • commit-echo latest
  • Node.js (any version)

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions