nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] /copy code extra reports 'Unknown option "code"', and /help does not mention the code argument

Open addyCooks opened this issue 1 month ago • 6 comments

Description

/copy accepts one optional argument, code. When there is an extra argument (/copy code extra), the error names args[0], which is the valid word code, instead of the extra word. The command description in /help also does not mention [code].

Environment

  • OS: Windows 11 (10.0.26300)
  • Node version: 22.22.3
  • Nanocoder version: 1.31.0 (main at 9d88dda7)
  • Provider / Model: not relevant

Steps to Reproduce

  1. Run /copy code extra.
  2. Run /copy cod for comparison.
  3. Run /help and read the /copy line.

Expected Behavior

Too many arguments. Usage: /copy [code], and the /help text mentions [code].

Actual Behavior

/copy code extra  -> Unknown option "code". Usage: /copy [code]
/copy cod         -> Unknown option "cod". Usage: /copy [code]      (correct)
/help             -> "Copy the last assistant response to the clipboard"

Suggested Fix

  • source/commands/copy.ts:62-66: handle args.length > 1 first with a "too many arguments" message, then the unknown-word case.
  • Change the description in copy.ts and in source/commands/lazy-registry.ts (the copy entry) to mention [code].
  • Update the existing test copyCommand warns when multiple arguments are provided in source/commands/copy.spec.tsx (around line 196-208), which currently asserts the confusing text Unknown option "code".

Additional Context

  • /copy validation came from #1603.
  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder

addyCooks avatar Oct 13 '26 12:10 addyCooks

Claim — termux-monorepo help-wanted lane

Taking a look at this issue as part of our external evaluation + contribution lane.

  • Lane: help-wanted / CPPH ranked
  • Actor: timerloggedout-spec (agentic)
  • Will open a focused PR if a clean fix is in scope

If someone is already actively working this, say so and we will yield.

timerloggedout-spec avatar Oct 13 '26 12:10 timerloggedout-spec

Hi @addyCooks , I'd like to work on this issue.

I recently contributed the "/copy" argument validation fix in #1603, which has now been merged. Thanks for linking that PR here!

I'll investigate the remaining behavior and focus on:

  • Reporting "Too many arguments. Usage: /copy [code]" when extra arguments are provided.
  • Ensuring the error identifies the actual problem rather than the valid "code" argument.
  • Updating the "/help" description to mention the optional "[code]" argument.
  • Adding regression tests for both invalid and multiple arguments.

Before I start implementing, could you please confirm that I can take this issue?

yunuschoudhurywork-lang avatar Oct 14 '26 13:10 yunuschoudhurywork-lang

Thanks everyone for picking this up. I'm assigning this issue to @yunuschoudhurywork-lang, whose PR I'll review first.

To the other contributors who opened PRs for it without being assigned (@timerloggedout-spec, @Vishesh-Verma-07): please ask for assignment first. Comment on the issue that you'd like to take it, and wait until a maintainer assigns it to you before opening a PR. Doing it in that order avoids duplicate work, and it lets us flag design concerns before you've written the code.

Since this one is now assigned, I'll soon close the unassigned PRs as duplicates. We'd love your help on other open issues, comment on the one you want, and those will be assigned to you. Thankyou : )

addyCooks avatar Oct 15 '26 07:10 addyCooks

Hi @yunuschoudhurywork-lang, thanks for the reply, and for the #1603 fix. Yes, this is yours, and I've assigned it to you. Your plan covers the issue. Please make sure of three things:

  1. Change the /help description in both source/commands/copy.ts and the copy entry in source/commands/lazy-registry.ts. /help reads from the registry, so updating only one leaves it stale.
  2. Update the existing test copyCommand warns when multiple arguments are provided in source/commands/copy.spec.tsx (around L196-208). It currently asserts the confusing Unknown option "code" text, so it needs to expect the new message. Keep a separate test for a single unknown argument like /copy cod.
  3. Add a patch changeset (pnpm changeset), since CI checks for one.

Open the PR once you're ready. Thanks!

addyCooks avatar Oct 15 '26 07:10 addyCooks

@addyCooks thanks for the assign, you proceed with review sir, also i see a blocking because PR #1761 targets the same issue.

yunuschoudhurywork-lang avatar Oct 15 '26 09:10 yunuschoudhurywork-lang

@yunuschoudhurywork-lang, the duplicate flag on #1767 is from the review bot, and I've closed the other PRs for #1748. I'll re-run the review now. Thanks for the quick PR.

addyCooks avatar Oct 15 '26 10:10 addyCooks