feat(claw): show the user's profile in the bottom-left account
android / debug (push) Successful in 2m26s
android / release (push) Successful in 2m19s
ci / checks (push) Successful in 3m48s
ci / test (push) Successful in 1m24s
ci / chart (push) Successful in 7s
ci / docker (push) Successful in 2m11s
ci / web (push) Successful in 15s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (push) Successful in 2m17s
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (push) Successful in 16s
ci / publish-edge-chart (push) Successful in 4s

The web shell's account showed the agent's identity and the word
"connected", which left no way to see or set the human's own name and
picture.

The claw now stores a user profile beside the bootstrap files and
serves it over /v1/user and /v1/user/avatar. The agent sets it during
onboarding with user_profile_set; the bottom-left account in both
sidebars renders it and opens an editor for the name and picture. The
prompt context exposes user_name and user_profile, and bootstrap
documents resolve {{ user_name }}, so USER.md and the other markdown
files can address the user by name.

The connection state stays with the unreachable banner, so the sidebars
no longer report it.

Unit and HTTP tests cover the profile store, the tool, the variable
expansion, and the routes. fmt, clippy, cargo test, nuxt typecheck, and
nuxt build pass; both sidebars and the editor checked at 1280x800.
This commit is contained in:
vhaudiquet committed 2026-12-01 18:30:50 +01:00
1 parent debc21a89f
commit cb1948742f
17 files changed
+1226 -149

No files matched your search

