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

109 lines
3.1 KiB
Vue

<script setup lang="ts">
import { nextTick, onBeforeUnmount, onMounted, ref, useId } from 'vue'
import { X } from 'lucide-vue-next'
const props = withDefaults(defineProps<{ title: string; description?: string; wide?: boolean }>(), {
description: '',
wide: false,
})
const emit = defineEmits<{ close: [] }>()
const titleId = useId()
const descId = useId()
const panel = ref<HTMLElement | null>(null)
let previousFocus: HTMLElement | null = null
let previousOverflow = ''
function focusable(): HTMLElement[] {
if (!panel.value) return []
const selector = [
'a[href]',
'button:not([disabled])',
'input:not([disabled]):not([type="hidden"])',
'select:not([disabled])',
'textarea:not([disabled])',
'[tabindex]:not([tabindex="-1"])',
].join(',')
return Array.from(panel.value.querySelectorAll<HTMLElement>(selector)).filter(
(element) => element.offsetParent !== null,
)
}
function onKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') {
event.preventDefault()
emit('close')
return
}
if (event.key !== 'Tab') return
const items = focusable()
if (items.length === 0) {
event.preventDefault()
panel.value?.focus()
return
}
const first = items[0]
const last = items[items.length - 1]
const active = document.activeElement as HTMLElement | null
if (event.shiftKey) {
if (active === first || !panel.value?.contains(active)) {
event.preventDefault()
last?.focus()
}
} else if (active === last || !panel.value?.contains(active)) {
event.preventDefault()
first?.focus()
}
}
function onBackdrop(event: MouseEvent) {
if (event.target === event.currentTarget) emit('close')
}
onMounted(async () => {
previousFocus = document.activeElement as HTMLElement | null
previousOverflow = document.body.style.overflow
document.body.style.overflow = 'hidden'
document.addEventListener('keydown', onKeydown)
await nextTick()
const preferred = panel.value?.querySelector<HTMLElement>('[autofocus]')
const items = focusable()
;(preferred ?? items[0] ?? panel.value)?.focus()
})
onBeforeUnmount(() => {
document.removeEventListener('keydown', onKeydown)
document.body.style.overflow = previousOverflow
previousFocus?.focus?.()
})
</script>
<template>
<Teleport to="body">
<div class="dialog-backdrop" @mousedown="onBackdrop">
<section
ref="panel"
class="dialog"
:class="{ 'dialog-wide': wide }"
role="dialog"
aria-modal="true"
:aria-labelledby="titleId"
:aria-describedby="description ? descId : undefined"
tabindex="-1"
>
<div class="dialog-head">
<div>
<h2 :id="titleId" class="dialog-title">{{ props.title }}</h2>
<p v-if="description" :id="descId" class="dialog-sub">{{ description }}</p>
</div>
<button type="button" class="icon-btn" aria-label="Close dialog" title="Close" @click="emit('close')">
<X :size="16" aria-hidden="true" />
</button>
</div>
<slot />
</section>
</div>
</Teleport>
</template>