fix(web/claw): name the human on their own chat rows
Every row the reader wrote said "you" under an avatar holding a bare Y, even with the profile set: the chat panel never read GET /v1/user, so the name and picture appeared only in the account row at the bottom of the sidebar, and the transcript contradicted it. The panel takes the profile now. Its rows label themselves with the name on the interactive and phone keys, "you" only until one is set, and the avatar renders the picture when there is one and the name's first letter otherwise. A dispatch row keeps its own label and initial: it speaks for the trigger that started it, not for the reader. nuxt typecheck passes; against the mock claw a profile named "Ada Lovelace" with a picture renders on its rows, and clearing the profile falls back to "you" and Y.
This commit is contained in:
1 parent
597c2a98d2
commit
68f1a6be89
2 files changed
+32
-5
No files matched your search
@@ -42,6 +42,11 @@ const props = defineProps<{
|
||||
prependCount?: number
|
||||
identity?: { name: string | null } | null
|
||||
avatarUrl?: string | null
|
||||
/** The human's profile: the name their own rows carry, while unset the
|
||||
* generic `you` stands in. */
|
||||
user?: { name: string | null; avatar: boolean } | null
|
||||
/** The picture from `GET /v1/user/avatar`, as an object URL. */
|
||||
userAvatarUrl?: string | null
|
||||
}>()
|
||||
|
||||
const agentName = computed(() => props.identity?.name?.trim() || 'rhema')
|
||||
@@ -59,7 +64,9 @@ const readOnlyNote = computed(() =>
|
||||
* web surface or on the phone; every other key's are the prompt its
|
||||
* dispatch was started with. */
|
||||
const userLabel = computed(() =>
|
||||
/^(interactive|phone):/.test(props.activeKey) ? 'you' : 'dispatch',
|
||||
/^(interactive|phone):/.test(props.activeKey)
|
||||
? props.user?.name?.trim() || 'you'
|
||||
: 'dispatch',
|
||||
)
|
||||
|
||||
/** Whether the key has a stream at all. A snapshot answers a page once
|
||||
@@ -423,9 +430,17 @@ function messageSegments(text: string, pastes: PasteSpan[] = []): MessageSegment
|
||||
|
||||
const displayName = computed(() => props.activeKey.replace(/^interactive:/, '') || 'Chat')
|
||||
|
||||
/** The letter in the human row's avatar; the dispatch row speaks for
|
||||
* its trigger, so it gets its own initial. */
|
||||
const userInitial = computed(() => (userLabel.value === 'you' ? 'Y' : 'D'))
|
||||
/** The letter in the human row's avatar, the name's first letter; the
|
||||
* dispatch row speaks for its trigger, so it keeps `D`. */
|
||||
const userInitial = computed(
|
||||
() => (Array.from(userLabel.value)[0] ?? 'Y').toUpperCase(),
|
||||
)
|
||||
|
||||
/** The picture beside the human's rows. A dispatch row speaks for the
|
||||
* trigger that started it, not for the human, so it never gets theirs. */
|
||||
const userRowAvatar = computed(() =>
|
||||
userLabel.value === 'dispatch' ? null : props.userAvatarUrl,
|
||||
)
|
||||
|
||||
// The dispatch internals live behind the info modal, not in the header.
|
||||
const infoOpen = ref(false)
|
||||
@@ -514,7 +529,10 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
|
||||
|
||||
<template v-for="item in items" :key="item.id">
|
||||
<div v-if="item.kind === 'sent'" class="msg msg-human">
|
||||
<span class="avatar user" aria-hidden="true">{{ userInitial }}</span>
|
||||
<span class="avatar user" aria-hidden="true">
|
||||
<img v-if="userRowAvatar" :src="userRowAvatar" alt="">
|
||||
<template v-else>{{ userInitial }}</template>
|
||||
</span>
|
||||
<div class="msg-body">
|
||||
<div class="msg-head">
|
||||
<span class="msg-author">{{ userLabel }}</span>
|
||||
@@ -814,6 +832,13 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
|
||||
.avatar.user img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: inherit;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.avatar.user {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
|
||||
Reference in new issue
Block a user