fig icon indicating copy to clipboard operation
fig copied to clipboard

Pasting large commands of text into fig enabled fish terminal breaks CLI

Open rcousens opened this issue 1 year ago • 11 comments

Description:

Please include a detailed description of the issue (and an image or screen recording, if applicable)

When pasting large amounts of text into a fish terminal window, the CLI input bugs out and does not enable me to execute the command. Screen Shot 2022-08-09 at 11 33 19 am

I have not found any way to recover the terminal session, so generally I just kill it if this happens.

If I disable the fig init scripts in ~/.config/fish/conf.d/00_fig_pre.fish and 99_fig_post.fish I can paste long commands fine:

Screen Shot 2022-08-09 at 11 35 28 am

Details:

macOS Fig Shell
12.4.0 Version 1.0.59 (B493) /opt/homebrew/bin/fish
fig diagnostic

Version 1.0.59 (B493) [Beta] [Australian] 
UserShell: /opt/homebrew/bin/fish
Bundle path: /Applications/Fig.app
Autocomplete: true
Settings.json: true
CLI installed: true
CLI tool path: /Users/ross/.fig/bin/fig
Accessibility: true
SSH Integration: false
Tmux Integration: false
iTerm Integration: true [Authenticated]
Hyper Integration: false
VSCode Integration: true
Docker Integration: false
Symlinked dotfiles: false
Only insert on tab: false
UNIX Socket Exists: true
Installation Script: true
PseudoTerminal Path: /Users/ross/.asdf/installs/python/3.10.4/bin:/Users/ross/.asdf/installs/direnv/2.31.0/bin:/Users/ross/.asdf/installs/packer/1.8.0/bin:/Users/ross/.asdf/installs/nomad/1.2.6/bin:/Users/ross/.asdf/installs/vault/1.10.0 ent/bin:/Users/ross/.asdf/installs/java/corretto-17.0.3.6.1/bin:/Users/ross/.asdf/installs/deno/1.23.1/bin:/Users/ross/.asdf/installs/deno/1.23.1/.deno/bin:/Users/ross/.asdf/installs/tflint/0.38.1/bin:/Users/ross/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/ross/.local/bin:/opt/homebrew/opt/fzf/bin:/Users/ross/.fig/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS
SecureKeyboardInput: false
SecureKeyboardProcess: 
Current active process: fish (60245) - /dev/ttys004
Current terminal session: w1t0p0:18C0714D-5B7F-4046-B15A-D8EE1BC1AF8E
Current working directory: /Users/ross
Current window identifier: 10751/% (com.googlecode.iterm2)

rcousens avatar Aug 09 '22 01:08 rcousens

Hey @rcousens! What version of fish are you using? (Run fish --version)

Can you try to reproduce in a different shell?

mschrage avatar Aug 09 '22 22:08 mschrage

Hey @rcousens, seems like this might have been a bug on the beta, can you try updating and see if you still have the issue.

grant0417 avatar Aug 10 '22 03:08 grant0417

@grant0417 Thanks, I'll test now!

rcousens avatar Aug 11 '22 23:08 rcousens

## Fig details:
  - Fig version: Version 1.0.60 (B501) [Beta] [Australian]
  - Bundle path: /Applications/Fig.app
  - Autocomplete: true
  - Settings.json: true
  - Accessibility: true
  - Number of specs: 0
  - Symlinked dotfiles: false
  - Only insert on tab: false
  - Keybindings path:
  - Installation Script: true
  - PseudoTerminal Path: /Users/ross/.asdf/installs/python/3.10.4/bin:/Users/ross/.asdf/installs/direnv/2.31.0/bin:/Users/ross/.asdf/installs/packer/1.8.0/bin:/Users/ross/.asdf/installs/nomad/1.2.6/bin:/Users/ross/.asdf/installs/vault/1.10.0+ent/bin:/Users/ross/.asdf/installs/java/corretto-17.0.3.6.1/bin:/Users/ross/.asdf/installs/deno/1.23.1/bin:/Users/ross/.asdf/installs/deno/1.23.1/.deno/bin:/Users/ross/.asdf/installs/tflint/0.38.1/bin:/Users/ross/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/ross/.local/bin:/opt/homebrew/opt/fzf/bin:/Users/ross/.fig/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS
  - SecureKeyboardInput: false
  - SecureKeyboardProcess: <none>
## Hardware Info:
  - Model Name: MacBook Pro
  - Model Identifier: MacBookPro18,1
  - Chip: Apple M1 Pro
  - Cores: 10 (8 performance and 2 efficiency)
  - Memory: 32 GB
