Skip to content

fix: strip OSC escape sequences from login shell path resolution#23

Closed
tuxfamily wants to merge 3 commits intojazzyalex:mainfrom
tuxfamily:fix/strip-escape-sequences-in-path
Closed

fix: strip OSC escape sequences from login shell path resolution#23
tuxfamily wants to merge 3 commits intojazzyalex:mainfrom
tuxfamily:fix/strip-escape-sequences-in-path

Conversation

@tuxfamily
Copy link

@tuxfamily tuxfamily commented Feb 19, 2026

Summary

  • Strip OSC escape sequences from all login shell path resolution (-lic commands). Terminal integrations like iTerm2 inject ESC]...BEL sequences into stdout, corrupting resolved paths (e.g. tmux, claude binary, terminal PATH).
  • Resolve terminal PATH from login shell for probe script environment, replacing the minimal GUI PATH (/usr/bin:/bin:/usr/sbin:/sbin) that prevented node from being found.
  • Respect custom Claude CLI binary path setting in probe execution — previously hardcoded to customPath: nil.
  • Update trust prompt detection to match Claude Code's new wording ("Yes, I trust this folder" instead of "Do you trust the files in this folder?").
  • Fix set -e silent exit((iterations++)) returns exit status 1 when counter is 0, replaced with iterations=$((iterations + 1)).

Affected files

File Changes
ClaudeStatusService.swift OSC stripping, terminal PATH resolution, binary path setting, new resolveTerminalPATH()
CodexStatusService.swift OSC stripping in resolveTerminalPATHFromLoginShell and resolveTmuxPathFromLoginShell
claude_usage_capture.sh Trust prompt regex, set -e safe iteration

Test plan

  • Build succeeds (xcodebuild)
  • Probe returns valid JSON on first run after app restart
  • CLI manual test: swift -e validates OSC regex strips sequences correctly
  • Custom Claude CLI binary path now reflected in probe logs (CLAUDE_BIN=...)
  • Verify on machine with iTerm2 shell integration that tmux/claude paths resolve cleanly

@tuxfamily tuxfamily force-pushed the fix/strip-escape-sequences-in-path branch from 4983cbf to 38fb607 Compare February 19, 2026 16:30
When resolving paths via interactive login shell (-lic), terminal
integrations like iTerm2 inject OSC escape sequences (ESC]...BEL)
into stdout, corrupting the resolved path.

Changes:
- Strip OSC sequences (\x1b\]...\x07) from output of all login shell
  path resolution functions in ClaudeStatusService and CodexStatusService
  (checkTmuxAvailable, resolveTmuxPath, resolveTerminalPATH,
  resolveTmuxPathFromLoginShell, resolveTerminalPATHFromLoginShell)
- Resolve terminal PATH from login shell for probe script environment,
  replacing the minimal GUI PATH (/usr/bin:/bin:/usr/sbin:/sbin)
- Respect user's custom Claude CLI binary path setting in probe
  execution instead of always passing customPath: nil
- Update trust prompt detection to match Claude Code's new wording
- Replace ((iterations++)) with iterations=$((iterations + 1)) to
  avoid silent exit under set -e when counter starts at zero

Tool: Claude Code
Model: claude-opus-4-6
Port two proven patterns from codex_status_capture.sh:
- Set TMUX_TMPDIR="/tmp" to avoid UNIX socket path length issues
  with the GUI app's long TMPDIR path
- Wrap tmux new-session in set +e with retry on failure, matching
  the resilient session creation used by the Codex probe

Tool: Claude Code
Model: claude-opus-4-6
The script's internal TIMEOUT_SECS (10s) was too short for Claude CLI
to boot in the tmux session, especially on first run where shell
initialization (fish/conda) adds several seconds.

- Increase script TIMEOUT_SECS from 10 to 14 (matching Codex)
- Increase Swift waitForProcessExit from 20s to 30s to accommodate
  the longer script timeout plus shell resolution overhead

Tool: Claude Code
Model: claude-opus-4-6
@tuxfamily tuxfamily force-pushed the fix/strip-escape-sequences-in-path branch from 38fb607 to a454c16 Compare February 19, 2026 16:31
@jazzyalex
Copy link
Owner

Thanks again for the detailed PR. I applied the fix directly on current main in commit e80b6e8 (adjusted to preserve newer timeout/runtime behavior while fixing the same root cause). Closing this PR as superseded by main.

@jazzyalex jazzyalex closed this Feb 24, 2026
@tuxfamily
Copy link
Author

Okay, thank you. I'll give it a try! :)

@jazzyalex
Copy link
Owner

Will be released in upcoming release this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants