The dev panel: tune, cheat, break and replay your game while you play it

Most of the time spent making a multiplayer game feel right isn’t spent writing code. It’s spent changing a number, reloading, walking back to the spot where the thing happens, trying it, and doing it all again. Then a second player is needed for anything worth testing, and there’s only one of you.

The dev panel is our answer to that loop. It’s a small bar in the corner of your game’s page that opens into a panel of tools: sliders for the values you’re tuning, buttons for cheats, simulated lag, saved room state you can go back to, and a recorder that lets you play against yourself. This post walks through it and the ways of working with it that we’ve found pay off.

Adding it

The panel lives in @irtio/client/dev, beside simulateNetwork(). Import it dynamically behind a flag, so it never reaches the bundle you ship:

// web/main.ts
import { connect } from "@irtio/client";
import type { DevConnectInit } from "@irtio/client/dev";

export const tuning = { speed: 6, jumpHeight: 2.4, gravity: 9.8, floaty: false };

const dev = new URLSearchParams(location.search).has("dev") ? (await import("@irtio/client/dev")).devPanel() : undefined;
const init: DevConnectInit = {};
if (dev) init.dial = dev.dial;
const room = await connect("main", init);

if (dev) {
  dev.client = room;
  dev.bind(tuning, "speed", { min: 0, max: 20, step: 0.5 });
  dev.bind(tuning, "jumpHeight", { min: 0.5, max: 6, step: 0.1 });
  dev.bind(tuning, "gravity", { min: 1, max: 30 });
  dev.bind(tuning, "floaty");
}