## OS Info:
  - macOS 12.4.0 (21F79)
## Environment:
  - User Shell: /opt/homebrew/bin/fish
  - Current Directory: /Users/ross
  - CLI Installed: true
  - Executable Location: /opt/homebrew/bin/fig
  - Current Window ID: 16394/% (com.googlecode.iterm2)
  - Active Process: fish (24894) - /dev/ttys002
  - Terminal: iterm
  - Installed via Brew: true
  - Environment Variables:
    - TERM_SESSION_ID=w0t0p0:1F13316C-EB02-4B84-BDAF-51BE9650F2CF
    - TERM=xterm-256color
    - FIG_INTEGRATION_VERSION=8
    - PATH=/Users/ross/.asdf/installs/python/3.10.4/bin:/Users/ross/.asdf/installs/direnv/2.31.0/bin:/Users/ross/.asdf/installs/packer/1.8.0/bin:/Users/ross/.asdf/installs/nomad/1.2.6/bin:/Users/ross/.asdf/installs/vault/1.10.0+ent/bin:/Users/ross/.asdf/installs/java/corretto-17.0.3.6.1/bin:/Users/ross/.asdf/installs/deno/1.23.1/bin:/Users/ross/.asdf/installs/deno/1.23.1/.deno/bin:/Users/ross/.asdf/installs/tflint/0.38.1/bin:/Users/ross/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/ross/.local/bin:/opt/homebrew/opt/fzf/bin:/Users/ross/.fig/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS
    - FIG_PID=24894
    - FIG_TERM_VERSION=5.1.0
    - FIG_TERM=1
## Integrations:
  - SSH: false
  - TMUX: false
  - iTerm: installed!
  - Hyper: application is not present.
  - Visual Studio Code: installed!
  - Docker: false

image

❯ fish --version
fish, version 3.5.1

no dice :(

rcousens avatar Aug 11 '22 23:08 rcousens

I'll try reproducing in a different shell, though I'm guessing it'll probably be a fish only thing! 👍

rcousens avatar Aug 11 '22 23:08 rcousens

How many are you pasting there? Also what fish plugins are you using?

grant0417 avatar Aug 11 '22 23:08 grant0417

@grant0417 Hrmm I can reproduce in bash, the behaviour is a little different though! It just freezes the CLI and doesn't show the pasted output.

Screen Shot 2022-08-12 at 9 18 27 am

1008 characters -> no problem. 1138 -> problem occurs.

Fish also exhibits the same behaviour, 1008 -> no problem, 1138 -> problem occurs.

Let me find the exact number for you.

rcousens avatar Aug 11 '22 23:08 rcousens

The magic number is 1011. 1010 'a' works, 1011 'a' doesn't.

rcousens avatar Aug 11 '22 23:08 rcousens

Fish plugins (though I don't think they are the culprit):

❯ fisher list
jorgebucaran/fisher
jethrokuan/z
franciscolourenco/done
wfxr/forgit
patrickf1/fzf.fish
jorgebucaran/autopair.fish
ilancosman/tide@v5

My initial testing involved disabling all plugins except for the fig pre/post.

rcousens avatar Aug 11 '22 23:08 rcousens

I have a clue for you, I think bracketed paste mode is related. I can replicate the behaviour in numerous applications when fig is enabled (vim, nano, micro).

It's eating the end of bracketed paste mode somehow?

rcousens avatar Aug 12 '22 05:08 rcousens

Additionally, I can recreate the issue in Alacritty and MacOS Terminal.app, but not WezTerm! Weird!

rcousens avatar Aug 12 '22 05:08 rcousens

image

I disabled ALL my plugins (mv ~/.config/fish ~/.config/fish.backup), quit iTerm, reinstalled Fig (Fig -> Integrations -> Developer -> Run Install Script), opened iTerm and started a shell with fish, and then pasted more than 1012 characters to recreate the issue. So I'm confident it's not plugin related. It could be related to the version of fish (3.5.1), but I can confirm the problem happens with a clean install of Fish and Fig 1.0.60 (B508).

This should be easy to recreate and only happens when I'm in the binary "fish (figterm)" which gets launched by the 00_fig_pre.fish script.

FIG_CHECKED_PROMPTS 1
FIG_DOTFILES_SOURCED 1
FIG_HOSTNAME pasito.local
FIG_INTEGRATION_VERSION 8
FIG_IN_DOCKER 0
FIG_PID 75787
FIG_SHELL_PATH /opt/homebrew/Cellar/fish/3.5.1/bin/fish
FIG_TERM 1
FIG_TERM_VERSION 5.1.0
FIG_WORKFLOWS_KEYBIND \\cf
FISH_VERSION 3.5.1

rcousens avatar Aug 18 '22 12:08 rcousens

Also, I think I am on to something with bracketed paste. Because if I type a lot of a's instead of PASTE a lot of a's then the problem doesn't occur: Screen Shot 2022-08-18 at 10 28 12 pm

1402 a's and no problem when holding down a for a minute.

rcousens avatar Aug 18 '22 12:08 rcousens

Using Edit -> Paste Special -> Advanced Paste... in iTerm is quite useful for testing. When I set Chunk Size to a max of 4B, it seems to fix my issues.

mpas97 avatar Aug 22 '22 15:08 mpas97

@mpas97 Thanks, that's a useful work around! I had to set it to 4 bytes to get it to work (took about 3s to paste ~1200 a's). However, I still hope there is a permanent fix here!

rcousens avatar Aug 22 '22 23:08 rcousens

I believe this should be fixed on beta, also setting the Chunk Size to any number <1000 might work, so that would speed up the pasting.

grant0417 avatar Aug 22 '22 23:08 grant0417

@grant0417 I'll test beta now, thanks for working on this! I did try 256 and 16 chunk size (didn't change the delay between chunks) and both resulted in the bug.

