Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Companion: off and unavailable behind one flag (owner 2 Nov) (#2256)

Eyal Golanc47b8e5c1af0
diff --git a/changelog.d/1119-companion.md b/changelog.d/1119-companion.md
index 43272da26..5ee25cc9a 100644
--- a/changelog.d/1119-companion.md
+++ b/changelog.d/1119-companion.md
@@ -1 +1 @@
-- Add a read-only WebGL companion beside the game for the current event, choices, game focus, status and the End Turn report. It is off by default (the owner's ruling of 1 November 2026, "Opt-in for now (Recommended)"): turn it on with Settings > Screen reader companion, or open the game with `?companion=1`. Keyboard play stays in the game; real screen-reader validation and the phone layout remain pending.
+- Add a read-only WebGL companion beside the game for the current event, choices, game focus, status and the End Turn report. It is off and unavailable for now (the owner's ruling of 2 November 2026; see the Changed entry). Keyboard play stays in the game; real screen-reader validation and the phone layout remain pending.
diff --git a/changelog.d/companion-off.md b/changelog.d/companion-off.md
new file mode 100644
index 000000000..bb98abd67
--- /dev/null
+++ b/changelog.d/companion-off.md
@@ -0,0 +1,4 @@
+### Changed
+- The read-only WebGL companion (#1119) is off and unavailable for now (the owner's ruling of 2 November 2026, "Remove it
+ from the game (Recommended)"): Settings has no "Screen reader companion" row, and `?companion=1` does nothing. The code
+ stays in, switched off by one flag (`WebCompanion.Available`), so it can come back later.
diff --git a/docs/accessibility-audit-2026-10-14.md b/docs/accessibility-audit-2026-10-14.md
index 0edced650..16b69167f 100644
--- a/docs/accessibility-audit-2026-10-14.md
+++ b/docs/accessibility-audit-2026-10-14.md
@@ -504,7 +504,15 @@ leaves the focus on the last stop instead of dropping it; and a drawn scope stil
first control, asserted on `minimap-overview` so the fallback cannot satisfy the test). No UI
string was added, so nothing goes to #564.
-## The WebGL companion is opt-in, 1 November 2026
+## The WebGL companion: off and unavailable for now, owner 2 November 2026
+
+**Status:** off and unavailable for now (owner, 2 November 2026). The owner asked to "disable the game companion" and
+chose "Remove it from the game (Recommended)": "A small PR before tonight's nightly hides it entirely: no Settings row,
+and ?companion=1 does nothing. The code stays in, switched off by one flag, so it can come back later." That flag is
+`WebCompanion.Available`, now `false`. While it is false `WebCompanion.On` is false whatever the switch, the stored
+choice or the address says, GameRoot gives Settings no switch, so the row stays hidden as it is outside WebGL, and the
+page's panel stays `hidden` because the game never publishes to it. `WebCompanionUnavailableTests` pins this. The
+rest of this section describes the companion as it works with the flag on (what `WebCompanionTests` runs, through the `WebCompanion.Offered` test seam), from the opt-in ruling of 1 November 2026.
The first step proposed under H5 is the read-only WebGL companion (#1119, PR #1920): an HTML panel beside the canvas
(`WebGLTemplates/Statecraft/index.html`, `WebCompanion.jslib`) that mirrors the open event, its choices, the game's focus,
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 5348e0a35..0053d406f 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -334,9 +334,10 @@ namespace Statecraft.Game.UI
// The language switch (#1036) builds every screen again in the new language over this game (SwitchLanguage).
Action<string> switchLanguage = language => SwitchLanguage(inputs, language); // the start screen's too (#2054)
// The WebGL companion (#1119) is opt-in (WebCompanion.On): Settings turns it on and off at once, where a page shows it.
+ // While the build does not offer it (WebCompanion.Available, owner 2 Nov 2026), there is no switch, so no row.
Action<bool>? setCompanion = null;
(Func<bool> on, Action<bool> set)? companionSwitch = null;
- if (CompanionPage)
+ if (CompanionPage && WebCompanion.Offered())
{
Action<bool> set = on =>
{
diff --git a/unity/Assets/Scripts/UI/SettingsPresenter.cs b/unity/Assets/Scripts/UI/SettingsPresenter.cs
index 7b45fda94..8d1875329 100644
--- a/unity/Assets/Scripts/UI/SettingsPresenter.cs
+++ b/unity/Assets/Scripts/UI/SettingsPresenter.cs
@@ -132,6 +132,7 @@ namespace Statecraft.Game.UI
// root's geometry (as TopBarInset does). The file keeps the choice, so a shape that holds it again gets it back.
root.RegisterCallback<GeometryChangedEvent>(OnGeometry);
// The WebGL companion (#1119): off unless the player turns it on here or the address asks for it (WebCompanion.On).
+ // Unavailable for now (WebCompanion.Available, owner 2 Nov 2026): GameRoot passes no switch, so the row stays hidden.
screen.Q<Label>("settings-companion-label").text = text["settings.companion"];
companionSwitch = screen.Q<Button>("settings-companion");
if (companion == null) companionSwitch.parent.style.display = DisplayStyle.None;
diff --git a/unity/Assets/Scripts/UI/WebCompanion.cs b/unity/Assets/Scripts/UI/WebCompanion.cs
index 4d46f5c1f..b21593366 100644
--- a/unity/Assets/Scripts/UI/WebCompanion.cs
+++ b/unity/Assets/Scripts/UI/WebCompanion.cs
@@ -9,7 +9,8 @@ using UnityEngine.UIElements;
namespace Statecraft.Game.UI
{
/// <summary>One-way WebGL mirror of the presenter's words. It never receives game commands or changes focus. Opt-in
- /// (<see cref="On"/>): the Settings switch or "?companion=1" turns it on.
+ /// (<see cref="On"/>): the Settings switch or "?companion=1" turns it on, and only while <see cref="Available"/>, which is
+ /// false for now (owner, 2 November 2026).
/// It publishes in the frame after a sim change, an End Turn, a refused order, a click, a submit or a focus move, once
/// the presenters have rendered; periodic sampling also catches toast writes and controls rebuilt without any of those.
/// Nothing is published before the first frame. Owned by GameRoot: a restart/language switch disposes it without clearing
@@ -36,6 +37,16 @@ namespace Statecraft.Game.UI
public Choice[] choices = Array.Empty<Choice>();
}
+ /// <summary>Whether this build offers the companion at all. The owner's ruling of 2 November 2026, "Remove it from the
+ /// game (Recommended)": "A small PR before tonight's nightly hides it entirely: no Settings row, and ?companion=1 does
+ /// nothing. The code stays in, switched off by one flag, so it can come back later." While false, nothing turns it on
+ /// (<see cref="On"/>), GameRoot gives Settings no switch, so its row stays hidden, and nothing reaches the page.</summary>
+ public const bool Available = false;
+
+ /// <summary><see cref="Available"/>, read where it applies. A seam: a test sets it to exercise the companion with the
+ /// flag on, and puts it back.</summary>
+ internal static Func<bool> Offered = () => Available;
+
// "?companion=1": a whole query parameter with a whole value (UrlFlags' rule), so "?companion=10" and "?xcompanion=1"
// are not it.
static readonly Regex Asked = new Regex(@"[?&]companion=1(?=&|#|$)", RegexOptions.CultureInvariant);
@@ -44,8 +55,9 @@ namespace Statecraft.Game.UI
/// (Recommended)", until the VoiceOver test and the phone layout are done. <paramref name="picked"/> is the Settings
/// switch pressed in this page's session, which wins; else the stored choice (<see cref="SettingsPresenter.CompanionKey"/>
/// "on") or "?companion=1" in the page address turns it on. The address wins over a stored "off" for that visit and
- /// writes nothing: the owner's ruling of 2 November 2026, "Link wins, that visit (Recommended)".</summary>
- public static bool On(bool? picked, string? stored, string? url) => picked ?? (stored == "on" || Asked.IsMatch(url ?? ""));
+ /// writes nothing: the owner's ruling of 2 November 2026, "Link wins, that visit (Recommended)". None of them counts
+ /// while the build does not offer it (<see cref="Available"/>).</summary>
+ public static bool On(bool? picked, string? stored, string? url) => Offered() && (picked ?? (stored == "on" || Asked.IsMatch(url ?? "")));
readonly VisualElement root;
readonly UiText text;
diff --git a/unity/Assets/Tests/EditMode/WebCompanionTests.cs b/unity/Assets/Tests/EditMode/WebCompanionTests.cs
index e3df41d87..0852fd145 100644
--- a/unity/Assets/Tests/EditMode/WebCompanionTests.cs
+++ b/unity/Assets/Tests/EditMode/WebCompanionTests.cs
@@ -10,6 +10,16 @@ using UnityEngine.UIElements;
public sealed class WebCompanionTests
{
+ // The companion is off and unavailable in the game (WebCompanion.Available, owner 2 November 2026); these tests keep it
+ // working for its return by turning the flag on through the test seam. WebCompanionUnavailableTests pins the game as shipped.
+ System.Func<bool>? offered;
+
+ [SetUp]
+ public void OfferTheCompanion() { offered = WebCompanion.Offered; WebCompanion.Offered = () => true; }
+
+ [TearDown]
+ public void PutTheFlagBack() => WebCompanion.Offered = offered!;
+
static UiText Text => UiText.Parse("ui.lang: en\ncompanion.title: Game companion\ncompanion.help: Read only\ncompanion.focus: Game focus\ncompanion.status: Status\ncompanion.choices: Choices\ncompanion.empty: No decision waiting\ncompanion.unavailable: Unavailable\n");
static VisualElement Tree()
@@ -572,3 +582,58 @@ public sealed class WebCompanionTests
}
}
}
+
+/// <summary>The game as shipped: the owner's ruling of 2 November 2026, "Remove it from the game (Recommended)": "no Settings
+/// row, and ?companion=1 does nothing" (WebCompanion.Available is false). Nothing here turns the flag on.</summary>
+public sealed class WebCompanionUnavailableTests
+{
+ [SetUp]
+ public void TheFlagIsOff() => Assert.IsFalse(WebCompanion.Offered(), "the game ships with the companion unavailable");
+
+ [TestCase(null, null, "https://example.org/statecraft/index.html?companion=1")]
+ [TestCase(null, "off", "https://example.org/statecraft/index.html?companion=1")]
+ [TestCase(null, "on", "")]
+ [TestCase(null, "on", "https://example.org/statecraft/index.html?companion=1")]
+ [TestCase(true, "on", "https://example.org/statecraft/index.html?companion=1")]
+ public void NothingTurnsItOn(bool? picked, string? stored, string? url) =>
+ Assert.IsFalse(WebCompanion.On(picked, stored, url));
+
+ [Test]
+ public void TheRealRootHasNoCompanionAndNoSettingsRowUnderTheLinkOrAStoredOn()
+ {
+ var dir = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "statecraft-companion-" + System.Guid.NewGuid().ToString("N"));
+ var inputs = Statecraft.Game.Boot.GameInputs.FromDisk(Statecraft.Game.Paths.Content, Statecraft.Game.Paths.StreamingMap);
+ try
+ {
+ UnityEditor.SceneManagement.EditorSceneManager.OpenScene("Assets/Map.unity", UnityEditor.SceneManagement.OpenSceneMode.Single);
+ Object.FindFirstObjectByType<Statecraft.Game.Map.MapScene>().Build(inputs.Map);
+ var game = Object.FindFirstObjectByType<GameRoot>();
+ game.Store = new Statecraft.Game.SaveStore(dir);
+ game.Settings = new Statecraft.Game.SettingsStore(dir);
+ game.Settings.Write(SettingsPresenter.CompanionKey, "on"); // kept from a build that offered it
+ var sent = new List<string>(); game.CompanionSend = sent.Add; // a page that could show it
+ game.CompanionAddress = "https://example.org/statecraft/index.html?companion=1";
+ game.Language = UiLanguage.English;
+ game.Begin(inputs, 0);
+ Assert.IsNull(game.Companion, "neither the link nor a stored \"on\" turns it on");
+ var ui = Object.FindFirstObjectByType<UIDocument>().rootVisualElement;
+ UiTestKit.Press(ui.Q<Button>("nav-settings"));
+ var button = ui.Q<Button>("settings-companion");
+ Assert.AreEqual(DisplayStyle.None, button.parent.style.display.value, "no Settings row");
+ Assert.AreNotEqual(DisplayStyle.None, ui.Q<Button>("settings-star").parent.style.display.value, "the rows after it still show");
+ UiTestKit.Press(button);
+ Assert.IsNull(game.Companion, "a press on the hidden switch turns nothing on");
+ Assert.AreEqual("on", game.Settings.Read(SettingsPresenter.CompanionKey), "and writes nothing");
+ game.Begin(inputs, 0);
+ Assert.IsNull(game.Companion, "a later game stays without it");
+ game.enabled = false;
+ Assert.IsEmpty(sent, "nothing reached the page");
+ }
+ finally
+ {
+ UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.EmptyScene, UnityEditor.SceneManagement.NewSceneMode.Single);
+ Statecraft.Game.Map.VisualToggles.Clear();
+ if (System.IO.Directory.Exists(dir)) System.IO.Directory.Delete(dir, true);
+ }
+ }
+}
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index 2c5369f59..a2a68b97b 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -501,7 +501,8 @@
<ui:Button name="settings-uiscale-150" text="150%" class="settings-switch" />
</ui:VisualElement>
</ui:VisualElement>
- <!-- The WebGL companion (#1119, WebCompanion): opt-in, off by default; the row shows only where a page can show it. -->
+ <!-- The WebGL companion (#1119, WebCompanion): opt-in, off by default; the row shows only where a page can show it,
+ and not at all while WebCompanion.Available is false (owner, 2 Nov 2026). -->
<ui:VisualElement class="row settings-row">
<ui:Label name="settings-companion-label" text="Screen reader companion" class="settings-name" />
<ui:Button name="settings-companion" class="settings-switch" />