Two lines do most of the work. Passing dev.dial to connect() routes the connection through the panel, which is what lets it simulate lag and record what you send. Setting dev.client gives it the room to show and drive. Open the game with ?dev and press Ctrl+` to open the panel; everything in it works from the keyboard, so you can keep your hands where they are.

Tune while you play

bind() is the fastest way in: hand it an object and a field, and it picks a control from the value. A number with min and max becomes a slider, a boolean a checkbox, a string with options a select. The control writes straight into your object, so the game reads tuning.speed as it always did and never knows a panel exists.

When you want more control, there’s a method per kind of input: slider, number, text, select, radio and checkbox, each with an onChange. Group them with menu(), which gives you a submenu that hides everything else while it’s open, so a menu per system, Camera, Movement, Weapons, keeps the panel short however much you add.

A few habits make tuning sessions go much faster:

Watch the number you’re tuning against. A slider for jump height is half the picture without the height the player actually reaches. monitor() adds a row that reads a value every frame:

// web/monitors.ts
import { devPanel } from "@irtio/client/dev";

declare const player: { y: number; vy: number; grounded: boolean };

const dev = devPanel();
let peak = 0;
dev.monitor("Jump peak", () => (peak = player.grounded ? 0 : Math.max(peak, player.y)));
dev.monitor("Vertical speed", () => player.vy);

Don’t fear the refresh. Every value you change is kept in your browser. A reload, whether you meant it or the build did it for you, puts every control back to its default, and the Saved values menu lists what you’d set in each of your last five sessions, with a button to put them all back. The panel even reopens at the menu you had open.

Bake the winners in. Once it feels right, Saved values’ Copy as code gives you this session’s changes as an object nested by menu, ready to paste over your defaults:

// web/defaults.ts
export const defaults = {
  speed: 7.5,
  Camera: {
    Zoom: 1.8,
  },
};

Compare feels side by side. Save the current values as a named preset, “floaty jump”, tune something else, save “tight jump”, and flip between them with Apply. Arguments about game feel go faster when both sides are one click away.

A small dot marks every control that differs from its default, and Delete puts the focused one back, so it’s always clear what you’ve changed.

Cheats are just buttons

The second thing everyone builds is a cheat menu. button() takes a label and, with text, shows the label as a caption beside the button, which is the shape of every item list:

// web/cheats.ts
import type { RoomClient } from "@irtio/client";
import { devPanel } from "@irtio/client/dev";

declare const room: RoomClient;
declare function give(item: string): Promise<void>;

const dev = devPanel();
const items = dev.menu("Items");
for (const [i, item] of ["Sword", "Shield", "Potion", "Grappling hook"].entries()) {
  items.button(item, { text: "Add to inventory", key: String(i + 1), onClick: () => give(item) });
}
dev.button("Heal", { key: "h", onClick: () => give("full-heal") });

key binds a key to the button that works while the panel is closed, but not while you’re typing in a field. Mid-fight, pressing 4 for a grappling hook beats opening a menu.

One thing to get right: in a room-authoritative game, an item only counts if the room gives it. So a cheat button usually calls one of your room’s calls, and that call is something a real player could send too. Keep it from working in a deployed room by checking something only your machine has. Under irt dev, a hook’s env is your shell’s environment, so a variable you set when you start it works:

// src/room.ts
import { call, defineCalls, defineRoom, defineSchema, entity } from "@irtio/room";

const Inventory = entity("inventory", { items: "string" });
const schema = defineSchema({ private: Inventory, calls: defineCalls({ give: call({ item: "string" }) }) });

export default defineRoom({
  schema,
  calls: {
    give({ item }, { room, connection, env }) {
      if (env.CHEATS !== "1") throw new Error("cheats are off");
      const inventory = room.private(connection);
      inventory.items = [inventory.items, item].filter(Boolean).join(",");
    },
  },
});

Start it with CHEATS=1 irt dev, and the same build deployed refuses the call, as long as you never set a secret named CHEATS.

When a list changes, say the items depend on the level, call the menu’s clear() and add them again. Setup code that runs twice, as hot reload does, replaces controls rather than doubling them.

Feel the network you’ll ship on

irt dev is on your machine, so every game feels great there. The Network menu fixes that: pick a preset, LAN, good broadband, mobile or poor wifi, or set latency, jitter and packet loss yourself. They change while you’re connected, no reload, so you can drag latency up and down and find the point where your prediction stops hiding it.

While any of it is on, the bar shows a chip for each, “150 ms”, “±40”, “2%”, so you won’t spend an hour chasing a bug that was your own simulated packet loss. Unreliable messages, inputs and pings can be dropped and overtake each other; reliable ones only arrive late, as on a real connection.

Drop connection and Offline test the moments players remember most: the connection dropping mid-game, and coming back. Watch what your game shows while the client is reconnecting, and whether you’d understand it as a player.

One thing that surprises people: the round trip the client reports is the smallest of its recent pings, so after you add latency it takes several seconds to climb.

Go back in time

Some bugs only happen in one place, after a lot of setting up: the third phase of a boss, with two players at low health, on the ledge. Getting there again is most of the cost of fixing it.

The Room menu’s Save room state saves the room’s state under irt dev, and Restore puts the room back to it. A running room starts again from the saved state, and every client reconnects at once and gets it. Saved states are kept in your project’s .irt/data folder, so they outlast irt dev restarting the room when you change its code.

That makes for a tight loop: get to the moment once, save, then edit room code, let irt dev rebuild, restore, and try again. You’re back at the boss in a second, running your new code.

The Room menu has the rest of the room’s life too. Sleep hibernates the room while holding its connections, so your next action wakes it, the path players hit after a quiet spell. Hibernate closes the connections, Wake brings a hibernated room back, and Crash restarts the room host as if it failed, which is the honest way to find out whether your game survives that. Inspect shows the room’s state, your private state and its entities, refreshed every second, and Bots adds and removes the bots your room declares, which fills the seats when you’re testing alone.

Calls sends any of your room’s calls with arguments as JSON, which is handy for poking a handler without wiring up a button for it.

Play against yourself

This is the one that changes how you test. Testing an interaction between two players usually means a second person, or two windows and a lot of alt-tabbing. The Recorder makes the other player you, a few seconds ago.

  1. Open your game in one tab, open the panel’s Recorder and press Record. It saves the room’s state first.
  2. Play the part of the first player: walk down the hallway, turn, empty a magazine down it. Press Stop recording.
  3. Open the game in a second tab. Each tab is its own guest, so this is a second player.
  4. Back in the first tab, press From start on the recording. The room goes back to the state it was in when you pressed Record, and your recorded player does it all again.
  5. Switch to the second tab and walk into the hallway.

You get shot by yourself. Change the damage falloff, restore, play it again, and see whether it feels fair from the other end.

A few things make this work, and they’re worth knowing:

It records what the room got, not what you pressed. The recorder keeps every input, call, message and owner write your tab sent, with its time. That’s exactly what the room acts on, so replaying it makes the room do it again.

It plays inside irt dev, not in your tab. irt dev connects as the recorded player and sends the messages on time, moving inputs onto the room’s current tick. Your first tab is in the background while you play in the second, and browsers slow background tabs’ timers to a crawl, but none of that matters, because the tab isn’t the one playing. It steps aside while the recording plays as its player, and rejoins when it ends.

From start is the one you usually want. Play runs the recording from the room as it is now, which is fine for “do this again here”. From start puts the room back to where the recording began, so the recorded player starts where they did and the hallway is the hallway.

Only your recorded player’s actions come back. Anything the room decides for itself, a dice roll, the time, where the other player is standing, it decides again on playback. That’s usually the point: the recording is the same, and the rest of the world is whatever you make it this time.

Keep recordings short and specific; ten seconds of one interaction is easier to reason about than a minute of play. irt dev keeps the newest 20 for each room.

Let your coding agent use it too

The panel is as useful to an agent as it is to you. dev.controls() lists your controls, buttons and monitors with their keys and values, dev.set() changes one, dev.press() presses a button, and dev.room() does what the Room and Recorder menus do. In a playtest, the play_dev tool exposes all of it, so an agent playing alongside you can turn up the gravity, give itself the grappling hook, or put the room back to your saved state before trying again.

A working rhythm

What we’ve settled into, for what it’s worth:

Everything here is in the dev tools docs, along with the inspector and tick profiler that irt dev gives you outside the page.

All posts · RSS feed