fix(terminal): clean profile/terminal startup under oh-my-posh#37
Open
kevmtt wants to merge 1 commit into
Open
fix(terminal): clean profile/terminal startup under oh-my-posh#37kevmtt wants to merge 1 commit into
kevmtt wants to merge 1 commit into
Conversation
…t, stall Opening a terminal (notably quick-launch profiles) under oh-my-posh showed garbled text on the prompt, a slow/stalled first prompt, and a doubled prompt. Root causes and fixes: - DA1 query leak: the xterm image addon answers Device Attributes with \x1b[?62;4;9;22c through a slow renderer<->main round-trip, so the reply landed on the prompt and PSReadLine echoed it as typed input. It is now answered in-process in PtyManager (effectively instant), and xterm's own DA1 reply is suppressed in useTerminal so there is no slow duplicate. - Doubled prompt: React StrictMode double-mounts the terminal; the async pty.has() check let pty.create() fire twice for one surfaceId, spawning a second shell that also streamed to the renderer (and leaked an orphan). PtyManager.create() is now idempotent per surfaceId and the IPC handler skips re-wiring a reused PTY. - Startup resize redraw: PTYs spawned at 80x24 then got resized, making the shell redraw its prompt. PTYs now spawn at the measured terminal size and redundant same-size resizes are dropped. - Slow first prompt: the PR-polling Start-Job (spins up a child runspace) ran during shell init. It is now deferred to the shell's first idle. - Quick-launch startup commands are baked into the shell's init for PowerShell instead of injected as keystrokes after a delay, avoiding a race with the shell's init-time terminal queries. - Guard async terminal callbacks against use-after-dispose (StrictMode), fixing an xterm "reading 'dimensions'" crash from Viewport.syncScrollArea.
Author
|
I'm honest here.. Many things I don't understood here, so I let AI add comments for me to understand. I left them in case they might be usefull. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes broken terminal/profile startup under oh-my-posh (PowerShell + PSReadLine): garbled prompt characters, a doubled prompt, and a slow first prompt.
Closes #36
Root causes & fixes
[?62;4;9;22cjunk echoed on the promptPtyManager(instant); suppress xterm's own DA1 reply inuseTerminalso there's no slow duplicatepty.has()→pty.create()fired twice → two shells under onesurfaceIdPtyManager.create()is idempotent per surfaceId; IPC handler skips re-wiring a reused PTYStart-Job(spins a child runspace) ran during shell initreading 'dimensions'crashterminal.dispose()(StrictMode)disposedflag + cancel pending rAFsFiles
src/main/pty-manager.ts— in-process DA1 reply, idempotent create, spawn-at-size, same-size resize dropsrc/main/ipc-handlers.ts— skip re-wiring reused PTYssrc/preload/index.ts—cols/rowsin create optionssrc/renderer/hooks/useTerminal.ts— DA1 suppression, dispose guards, spawn-at-measured-sizesrc/shell-integration/wmux-powershell-integration.ps1— deferredStart-Job, baked startup commandsTest plan
npm run build:main+tsc(main & renderer) clean;eslint0 errors on changed files[?62;4;9;22c, no stall (verified via PTY trace: one shell-init sequence, one prompt render)Notes
All temporary diagnostic instrumentation has been removed; only the fixes remain, each with an explanatory comment.