garrytan/gstack · error · Error

Usage: browse tab-each

Error message

Usage: browse tab-each <command> [args...]
Example: browse tab-each snapshot -i

What it means

Thrown by the 'tab-each' meta-command when called with zero arguments. tab-each fans out a single inner command across all open tabs, so it requires at least the inner command name plus optional arguments.

Solutions

  1. Provide the inner command and its arguments, e.g., 'browse tab-each snapshot -i' or 'browse tab-each text'
  2. Consult the usage example in the error message for valid patterns

Example fix

# before
$B tab-each

# after
$B tab-each snapshot -i
Defensive patterns

Strategy: validation

Validate before calling

if (args.length === 0) {
  throw new Error('tab-each requires a command. Example: tab-each snapshot -i');
}

Prevention

When it happens

Trigger: Calling 'browse tab-each' with an empty args array.

Common situations: User runs tab-each without specifying which command to fan out, or a script constructs the command with an empty arguments list.

Related errors


AI-assisted analysis of garrytan/gstack@94993f7401 (2026-08-12). Data as JSON: /api/errors/3d5aa3f52ea1424b. Report an issue: GitHub.

Appendix: source

Thrown at browse/src/meta-commands.ts:314

    case 'closetab': {
      const id = args[0] ? parseInt(args[0], 10) : undefined;
      await bm.closeTab(id);
      return `Closed tab${id ? ` ${id}` : ''}`;
    }

    case 'tab-each': {
      // Fan out a single command across every open tab. Returns a JSON
      // object: { results: [{tabId, url, title, status, output}], total }.
      // Restores the originally active tab when done so the user's view
      // doesn't shift under them.
      //
      // Usage: $B tab-each <command> [args...]
      //   $B tab-each snapshot -i      → snapshot every tab
      //   $B tab-each text             → grab clean text from every tab
      //   $B tab-each goto https://x.y → load the same URL in every tab
      if (args.length === 0) {
        throw new Error(
          'Usage: browse tab-each <command> [args...]\n' +
          'Example: browse tab-each snapshot -i'
        );
      }

      const innerRaw = args[0];
      const innerName = canonicalizeCommand(innerRaw);
      const innerArgs = args.slice(1);

      // Scope check the inner command before fanning out, so a single
      // permission failure aborts the whole batch instead of partially
      // mutating tabs.
      if (tokenInfo && tokenInfo.clientId !== 'root' && !checkScope(tokenInfo, innerName)) {
        throw new Error(
          `tab-each rejected: subcommand "${innerRaw}" not allowed by your token scope (${tokenInfo.scopes.join(', ')}).`
        );
      }

View on GitHub (pinned to 94993f7401)