Skip to content

fix the embedded url times (-10 : 30seconds)#3026

Open
ryanbarlow97 wants to merge 10 commits intomainfrom
embeddedurlfix
Open

fix the embedded url times (-10 : 30seconds)#3026
ryanbarlow97 wants to merge 10 commits intomainfrom
embeddedurlfix

Conversation

@ryanbarlow97
Copy link
Contributor

Description:

The embedded url would add 30 seconds to the gameplay time (which looked confusing for ranked games as they are capped to 10mins)
image

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:

w.o.n

@ryanbarlow97 ryanbarlow97 requested a review from a team as a code owner January 25, 2026 19:57
@ryanbarlow97 ryanbarlow97 added Bugfix Fixes a bug UI/UX UI/UX changes including assets, menus, QoL, etc. labels Jan 25, 2026
@ryanbarlow97 ryanbarlow97 added this to the v30 milestone Jan 25, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 25, 2026

Walkthrough

Added spawn-phase timing methods to the ServerConfig interface and implementations; DefaultConfig now delegates spawn-phase turns to the server config; GamePreviewBuilder and its route were updated so previews accept ServerConfig and compute adjusted spawn-phase durations.

Changes

Cohort / File(s) Summary
Configuration Interface
src/core/configuration/Config.ts
Added spawnPhaseTicks(gameType: GameType): number and spawnPhaseSeconds(gameType: GameType): number to ServerConfig.
Default server config
src/core/configuration/DefaultConfig.ts
Added ticksPerSecond(), spawnPhaseTicks(gameType: GameType), and spawnPhaseSeconds(gameType: GameType) to DefaultServerConfig. DefaultConfig.numSpawnPhaseTurns() now delegates to this._serverConfig.spawnPhaseTicks(this._gameConfig.gameType).
Test config
tests/util/TestServerConfig.ts
Implemented spawnPhaseTicks(gameType: GameType) and spawnPhaseSeconds(gameType: GameType); turnIntervalMs() now returns 100 for tests (concrete).
Game preview builder
src/server/GamePreviewBuilder.ts
buildPreview() signature now accepts serverConfig: ServerConfig; computes adjusted spawn-phase duration via serverConfig.spawnPhaseSeconds(gameType) and uses it when rendering finished-state details; consolidated gameType resolution and imports.
Route / Call site
src/server/GamePreviewRoute.ts
Updated call to buildPreview() to pass the ServerConfig argument (new sixth parameter).

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Route as GamePreviewRoute
  participant Builder as GamePreviewBuilder
  participant Config as ServerConfig

  Client->>Route: GET /preview (gameID, ...)
  Route->>Builder: buildPreview(gameID, origin, workerPath, lobby, publicInfo, serverConfig)
  Builder->>Config: spawnPhaseSeconds(gameType)
  Config-->>Builder: seconds
  Builder-->>Route: PreviewMeta (uses adjusted duration)
  Route-->>Client: HTTP 200 with preview
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🕰️ Ticks added, a gentle beat aligns,
Builders read the clock and shape the lines,
Configs speak seconds for each game type,
Routes pass the cue, previews light the night,
Tests keep cadence so the whole thing rhymes.

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title describes the core bug fix but uses unclear notation '(-10 : 30seconds)' that doesn't clearly convey what was changed. Clarify the title to better describe the change, such as 'Fix embedded URL duration calculation in game preview' to make the purpose clearer.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description is related to the changeset, explaining that the embedded URL was adding 30 seconds to gameplay time, which the code changes address through spawn phase duration adjustments.

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


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.

