Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal context for Assistant should not include linebreaks for softwraps #25341

Open
notpeter opened this issue Feb 21, 2025 · 0 comments · May be fixed by #25415
Open

Terminal context for Assistant should not include linebreaks for softwraps #25341

notpeter opened this issue Feb 21, 2025 · 0 comments · May be fixed by #25415
Labels
assistant AI feedback for Assistant (inline or panel) terminal Feedback for terminal integration, shell commands, etc

Comments

@notpeter
Copy link
Member

Summary

If you use /terminal to import terminal context into the Assistant, it will include linebreaks which correspond to your terminal width. This extra linebreaks can confuse the assistant.

Steps to trigger the problem:

  1. Paste this into your terminal
perl -i -pe \
    's/"vscode-languageserver(\/node)?"/"\@zed-industries\/vscode-languageserver$1"/g' packages/css/lib/node/cssServerMain.js
  1. Adjust the width of your terminal so that the command is split across multiple lines
  2. Open the Assistant and type /terminal
  3. Adjust the width of your terminal window and do /terminal again

Actual Behavior: Assistant gets a linebreak where softwraps in terminal occur.

# Original text (pasted from script)
perl -i -pe \
    's/"vscode-languageserver(\/node)?"/"\@zed-industries\/vscode-languageserver$1"/g' packages/css/lib/node/cssServerMain.js

# Terminal is ~80chars wide
Terminal output:
~/zcode/vscode-extracted (main) $ perl -i -pe \
    's/"vscode-languageserver(\/node)?"/"\@zed-industries\/vscode-languageserver$1"/g' pa
ckages/css/lib/node/cssServerMain.js

# Super wide terminal
Terminal output:
~/zcode/vscode-extracted (main) $ perl -i -pe \
    's/"vscode-languageserver(\/node)?"/"\@zed-industries\/vscode-languageserver$1"/g' packages/css/lib/node/cssServerMain.js

Expected Behavior: The width of the terminal should have no impact on the context provided to the Assistant


The \\n in the original command is not necessary to trigger this behavior, but it helps demonstrate that real linebreaks should be preserved

Noticeably, an extra linebreak can totally confuse the assistant as it can totally change the token boundaries. Mine split between "packages" and "/css/lib/node/cssServerMain.js" and Claude was convinced I had provided two filenames and assumed that was the source of my bug. (I was troubleshooting the regex).

Image

Zed Version and System Specs

Zed: v0.176.0 (Zed Nightly 4871d3c)
OS: macOS 15.3.0
Memory: 64 GiB
Architecture: aarch64

@notpeter notpeter added assistant AI feedback for Assistant (inline or panel) terminal Feedback for terminal integration, shell commands, etc labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assistant AI feedback for Assistant (inline or panel) terminal Feedback for terminal integration, shell commands, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant