Repository navigation
fix(server): an unfinished control sequence no longer delays terminal output #39861
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
Open
viktorce
wants to merge
5
commits into
pingdotgg:main
Choose a base branch
from
viktorce:fix/terminal-unending-string
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+211
−9
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1662c3c
fix(server): terminal output after an unfinished control sequence no …
viktorce c066646
Merge remote-tracking branch 'origin/main' into fix/terminal-unending…
juliusmarminge 6d435a7
chore(server): drop a stale note about held control sequences reachin…
juliusmarminge 43c7f1a
Merge branch 'main' into fix/terminal-unending-string
viktorce 0321f5e
Merge branch 'main' into fix/terminal-unending-string
viktorce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stop unfinished OSC 4 palette queries from replaying replies on Android.
When the sanitizer closes an unfinished OSC 4 query with ST, the query stays in history.
shouldStripOscSequencecovers only OSC 10, 11, and 12, so this query is not stripped. On Android restore, the parser dispatches the closed query, and the terminal can answer it.feedPendingBufferforwards that reply throughemitResponseasonInput, with no replay guard.terminal-runtime.mdrequires that restoring scrollback send no replies. The web renderer meets that requirement by detaching its writer during replay. Android does not.Either the sanitizer must drop OSC 4 query traffic from retained history, or the Android restore path must suppress replies while replaying. Choose the policy that keeps the restore free of replies.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The finding is right about the code, the gap is on
mainalready, and this PR does not change the strip rules.shouldStripOscSequencecovers only OSC 10, 11, and 12. A finished OSC 4 query,ESC ]4;1;? BEL, passes through unchanged onmainand with this PR, and the first evidence comment shows its replay answering under "OSC 4 query". On Android,feedPendingBufferatT3TerminalView.kt:431andfeedOutputat:459pass replies toemitResponseat:473unless the view is read-only. I read that code and did not run Android.When a sequence outgrows its limit after an unfinished OSC 4 query in history, this PR writes one ST to history. The ST closes the query, and replay answers it. The live terminal answered at the same point. On
main, replay sends nothing because it swallows text after the query. Two of the 76 test streams in the description's replay comparison show this. The description states this under "Costs I accept", "Replay replies", and lists strip rules under "Left out".This PR fixes one problem, the unlimited hold. During review I widened the OSC rule to catch a query behind a control character, and took it out again. A stripped string writes nothing to history, so a sequence that history left open before it stays open and swallows what follows. Covering OSC 4 on the server replaces a finished OSC 4 query with one ST to close any earlier open sequence, and the rule for the queries the server already strips stays as it is. I am preparing that change as its own issue and PR. Blocking replies during replay on Android, as the web client does at
apps/web/src/terminal/ghostty/core.ts:429, covers the whole class and is a separate change too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gap now has its own issue, #40148, and its own pull request, #40149, which is stacked on this one. #40149 fixes it on the server so history no longer keeps an OSC 4 palette query that has its own terminator. I wrote above that covering OSC 4 in the filter needs an ST after every stripped sequence. #40149 writes ST only in place of the OSC 4 query and leaves the older strip rules as they are. A guard in the mobile clients is still the fix for the whole class, and #40149 does not add one.