@ryanbarlow97 ryanbarlow97 changed the title fix the embedded url times fix the embedded url times (-30seconds) Jan 25, 2026
@ryanbarlow97 ryanbarlow97 changed the title fix the embedded url times (-30seconds) fix the embedded url times (-10 : 30seconds) Jan 25, 2026
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/core/configuration/Timing.ts`:
- Around line 9-14: The type alias GameTypeLike is too permissive for
spawnPhaseTurns; narrow it to GameType so the function signature matches the
implementation: change GameTypeLike to just GameType and update the
spawnPhaseTurns parameter type accordingly (function spawnPhaseTurns(gameType:
GameType): number), keeping the existing comparison against
GameType.Singleplayer and using SPAWN_PHASE_TICKS; ensure callers such as
DefaultConfig still pass a GameType and adjust any call sites if necessary.

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Jan 25, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 26, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 28, 2026
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/server/GamePreviewBuilder.ts`:
- Around line 184-194: The code currently defaults an unknown gameType to
GameType.Public when computing spawnPhaseSeconds and adjustedDuration, which can
under-report durations; update the logic in GamePreviewBuilder (symbols:
gameType, lobby.gameConfig, GameType enum, spawnPhaseSeconds,
serverConfig.spawnPhaseTicks, adjustedDuration, duration) to treat gameType as a
typed union and only compute/adjust for known values: compute spawnPhaseSeconds
and subtract it from duration only when gameType === GameType.Singleplayer or
gameType === GameType.Public (use a switch/if that checks explicitly against
GameType members), otherwise leave adjustedDuration as duration (or undefined
when duration is not a number) and do not assume Public; apply the same guarded
logic to the other occurrence referenced (lines ~226-228).
🧹 Nitpick comments (1)
tests/util/TestServerConfig.ts (1)

49-54: Provide safe defaults for new timing methods in tests.

Throwing here can break any test that uses buildPreview with TestServerConfig. A small constant default keeps the helper usable.

✅ Suggested defaults
   ticksPerSecond(): number {
-    throw new Error("Method not implemented.");
+    return 10;
   }
   spawnPhaseTicks(gameType: GameType): number {
-    throw new Error("Method not implemented.");
+    return gameType === GameType.Singleplayer ? 100 : 300;
   }

Copilot AI review requested due to automatic review settings February 1, 2026 12:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts how game durations are calculated for preview embeds so that the initial spawn phase time is excluded, fixing the confusing extra ~30 seconds shown for ranked (and other) games. It centralizes spawn phase timing in ServerConfig and reuses that logic both in core config and in the server-side preview builder.

Changes:

  • Extended the ServerConfig interface and DefaultServerConfig implementation with spawnPhaseTicks and spawnPhaseSeconds, and refactored DefaultConfig.numSpawnPhaseTurns() to delegate to ServerConfig.
  • Updated GamePreviewBuilder.buildPreview to accept ServerConfig and subtract the appropriate spawn-phase duration from the reported match duration, using GameType to distinguish singleplayer vs other games.
  • Wired GamePreviewRoute to pass the server config into buildPreview and updated TestServerConfig to implement the new interface methods for tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/util/TestServerConfig.ts Implements spawnPhaseTicks/spawnPhaseSeconds and a concrete turnIntervalMs() in the test server config to align tests with the new ServerConfig interface.
src/server/GamePreviewRoute.ts Passes the ServerConfig instance into buildPreview so the preview builder can compute spawn-phase-adjusted durations.
src/server/GamePreviewBuilder.ts Imports ServerConfig/GameType, adds a serverConfig parameter, and uses spawnPhaseSeconds to subtract the spawn phase from the displayed duration while preserving existing title/description behavior.
src/core/configuration/DefaultConfig.ts Adds ticksPerSecond, spawnPhaseTicks, and spawnPhaseSeconds to DefaultServerConfig, and refactors numSpawnPhaseTurns() to use ServerConfig.spawnPhaseTicks.
src/core/configuration/Config.ts Extends the ServerConfig interface with spawnPhaseTicks(gameType: GameType) and spawnPhaseSeconds(gameType: GameType) so spawn-phase timing is consistently defined.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix Fixes a bug UI/UX UI/UX changes including assets, menus, QoL, etc.

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

2 participants