Repository navigation
Conversation
WalkthroughThe changes introduce dynamic loading of the game version and changelog via new resource files and client logic. The header now displays a version fetched at runtime. The news modal content is rendered from markdown, replacing hardcoded HTML. The Dockerfile and dependencies are updated for reproducible builds and markdown support. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Client (Main.ts)
participant Server
participant NewsModal
User->>Client (Main.ts): Loads page
Client (Main.ts)->>Server: Fetch /version.txt
Server-->>Client (Main.ts): Returns version string
Client (Main.ts)->>index.html: Updates #game-version text
Client (Main.ts)->>Server: Fetch /changelog.md
Server-->>Client (Main.ts): Returns changelog markdown
Client (Main.ts)->>NewsModal: Sets markdown property
NewsModal->>NewsModal: Renders markdown content
Poem
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
npm error Exit handler never called! 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (3)
Dockerfile (3)
26-31: Document purpose of GAME_CHANGELOG and GAME_VERSION build args
Add a brief comment above these ARG/ENV lines explaining why we’re embedding changelog and version into the image. This will help future maintainers understand their usage.
42-42: Clarify the.gitdirectory hack
Why is an empty.gitfolder created beforenpm ci? Please add a comment or remove this step if it’s no longer needed.
52-54: Combine RUN steps to reduce layers
You can merge the three echo commands into one RUN block to keep the image lean:- RUN echo "$GIT_COMMIT" > static/commit.txt - RUN echo "$GAME_CHANGELOG" > static/changelog.txt - RUN echo "$GAME_VERSION" > static/version.txt + RUN \ + echo "$GIT_COMMIT" > static/commit.txt && \ + echo "$GAME_CHANGELOG" > static/changelog.txt && \ + echo "$GAME_VERSION" > static/version.txt
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.github/workflows/deploy.yml(1 hunks)Dockerfile(3 hunks)deploy.sh(1 hunks)src/client/Main.ts(1 hunks)src/client/index.html(1 hunks)webpack.config.js(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/client/Main.ts (1)
webpack.config.js (1)
gameVersion(14-15)
🪛 GitHub Actions: 🧪 CI
webpack.config.js
[error] 15-15: Build failed: Command 'git describe --tags' failed with fatal error 'No names found, cannot describe anything.' causing webpack config load failure.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Deploy to openfront.dev
🔇 Additional comments (1)
webpack.config.js (1)
127-127: Approve injection of GAME_VERSION into client bundle
Good use ofDefinePluginto exposeprocess.env.GAME_VERSIONto the client code.
| <div id="game-version" class="l-header__highlightText"> | ||
| Loading version... | ||
| </div> |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Wrap placeholder text in translation and add ARIA live region
The hardcoded “Loading version...” must go through translateText() (e.g. via data-i18n) to support i18n, and you should add aria-live="polite" so screen readers announce the version update:
<div id="game-version" class="l-header__highlightText" data-i18n="main.loading_version" aria-live="polite">
<!-- translated at runtime -->
</div>Add main.loading_version to en.json.
🤖 Prompt for AI Agents
In src/client/index.html around lines 206 to 208, the placeholder text "Loading
version..." is hardcoded and not internationalized. Replace the text with an
empty div that uses the attribute data-i18n="main.loading_version" to enable
translation via translateText(), and add aria-live="polite" to the div to ensure
screen readers announce updates. Additionally, add the key
"main.loading_version" with the appropriate translation string to the en.json
localization file.
| VERSION_TAG: latest | ||
| run: | | ||
| echo "::group::deploy.sh" | ||
| git fetch --filter=tree:0 --prune --unshallow |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Use checkout with full history instead of manual git fetch
Instead of running git fetch later, set fetch-depth: 0 on the actions/checkout step to pull all tags and history up front:
- uses: actions/checkout@v4
with:
fetch-depth: 0This removes the need for manual unshallowing.
🤖 Prompt for AI Agents
In .github/workflows/deploy.yml at line 129, the manual git fetch command with
unshallowing is used to get full history. Replace this by setting fetch-depth: 0
in the actions/checkout step earlier in the workflow to fetch the entire git
history and tags upfront, eliminating the need for the manual git fetch command.
| --build-arg GAME_VERSION=$GAME_VERSION \ | ||
| --build-arg GIT_COMMIT=$GIT_COMMIT \ |
There was a problem hiding this comment.
Pass GAME_CHANGELOG or remove unused arg
The Dockerfile expects --build-arg GAME_CHANGELOG, but this script never sets it. Either compute and pass GAME_CHANGELOG here or drop that build arg from the Dockerfile.
🤖 Prompt for AI Agents
In deploy.sh around lines 151 to 152, the script passes build arguments
GAME_VERSION and GIT_COMMIT but does not set or pass GAME_CHANGELOG, which the
Dockerfile expects. To fix this, either compute the GAME_CHANGELOG value in the
script and add it as a build argument like --build-arg
GAME_CHANGELOG=$GAME_CHANGELOG, or if GAME_CHANGELOG is not needed, remove the
corresponding build-arg line from the Dockerfile to avoid passing an unset
argument.
| # Get game version for build info | ||
| GAME_VERSION=$(git describe --tags) | ||
| echo "Game version: $GAME_VERSION" | ||
|
|
There was a problem hiding this comment.
Guard against missing tags and handle failures
git describe --tags will crash if no tags are present. Wrap it to fallback gracefully and/or use --always:
- GAME_VERSION=$(git describe --tags)
+ GAME_VERSION=$(git describe --tags --always 2>/dev/null || echo "unknown")Also consider adding or removing GAME_CHANGELOG if it’s not being set.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Get game version for build info | |
| GAME_VERSION=$(git describe --tags) | |
| echo "Game version: $GAME_VERSION" | |
| # Get game version for build info | |
| - GAME_VERSION=$(git describe --tags) | |
| + GAME_VERSION=$(git describe --tags --always 2>/dev/null || echo "unknown") | |
| echo "Game version: $GAME_VERSION" |
🤖 Prompt for AI Agents
In deploy.sh around lines 141 to 144, the command `git describe --tags` can fail
if no tags exist, causing the script to crash. Modify the command to use `git
describe --tags --always` to ensure it returns a value even without tags.
Additionally, add error handling to fallback gracefully if the command fails.
Review the usage of `GAME_CHANGELOG` and remove or set it appropriately if it is
not currently handled.
| const gameVersion = | ||
| process.env.GAME_VERSION ?? execSync("git describe --tags").toString().trim(); | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add fallback for git describe in webpack config
execSync("git describe --tags") will throw if no tags exist and break the build. Wrap the call in a try/catch or use --always and default to "unknown":
- const gameVersion =
- process.env.GAME_VERSION ?? execSync("git describe --tags").toString().trim();
+ let gameVersion = process.env.GAME_VERSION;
+ if (!gameVersion) {
+ try {
+ gameVersion = execSync("git describe --tags --always").toString().trim();
+ } catch {
+ gameVersion = "unknown";
+ }
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const gameVersion = | |
| process.env.GAME_VERSION ?? execSync("git describe --tags").toString().trim(); | |
| let gameVersion = process.env.GAME_VERSION; | |
| if (!gameVersion) { | |
| try { | |
| gameVersion = execSync("git describe --tags --always").toString().trim(); | |
| } catch { | |
| gameVersion = "unknown"; | |
| } | |
| } |
🧰 Tools
🪛 GitHub Actions: 🧪 CI
[error] 15-15: Build failed: Command 'git describe --tags' failed with fatal error 'No names found, cannot describe anything.' causing webpack config load failure.
🤖 Prompt for AI Agents
In webpack.config.js around lines 14 to 16, the call to execSync("git describe
--tags") can throw an error if no git tags exist, causing the build to break. To
fix this, wrap the execSync call in a try/catch block or modify the command to
use "git describe --tags --always" and provide a default fallback value like
"unknown" if the command fails or returns empty. This will ensure the build does
not break due to missing git tags.
| const gameVersion = document.getElementById( | ||
| "game-version", | ||
| ) as HTMLDivElement; | ||
| if (!gameVersion) { | ||
| console.warn("Game version element not found"); | ||
| } | ||
| fetch("/version.txt") | ||
| .then((response) => { | ||
| return response.ok ? response.text() : "Failed to load version"; | ||
| }) | ||
| .then((version) => { | ||
| gameVersion.innerText = version; | ||
| }); |
There was a problem hiding this comment.
Fix null pointer bug and improve error handling.
The code checks if gameVersion is null but still tries to use it in the .then() block. This will cause a runtime error if the element doesn't exist.
Also, the fetch error handling only covers HTTP errors but not network failures.
Apply this diff to fix the issues:
-const gameVersion = document.getElementById(
- "game-version",
-) as HTMLDivElement;
-if (!gameVersion) {
- console.warn("Game version element not found");
-}
-fetch("/version.txt")
- .then((response) => {
- return response.ok ? response.text() : "Failed to load version";
- })
- .then((version) => {
- gameVersion.innerText = version;
- });
+const gameVersion = document.getElementById(
+ "game-version",
+) as HTMLDivElement;
+if (!gameVersion) {
+ console.warn("Game version element not found");
+ return;
+}
+
+fetch("/version.txt")
+ .then((response) => {
+ if (!response.ok) {
+ throw new Error(`HTTP ${response.status}`);
+ }
+ return response.text();
+ })
+ .then((version) => {
+ gameVersion.innerText = version;
+ })
+ .catch((error) => {
+ console.warn("Failed to load version:", error);
+ gameVersion.innerText = "Failed to load version";
+ });📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const gameVersion = document.getElementById( | |
| "game-version", | |
| ) as HTMLDivElement; | |
| if (!gameVersion) { | |
| console.warn("Game version element not found"); | |
| } | |
| fetch("/version.txt") | |
| .then((response) => { | |
| return response.ok ? response.text() : "Failed to load version"; | |
| }) | |
| .then((version) => { | |
| gameVersion.innerText = version; | |
| }); | |
| const gameVersion = document.getElementById( | |
| "game-version", | |
| ) as HTMLDivElement; | |
| if (!gameVersion) { | |
| console.warn("Game version element not found"); | |
| return; | |
| } | |
| fetch("/version.txt") | |
| .then((response) => { | |
| if (!response.ok) { | |
| throw new Error(`HTTP ${response.status}`); | |
| } | |
| return response.text(); | |
| }) | |
| .then((version) => { | |
| gameVersion.innerText = version; | |
| }) | |
| .catch((error) => { | |
| console.warn("Failed to load version:", error); | |
| gameVersion.innerText = "Failed to load version"; | |
| }); |
🤖 Prompt for AI Agents
In src/client/Main.ts around lines 62 to 74, the code checks if the gameVersion
element exists but still uses it without guarding against null, causing a
potential runtime error. To fix this, add a return or conditional to avoid using
gameVersion if it is null. Also, improve fetch error handling by adding a
.catch() block to handle network failures and log or handle those errors
appropriately.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/client/NewsModal.ts (2)
2-2: Consider if the markdown library is necessary.Adding
lit-markdownintroduces a new dependency. For simple news content, basic HTML might be enough. If markdown is required, ensure this library is the best choice for the project.Alternative approach using template literals for simple formatting:
-import { resolveMarkdown } from "lit-markdown";Then in the render method, use simple HTML templates instead of markdown processing.
15-15: Use lowercase primitive type.TypeScript style guide recommends using lowercase
stringinstead ofStringfor primitive types.- @property({ type: String }) markdown = "Loading..."; + @property({ type: String }) markdown: string = "Loading...";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
Dockerfile(3 hunks)package.json(1 hunks)resources/changelog.md(1 hunks)resources/version.txt(1 hunks)src/client/Main.ts(2 hunks)src/client/NewsModal.ts(3 hunks)
✅ Files skipped from review due to trivial changes (3)
- package.json
- resources/version.txt
- resources/changelog.md
🚧 Files skipped from review as they are similar to previous changes (2)
- Dockerfile
- src/client/Main.ts
| ${resolveMarkdown(this.markdown, { | ||
| includeImages: true, | ||
| includeCodeBlockClassNames: true, | ||
| })} |
There was a problem hiding this comment.
Add security measures and error handling for markdown rendering.
Enabling images and code blocks in markdown can create security risks. Consider these concerns:
- Security: Images can be used for tracking or XSS attacks
- Performance: External images can slow down the modal
- Error handling: No fallback if markdown parsing fails
Consider this safer approach:
- ${resolveMarkdown(this.markdown, {
- includeImages: true,
- includeCodeBlockClassNames: true,
- })}
+ ${this.renderSafeMarkdown()}Add a helper method:
private renderSafeMarkdown() {
try {
return resolveMarkdown(this.markdown, {
includeImages: false, // Disable for security
includeCodeBlockClassNames: false, // Disable unless needed
});
} catch (error) {
console.error('Markdown rendering failed:', error);
return html`<p>Failed to load content. Please try again.</p>`;
}
}🤖 Prompt for AI Agents
In src/client/NewsModal.ts around lines 57 to 60, the current markdown rendering
enables images and code block class names without error handling, which poses
security and performance risks. Refactor by creating a helper method that
disables image inclusion and code block class names for safety, wraps the
markdown rendering in a try-catch block to handle errors gracefully, logs any
rendering errors, and returns a fallback HTML message if rendering fails.
Replace the direct call to resolveMarkdown with this new safe rendering method.
## Description: Move these assets to files so that they can be replaced with generated assets in the future. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
## Description: Move these assets to files so that they can be replaced with generated assets in the future. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
## Description: Move these assets to files so that they can be replaced with generated assets in the future. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
Move these assets to files so that they can be replaced with generated assets in the future. - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
Move these assets to files so that they can be replaced with generated assets in the future. - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
… did (#6287) Client half of the stacked-gift work. The server side is in openfrontio/infra#1107, #1108 and #1109, and this needs those deployed to show anything new. On an older API it falls back to `subscription` and behaves as it does today. A player can now hold a paid subscription and a free one at once. A Steam purchase at or below the paid tier moves the next payment back instead of granting a month. This PR makes each outcome explain itself, so nobody has to open a ticket to find out what happened. ## What changes - **Account modal.** It shows a tile for each subscription when there are two. The paid tile is never hidden behind the gift. - Paid tile: "Steam Plus · next payment 23 Nov · $4.99/mo" - Gift tile: "Sovereign from your Steam purchase · ends 23 Dec · 25 plutonium a day" - A moved payment reads "Next payment 23 Dec (free month from the Deluxe Edition)". A past-due paid sub is no longer hidden behind a gift. - **Notices on boot.** These go through the existing `BootInterrupts` ordering: - **Stacked welcome:** "Thanks for your Steam purchase. You've got Sovereign until 23 Dec, on top of your Steam Plus, so that's an extra 25 plutonium a day. Your Steam Plus still renews on 23 Nov as normal." - **Renewal moved** (the new `renewal_pushed` server message): "You already have Sovereign, so the Deluxe Edition gives you a free month instead. Your next payment is on 23 Dec." It is marked seen the way `report_thanks` is. - **Gift ending in 3 days:** "Your Sovereign month ends on 23 Dec. After that you'll be back on Steam Plus." Without a paid sub it says "Subscribe to keep your perks." It shows once per end date. - **Subscribing over a gift.** - A higher gift: "You'll keep your Sovereign until 23 Dec as well." - A same or lower gift: "You pay for the first month today. You've still got 12 free days, so your next payment moves 12 days later." This now holds on both rails, so the Stripe "the days are not refunded" copy is gone. - Tier changes and the "Subscribed" marking in the store follow the paid row. ## Known gap A gift row doesn't say which Steam product funded it, so the stacked welcome and the gift tile say "your Steam purchase" rather than naming the Deluxe Edition. The moved-payment copy can name the product, because the server sends `renewalPushedBy`. Naming the product on a gift row needs a small server field, which can follow. ## Tests Typecheck, lint, oxfmt and `test:changed` pass (5390 tests). There are new cases in BootInterrupts, SteamGrantNotices, SteamNotices, SubscriptionPanel, GrantedSubscriptionPurchase and ApiSchemas. Screenshots will follow from the preview deploy once the infra PRs are on staging. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… did (#6287) Client half of the stacked-gift work. The server side is in openfrontio/infra#1107, #1108 and #1109, and this needs those deployed to show anything new. On an older API it falls back to `subscription` and behaves as it does today. A player can now hold a paid subscription and a free one at once. A Steam purchase at or below the paid tier moves the next payment back instead of granting a month. This PR makes each outcome explain itself, so nobody has to open a ticket to find out what happened. - **Account modal.** It shows a tile for each subscription when there are two. The paid tile is never hidden behind the gift. - Paid tile: "Steam Plus · next payment 23 Nov · $4.99/mo" - Gift tile: "Sovereign from your Steam purchase · ends 23 Dec · 25 plutonium a day" - A moved payment reads "Next payment 23 Dec (free month from the Deluxe Edition)". A past-due paid sub is no longer hidden behind a gift. - **Notices on boot.** These go through the existing `BootInterrupts` ordering: - **Stacked welcome:** "Thanks for your Steam purchase. You've got Sovereign until 23 Dec, on top of your Steam Plus, so that's an extra 25 plutonium a day. Your Steam Plus still renews on 23 Nov as normal." - **Renewal moved** (the new `renewal_pushed` server message): "You already have Sovereign, so the Deluxe Edition gives you a free month instead. Your next payment is on 23 Dec." It is marked seen the way `report_thanks` is. - **Gift ending in 3 days:** "Your Sovereign month ends on 23 Dec. After that you'll be back on Steam Plus." Without a paid sub it says "Subscribe to keep your perks." It shows once per end date. - **Subscribing over a gift.** - A higher gift: "You'll keep your Sovereign until 23 Dec as well." - A same or lower gift: "You pay for the first month today. You've still got 12 free days, so your next payment moves 12 days later." This now holds on both rails, so the Stripe "the days are not refunded" copy is gone. - Tier changes and the "Subscribed" marking in the store follow the paid row. A gift row doesn't say which Steam product funded it, so the stacked welcome and the gift tile say "your Steam purchase" rather than naming the Deluxe Edition. The moved-payment copy can name the product, because the server sends `renewalPushedBy`. Naming the product on a gift row needs a small server field, which can follow. Typecheck, lint, oxfmt and `test:changed` pass (5390 tests). There are new cases in BootInterrupts, SteamGrantNotices, SteamNotices, SubscriptionPanel, GrantedSubscriptionPurchase and ApiSchemas. Screenshots will follow from the preview deploy once the infra PRs are on staging. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 8ed9d42) Conflicts resolved for v35 by Claude.
Description:
Move these assets to files so that they can be replaced with generated assets in the future.
Please complete the following: