fix: submit the argument to opencode --prompt commands (resolves #4700)
Resolves #4700.
Submit the argument following opencode --prompt in order to resolve this issue.
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.
This looks good but can we fix the double render? The screen flashes twice
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 ill send a video
https://github.com/user-attachments/assets/2b478c37-c0b7-422d-bd05-09e907d450c8
notice once the prompt is submitted it flashes
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.
It was in Zed (which uses alacritty) but I get same behavior in my other terminals too like ghostty
Re-rolled the fix.
In this re-roll, a brief delay avoids the flashing defect.
settimeout is such a hack :/
Best I've managed to get out of my robots so far. I can keep playing with it if ya like though.
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.
Does my PR work for you? It's a much smaller change: https://github.com/sst/opencode/pull/4510/files
@markjaquith I'll give it a try, if it does work for me then I'll close this draft PR. Thanks!
@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:
- Insertion of the prompt in the text input, but no auto-submission.
- 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.