Files
rhema-together/web/app/pages/setup.vue
T
vhaudiquet 0035f4e031 feat: add the multiplayer room server and client
A room is one conversation, one ssh sandbox, and one agent. Accounts
create rooms; friends join through a single-use invite link and a
display name; the agent speaks only through the message tool.

The server is Axum and SQLite. It serves the built Nuxt client, streams
room events over SSE, and runs one serialized turn loop per room with
turn-level steering copied from rhema-code. The client has the chat,
preview iframe, read-only file pane, xterm terminal, and presence.

Preview URLs are signed wildcard hosts, and the proxy tunnels HTTP over
ssh direct-tcpip. HostAgent::step remains deferred in the framework.
2026-11-28 01:09:37 +01:00

127 lines
3.5 KiB
Vue

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import type { User } from '~/types'
import { apiErrorMessage } from '~/utils/errors'
definePageMeta({ layout: 'auth' })
useHead({ title: 'Set up the server · rhema together' })
const api = useApi()
const { load } = useSession()
const token = ref('')
const displayName = ref('')
const handle = ref('')
const email = ref('')
const password = ref('')
const checking = ref(true)
const submitting = ref(false)
const error = ref('')
onMounted(async () => {
try {
const state = await load(true)
if (!state.needsSetup) {
await navigateTo('/login', { replace: true })
}
} catch (err) {
error.value = apiErrorMessage(err)
} finally {
checking.value = false
}
})
async function submit() {
if (submitting.value) return
submitting.value = true
error.value = ''
try {
await api.post<User>('/setup', {
token: token.value.trim(),
display_name: displayName.value.trim(),
handle: handle.value.trim().toLowerCase(),
email: email.value.trim() || null,
password: password.value,
})
await load(true)
await navigateTo('/rooms', { replace: true })
} catch (err) {
error.value = apiErrorMessage(err)
} finally {
submitting.value = false
}
}
</script>
<template>
<div>
<h1 class="auth-title">Set up the server</h1>
<p class="auth-note">Create the owner account. The token is printed in the server log at startup.</p>
<p v-if="checking" class="meta">Checking the server.</p>
<form v-else class="form" @submit.prevent="submit">
<div class="field">
<label class="field-label" for="setup-token">Setup token</label>
<input
id="setup-token"
v-model="token"
class="input"
type="text"
autocomplete="off"
spellcheck="false"
autofocus
required
>
</div>
<div class="field">
<label class="field-label" for="setup-name">Display name</label>
<input id="setup-name" v-model="displayName" class="input" type="text" autocomplete="name" required>
</div>
<div class="field">
<label class="field-label" for="setup-handle">Handle</label>
<input
id="setup-handle"
v-model="handle"
class="input"
type="text"
autocomplete="username"
spellcheck="false"
pattern="[A-Za-z0-9_-]{3,32}"
minlength="3"
maxlength="32"
required
>
<span class="hint">3 to 32 lowercase letters, digits, _ or -.</span>
</div>
<div class="field">
<label class="field-label" for="setup-email">Email <span class="field-optional">optional</span></label>
<input id="setup-email" v-model="email" class="input" type="email" autocomplete="email">
</div>
<div class="field">
<label class="field-label" for="setup-password">Password</label>
<input
id="setup-password"
v-model="password"
class="input"
type="password"
autocomplete="new-password"
minlength="8"
required
>
<span class="hint">At least 8 characters.</span>
</div>
<p v-if="error" class="form-error" role="alert">{{ error }}</p>
<button type="submit" class="btn btn-primary" :disabled="submitting">
{{ submitting ? 'Creating the account' : 'Create the account' }}
</button>
</form>
</div>
</template>