m1k1o/neko · error

is not the host

Error message

is not the host

What it means

keyboardMap in server/internal/websocket/handler/keyboard.go rejects requests to change the remote keyboard layout when the sender is not the host. Keyboard layout is a host-level desktop setting, so only the session controlling the machine may alter it via h.desktop.SetKeyboardMap.

Source

Thrown at server/internal/websocket/handler/keyboard.go:12

package handler

import (
	"errors"

	"github.com/m1k1o/neko/server/pkg/types"
	"github.com/m1k1o/neko/server/pkg/types/message"
)

func (h *MessageHandlerCtx) keyboardMap(session types.Session, payload *message.KeyboardMap) error {
	if !session.IsHost() {
		return errors.New("is not the host")
	}

	return h.desktop.SetKeyboardMap(payload.KeyboardMap)
}

func (h *MessageHandlerCtx) keyboardModifiers(session types.Session, payload *message.KeyboardModifiers) error {
	if !session.IsHost() {
		return errors.New("is not the host")
	}

	h.desktop.SetKeyboardModifiers(payload.KeyboardModifiers)
	return nil
}

View on GitHub (pinned to b0f01cedea)

Solutions

  1. Take host control before sending keyboard map changes.
  2. Stop the client from auto-syncing keyboard layout when not host.
  3. Only send keyboard settings after receiving confirmation that the session is host.
  4. If layout control is needed, request host from the current host/admin.

Example fix

// before
socket.send({ event: 'keyboard/map', keyboardMap: layout }) // on focus
// after
if (state.isHost) socket.send({ event: 'keyboard/map', keyboardMap: layout })
Defensive patterns

Strategy: validation

Validate before calling

// client-side, before sending keyboard map
if (!state.isHost) {
  console.warn('not the host: keyboard map change skipped')
  return
}

Type guard

function isCurrentHost(state) {
  return state.hostId != null && state.hostId === state.sessionId
}

Try / catch

try {
  socket.emit('keyboard/map', keyboardMap)
} catch (e) {
  if (e.message === 'is not the host') stopLayoutAutoSync()
}

Prevention

When it happens

Trigger: A WebSocket client sends a keyboard map message while session.IsHost() is false.

Common situations: A viewer's client auto-syncing its local keyboard layout to the remote on connect or on window focus while another user hosts; a user who previously hosted and lost control but whose client still pushes layout settings.

Related errors


AI-assisted analysis of m1k1o/neko@b0f01cedea (2026-09-01). Data as JSON: /api/errors/2f6e9513e670192f. Report an issue: GitHub.