Files
ai-spel-frontend/README.md
T
Ein Anderssono 69184d1920
Build and publish frontend / publish (push) Successful in 38s
Speak onboarding and all game dialogue automatically
2026-10-15 10:54:10 +02:00

6.3 KiB

AI-spel frontend

This repository contains the static Swedish web client for the AI-driven life simulator. The intended deployment is a small Nginx pod in the ai-spel namespace. The existing Rust service remains authoritative for accounts, game state, and all /api/... routes.

After login, character creation and play use one dialogue history and one text input. The player writes a free biography, receives a temporary AI draft, can request revisions, and approves it by writing godkänn. The player then receives a proposed start world and place based on the biography. That draft can also be revised in dialogue and is saved only after a second explicit godkänn. Drafts stay in the browser until approval and are lost if the page is reloaded first. The backend creates the character and initializes the world only after their respective approvals.

During play the UI has no persistent location, task, inventory, economy, status, or purchase panels. The player asks for information or writes an action in the same input. Rust validates state changes; the AI can only propose a typed intent. A direct request to travel may establish a new place and an encounter when Rust commits that movement.

If the player asks to find or approach someone and no NPC is present, the direct dialogue scene may propose one person and an opening line. Rust creates that NPC only for the explicit request and commits the first exchange idempotently; a later turn continues the saved conversation. Clear requests about the current location are answered from its saved facts without asking the player to restate what they want to inspect.

The separate /admin route provides an authenticated, read-only operations view for player search/profile/trace, YAML prompt assets, generated Luau rules with validation results, and the append-only audit log. All privileged data comes from the Rust /api/admin/... API; the browser never connects directly to PostgreSQL. Backend endpoints require accounts.is_admin=true.

The game is text- and dialogue-based and uses no images. Place descriptions include sound, smell, air/temperature, touch/surface, and spatial-orientation cues. Visible details may also be described in words, but are never required to understand the scene or play. The transcript is screen-reader announced, and Enter submits the input while Shift+Enter inserts a newline; no separate send button is required.

Voice output uses the browser's Swedish speech synthesis for all player-facing game dialogue, onboarding, account responses, character and world creation, gameplay replies, in-game errors, and microphone disclosures. The /admin route is excluded. The first unauthenticated visit automatically reads an introduction that explains the game, how to create an account, and how to play; the introduction stays visible as text and can be replayed with Läs introduktionen igen. New game replies are read automatically and the transcript remains available to screen readers and as text. Returning players hear the latest saved game reply when they reopen the game. Voice settings can change the Swedish voice and speaking rate, but cannot disable automatic speech. These preferences are stored in browser localStorage. If the browser lacks speech synthesis or blocks playback, the same content remains available as text and the introduction can be started again with its replay button.

The microphone button beside the text field uses Web Speech API when available and sends only its final Swedish transcript through the same submission path as typed text. Before its first use, the client explains that the browser may process audio through a provider-selected service; the game itself does not receive or store recordings, while the final transcript is saved as ordinary dialogue. Writing röstinställningar or saying röstkommando alternativ opens temporary voice controls in the dialogue. The player can select an available Swedish voice and speaking rate and enable or disable short audio cues. Voice preferences are stored in browser localStorage.

When a character or NPC is created, its saved voice identity is masculine, feminine, or neutral. The biography prompt only assigns masculine/feminine when the character is explicitly described that way; otherwise it uses neutral. Speech synthesis applies a stable, subtly varied pitch/rate profile per character, so a character keeps the same sound across visits. Narration always uses neutral pitch. The browser's selected Swedish voice still determines the underlying voice, so the exact sound depends on installed system voices.

System voice commands require the prefix röstkommando: upprepa, avbryt, hjälp, alternativ, or paus. Without the prefix, the same words remain ordinary dialogue. Speech recognition and synthesis are browser-dependent; release acceptance must record which real iPhone/Safari/VoiceOver and Android/Chrome/TalkBack combinations were actually checked.

The browser and API stay on the same public origin, https://ai-spel.k3s.k0.nu. The ingress routes / to this frontend service and routes /api, /version, and /health to the Rust service. That keeps the current server-side session cookie same-origin and avoids browser CORS configuration.

Release flow

VERSION is the only version source for this repository. Gitea Actions on the existing large runner runs the static checks, Helm lint/template, publishes a commit image, bumps the patch version through scripts/bump-version.py, creates the matching release commit and Git tag, and publishes the release image, Helm chart, and rendered frontend manifest to Harbor. Argo CD tracks the newest published frontend chart. The image and chart releases use the same version as the commit and tag.

CI needs repository Action secrets named HARBOR_USERNAME and HARBOR_PASSWORD. The Harbor pull secret harbor-pull is already present in the Kubernetes namespace. Argo CD uses the existing ai-spel project and Harbor OCI credentials.

The first Argo Application is described in deploy/argocd/application.yaml. The backend ingress routes /api, /version, and health checks to Rust while serving the static client at /. Both services share the same origin so the session cookie remains same-origin.

Builds, checks, and runtime verification happen in the pipeline and Kubernetes. Do not run the app, tests, container images, or binaries locally.