Files
rhema-together/web/app/components/InviteDialog.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

81 lines
2.5 KiB
Vue

<script setup lang="ts">
import { computed, nextTick, onMounted, ref } from 'vue'
import { Check, Copy } from 'lucide-vue-next'
import type { Invite } from '~/types'
import { apiErrorMessage } from '~/utils/errors'
import { formatDate } from '~/utils/format'
import BaseDialog from '~/components/BaseDialog.vue'
const props = defineProps<{ roomId: string; roomName: string }>()
const emit = defineEmits<{ close: [] }>()
const api = useApi()
const invite = ref<Invite | null>(null)
const loading = ref(true)
const error = ref('')
const copied = ref(false)
const linkInput = ref<HTMLInputElement | null>(null)
const inviteUrl = computed(() => invite.value?.url ?? '')
async function create() {
loading.value = true
error.value = ''
try {
invite.value = await api.post<Invite>(`/rooms/${props.roomId}/invites`)
await nextTick()
linkInput.value?.focus()
linkInput.value?.select()
} catch (err) {
error.value = apiErrorMessage(err)
} finally {
loading.value = false
}
}
async function copy() {
if (!inviteUrl.value) return
try {
await navigator.clipboard.writeText(inviteUrl.value)
copied.value = true
window.setTimeout(() => {
copied.value = false
}, 1800)
} catch {
error.value = 'The clipboard is not available. Select the link and copy it by hand.'
}
}
onMounted(create)
</script>
<template>
<BaseDialog title="Invite people" @close="emit('close')">
<p v-if="loading" class="meta">Creating the link.</p>
<p v-else-if="error && !invite" class="form-error" role="alert">{{ error }}</p>
<div v-if="invite" class="form">
<div class="field">
<label class="field-label" for="invite-url">Invite link</label>
<div class="key-line">
<input id="invite-url" ref="linkInput" class="input mono" :value="inviteUrl" readonly autofocus>
<button type="button" class="btn" aria-label="Copy invite link" title="Copy invite link" @click="copy">
<component :is="copied ? Check : Copy" :size="14" aria-hidden="true" />
{{ copied ? 'Copied' : 'Copy' }}
</button>
</div>
</div>
<p class="form-note">
Anyone with this link can join {{ roomName }}. It works once and expires {{ formatDate(invite.expires_at) }}.
</p>
<p v-if="error" class="form-error" role="alert">{{ error }}</p>
</div>
<div class="dialog-actions">
<button type="button" class="btn" @click="emit('close')">Done</button>
</div>
</BaseDialog>
</template>