Force UTF-8 on clicker output so Windows stops failing runs

A run died with "'charmap' codec can't encode character '▶'" at step 1.
Python picks the console code page for stdout, and under PM2 - where stdout is
a pipe rather than a console - that is cp1252 on Windows. cp1252 handles the em
dashes in these files but not the run markers, so the first one raised
UnicodeEncodeError from inside run_steps and the runner reported it as a step
failure rather than an output problem.

Reconfigure stdout and stderr to UTF-8 at the top of each entry point, with
errors="replace" as a backstop for streams that cannot be reconfigured. Fixing
the encoding once beats stripping the glyphs from ~30 call sites, and covers
manual runs in a plain console too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-08-30 18:28:39 -05:00
co-authored by Claude Opus 5
parent 724ba5581c
commit fbe2c47ed4
3 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -25,7 +25,7 @@ import time
import actions
import focus
from clicker import Dashboard, DashboardError, NotFoundError
from clicker import Dashboard, DashboardError, NotFoundError, force_utf8_output
POLL_SECONDS = 1.0
HEARTBEAT_SECONDS = 2.0
@@ -362,6 +362,7 @@ def finish(dash, run_id, error):
def main() -> int:
force_utf8_output()
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--api", default="http://localhost:3000", help="dashboard URL")