From 6c139f7c4ddca6b5a653496d3e225612b66d0aee Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Wed, 11 Nov 2026 13:46:24 +0000 Subject: [PATCH] fix(viewer): restore concurrent charge controls from legacy caches --- old-ui/package.json | 2 +- viewer/package.json | 2 +- viewer/src/components/Game.vue | 6 ++++ .../src/components/concurrent-charges.spec.ts | 35 +++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/old-ui/package.json b/old-ui/package.json index a738e970..edc20d0d 100644 --- a/old-ui/package.json +++ b/old-ui/package.json @@ -1,6 +1,6 @@ { "name": "@gaia-project/old-ui", - "version": "1.2.34", + "version": "1.2.35", "scripts": { "serve": "vite --port 5193", "build": "vite build", diff --git a/viewer/package.json b/viewer/package.json index 5737655f..0ab5aad0 100644 --- a/viewer/package.json +++ b/viewer/package.json @@ -1,6 +1,6 @@ { "name": "@gaia-project/viewer", - "version": "5.22.34", + "version": "5.22.35", "description": "Functions to visualize the map and boards for gaia project inside html canvas", "contributors": [ "coyotte508", diff --git a/viewer/src/components/Game.vue b/viewer/src/components/Game.vue index 2c036240..7c9f8990 100644 --- a/viewer/src/components/Game.vue +++ b/viewer/src/components/Game.vue @@ -2059,6 +2059,12 @@ export default class Game extends Vue { data.moveHistory.pop(); } + // fromData discards obsolete concurrent-charge caches (e.g. legacy Resume). + // Rebuild those decisions before committing the non-deeply-reactive engine; + // otherwise the active recipient gets a turn banner but no action buttons. + if (hasConcurrentCharges(data) && data.newTurn) { + data.generateAvailableCommandsIfNeeded(); + } this.$store.commit("receiveData", data); setTimeout(() => { diff --git a/viewer/src/components/concurrent-charges.spec.ts b/viewer/src/components/concurrent-charges.spec.ts index c8135a6c..f1b06d88 100644 --- a/viewer/src/components/concurrent-charges.spec.ts +++ b/viewer/src/components/concurrent-charges.spec.ts @@ -131,6 +131,41 @@ describe("concurrent charge controls", () => { expect(button(vm, "Research")).not.to.equal(undefined); }); + for (const answer of ["charge", "decline"]) { + it(`restores a legacy wait cache's charge controls and resolves ${answer} locally`, async () => { + const saved = hostedMove(JSON.parse(JSON.stringify(position())), "nevlas waitForCharges", 1); + // Old saved games include Resume alongside another seat's pending decision. + // fromData invalidates that cache; the viewer must rebuild it before rendering. + const incoming = JSON.parse(JSON.stringify(saved)); + incoming.version = "4.17.3"; + incoming.availableCommands.push({ name: Command.ResumeCharges, player: 1 }); + const before = JSON.stringify(incoming); + const vm = mountGame(3, position()); + await vm.$store.dispatch("externalData", incoming); + await Vue.nextTick(); + expect(vm.canPlay).to.equal(true); + expect(vm.engine.availableCommands).not.to.equal(null); + expect(vm.$el.querySelector("#move").textContent).to.contain("Charge power"); + expect(button(vm, "Decline")).not.to.equal(undefined); + expect(button(vm, "Resume")).to.equal(undefined); + expect(button(vm, "Research")).to.equal(undefined); + expect(JSON.stringify(incoming)).to.equal(before); + + vm.$store.commit("player", { index: 1 }); + await Vue.nextTick(); + expect(vm.canPlay).to.equal(false); + expect(button(vm, "Resume")).to.equal(undefined); + expect(button(vm, "Research")).to.equal(undefined); + const resolved = hostedMove(incoming, `hadsch-hallas ${answer} 1pw @2`, 3); + await vm.$store.dispatch("externalData", JSON.parse(JSON.stringify(resolved))); + await Vue.nextTick(); + expect(vm.engine.pendingCharges).to.have.length(0); + expect(vm.engine.chargeWaits).to.deep.equal({}); + expect(vm.canPlay).to.equal(true); + expect(button(vm, "Research")).not.to.equal(undefined); + }); + } + it("keeps an unfinished turn when an opponent answers, without modifying the incoming saved position", async () => { const saved = position(); const partial = Engine.fromData(JSON.parse(JSON.stringify(saved)));