Skip to content

feat(tui): support drag-and-drop for .docx and .xlsx files - #32102

Closed
GP-commits wants to merge 3 commits into
anomalyco:devfrom
GP-commits:office-file-drop
Closed

GP-commits wants to merge 3 commits into
anomalyco:devfrom
GP-commits:office-file-drop

Conversation

@GP-commits

Copy link
Copy Markdown

Closes #27689

What

Adds drag-and-drop (and paste) support for Microsoft Office files in the opencode TUI, the read tool, and the desktop app file picker.

How

.docx

Uses mammoth.convertToHtml() (the recommended API — convertToMarkdown is deprecated per mammoth docs) then converts the HTML to GFM Markdown via a custom htmlToMarkdown() function that handles headings, bold/italic, tables, lists, links, blockquotes, and HTML entities.

.xlsx

Uses SheetJS sheet_to_json({ header: 1, defval: '' }) to read rows as arrays and renders each worksheet as a GFM Markdown table under a ## Sheet: Name heading.

Changes

Package File Change
tui src/component/prompt/office-converter.ts NEW — docx/xlsx → Markdown converter
tui src/component/prompt/local-attachment.ts Added MIME types + "office" attachment type
tui src/component/prompt/index.tsx Handles "office" attachment in prompt
tui src/feature-plugins/home/tips-view.tsx Updated drag-and-drop tip
tui test/prompt/local-attachment.test.ts 3 new unit tests
opencode src/util/office.ts NEW — same converter for the read tool
opencode src/tool/read.ts Intercepts .docx/.xlsx before binary rejection, returns converted text in <content> tags
app src/constants/file-picker.ts Added .docx/.xlsx MIME types to desktop file picker

Testing

  • 20/20 existing tests pass
  • 3 new unit tests for .docx and .xlsx attachment handling

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@GP-commits

Copy link
Copy Markdown
Author

Closing to reopen with proper PR template and contribution guidelines.

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

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]:Support drag-and-drop for Microsoft Office files (.docx, .xlsx)

1 participant