Public: anyone can read this; the crew can change it.

Game door: lock automatically when the player leaves the network, as a setting (#18247) #18329

opened this

Merged 7h 21m ago, live in production

The game door can now lock itself when the player who opened the write window leaves the network. It is a per-box setting, off by default, and a passkey opens the door again as after any lock. The new tests, tsc and the gate's rules pass.

Notes

opened this

The game door can now lock itself when the player who opened the write window leaves the network. It is a per-box setting, off by default, and a passkey opens the door again as after any lock. The new tests, tsc and the gate's rules pass. I did not run the whole suite or try it on a live preview.

  • Trigger: the sync that records a leave (recordMetrics) now calls lockWhenLeft in the new src/games/door_leave.ts. The door locks only when all of these hold:
    • the setting is on;
    • the window is open;
    • the name that left is linked on the box to the account that opened the window;
    • none of that account's linked names is still on any server or in the proxy's player list.
  • Audit: the lock writes a lock row in the box's command log with window locked, naming the player and saying they left the network.
  • Page: the Game door block on /games/<box> has a "Lock when the player leaves" toggle. It is a same-origin POST (op=leave) in src/web/pages/games_door.ts, and the owner sees one line of what it does and why.
  • Terminal: a on the box screen switches the setting and shows the same line (src/tui/screens/games.ts).
  • Storage: an additive column game_door.lock_on_leave, with its pin.
  • Docs: docs/features/games.md has a paragraph on it.
  • Tests: test/game-door-lock-on-leave.test.ts covers five cases:
    • the setting is off by default;
    • the opener leaving locks the door and writes the audit row;
    • someone else leaving, or the opener still on the network, locks nothing;
    • a closed door stays closed;
    • the page sets the setting and refuses a cross-origin post.

Choices to know about:

  • The player is the opener's linked Minecraft name, because windows open from the web with a passkey. If the opener has no linked name, the setting does nothing.
  • If the opener moves between servers and the sync catches the gap, the door locks. That fails safe.
  • I did not touch /forge commands or Talk. Turning the setting on from game would let a line a server shows change the owner's settings.
  • The gate's both-doors rule wanted a new screen or doc, so the commit says No door: and explains that the existing page and terminal screen carry it.
  • Two over-width comment notes remain in metrics.ts and games.ts. They are not from my lines, and the nightly rewrap handles them.

Try it: as the box's owner, open /games/<box> and press "Lock when the player leaves" (or a in the terminal). Open a window with a passkey, then leave the game as your linked name. At the next sync the Game door block reads "Locked by …".

🤖 Generated with Claude Code

Closes #18314

commented

The game door can now lock itself when the player who opened the write window leaves the network. It is a per-box setting, off by default, and a passkey opens the door again as after any lock. The new tests, tsc and the gate's rules pass. I did not run the whole suite or try it on a live preview.

  • Trigger: the sync that records a leave (recordMetrics) now calls lockWhenLeft in the new src/games/door_leave.ts. The door locks only when all of these hold:
    • the setting is on;
    • the window is open;
    • the name that left is linked on the box to the account that opened the window;
    • none of that account's linked names is still on any server or in the proxy's player list.
  • Audit: the lock writes a lock row in the box's command log with window locked, naming the player and saying they left the network.
  • Page: the Game door block on /games/<box> has a "Lock when the player leaves" toggle. It is a same-origin POST (op=leave) in src/web/pages/games_door.ts, and the owner sees one line of what it does and why.
  • Terminal: a on the box screen switches the setting and shows the same line (src/tui/screens/games.ts).
  • Storage: an additive column game_door.lock_on_leave, with its pin.
  • Docs: docs/features/games.md has a paragraph on it.
  • Tests: test/game-door-lock-on-leave.test.ts covers five cases:
    • the setting is off by default;
    • the opener leaving locks the door and writes the audit row;
    • someone else leaving, or the opener still on the network, locks nothing;
    • a closed door stays closed;
    • the page sets the setting and refuses a cross-origin post.

Choices to know about:

  • The player is the opener's linked Minecraft name, because windows open from the web with a passkey. If the opener has no linked name, the setting does nothing.
  • If the opener moves between servers and the sync catches the gap, the door locks. That fails safe.
  • I did not touch /forge commands or Talk. Turning the setting on from game would let a line a server shows change the owner's settings.
  • The gate's both-doors rule wanted a new screen or doc, so the commit says No door: and explains that the existing page and terminal screen carry it.
  • Two over-width comment notes remain in metrics.ts and games.ts. They are not from my lines, and the nightly rewrap handles them.

Try it: as the box's owner, open /games/<box> and press "Lock when the player leaves" (or a in the terminal). Open a window with a passkey, then leave the game as your linked name. At the next sync the Game door block reads "Locked by …".

🤖 Generated with Claude Code

commented

The game door can now lock itself when the player who opened the write window leaves the network. It is a per-box setting, off by default, and a passkey opens the door again as after any lock. This push addresses all three review points and the wording duplication. The new tests, tsc and the gate's rules pass; I did not run the full suite.

What changed this round

  • Opener with no linked name: the Game door block and the terminal now say so when the setting is on and the open window's opener has no linked Minecraft name on the box. The line reads "The open window was opened by someone with no linked name on this box, so nothing will lock it: lock it yourself." I chose to say so rather than lock on any leave, because locking on someone else's leave would surprise the owner.
  • Guarded lock: lockWhenLeft now catches a failure and logs it with log.warn, so the sync still succeeds.
  • One wording: leaveWords carries the whole explanation, and LEAVE_WHY and its page paragraph are gone. The page, the terminal and the flash all use the same sentence.
  • Tests: test/game-door-lock-on-leave.test.ts has ten tests. The new ones cover:
    • pressing a on the box screen as owner switches the setting and says so;
    • an operator's a does nothing;
    • a non-owner's op=leave post is refused;
    • an opener with no linked name gets the "nothing will lock it" line on both the page and the terminal;
    • a leave and a rejoin in one sync keep the door open;
    • a failing lock does not fail the sync.

Not changed: the reviewer asked for tests of the terminal key and of a non-owner's a. The terminal test calls the box screen's key handler with a real key event, not a rendered keypress. The commits carry No door:, because the page block and the a key already exist and docs/features/games.md covers them.

How to try it: as the box's owner, open /games/<box> and turn on "Lock when the player leaves", or press a in the terminal. Open a window with a passkey and leave the game as your linked name. At the next sync the Game door block reads "Locked by …".

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs