Skip to content

[FIX] Filters actionable events to remove dead requestors - #4238

Merged
evanpelle merged 1 commit into
openfrontio:mainfrom
Katokoda:fix/alliance-request-stay-visible-after-requestor-death
Jun 12, 2026
Merged

evanpelle merged 1 commit into
openfrontio:mainfrom
Katokoda:fix/alliance-request-stay-visible-after-requestor-death

Conversation

@Katokoda

@Katokoda Katokoda commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #4220

Description:

Filters ActionableEvents to remove dead requestors.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
    I do not know how to create and then kill a player in tests/client/graphics/layers/ActionableEventsAlliance.test.ts.

Please put your Discord username so you can be contacted if a bug or regression is found:

Katokoda

@coderabbitai

coderabbitai Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ac59e5ae-671a-41e0-9b72-fedb33fda515

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef3fca and bc7f301.

📒 Files selected for processing (1)
  • src/client/hud/layers/ActionableEvents.ts

Walkthrough

Alliance request event cards now filter out entries when the requestor player is dead. The tick() method's remaining-events logic adds an isAlive() guard to the existing alliance-request condition, removing stale cards from the HUD.

Changes

Alliance request visibility filtering

Layer / File(s) Summary
Alliance request dead-player filtering
src/client/hud/layers/ActionableEvents.ts
The remainingEvents filter for ALLIANCE_REQUEST events now requires the requestor player to be alive, preventing dead players' alliance request cards from cluttering the HUD.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested labels

small-fix

Suggested reviewers

  • evanpelle

Poem

📜 A fallen ally calls no more, 🪦
Their card now fades before the door;
Clean HUD, clear sight, no ghostly plea—
Dead players' requests cease to be. ⚔️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: filtering actionable events to exclude dead requestors in alliance requests.
Description check ✅ Passed The description is related to the changeset, referencing issue #4220 and explaining the fix to remove dead requestors from alliance request events.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #4220: filtering alliance requests to hide them when the requestor dies, matching the expected behavior described.
Out of Scope Changes check ✅ Passed All changes are scoped to the ActionableEvents filtering logic for dead alliance requestors, directly addressing issue #4220 without introducing unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed due to a network error.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Celant

Celant commented Jun 12, 2026

Copy link
Copy Markdown
Member

Re: not knowing how to "create and then kill a player" — good news, you don't need a real player at all. The existing tests in this file just stub game with a plain object whose methods return whatever the case needs, so "killing" a requestor is simply isAlive: () => false.

Since the filter lives in tick(), you mock only what tick() reads:

test("removes ALLIANCE_REQUEST when the requestor is dead", () => {
  const display = new ActionableEvents();

  const myPlayer = { isAlive: () => true, alliances: () => [], smallID: () => 1 };
  // dead but still "requesting" — proves the new isAlive() guard is what removes it
  const deadRequestor  = { isAlive: () => false, isRequestingAllianceWith: () => true };
  const aliveRequestor = { isAlive: () => true,  isRequestingAllianceWith: () => true };
  const players: Record<number, any> = { 2: deadRequestor, 3: aliveRequestor };

  (display as any).game = {
    inSpawnPhase: () => false,
    myPlayer: () => myPlayer,
    updatesSinceLastTick: () => null, // skips the updateMap loop
    ticks: () => 0,
    playerBySmallID: (id: number) => players[id],
  };
  (display as any).requestUpdate = () => {};
  (display as any)._isVisible = true;
  (display as any).events = [
    { description: "from dead",  type: MessageType.ALLIANCE_REQUEST, requestorID: 2, createdAt: 0 },
    { description: "from alive", type: MessageType.ALLIANCE_REQUEST, requestorID: 3, createdAt: 0 },
  ];

  (display as any).tick();

  const remaining = (display as any).events;
  expect(remaining.some((e: any) => e.requestorID === 2)).toBe(false); // dead → removed
  expect(remaining.some((e: any) => e.requestorID === 3)).toBe(true);  // alive → kept
});

A good set would be: dead → removed (the fix), alive + still requesting → kept, alive + no longer requesting → removed (proves you didn't break the old behavior — just isRequestingAllianceWith: () => false), and a non-ALLIANCE_REQUEST event left untouched.

Optional: since the filter is inline in tick(), the test has to stub inSpawnPhase/updatesSinceLastTick/etc. just to reach it. If you pull that predicate out into a small private helper — something like removeDeadOrInactiveAllianceRequests(), paralleling the existing removeAllianceRenewalEvents() — the tests can call it directly with nothing but events and a game stub for playerBySmallID/myPlayer. Cleaner and consistent with the rest of the file, though the tick() version above works fine as-is if you'd rather not touch the source again.

@Celant Celant added this to the Backlog milestone Jun 12, 2026
@Katokoda

Copy link
Copy Markdown
Contributor Author

Oh, thank you very much @Celant !
I'll indeed do that refactoring and test it cleanly!

@github-project-automation github-project-automation Bot moved this from Triage to Final Review in OpenFront Release Management Jun 12, 2026
@evanpelle evanpelle modified the milestones: Backlog, v32 Jun 12, 2026
@evanpelle
evanpelle merged commit 27054bd into openfrontio:main Jun 12, 2026
13 of 20 checks passed
@github-project-automation github-project-automation Bot moved this from Final Review to Complete in OpenFront Release Management Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

[GLITCH] Alliance requests stay visible even if the requestor is dead

3 participants