opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix: submit the argument to opencode --prompt commands (resolves #4700)

Open ariane-emory opened this issue 1 month ago • 15 comments

Resolves #4700.

Submit the argument following opencode --prompt in order to resolve this issue.

ariane-emory avatar Nov 26 '25 21:11 ariane-emory

Ohhhhh... I see that the format action is the one adding the trailing whitespace on package.json files. I'll stop trying to 'fix' (air quotes) it.

ariane-emory avatar Nov 27 '25 05:11 ariane-emory

This looks good but can we fix the double render? The screen flashes twice

rekram1-node avatar Nov 28 '25 22:11 rekram1-node

Huh, I don't think I've seen that myself but I can definitely take a closer look! I'll redraft it for now and undraft it again once I've addressed this issue.

ariane-emory avatar Nov 28 '25 22:11 ariane-emory

@ariane-emory ill send a video

rekram1-node avatar Nov 28 '25 22:11 rekram1-node

https://github.com/user-attachments/assets/2b478c37-c0b7-422d-bd05-09e907d450c8

notice once the prompt is submitted it flashes

rekram1-node avatar Nov 28 '25 22:11 rekram1-node

Is this in Zed? I'm not 100% certain. Maybe it isn't as visible in iTerm2, but I should be able to grab whichever editor this is this evening and try to figure out enough about it to try replicating.

ariane-emory avatar Nov 28 '25 22:11 ariane-emory

It was in Zed (which uses alacritty) but I get same behavior in my other terminals too like ghostty

rekram1-node avatar Nov 28 '25 22:11 rekram1-node

Re-rolled the fix.

In this re-roll, a brief delay avoids the flashing defect.

ariane-emory avatar Nov 29 '25 02:11 ariane-emory

settimeout is such a hack :/

rekram1-node avatar Nov 29 '25 03:11 rekram1-node

Best I've managed to get out of my robots so far. I can keep playing with it if ya like though.

ariane-emory avatar Nov 29 '25 04:11 ariane-emory

Reverting to draft status until I can figure out a way to do this without either the unwanted TUI flashing defect or use of setTimeout.

ariane-emory avatar Dec 02 '25 10:12 ariane-emory

Does my PR work for you? It's a much smaller change: https://github.com/sst/opencode/pull/4510/files

markjaquith avatar Dec 03 '25 17:12 markjaquith

@markjaquith I'll give it a try, if it does work for me then I'll close this draft PR. Thanks!

ariane-emory avatar Dec 03 '25 19:12 ariane-emory

@markjaquith I'm afraid that your branch has a problem I ran into a few times: successfully submitting the prompt but having unwanted flashing of the whole TUI afterwards.

So far, my fix attempts have gotten me to one of these points:

  1. Insertion of the prompt in the text input, but no auto-submission.
  2. Successful insertion and auto-submission, but with unwanted flashing of the whole TUI afterwards.

So far, this PR involving setTimeout is the only solution I've managed to come up with that doesn't have either problem. However, as @rekram1-node pointed out, setTimeout isn't very pretty.

So, I guess I'll keep whacking on this one and hopefully I'll come up with something that satisfies everybody.

ariane-emory avatar Dec 03 '25 20:12 ariane-emory