xonecas.io
5875
Os

ollama-space-molt-player / commit e940c44

Fix auto-login by moving it to handleWelcome

- Move auto-login from start() to handleWelcome()
- Auto-login now happens after welcome message is received
- Skip processTick() when auto-login is sent
- Only call processTick() for fresh instances (no account)

This fixes the issue where auto-login was sent before the welcome
message, and processTick() was always called even when logging in
with an existing account, causing the LLM to generate duplicate
commands.

Tested:
- Existing instance (human-partner): Auto-login successful, ticks received
- Fresh instance (fresh-test): processTick() called for registration

xonecas2026-02-03 e940c446fffa90641c1fdf6f9918c9e33038197d parent 3112ce2

1 file changed

packages/client/src/game-client.ts+15−15
@@ -74,15 +74,6 @@ export class GameClient {
7474
7575 await this.ws.connect();
7676 this.isRunning = true;
77-
78- const activeUsername = this.db.getActiveUsername();
79- if (activeUsername) {
80- console.log(`[${this.config.instanceId}] Auto-login as ${activeUsername.username}`);
81- this.ws.send({
82- type: "login",
83- payload: { username: activeUsername.username, token: activeUsername.token },
84- });
85- }
8677 }
8778
8879 stop(): void {
@@ -160,13 +151,22 @@ export class GameClient {
160151 this.startWatchdog();
161152
162153 if (this.isRunning) {
163- await this.processTick().catch((error) => {
164- console.error(`[${this.config.instanceId}] Initial tick processing error:`, error);
165- this.db.saveMessage(this.currentTick, "client", {
166- error: "Initial tick processing failed",
167- code: "TICK_PROCESSING_ERROR",
154+ const activeUsername = this.db.getActiveUsername();
155+ if (activeUsername) {
156+ console.log(`[${this.config.instanceId}] Auto-login as ${activeUsername.username}`);
157+ this.ws.send({
158+ type: "login",
159+ payload: { username: activeUsername.username, token: activeUsername.token },
168160 });
169- });
161+ } else {
162+ await this.processTick().catch((error) => {
163+ console.error(`[${this.config.instanceId}] Initial tick processing error:`, error);
164+ this.db.saveMessage(this.currentTick, "client", {
165+ error: "Initial tick processing failed",
166+ code: "TICK_PROCESSING_ERROR",
167+ });
168+ });
169+ }
170170 }
171171 }