Fix CLI-launched agent terminal viewport (#2561)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo Hong
2026-05-21 15:35:48 -07:00
committed by GitHub
co-authored by Orca
parent 630de67fcb
commit a75a822339
8 changed files with 233 additions and 46 deletions
+31 -1
View File
@@ -130,6 +130,10 @@ function isCodexExecutable(command: string): boolean {
return command === 'codex' || command === 'codex.exe' || command === 'codex.cmd'
}
function isClaudeExecutable(command: string): boolean {
return command === 'claude' || command === 'claude.exe' || command === 'claude.cmd'
}
function isShellAssignment(token: string): boolean {
return /^[A-Za-z_][A-Za-z0-9_]*=/.test(token)
}
@@ -178,6 +182,11 @@ function isVersionFlag(token: string): boolean {
return token === '--version' || token === '-V'
}
function isClaudePrintFlag(token: string): boolean {
const optionName = codexGlobalOptionName(token)
return optionName === '-p' || optionName === '--print'
}
function findCodexSubcommand(
tokens: string[],
startIndex: number,
@@ -259,7 +268,7 @@ function isNonInteractiveCodexSubcommand(tokens: string[]): boolean {
return CODEX_NON_INTERACTIVE_SUBCOMMANDS.has(normalizedSubcommand)
}
export function shouldForceVisibleCodexTerminal(command: string | undefined): boolean {
export function shouldUseRendererBackedCodexTerminal(command: string | undefined): boolean {
if (!command) {
return false
}
@@ -275,3 +284,24 @@ export function shouldForceVisibleCodexTerminal(command: string | undefined): bo
return !isNonInteractiveCodexSubcommand(tokens)
}
export function shouldUseRendererBackedInteractiveTerminal(command: string | undefined): boolean {
if (!command) {
return false
}
const tokens = stripShellLaunchPrefix(
tokenizeLeadingShellWords(command.trim(), 32).filter((token) => token.length > 0)
)
const executable = tokens[0] ? commandBasename(tokens[0]) : ''
if (isCodexExecutable(executable)) {
return !isNonInteractiveCodexSubcommand(tokens)
}
if (isClaudeExecutable(executable)) {
return !tokens
.slice(1)
.some((token) => isHelpFlag(token) || isVersionFlag(token) || isClaudePrintFlag(token))
}
return false
}