nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Bracketed paste only works in the main prompt, every other text field in the app silently receives nothing

Open addyCooks opened this issue 2 months ago • 5 comments

Description

cli.tsx enables bracketed paste (DECSET 2004) for the whole interactive session and strips each pasted payload out of the raw stdin stream before Ink ever sees it, re-emitting it on a singleton pasteEvents bus instead. Exactly one component in the entire codebase subscribes to that bus: the main composer (UserInput). Every other text field the MCP setup wizard, settings panels, the ask_user prompt, the architect review's revise-instructions box receives neither the paste event (nothing subscribes) nor the raw keystrokes (they were already stripped out at the source), so a paste into any of them is silently discarded.

Parent: #907

Steps to Reproduce

  1. Run /settings mcp → "Configure MCP Servers" → "+ Add an MCP server…" → accept the default config location → "Add MCP servers" → scroll down and select "Custom MCP Server".
  2. Accept the default transport (Field 1/6) to reach "Server name" (Field 2/6).
  3. Paste any text into the field.

Expected Behavior

The pasted text appears in the field, the same way it would in the main composer.

Actual Behavior

Nothing appears. The field stays completely empty no text, no error, no indication the paste was even received.

Recording

Image

Root Cause

source/utils/terminal-paste.ts:45: /** Singleton bus: cli.tsx publishes payloads, UserInput subscribes. */ and indeed, a repo-wide search for pasteEvents turns up exactly one subscriber, source/components/user-input.tsx:304-306 (pasteEvents.on('paste', handleTerminalPaste) / the matching .off on cleanup). Every other TextInput-based field in the codebase wizards/steps/mcp-step.tsx, wizards/steps/field-input-view.tsx, components/question-prompt.tsx, components/architect-review-prompt.tsx, the app/components/settings-*.tsx panels, components/json-viewer/json-viewer.tsx has no path to receive a paste at all, because cli.tsx already removed the payload from the stream before any of them could see it as ordinary keystrokes.

Suggested Fix

Move the paste subscription into the shared TextInput component (or a small hook it uses) so every text field receives payloads by default, instead of wiring it into one specific composer component.

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs on the latest main

addyCooks avatar Sep 23 '26 11:09 addyCooks

Hi @akramcodez, can you assign this to me ?

addyCooks avatar Sep 23 '26 11:09 addyCooks

My bad, I kinda looked at the issues tab and grabbed the first one. Totally my fault

closed my PR,. feel free to pick up where I left off.

Aryagarg23 avatar Sep 24 '26 02:09 Aryagarg23

Picking this up - a fix will follow shortly.

awhite0030 avatar Sep 24 '26 05:09 awhite0030

@awhite0030 I want to clarify the contribution process here. @addyCooks asked to be assigned to this issue first. Please don’t pick up an already-assigned issue or open a PR for it without first coordinating with the assignee or sharing your plan. I’ve noticed this happening across multiple issues, where PRs are opened without checking the existing assignment or communicating the intended approach. I’ll be closing duplicate or inappropriate PRs that follow this pattern.

Please make sure to check the issue, existing PRs, and assignees before starting work, and follow the contribution guidelines: https://github.com/Nano-Collective/nanocoder/blob/main/CONTRIBUTING.md Please contribute properly going forward. Thanks.

akramcodez avatar Sep 25 '26 09:09 akramcodez

Adding the first-run provider setup as another (and probably the most common) place this bites.

Repro

  1. Fresh machine, no agents.config.json and no ~/.config/nanocoder/.
  2. Start nanocoder. useAppInitialization sees No providers configured and opens the configWizard (ProviderWizard → ProviderStep → FieldInputView).
  3. Pick a provider, e.g. OpenRouter, and reach the API Key field.
  4. Paste the key from the clipboard → nothing appears.

Why

The API key field is a TextInput with mask="*" in source/wizards/steps/field-input-view.tsx, which has no pasteEvents subscription — same as the MCP wizard field in the original repro. cli.tsx has already lifted the payload out of stdin by then, so the paste goes nowhere. Typing the same string manually works, so the field itself is fine; only the paste path is broken.

This is the path users hit first, and the API key is usually sitting on the clipboard at that exact moment, so a fresh install currently looks like it "doesn't accept the key".

Workaround until a fix lands

Skip the wizard and reference an env var from config (uppercase names only, ${VAR:-default} supported):

{
	"providers": [
		{
			"name": "OpenRouter",
			"baseUrl": "https://openrouter.ai/api/v1",
			"apiKey": "${OPENROUTER_API_KEY}",
			"models": ["google/gemini-3.1-flash"]
		}
	]
}
export OPENROUTER_API_KEY="sk-or-..."

Local providers such as Ollama avoid it entirely since they need no key.

Vishesh-Verma-07 avatar Nov 05 '26 11:11 Vishesh-Verma-07