Files
Warp/apps/web/src/components/JoinRoomDialog.vue
T
tajniak81andClaude Opus 5.5 8ff2730676
CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Test (windows-latest) (push) Canceled after 0s
CI / Storage tests on PostgreSQL (push) Canceled after 0s
CI / Complement (federation off) (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
CI / Smoke test the binary (push) Canceled after 0s
CI / Admin panel (push) Canceled after 0s
CI / Web client (push) Canceled after 0s
Web client: replies, reactions, threads and spaces
- Replies: Reply on a message puts it above the composer; the reply
  quotes it (sender and first line), and the quote goes to the message.
  Sent without the quoted fallback (Matrix 1.13); the fallback in older
  replies is not shown.
- Reactions: the six quick ones of the Android app or any other emoji,
  chips under the message with counts, yours highlighted; a chip adds
  yours or takes it back.
- Threads: matrix-js-sdk's thread support is on. Reply in thread opens
  the thread beside the room with its own composer; the root shows
  "N replies" and the last reply; Threads in the header lists them.
  Receipts are per thread (MSC3771): the room is marked read with its
  read marker and a separate receipt for "main", since /read_markers'
  receipt has no thread_id and would read every thread. Unread counts
  per thread (MSC3773) and a dot on unread threads.
  Two SDK quirks worked around: the thread view creates the thread
  object when a thread starts here (else the first reply's remote echo
  is dropped until reload), and the reply count is re-read from the
  root's bundled count after replies arrive (the SDK can count one
  twice).
- Spaces: kept out of the room list; a picker narrows the list to a
  space's rooms and its subspaces'. A space's page (/hierarchy) lists
  its rooms with Open or Join; admins add existing rooms, create new
  ones in it and take rooms out. New space in the + menu and picker.
- The room composer moved into RoomComposer.vue, shared by the room
  and the thread pane. New thread and space icons in apps/ui.
- Dev server: the Rust crypto's .wasm was lost to vite's pre-bundling,
  so E2EE never started under `pnpm web:dev`; the package is now served
  as it is in dev.

Server: /versions lists v1.1 to v1.14. matrix-js-sdk checks for the
exact version a feature came in, and with only v1.13 and v1.14 it kept
threads, per-thread unread counts, recursive relations and intentional
mentions off.

Tested in the browser against a local server: replies, reactions,
threads (new and existing, in plain and encrypted rooms, receipts
checked on the server) and spaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 10:09:12 +02:00

121 lines
4.2 KiB
Vue

<script setup lang="ts">
import type { IPublicRoomsChunkRoom } from 'matrix-js-sdk'
import { computed, ref, watch } from 'vue'
import { WBanner, WButton, WDialog, WSpinner, WTextField } from '@warp/ui'
import MxcAvatar from '@/components/MxcAvatar.vue'
import { errorMessage } from '@/lib/format'
import { client } from '@/matrix/client'
import { useChat } from '@/stores/chat'
// Join by address or ID, or pick from this homeserver's room directory.
const open = defineModel<boolean>('open', { default: false })
const emit = defineEmits<{ joined: [roomId: string] }>()
const chat = useChat()
const address = ref('')
const busy = ref('')
const error = ref('')
const directory = ref<IPublicRoomsChunkRoom[]>()
const directoryError = ref('')
const search = ref('')
const joined = computed(() => new Set([...chat.rooms, ...chat.spaces].map((r) => r.roomId)))
async function loadDirectory() {
directoryError.value = ''
try {
const res = await client().publicRooms({ limit: 50, filter: search.value.trim() ? { generic_search_term: search.value.trim() } : undefined })
directory.value = res.chunk
} catch (e) {
directoryError.value = errorMessage(e)
}
}
watch(open, (v) => {
if (!v) return
address.value = ''
error.value = ''
search.value = ''
directory.value = undefined
loadDirectory()
})
let searchTimer = 0
watch(search, () => {
window.clearTimeout(searchTimer)
searchTimer = window.setTimeout(loadDirectory, 300)
})
async function join(target: string) {
const t = target.trim()
if (!t) return
if (joined.value.has(t)) {
open.value = false
emit('joined', t)
return
}
busy.value = t
error.value = ''
try {
const roomId = await chat.join(t)
open.value = false
emit('joined', roomId)
} catch (e) {
error.value = errorMessage(e)
} finally {
busy.value = ''
}
}
const validAddress = computed(() => /^[#!][^:\s]+:\S+$/.test(address.value.trim()))
</script>
<template>
<WDialog v-model:open="open" title="Join room" wide :persistent="busy !== ''">
<form class="flex items-end gap-2" @submit.prevent="join(address)">
<WTextField
v-model="address"
class="flex-1"
wide
mono
label="Room address or ID"
placeholder="#homelab-ops:warp.example"
autocomplete="off"
autocapitalize="off"
spellcheck="false"
autofocus
/>
<WButton type="submit" variant="primary" :loading="busy === address.trim() && busy !== ''" :disabled="!validAddress">Join</WButton>
</form>
<WBanner v-if="error" tone="danger">{{ error }}</WBanner>
<div class="flex flex-col gap-2">
<div class="flex items-center gap-2">
<h3 class="body-strong m-0 flex-1">Room directory</h3>
</div>
<WTextField v-model="search" wide label="Search the directory" type="search" />
<WBanner v-if="directoryError" tone="warning">{{ directoryError }}</WBanner>
<div v-else-if="!directory" class="flex justify-center py-6"><WSpinner /></div>
<p v-else-if="!directory.length" class="body py-4 text-center text-ink-muted">
{{ search ? 'No public rooms match.' : 'There are no public rooms on this homeserver yet.' }}
</p>
<ul v-else class="m-0 flex max-h-80 list-none flex-col overflow-y-auto p-0">
<li v-for="r in directory" :key="r.room_id" class="flex items-center gap-3 rounded-md px-2 py-2">
<MxcAvatar :name="r.name ?? r.canonical_alias ?? r.room_id" :mxc="r.avatar_url" :size="36" />
<div class="min-w-0 flex-1">
<p class="body-strong m-0 truncate">{{ r.name ?? r.canonical_alias ?? r.room_id }}</p>
<p class="small m-0 truncate text-ink-muted">
<span v-if="r.canonical_alias" class="mxid">{{ r.canonical_alias }} · </span>{{ r.num_joined_members }}
{{ r.num_joined_members === 1 ? 'member' : 'members' }}<template v-if="r.topic"> · {{ r.topic }}</template>
</p>
</div>
<WButton size="sm" :variant="joined.has(r.room_id) ? 'ghost' : 'secondary'" :loading="busy === r.room_id" @click="join(r.room_id)">
{{ joined.has(r.room_id) ? 'Open' : 'Join' }}
</WButton>
</li>
</ul>
</div>
</WDialog>
</template>