[PR #3866] Fix @ file tagging on new lines in both desktop and TUI #10786

Closed
opened 2026-02-16 18:15:32 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3866

State: closed
Merged: No


Fixes #3860

Changes

This PR fixes the issue where @ file tagging doesn't work on new lines in both the desktop and TUI components.

Desktop Component

  • Modified parseFromDOM in packages/desktop/src/components/prompt-input.tsx to recursively traverse nested DOM nodes
  • Properly handles BR and DIV elements as newlines
  • When you press Enter in the contenteditable div, the browser creates nested DIV elements, and the previous implementation only parsed direct child nodes

TUI Component

  • Added explicit start-of-line check (logicalCursor.col === 0) in packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx
  • The issue was that getTextRange(cursorOffset - 1, cursorOffset) wasn't returning "\n" at the start of a new line
  • Now the autocomplete triggers correctly when @ is typed at the beginning of any line

Demo

https://github.com/user-attachments/assets/70eeba1c-8312-4735-bbe0-41a24d32330c


Link to Devin run: https://cognition.devinenterprise.com/sessions/c432df81027546de8f1804d2655f6c6c
Requested by: Walden Yan (walden@cognition-labs.com) (@walnutwaldo)

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3866 **State:** closed **Merged:** No --- Fixes #3860 ## Changes This PR fixes the issue where @ file tagging doesn't work on new lines in both the desktop and TUI components. ### Desktop Component - Modified `parseFromDOM` in `packages/desktop/src/components/prompt-input.tsx` to recursively traverse nested DOM nodes - Properly handles BR and DIV elements as newlines - When you press Enter in the contenteditable div, the browser creates nested DIV elements, and the previous implementation only parsed direct child nodes ### TUI Component - Added explicit start-of-line check (`logicalCursor.col === 0`) in `packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx` - The issue was that `getTextRange(cursorOffset - 1, cursorOffset)` wasn't returning "\n" at the start of a new line - Now the autocomplete triggers correctly when @ is typed at the beginning of any line ## Demo https://github.com/user-attachments/assets/70eeba1c-8312-4735-bbe0-41a24d32330c --- **Link to Devin run:** https://cognition.devinenterprise.com/sessions/c432df81027546de8f1804d2655f6c6c **Requested by:** Walden Yan (walden@cognition-labs.com) (@walnutwaldo)
yindo added the pull-request label 2026-02-16 18:15:32 -05:00
yindo closed this issue 2026-02-16 18:15:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10786