From bfb9829152a4227a3833fe8512a2a2fd6adaa44d Mon Sep 17 00:00:00 2001 From: Song He Date: Sat, 15 Aug 2026 18:43:56 -0700 Subject: [PATCH] feat: honour OFFICECLI_BROWSER as an explicit chrome-family executable Hosts that ship their own Chromium build outside the standard PATH names / platform install locations (for example a Chrome for Testing binary staged under an app-support directory) have no way to point FindChrome() at it. Read OFFICECLI_BROWSER first, before the PATH and absolute-path fallbacks, when it names an existing file. --- README.md | 2 +- src/officecli/Core/HtmlScreenshot.cs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b843ad29..17c2129b1 100644 --- a/README.md +++ b/README.md @@ -256,7 +256,7 @@ OfficeCLI is self-contained. The capabilities below ship inside the binary — * #### Rendering engine — high-fidelity, built-in -OfficeCLI's keystone: a from-scratch, high-fidelity HTML rendering engine that lets an AI agent *see* the rendered document instead of guessing from the DOM. It covers shapes, charts (trendlines, error bars, waterfall, candlestick, sparklines), equations (OMML → LaTeX, rendered with KaTeX), 3D `.glb` models via Three.js, morph transitions, slide zoom, and shape effects. Per-page PNG screenshots are produced by piping the rendered HTML through a headless browser. Three modes: +OfficeCLI's keystone: a from-scratch, high-fidelity HTML rendering engine that lets an AI agent *see* the rendered document instead of guessing from the DOM. It covers shapes, charts (trendlines, error bars, waterfall, candlestick, sparklines), equations (OMML → LaTeX, rendered with KaTeX), 3D `.glb` models via Three.js, morph transitions, slide zoom, and shape effects. Per-page PNG screenshots are produced by piping the rendered HTML through a headless browser — found on PATH or in a platform-standard install location, or set `OFFICECLI_BROWSER=/path/to/chrome-family-binary` to point OfficeCLI at an explicit Chrome/Chromium/Edge executable outside those locations (e.g. a Chrome for Testing build a host manages itself). Three modes: - **`view html`** — standalone HTML file, assets inlined. Open in any browser. - **`view screenshot`** — per-page PNG, ready for multimodal agents to read. diff --git a/src/officecli/Core/HtmlScreenshot.cs b/src/officecli/Core/HtmlScreenshot.cs index 787e77288..94c1ce19f 100644 --- a/src/officecli/Core/HtmlScreenshot.cs +++ b/src/officecli/Core/HtmlScreenshot.cs @@ -411,6 +411,13 @@ private static (bool, string?) TryChrome(string url, string outPath, int w, int private static string? FindChrome() { + // Explicit override first: lets hosts that ship their own Chromium + // (e.g. a Chrome for Testing build outside the standard install + // paths) point OfficeCLI at it without touching PATH. + var explicitBrowser = Environment.GetEnvironmentVariable("OFFICECLI_BROWSER"); + if (!string.IsNullOrWhiteSpace(explicitBrowser) && File.Exists(explicitBrowser)) + return explicitBrowser; + string[] names = ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser", "chrome", "microsoft-edge", "microsoft-edge-stable", "msedge"]; var pathHit = WhichFirst(names);