fix the embedded url times (-10 : 30seconds)#3026
fix the embedded url times (-10 : 30seconds)#3026ryanbarlow97 wants to merge 10 commits intomainfrom
Conversation
WalkthroughAdded 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
buildPreviewwithTestServerConfig. 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; }
There was a problem hiding this comment.
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
ServerConfiginterface andDefaultServerConfigimplementation withspawnPhaseTicksandspawnPhaseSeconds, and refactoredDefaultConfig.numSpawnPhaseTurns()to delegate toServerConfig. - Updated
GamePreviewBuilder.buildPreviewto acceptServerConfigand subtract the appropriate spawn-phase duration from the reported match duration, usingGameTypeto distinguish singleplayer vs other games. - Wired
GamePreviewRouteto pass the server config intobuildPreviewand updatedTestServerConfigto 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.
Description:
The embedded url would add 30 seconds to the gameplay time (which looked confusing for ranked games as they are capped to 10mins)

Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
w.o.n