fix(pty): ensure runtime args precede positional prompt in CLI arg order#1399
Merged
arnestrickmann merged 1 commit intomainfrom Mar 10, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR fixes two distinct bugs affecting Codex (and similar agents) when launched via the PTY manager:
Key changes:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| src/main/services/ptyManager.ts | Adds runtimeArgs to ProviderCliArgsOptions, moves both extraArgs and runtimeArgs before the positional initialPrompt in buildProviderCliArgs, and updates both startDirectPty and startPty to pass getProviderRuntimeCliArgs as runtimeArgs rather than appending after the fact. The fix is correct and both call sites are updated consistently. |
| src/renderer/terminal/stripAnsi.ts | Extends ANSI stripping with ST-terminated OSC, DCS, and lone-ESC patterns. The regexes are correct for the targeted sequences. One minor edge case: the final lone-ESC regex /\x1b[^[\]P]/g only handles 2-character ESC sequences; multi-character private sequences like \x1b(B (charset selection) would leave a stray trailing character, though this is an inherent limitation of the regex approach and pre-existing non-standard CSI variants (e.g. \x1b[?25h) are likewise not caught by the CSI regex. Neither scenario is introduced by this PR. |
| src/test/main/ptyManager.test.ts | Adds two well-targeted tests: one confirming the full arg ordering (resume → defaultArgs → autoApproveFlag → extraArgs → runtimeArgs → prompt) and one confirming the Codex-specific --full-auto + -c notify=... case. Both tests accurately reflect the new implementation. |
| src/test/renderer/terminalInputBuffer.test.ts | Adds two tests exercising the new ST-terminated OSC stripping: one ensures real user input survives after OSC color responses, the other confirms an OSC-only input does not trigger capture. Both are correct and cover the specific bug scenario. |
| docs/content/docs/mcp.mdx | Whitespace-only cleanup of the Markdown table column widths. No functional change. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[startDirectPty / startPty] --> B[buildProviderCliArgs]
B --> C[resume + resumeFlag]
C --> D[defaultArgs]
D --> E[autoApproveFlag]
E --> F[extraArgs]
F --> G[runtimeArgs\ne.g. -c notify=...]
G --> H{initialPromptFlag\ndefined AND\nnot keystroke injection?}
H -- Yes --> I[push initialPromptFlag\nif non-empty]
I --> J[push initialPrompt\npositional arg]
H -- No --> K[skip prompt args]
J --> L[return cliArgs]
K --> L
style G fill:#d4edda,stroke:#28a745
style F fill:#d4edda,stroke:#28a745
style J fill:#cce5ff,stroke:#004085
Last reviewed commit: 18bcc09
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.
Summary
buildProviderCliArgsso thatextraArgsandruntimeArgs(e.g. Codex-c notify=...) are placed before the positional initial prompt, preventing agents like Codex from misinterpreting flags as part of the prompt textstripAnsito handle additional ANSI escape sequences: ST-terminated OSC (\x1b\\), DCS sequences, and lone ESC codes (SS2/SS3) — fixes issues where terminal color query responses from agent TUIs leaked into captured inputTest plan
--full-autoand runtime args for CodexextraArgsandruntimeArgsincluded before prompt in arg outputFixes GEN-508