nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

feat: support image attachments on user messages

Open ragini-pandey opened this issue 5 months ago • 0 comments

Description

Adds multimodal image input to user messages across all chat surfaces (interactive TUI, VS Code prompt path, and ACP). Images are carried as base64 on the internal Message type and converted to AI SDK image parts (a data: URL) at the provider boundary, which Anthropic, Google, and OpenAI-compatible providers all accept.

Highlights:

  • New ImageAttachment type threaded through the submit chain (useChatHandler, useAppHandlers, app-util, message-builder, chat-input/user-input).
  • Clipboard paste via Ctrl+V (macOS osascript, Linux wl-paste/xclip, Windows PowerShell).
  • Image file paths typed/pasted/dragged into the terminal are resolved to attachments and stripped from the message text.
  • ACP image content blocks collected as attachments; unsupported media types and audio are noted rather than silently dropped.
  • modelSupportsVision() heuristic drives a non-blocking warning when the active model likely can't see images (the image is still sent).
  • UserInput lists pending attachments (Ctrl+X removes the last); UserMessage shows an attached-image count.

Note: the ACP and message-converter portions existed in a partially-applied, non-compiling state on the base; this PR completes them (adds the missing ImageAttachment type they imported and restores a dropped return in the user branch of convertToModelMessages).

Type of Change

  • [ ] Bug fix
  • [x] New feature
  • [ ] Breaking change
  • [ ] Documentation update

Testing

Automated Tests

  • [x] New features include passing tests in .spec.ts/tsx files
  • [ ] All existing tests pass (pnpm test:all completes successfully)
  • [x] Tests cover both success and error scenarios

pnpm test:types and pnpm test:lint pass, and all new/updated specs pass (clipboard-image, vision-support, message-converter, acp-content). pnpm test:all currently fails on 3 pre-existing tests in source/utils/tool-result-display.spec.tsx that also fail on main and are unrelated to this change.

Manual Testing

  • [x] Tested with Ollama
  • [ ] Tested with OpenRouter
  • [ ] Tested with OpenAI-compatible API
  • [ ] Tested MCP integration (if applicable)

Checklist

  • [x] Code follows project style guidelines
  • [x] Self-review completed
  • [ ] Documentation updated (if needed)
  • [x] No breaking changes (or clearly documented)
  • [x] Appropriate logging added using structured logging (see CONTRIBUTING.md)

https://github.com/user-attachments/assets/92d77d82-2771-48c1-adcd-bb9443c2b5c5

ragini-pandey avatar Jun 14 '26 15:06 ragini-pandey