Skip to content

fix(desktop): collapse spreadsheet column tabs on paste#42573

Open
sanidhyasin wants to merge 1 commit into
NousResearch:mainfrom
sanidhyasin:fix/desktop-composer-tab-paste-42256
Open

fix(desktop): collapse spreadsheet column tabs on paste#42573
sanidhyasin wants to merge 1 commit into
NousResearch:mainfrom
sanidhyasin:fix/desktop-composer-tab-paste-42256

Conversation

@sanidhyasin

Copy link
Copy Markdown
Contributor

Summary

Pasting several cells from a spreadsheet (Excel / Google Sheets / Numbers) into the Desktop chat composer dumped literal tab characters into the contentEditable, which rendered as ragged, uneven column gaps instead of readable text. Closes #42256.

The composer's paste handler took the plain-text clipboard payload verbatim (only .trim()-ed it). Spreadsheet apps put cell data on the plain-text clipboard as tab-separated columns, so a row like FEERUM | 2026-06-05 | 17,95 arrived as FEERUM\t2026-06-05\t17,95.

Changes

  • apps/desktop/src/app/chat/composer/text-utils.ts — new pure readPastedText(clipboard) helper that trims edge whitespace (preserving internal newlines, as before) and collapses tab columns to single spaces only when the clipboard also exposes an HTML <table> — the marker spreadsheet apps emit. Gating on the table means tab indentation in pasted code is left completely untouched, avoiding a regression for the common "paste code into the agent" workflow.
  • apps/desktop/src/app/chat/composer/index.tsx — route the paste handler through readPastedText instead of the inline .trim().
  • apps/desktop/src/app/chat/composer/text-utils.test.ts — unit tests covering the spreadsheet paste, code-with-tabs (untouched), non-table HTML (untouched), and the existing trim behaviour.

How to test

  1. In Excel/Sheets, copy 3 cells in one row, e.g. FEERUM | 2026-06-05 | 17,95.
  2. Paste into the Desktop composer → text now reads FEERUM 2026-06-05 17,95 on a single clean line.
  3. Copy tab-indented code from an editor and paste → indentation is preserved (no regression).

Unit tests: npm run test:ui (from apps/desktop), text-utils.test.ts.

Platforms

Logic is platform-independent (clipboard text + text/html); verified via the new vitest cases. Behaviour matches Excel, Google Sheets, and Numbers, which all expose an HTML <table> alongside the tab-separated plain text.

Pasting multiple cells from Excel/Sheets into the composer dropped literal
tab characters into the contenteditable, rendering as ragged column gaps.

Route paste text through a new readPastedText helper that collapses tabs to
spaces only when the clipboard also exposes an HTML <table> (the marker
spreadsheet apps emit), so tab indentation in pasted code is left untouched.

Closes NousResearch#42256
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have labels Jun 9, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Replaces the simplistic .trim() on pasted text with a new readPastedText() function that collapses spreadsheet column tabs (from Excel/Sheets) to spaces, but only when the paste is tabular (detected via HTML <table> presence). Tab indentation in code pastes is preserved.

  • Well-scoped helper function with clear documentation
  • Good test coverage (4 new test cases)
  • No security concerns

Reviewed by Hermes Agent (cron batch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop composer handlePaste inserts tab characters from Excel paste, messy output in contenteditable

3 participants