Skip to content

Conversation

@bijx
Copy link
Contributor

@bijx bijx commented Jan 10, 2026

Description:

Introduces a light distance estimation function for troop transports that displays their ETA to target destination in the event display in seconds. Works for both outbound and retreating transports. Based on this suggestion in the official Discord.

Screen.Recording.2026-01-10.033708.mp4

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 confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

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

bijx

@bijx bijx self-assigned this Jan 10, 2026
@bijx bijx requested a review from a team as a code owner January 10, 2026 08:43
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 10, 2026

Walkthrough

A new helper method estimateBoatEtaSeconds() computes boat ETAs in seconds using distance to target and server turn interval. Boat labels in renderBoats and outgoingBoats now include ETA text when available; no public signatures changed.

Changes

Cohort / File(s) Summary
Boat ETA Display Enhancement
src/client/graphics/layers/EventsDisplay.ts
Added estimateBoatEtaSeconds() to compute ETA in seconds. Updated renderBoats() and outgoing boats mapping to append ETA (using localized seconds_abbrev) to boat labels when available.
Localization
resources/lang/en.json
Added events_display.seconds_abbrev key with value "{seconds}s" for ETA formatting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • evanpelle

Poem

⛵ A tiny tick for each hull's race,
Seconds added to their moving trace,
Labels whisper when they'll arrive,
Quiet math keeps the map alive. ⏳

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main feature: adding ETA display for transport boats.
Description check ✅ Passed The description is directly related to the changeset, explaining the ETA feature for troop transports and referencing the source Discord suggestion.
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.


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0bcf00 and ff6b793.

📒 Files selected for processing (2)
  • resources/lang/en.json
  • src/client/graphics/layers/EventsDisplay.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/client/graphics/layers/EventsDisplay.ts
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 784
File: src/core/game/StatsImpl.ts:125-134
Timestamp: 2025-05-19T06:00:38.007Z
Learning: In StatsImpl.ts, unused parameters in boat/stats-related methods are intentionally kept for future use and shouldn't be removed.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Deploy to openfront.dev
🔇 Additional comments (1)
resources/lang/en.json (1)

694-694: LGTM! Clean localization addition.

The abbreviated seconds format is appropriate for compact ETA display in the events panel. The placeholder syntax matches existing patterns in the file.

If other language files exist (e.g., de.json, fr.json), remember to add equivalent translations there as well, as each language may have different abbreviations for seconds.


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @src/client/graphics/layers/EventsDisplay.ts:
- Around line 937-939: The hardcoded "s" suffix in EventsDisplay.ts should be
replaced with a translation lookup so time unit formatting is localizable:
update the template that currently inserts (${etaSeconds}s) to call
translateText with a new key (e.g. "events_display.eta_seconds") and substitute
the seconds value (use the existing translateText usage pattern in this file),
and add "events_display.eta_seconds": "{seconds}s" to en.json; locate the string
around renderTroops(boat.troops()) and the conditional using etaSeconds to make
this change.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 240690c and b0bcf00.

📒 Files selected for processing (1)
  • src/client/graphics/layers/EventsDisplay.ts
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 784
File: src/core/game/StatsImpl.ts:125-134
Timestamp: 2025-05-19T06:00:38.007Z
Learning: In StatsImpl.ts, unused parameters in boat/stats-related methods are intentionally kept for future use and shouldn't be removed.
📚 Learning: 2025-05-19T06:00:38.007Z
Learnt from: scottanderson
Repo: openfrontio/OpenFrontIO PR: 784
File: src/core/game/StatsImpl.ts:125-134
Timestamp: 2025-05-19T06:00:38.007Z
Learning: In StatsImpl.ts, unused parameters in boat/stats-related methods are intentionally kept for future use and shouldn't be removed.

Applied to files:

  • src/client/graphics/layers/EventsDisplay.ts
🧬 Code graph analysis (1)
src/client/graphics/layers/EventsDisplay.ts (3)
src/core/game/GameView.ts (2)
  • UnitView (48-183)
  • targetTile (134-136)
src/core/game/UnitImpl.ts (1)
  • targetTile (381-383)
src/client/Utils.ts (2)
  • translateText (147-202)
  • renderTroops (15-17)
🔇 Additional comments (2)
src/client/graphics/layers/EventsDisplay.ts (2)

931-958: Clean integration of ETA display.

The map-based iteration with inline ETA calculation is a clean approach. The conditional rendering when etaSeconds is null handles edge cases well, and the existing retreat/cancel behavior remains intact.


910-924: The ETA calculation is correct as-is.

The formula distance * secondsPerTick accurately estimates boat travel time because boats move exactly 1 tile per tick (see ticksPerMove = 1 in TransportShipExecution). The calculation is:

  • Distance in tiles (10) × seconds per tick (0.1) = total seconds (1)

Boats do not have individual speed properties. Movement speed is hardcoded at the class level (ticksPerMove = 1), not per unit. Manhattan distance is the appropriate metric throughout the codebase for distance calculations on the grid.

While the TODO comment in TransportShipExecution suggests ticksPerMove may become configurable in the future, the current implementation is sound. If boat speed were to become configurable, the formula would need updating at that time, but no change is needed now.

Likely an incorrect or invalid review comment.

@VariableVince
Copy link
Contributor

VariableVince commented Jan 10, 2026

Probably like #2061. Which, FYI, got closed 'in PR review' between @iiamlewis and evan, but not sure if they decided not to go with the feature or for other reasons

@VariableVince
Copy link
Contributor

VariableVince commented Jan 10, 2026

Linked to issue #1793, which wasn't closed by evan when he removed a label so probably still a chance it'll be accepted as a feature

@VariableVince VariableVince linked an issue Jan 10, 2026 that may be closed by this pull request
@bijx bijx marked this pull request as draft January 10, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display real-time countdown for boats in transit

3 participants