Skip to content

Close the manual's window on Back to game in the installed app - #2349

Merged
maniator merged 1 commit into
mainfrom
help-back-to-game
Nov 16, 2026
Merged

maniator merged 1 commit into
mainfrom
help-back-to-game

Conversation

@maniator

Copy link
Copy Markdown
Owner

Requested by Naftali · project thread

What & why

Production bug on 4.5.1, reported by Naftali: in the installed app, Back to game in the Player's Manual opens the game inside the manual's popped-out window instead of returning to the app.

Since 4.5.0 (#2339) the manual is on help.verticopolis.com, outside the app's scope, so the app opens it in a browser view over itself. backToOpenGame (src/ui/fromGame.ts) still ran the in-app rule from #2316. It asked the game over the same-origin vc-game-presence BroadcastChannel, heard nothing from the other host, and called location.replace("https://verticopolis.com/"). That loaded a second copy of the game inside the manual's view.

Now, when the game's address (the link's href) is on another origin than the page, Back to game closes the page without asking. If the browser keeps it open, it shows the existing "close this tab" note. Closing the view brings back the app with its running game. Same-host pages keep #2316's rule: a /help build on previews and staging, and the game's own 404 page.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • Classic-canon fix (matches the 1994 original for all towers)
  • Modern-mode feature (opt-in, "what the original couldn't do")
  • New player-facing feature (mode-agnostic)
  • Refactor / internal-only (no player-facing behavior change)
  • Docs / tooling

Game mode impact

n/a: the manual's Back to game button only.

Quality gates

  • npm run typecheck
  • npm run lint
  • npm test (CI. fromGame, helpSiteMenu and notFoundPage suites pass locally, 42 tests, including a new one for a manual on another host.)
  • npm run build (CI)

Versioning

  • Added a .changes note with the right app: and crate: levels, or this PR changes no deployed path
  • Engine change: updated packages/verticopolis-engine/README.md and/or engine-rs/CRATE_README.md, or read both and put readmes: unchanged in the note, or this PR changes no engine source

Complexity

n/a: no hot path. One URL comparison on a button click.

Hot-path record (section 6): no hot-path surface

Screenshots / recordings

n/a: no visual change. Naftali's report is in the project thread.

Notes for reviewers

  • Analytics are unchanged: the pick is still counted as help_menu_pick game.
  • I can't confirm from here whether Chrome's in-app browser view honors window.close(). If it doesn't, the player sees the note and taps the view's close button, which still returns to the running game rather than opening a second one.

Generated by Claude Code

Since 4.5.0 the manual lives on help.verticopolis.com, outside the app's
scope, so the installed app opens it in a browser view over itself. Back
to game there still ran the in-app rule: ask the game over a same-origin
BroadcastChannel, hear nothing from the other host, and load the game in
place, which put a second copy of the game inside the manual's view.

When the game's address is on another host than the page, the button now
closes the page (saying so if the browser refuses) without asking, which
brings back the app and its running game. Same-host pages keep the old
rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7trYsinXUbmcSQZ3d6N7
@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
verticopolis Ready Ready Preview Nov 16, 2026 12:15am UTC

Request Review

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T00:07:13.990822Z
We couldn’t complete this review. Comment @codex review to try again.
23a7a3f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions Bot added this to the 4.x milestone Nov 16, 2026

@maniator maniator left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Stand-in review (Copilot, Codex and PR-Agent are down): GO at 23a7a3f

Ran stand-in-pr-review with /bmad-code-review (Blind Hunter, Edge Case Hunter, Acceptance Auditor, one lean pass) on head 23a7a3f235e600decef2075f5e5e6a698538d38d. No patch and no defer findings, so nothing goes to the backlog.

What I checked

  • Every Back to game on the manual's host goes cross-host. The menu bar's game item, the title bar's game button and the front page's Play button all take siteHref("/"), which is https://verticopolis.com/ in a production build (checked with VC_HELP_ORIGIN set) and / otherwise. The help host's shared 404 page uses GAME_HOME, also absolute in production. Each listener is on the anchor itself, so e.currentTarget.href is the game's address and never the "/" fallback.
  • #2316's same-origin rule still holds. Previews and staging keep /help (siteHref("/") is /), the game host's own pages (How to Play, release notes, the game's 404) link / or https://verticopolis.com/ on the same origin, so they still ask over vc-game-presence and load the game in place when nothing answers. The two existing installed-app tests still run that path and pass.
  • Fallback when window.close() is refused. The cross-host branch goes through the same closeOrSay as a browser tab: after 250 ms, if the view is still open, it fills #back-note (present on every help page via Header.astro) and moves focus there. The player then taps the view's own close button and lands on the running game. No second copy of the game starts on any path, which is the important part: two copies could both autosave the same tower.
  • Tests. fromGame, helpSiteMenu and notFoundPage suites pass locally (42). With fromGame.ts reverted to main, the new test fails (stillOpen called, close not called), so it guards the fix.
  • Change note, history, version. app: patch, crate: none, one Player line; no version edited. One commit with a clear message, based on current main (2b991a4). No em-dashes. "Back to Game" in the note matches the menu item's label.
  • Hot path. No section 1 surface: one URL comparison on a button click on a help page.

Optional (not required for GO)

  1. When the close is refused inside the app's browser view, the note says "Your tower is still open in its own tab. Close this tab to get back to it." It is accurate enough, since the view has a close button, but "window" would read better there than "tab". Fine to leave.
  2. This path only runs on production, because previews and staging keep the manual under /help. Once 4.5.2 is live, one tap of Back to game in the installed app on a phone confirms whether Chrome's view honors window.close() or shows the note.
  3. Design note, no change asked: if a manual page on the other host ever loaded in the app's own window, closing would end the app rather than reload the game. The tower is saved when the page goes away, so nothing is lost, and that beats starting a second game. Today the game opens every manual link with window.open or target="_blank", so this does not arise.

Verdict: GO at 23a7a3f, on the condition that the required checks finish green (e2e, test and the screenshot shards were still running when I reviewed).

Reviewed against Verticopolis conventions (.github/copilot-instructions.md).


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

📸 Screenshot drift check

No drift: the committed screenshots already match a fresh deterministic generation. ✅

@maniator
maniator merged commit 3d34637 into main Nov 16, 2026
49 checks passed
@maniator
maniator deleted the help-back-to-game branch November 16, 2026 00:20

This branch was successfully deployed

1 active deployment
Preview — 23a7a3f2 Deployed Nov 16, 2026 by vercel[bot]
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.

2 participants