rcousens avatar Aug 22 '22 23:08 rcousens

## Fig details:
  - Fig version: Version 1.0.60 (B509) [Beta] [Australian]

Screen Shot 2022-08-23 at 9 14 38 am

Error still there generally, but 4b chunk size fixes the issue. Anything over 4b and I still have the issue. At least I have a workaround for pasting certs and AWS creds in to my terminal. First two tests are 4b with different delays (made no difference, both worked). The last is 16b size with ~60ms delay between chunks.

rcousens avatar Aug 22 '22 23:08 rcousens

Make sure to open a new terminal session after updating, will keep investigating this!

grant0417 avatar Aug 22 '22 23:08 grant0417

Problem still there with new iTerm2 and new terminal session (quit iTerm2, reopen, CMD-N for new terminal). Thanks for your persistence @grant0417. I haven't disabled fig generally yet because I love it so much, but I have a second setup with WezTerm for stuff where I need to paste!

rcousens avatar Aug 22 '22 23:08 rcousens

I've now disabled fig permanently (by renaming the ~/.config/fish/conf.d/00_fish_pre.fish and 99_fish_post.fish scripts) until this is fixed as it has been making the terminal generally unusable for me. Otherwise, I love fig and appreciate all the hard work you guys are doing. Thank you!

rcousens avatar Aug 29 '22 23:08 rcousens

I spend a while working out what is actually going on here, I believe the actual fix should be on beta soon (within the next couple hours).

So sorry once again @rcousens for the issue and thank you so much for your debugging on it!

grant0417 avatar Aug 30 '22 01:08 grant0417

I know this is the second time I have said this, but I very thoroughly tested this time (plus it was a very strange bug)

grant0417 avatar Aug 30 '22 01:08 grant0417

I've now disabled fig permanently (by renaming the ~/.config/fish/conf.d/00_fish_pre.fish and 99_fish_post.fish scripts) until this is fixed as it has been making the terminal generally unusable for me. Otherwise, I love fig and appreciate all the hard work you guys are doing. Thank you!

~~You don't need to do that, just rename the middle layer binary is okay for me.~~

2022-08-31 09:09:54 CST Edit: Correct a workaround, just do below can fix the bug in current release version.

mv $HOME/.fig/bin $HOME/.fig/bin.bak

ChowRex avatar Aug 30 '22 01:08 ChowRex

Wow, it's fixed! THANK YOU @grant0417, I really appreciate your effort on resolving this. 👏 🙏 🥳

@ChowRex if you can confirm your use case is fixed then I will close this issue.

rcousens avatar Aug 31 '22 00:08 rcousens

Wow, it's fixed! THANK YOU @grant0417, I really appreciate your effort on resolving this. 👏 🙏 🥳

@ChowRex if you can confirm your use case is fixed then I will close this issue.

I have tested again, correct my answer: rename the ~/.fig/bin directory is a work around to fix this bug in current release version.

ChowRex avatar Aug 31 '22 01:08 ChowRex

@grant0417 Hi, I'm very happy with the fix! Thanks again!

I'm going to close this issue as @ChowRex hasn't indicated he's still having issues either :)

rcousens avatar Sep 05 '22 22:09 rcousens