+4 -3
View File
@@ -1,7 +1,8 @@
<script setup lang="ts">
// The agent's face at one size: the uploaded avatar when there is one,
// the name's initial when not. The precedence lives here and nowhere
// else.
// A face at one size: the uploaded avatar when there is one, the
// name's initial when not. The agent's own pages and the user's
// bottom-left account both render through it, so the precedence lives
// here and nowhere else.
const props = withDefaults(
defineProps<{
/** The uploaded avatar's object URL, when the claw has one. */
+9 -61
View File
@@ -22,15 +22,14 @@
// queued work when none runs.
import { Pause, Play, Plus, RefreshCw, Settings, Square, Trash2 } from 'lucide-vue-next'
import { SESSION_NAME_PATTERN, isResidentKey } from '~/composables/useClaw'
import type { ClawSession } from '~/composables/useClaw'
import type { ClawSession, UserProfile } from '~/composables/useClaw'
const props = defineProps<{
sessions: ClawSession[]
activeKey: string
loading: boolean
clawUp: boolean | null
identity?: { name: string | null } | null
avatarUrl?: string | null
user: UserProfile | null
userAvatarUrl: string | null
}>()
const emit = defineEmits<{
@@ -43,6 +42,7 @@ const emit = defineEmits<{
resume: [key: string]
abort: [key: string]
navigateSettings: []
editProfile: []
}>()
interface Group {
@@ -118,14 +118,6 @@ const shownCount = computed(() =>
groups.value.reduce((total, group) => total + group.rows.length, 0),
)
const healthLabel = computed(() =>
props.clawUp === null ? 'checking' : props.clawUp ? 'connected' : 'unreachable',
)
const healthTone = computed(() =>
props.clawUp === null ? 'idle' : props.clawUp ? 'ok' : 'error',
)
// --- new sessions -----------------------------------------------------
const creating = ref(false)
const nameDraft = ref('')
@@ -302,19 +294,11 @@ watch(
<Settings :size="16" aria-hidden="true" />
<span>Settings</span>
</button>
<div class="sidebar-account">
<AgentAvatar
:avatar-url="avatarUrl"
:initials="identity?.name?.slice(0, 1)"
:size="26"
/>
<div class="account-text">
<span class="account-name" :title="identity?.name ?? undefined">
{{ identity?.name?.trim() || 'rhema' }}
</span>
<span class="account-state" :class="healthTone">{{ healthLabel }}</span>
</div>
</div>
<UserProfileButton
:profile="user"
:avatar-url="userAvatarUrl"
@edit="$emit('editProfile')"
/>
</div>
</aside>
</template>
@@ -560,42 +544,6 @@ watch(
color: var(--text);
}
.sidebar-account {
display: flex;
align-items: center;
gap: var(--sp-2);
min-width: 0;
padding: var(--sp-2);
}
.account-text {
display: flex;
flex-direction: column;
min-width: 0;
line-height: 1.3;
}
.account-name {
overflow: hidden;
color: var(--text);
font-size: var(--fs-meta);
text-overflow: ellipsis;
white-space: nowrap;
}
.account-state {
color: var(--faint);
font-size: var(--fs-small);
}
.account-state.ok {
color: var(--accent);
}
.account-state.error {
color: var(--danger);
}
@media (max-width: 860px) {
.sidebar {
position: static;
+9 -26
View File
@@ -3,6 +3,7 @@
// slot as the session list. The search is a client-side filter over
// these entries; it hides nothing the claw cannot serve.
import { MessageSquare, Search } from 'lucide-vue-next'
import type { UserProfile } from '~/composables/useClaw'
export interface SettingsEntry {
id: string
@@ -17,11 +18,11 @@ export interface SettingsSection {
const props = defineProps<{
sections: SettingsSection[]
active: string
/** Health echo for the footer, so the nav answers "am I connected". */
clawUp: boolean | null
user: UserProfile | null
userAvatarUrl: string | null
}>()
defineEmits<{ home: []; select: [id: string]; navigateChat: [] }>()
defineEmits<{ home: []; select: [id: string]; navigateChat: []; editProfile: [] }>()
const query = ref('')
@@ -37,14 +38,6 @@ const filtered = computed<SettingsSection[]>(() => {
}))
.filter((section) => section.entries.length > 0)
})
const healthLabel = computed(() =>
props.clawUp === null ? 'Checking the claw' : props.clawUp ? 'Claw connected' : 'Claw unreachable',
)
const healthTone = computed(() =>
props.clawUp === null ? 'idle' : props.clawUp ? 'ok' : 'error',
)
</script>
<template>
@@ -80,7 +73,11 @@ const healthTone = computed(() =>
<MessageSquare :size="16" aria-hidden="true" />
<span>Chat</span>
</button>
<p class="health" :class="healthTone">{{ healthLabel }}</p>
<UserProfileButton
:profile="user"
:avatar-url="userAvatarUrl"
@edit="$emit('editProfile')"
/>
</div>
</aside>
</template>
@@ -209,20 +206,6 @@ const healthTone = computed(() =>
color: var(--text);
}
.health {
padding: 0 var(--sp-2) var(--sp-1);
color: var(--faint);
font-size: var(--fs-small);
}
.health.ok {
color: var(--accent);
}
.health.error {
color: var(--danger);
}
@media (max-width: 860px) {
.sidebar {
position: static;
@@ -0,0 +1,71 @@
<script setup lang="ts">
// The human's account, in the bottom-left slot of both sidebars: their
// picture and name, or an invitation to set them. Clicking opens the
// editor; the health of the connection is the banner's business, not
// this row's.
import { User } from 'lucide-vue-next'
import type { UserProfile } from '~/composables/useClaw'
const props = defineProps<{
profile: UserProfile | null
avatarUrl: string | null
}>()
defineEmits<{ edit: [] }>()
const name = computed(() => props.profile?.name?.trim() ?? '')
const label = computed(() => name.value || 'Set your profile')
</script>
<template>
<button class="profile" :title="label" :aria-label="label" @click="$emit('edit')">
<AgentAvatar
v-if="avatarUrl || name"
:avatar-url="avatarUrl"
:initials="name.slice(0, 1)"
:size="26"
/>
<span v-else class="glyph" aria-hidden="true"><User :size="14" /></span>
<span class="profile-name">{{ label }}</span>
</button>
</template>
<style scoped>
.profile {
display: flex;
align-items: center;
gap: var(--sp-2);
width: 100%;
min-height: 0;
padding: var(--sp-2);
border: 0;
border-radius: var(--r-control);
background: transparent;
color: var(--text);
font-size: var(--fs-meta);
font-weight: 400;
text-align: left;
}
.profile:hover:not(:disabled) {
background: var(--surface-2);
}
.glyph {
display: grid;
place-items: center;
flex: none;
width: 26px;
height: 26px;
border-radius: var(--r-avatar);
background: var(--surface-2);
color: var(--muted);
}
.profile-name {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>
@@ -0,0 +1,170 @@
<script setup lang="ts">
// The user-profile editor the bottom-left account opens: a display name
// and a picture. The name saves from the footer; the picture applies as
// soon as a file is chosen, the same immediate upload the agent's own
// avatar uses. Presentational: data in as props, intent out as events.
import { User } from 'lucide-vue-next'
import type { UserProfile } from '~/composables/useClaw'
const props = defineProps<{
open: boolean
profile: UserProfile | null
avatarUrl: string | null
/** A name save is in flight. */
saving: boolean
/** A picture upload or clear is in flight. */
mutating: boolean
}>()
const emit = defineEmits<{
close: []
save: [name: string]
uploadAvatar: [file: File]
clearAvatar: []
}>()
const draft = ref('')
const nameToken = '{{ user_name }}'
const initialized = ref(false)
const dirty = computed(() => draft.value.trim() !== (props.profile?.name ?? ''))
// The first profile arrival fills the draft; later ones only when the
// operator has not typed, so a background refresh never erases an edit.
watch(
() => props.profile,
(profile) => {
if (!profile || (initialized.value && dirty.value)) return
initialized.value = true
draft.value = profile.name ?? ''
},
{ immediate: true },
)
// Opening starts from the saved profile: a cancelled edit is gone the
// next time the modal opens.
watch(
() => props.open,
(open) => {
if (!open) return
draft.value = props.profile?.name ?? ''
initialized.value = true
},
)
const fileInput = ref<HTMLInputElement | null>(null)
function chooseFile(): void {
fileInput.value?.click()
}
function onFileChosen(event: Event): void {
const input = event.target as HTMLInputElement
const file = input.files?.[0]
if (file) emit('uploadAvatar', file)
input.value = ''
}
function save(): void {
if (!dirty.value || props.saving) return
emit('save', draft.value.trim())
}
</script>
<template>
<AppModal :open="open" title="Your profile" @close="$emit('close')">
<div class="identity">
<AgentAvatar
v-if="avatarUrl || draft.trim()"
:avatar-url="avatarUrl"
:initials="draft.trim().slice(0, 1)"
:size="48"
/>
<span v-else class="glyph" aria-hidden="true"><User :size="20" /></span>
<div class="image-control">
<button :disabled="mutating" @click="chooseFile">Upload picture…</button>
<button
v-if="profile?.avatar"
class="btn-quiet"
:disabled="mutating"
@click="$emit('clearAvatar')"
>
Remove
</button>
<input
ref="fileInput"
type="file"
accept="image/png,image/jpeg,image/gif,image/webp"
@change="onFileChosen"
>
</div>
</div>
<label class="field">
<span class="field-name">Display name</span>
<input
v-model="draft"
type="text"
maxlength="64"
placeholder="Your name"
autocomplete="off"
:disabled="saving"
@keydown.enter.prevent="save"
>
<span class="field-note">Shown on the account in the sidebar and readable as {{ nameToken }} by the agent's documents.</span>
</label>
<template #actions>
<button class="btn-quiet" :disabled="saving" @click="$emit('close')">Cancel</button>
<button :disabled="!dirty || saving" @click="save">
{{ saving ? 'Saving…' : 'Save' }}
</button>
</template>
</AppModal>
</template>
<style scoped>
.identity {
display: flex;
align-items: center;
gap: var(--sp-4);
margin-bottom: var(--sp-4);
}
.glyph {
display: grid;
place-items: center;
flex: none;
width: 48px;
height: 48px;
border-radius: var(--r-avatar);
background: var(--surface-2);
color: var(--muted);
}
.image-control {
display: flex;
align-items: center;
gap: var(--sp-2);
}
.image-control input[type='file'] {
display: none;
}
.field {
display: flex;
flex-direction: column;
gap: var(--sp-1);
}
.field-name {
color: var(--text);
font-size: var(--fs-ui);
font-weight: 500;
}
.field-note {
color: var(--muted);
font-size: var(--fs-small);
}
</style>