Skip to content

Commit

Permalink
Fixed bug where non unicode bytes were in the output the terminal wou…
Browse files Browse the repository at this point in the history
…ld drastically fail
  • Loading branch information
rusiaaman committed Feb 4, 2025
1 parent e1646cc commit a949ea3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
authors = [{ name = "Aman Rusia", email = "[email protected]" }]
name = "wcgw"
version = "2.8.8"
version = "2.8.9"
description = "Shell and coding agent on claude and chatgpt"
readme = "README.md"
requires-python = ">=3.11, <3.13"
Expand Down
12 changes: 9 additions & 3 deletions src/wcgw/client/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: #
encoding="utf-8",
timeout=TIMEOUT,
cwd=initial_dir,
codec_errors="backslashreplace",
)
shell.sendline(
f"export PROMPT_COMMAND= PS1={PROMPT_CONST}"
Expand All @@ -161,6 +162,7 @@ def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: #
echo=False,
encoding="utf-8",
timeout=TIMEOUT,
codec_errors="backslashreplace",
)
shell.sendline(f"export PS1={PROMPT_CONST}")
shell.expect(PROMPT_CONST, timeout=TIMEOUT)
Expand Down Expand Up @@ -256,7 +258,9 @@ def ensure_env_and_bg_jobs(self) -> Optional[int]:
before = "\n".join(before_lines).strip()
counts += 1
if counts > 100:
raise ValueError("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it")
raise ValueError(
"Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it"
)

try:
return int(before)
Expand All @@ -273,7 +277,7 @@ def _init_shell(self) -> None:
self._bash_command_mode.bash_mode == "restricted_mode",
self._cwd,
)

self._pending_output = ""

# Get exit info to ensure shell is ready
Expand Down Expand Up @@ -414,7 +418,9 @@ def update_repl_prompt(self, command: str) -> bool:
index = self.shell.expect([self._prompt, pexpect.TIMEOUT], timeout=0.2)
counts += 1
if counts > 100:
raise ValueError("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it")
raise ValueError(
"Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it"
)
console.print(f"Prompt updated to: {self._prompt}")
return True
return False
Expand Down

0 comments on commit a949ea3

Please sign in to comment.