Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
fix(bash): emit the shell-ready marker when ble.sh owns the prompt (#35784) (#36163)
Neilf11e71a3ff0c
diff --git a/src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txtindex 3b61d36b65d..1c93e48d78c 100644--- a/src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt+++ b/src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt@@ -8,6 +8,12 @@ __orca_ready_marker=""__orca_has_feature ready && __orca_ready_marker=1unset _orca_shell_featuresunset -f __orca_has_feature+# A system bashrc may already run ble.sh; it never exports this state, so exported copies are inherited.+for __orca_ble_var in _ble_attached _ble_decode_bind_state; do+ [[ -n "${!__orca_ble_var+set}" ]] || continue+ case "$(declare -p "$__orca_ble_var" 2>/dev/null)" in "declare -x"*) unset "$__orca_ble_var" ;; esac+done+unset __orca_ble_var[[ -f /etc/profile ]] && source /etc/profileif [[ -f "$HOME/.bash_profile" ]]; thensource "$HOME/.bash_profile"@@ -236,8 +242,17 @@ __orca_osc133_epilogue() {trap '__orca_osc133_preexec' DEBUG# Readline renders PS1 after entering raw mode; prompt hooks still run in cooked mode.if [[ -n "$__orca_ready_marker" ]]; then- PS1="${PS1-}"'\[\e]777;orca-shell-ready\a\]'- __orca_ready_marker=""+ # Attached ble.sh (0.3+) discards Bash's own prompt output and owns the TTY, so print directly.+ if [[ -n "${_ble_attached-}" ]]; then+ # Its first render runs this before the key decoder attaches; wait for a later prompt.+ if [[ "${_ble_decode_bind_state:-none}" != none ]]; then+ printf "\033]777;orca-shell-ready\007"+ __orca_ready_marker=""+ fi+ else+ PS1="${PS1-}"'\[\e]777;orca-shell-ready\a\]'+ __orca_ready_marker=""+ fifi}__orca_normalize_prompt_command_part() {diff --git a/src/main/daemon/daemon-bash-shell-ready-rcfile.ts b/src/main/daemon/daemon-bash-shell-ready-rcfile.tsindex e5c13faa4ff..52c03a4a747 100644--- a/src/main/daemon/daemon-bash-shell-ready-rcfile.ts+++ b/src/main/daemon/daemon-bash-shell-ready-rcfile.ts@@ -15,6 +15,12 @@ __orca_ready_marker=""__orca_has_feature ready && __orca_ready_marker=1unset _orca_shell_featuresunset -f __orca_has_feature+# A system bashrc may already run ble.sh; it never exports this state, so exported copies are inherited.+for __orca_ble_var in _ble_attached _ble_decode_bind_state; do+ [[ -n "\${!__orca_ble_var+set}" ]] || continue+ case "$(declare -p "$__orca_ble_var" 2>/dev/null)" in "declare -x"*) unset "$__orca_ble_var" ;; esac+done+unset __orca_ble_var[[ -f /etc/profile ]] && source /etc/profileif [[ -f "$HOME/.bash_profile" ]]; thensource "$HOME/.bash_profile"@@ -106,8 +112,17 @@ __orca_osc133_epilogue() {trap '__orca_osc133_preexec' DEBUG# Readline renders PS1 after entering raw mode; prompt hooks still run in cooked mode.if [[ -n "$__orca_ready_marker" ]]; then- PS1="\${PS1-}"'\\[\\e]777;orca-shell-ready\\a\\]'- __orca_ready_marker=""+ # Attached ble.sh (0.3+) discards Bash's own prompt output and owns the TTY, so print directly.+ if [[ -n "\${_ble_attached-}" ]]; then+ # Its first render runs this before the key decoder attaches; wait for a later prompt.+ if [[ "\${_ble_decode_bind_state:-none}" != none ]]; then+ printf "\\033]777;orca-shell-ready\\007"+ __orca_ready_marker=""+ fi+ else+ PS1="\${PS1-}"'\\[\\e]777;orca-shell-ready\\a\\]'+ __orca_ready_marker=""+ fifi}${BASH_PROMPT_COMMAND_COMPOSITION_BLOCK}diff --git a/src/main/daemon/daemon-bash-wrapper-osc133-fixture.ts b/src/main/daemon/daemon-bash-wrapper-osc133-fixture.tsindex 3eac907f77d..1032dbb9c6d 100644--- a/src/main/daemon/daemon-bash-wrapper-osc133-fixture.ts+++ b/src/main/daemon/daemon-bash-wrapper-osc133-fixture.ts@@ -4,7 +4,11 @@ import { join } from 'node:path'import { writeFileSync } from 'node:fs'import { expect } from 'vitest'-export function runInteractiveBashRcfile(rcfileContent: string, tempDir: string): string {+export function runInteractiveBashRcfile(+ rcfileContent: string,+ tempDir: string,+ inheritedEnv: Record<string, string> = {}+): string {const rcfile = join(tempDir, 'bash-osc133-rcfile')writeFileSync(rcfile, rcfileContent)@@ -16,6 +20,7 @@ export function runInteractiveBashRcfile(rcfileContent: string, tempDir: string)encoding: 'utf8',env: {...process.env,+ ...inheritedEnv,HOME: tempDir,ORCA_SHELL_FEATURES: 'ready',TERM: process.env.TERM || 'xterm'diff --git a/src/main/daemon/shell-ready-bash-wrapper.test.ts b/src/main/daemon/shell-ready-bash-wrapper.test.tsindex 9e5eb00f254..a3fa3599ca4 100644--- a/src/main/daemon/shell-ready-bash-wrapper.test.ts+++ b/src/main/daemon/shell-ready-bash-wrapper.test.ts@@ -219,6 +219,66 @@ describePosix('daemon shell-ready bash wrapper', () => {})+ // Profiles discard Bash's own prompt output the way attached ble.sh does (internal_suppress_bash_output).+ itWithBash('signals readiness at the first prompt once ble.sh attaches its decoder', async () => {+ const { getDaemonBashShellReadyRcfileContent } = await importFreshDaemonBashRcfile()+ // Prompt-time ble-attach renders, running Orca's epilogue, before its decoder attaches.+ writeFileSync(+ join(userDataPath, '.bash_profile'),+ [+ '__fake_ble_attach() {',+ ' [[ -z "${_ble_attached-}" ]] || return 0',+ ' _ble_attached=1 _ble_decode_bind_state=none',+ ' __orca_osc133_epilogue',+ ' _ble_decode_bind_state=emacs',+ " printf 'DECODER_ATTACHED\\n'",+ '}',+ 'PROMPT_COMMAND=__fake_ble_attach',+ 'exec 2>/dev/null'+ ].join('\n')+ )++ const output = runInteractiveBashRcfile(getDaemonBashShellReadyRcfileContent(), userDataPath)++ const marker = output.indexOf('\x1b]777;orca-shell-ready\x07')+ expect(output.split('\x1b]777;orca-shell-ready\x07')).toHaveLength(2)+ expect(marker).toBeGreaterThan(output.indexOf('DECODER_ATTACHED'))+ expect(marker).toBeLessThan(output.indexOf('\x1b]133;D;'))+ })++ itWithBash('signals readiness when a system bashrc already attached ble.sh', async () => {+ const { getDaemonBashShellReadyRcfileContent } = await importFreshDaemonBashRcfile()+ // Bash sources /etc/bash.bashrc before --rcfile, so ble.sh state can already be live.+ const systemBashrc = '_ble_attached=1\n_ble_decode_bind_state=emacs\nexec 2>/dev/null\n'++ const output = runInteractiveBashRcfile(+ systemBashrc + getDaemonBashShellReadyRcfileContent(),+ userDataPath+ )++ const marker = output.indexOf('\x1b]777;orca-shell-ready\x07')+ expect(output.split('\x1b]777;orca-shell-ready\x07')).toHaveLength(2)+ expect(marker).toBeLessThan(output.indexOf('\x1b]133;D;'))+ })++ itWithBash('keeps the PS1 marker when ble.sh state is only inherited', async () => {+ const { getDaemonBashShellReadyRcfileContent } = await importFreshDaemonBashRcfile()+ writeFileSync(+ join(userDataPath, '.bash_profile'),+ 'PROMPT_COMMAND=\'printf "PS1=[%s]\\n" "$PS1"\'\nexec 2>/dev/null\n'+ )++ const output = runInteractiveBashRcfile(getDaemonBashShellReadyRcfileContent(), userDataPath, {+ _ble_attached: '1',+ _ble_decode_bind_state: 'emacs',+ BLE_ATTACHED: '1',+ 'BASH_FUNC_ble-attach%%': '() { :; }'+ })++ expect(output).not.toContain('\x1b]777;orca-shell-ready\x07')+ expect(output).toContain('\\e]777;orca-shell-ready\\a')+ })+itWithBash('normalizes array PROMPT_COMMAND hooks so bash 3.2 still runs cleanup', async () => {const { getDaemonBashShellReadyRcfileContent } = await importFreshDaemonBashRcfile()writeFileSync(