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
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:
1 parent
debc21a89f
commit
cb1948742f
17 files changed
+1226
-149
No files matched your search
+103
-5
@@ -23,6 +23,7 @@ import type {
|
||||
SandboxState,
|
||||
SkillsState,
|
||||
StreamStatus,
|
||||
UserProfile,
|
||||
} from '~/composables/useClaw'
|
||||
import { composeChips, useTranscript } from '~/composables/useTranscript'
|
||||
import type { AttachmentCard, StagedImage } from '~/composables/useTranscript'
|
||||
@@ -258,6 +259,82 @@ async function clearIdentityImage(kind: AgentImageKind): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// --- the user's profile ---------------------------------------------
|
||||
// The human's own name and picture, in the bottom-left account. The
|
||||
// same store the claw writes during onboarding and the prompt reads as
|
||||
// {{ user_name }}.
|
||||
const userProfile = ref<UserProfile | null>(null)
|
||||
const userAvatarUrl = ref<string | null>(null)
|
||||
const profileOpen = ref(false)
|
||||
const savingProfile = ref(false)
|
||||
const mutatingProfile = ref(false)
|
||||
|
||||
async function loadUserAvatarUrl(): Promise<void> {
|
||||
if (userAvatarUrl.value) URL.revokeObjectURL(userAvatarUrl.value)
|
||||
userAvatarUrl.value = null
|
||||
if (!userProfile.value?.avatar) return
|
||||
try {
|
||||
userAvatarUrl.value = await claw.userAvatar()
|
||||
} catch {
|
||||
userAvatarUrl.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshUserProfile(): Promise<void> {
|
||||
try {
|
||||
const next = await claw.userProfile()
|
||||
// Re-download the picture only when its presence changed: a poll
|
||||
// after every turn should not refetch identical bytes.
|
||||
const changed = next.avatar !== userProfile.value?.avatar
|
||||
userProfile.value = next
|
||||
if (changed || !next.avatar || userAvatarUrl.value === null) await loadUserAvatarUrl()
|
||||
} catch (err) {
|
||||
noteApiError(err)
|
||||
}
|
||||
}
|
||||
|
||||
async function saveUserName(name: string): Promise<void> {
|
||||
savingProfile.value = true
|
||||
try {
|
||||
userProfile.value = await claw.setUserName(name)
|
||||
profileOpen.value = false
|
||||
pushNotice('profile saved')
|
||||
apiError.value = null
|
||||
} catch (err) {
|
||||
noteApiError(err)
|
||||
} finally {
|
||||
savingProfile.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadUserAvatar(file: File): Promise<void> {
|
||||
mutatingProfile.value = true
|
||||
try {
|
||||
userProfile.value = await claw.setUserAvatar(file)
|
||||
await loadUserAvatarUrl()
|
||||
pushNotice('profile picture updated')
|
||||
apiError.value = null
|
||||
} catch (err) {
|
||||
noteApiError(err)
|
||||
} finally {
|
||||
mutatingProfile.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function clearUserAvatar(): Promise<void> {
|
||||
mutatingProfile.value = true
|
||||
try {
|
||||
userProfile.value = await claw.clearUserAvatar()
|
||||
await loadUserAvatarUrl()
|
||||
pushNotice('profile picture removed')
|
||||
apiError.value = null
|
||||
} catch (err) {
|
||||
noteApiError(err)
|
||||
} finally {
|
||||
mutatingProfile.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// The window title answers to the identity and the view, as the design
|
||||
// shows it: "Kosmos, Settings · Model providers".
|
||||
const viewTitle = computed(() => {
|
||||
@@ -768,6 +845,7 @@ function saveToken(): void {
|
||||
void refreshProviders()
|
||||
void refreshSessions()
|
||||
void refreshIdentity()
|
||||
void refreshUserProfile()
|
||||
void refreshAccounts()
|
||||
void refreshSkills()
|
||||
void refreshBootstrap()
|
||||
@@ -810,7 +888,12 @@ function resubscribe(): void {
|
||||
return
|
||||
}
|
||||
stream = claw.subscribeEvents(activeKey.value, {
|
||||
onEvent: (event, seq) => transcript.applyEvent(event, seq),
|
||||
onEvent: (event, seq) => {
|
||||
transcript.applyEvent(event, seq)
|
||||
// The claw can set the user's profile during onboarding; the
|
||||
// account should catch up when the turn that set it ends.
|
||||
if (event.type === 'turn_done') void refreshUserProfile()
|
||||
},
|
||||
// The record lost what this mirror holds (a wiped or reset
|
||||
// database): drop it, and the tail the claw sends next rebuilds it.
|
||||
onReset: () => {
|
||||
@@ -896,6 +979,7 @@ onMounted(() => {
|
||||
resubscribe()
|
||||
void checkHealth()
|
||||
void refreshIdentity()
|
||||
void refreshUserProfile()
|
||||
void refreshProviders()
|
||||
void refreshAccounts()
|
||||
void refreshSkills()
|
||||
@@ -922,11 +1006,11 @@ onUnmounted(() => {
|
||||
:sessions="sessions"
|
||||
:active-key="activeKey"
|
||||
:loading="sessionsLoading"
|
||||
:claw-up="clawUp"
|
||||
:identity="identity"
|
||||
:avatar-url="identityAvatarUrl"
|
||||
:user="userProfile"
|
||||
:user-avatar-url="userAvatarUrl"
|
||||
@home="go({ view: 'chat' })"
|
||||
@navigate-settings="go({ view: 'settings', section: 'providers' })"
|
||||
@edit-profile="profileOpen = true"
|
||||
@select="activeKey = $event"
|
||||
@refresh="refreshSessions"
|
||||
@create="createSession"
|
||||
@@ -939,10 +1023,12 @@ onUnmounted(() => {
|
||||
v-else
|
||||
:sections="SETTINGS_SECTIONS"
|
||||
:active="route.section"
|
||||
:claw-up="clawUp"
|
||||
:user="userProfile"
|
||||
:user-avatar-url="userAvatarUrl"
|
||||
@home="go({ view: 'chat' })"
|
||||
@navigate-chat="go({ view: 'chat' })"
|
||||
@select="go({ view: 'settings', section: $event })"
|
||||
@edit-profile="profileOpen = true"
|
||||
/>
|
||||
|
||||
<div class="body">
|
||||
@@ -1074,6 +1160,18 @@ onUnmounted(() => {
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<UserProfileModal
|
||||
:open="profileOpen"
|
||||
:profile="userProfile"
|
||||
:avatar-url="userAvatarUrl"
|
||||
:saving="savingProfile"
|
||||
:mutating="mutatingProfile"
|
||||
@close="profileOpen = false"
|
||||
@save="saveUserName"
|
||||
@upload-avatar="uploadUserAvatar"
|
||||
@clear-avatar="clearUserAvatar"
|
||||
/>
|
||||
|
||||
<AppModal
|
||||
:open="deletingKey !== null"
|
||||
title="Delete session"
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
@@ -212,6 +212,13 @@ export interface AgentIdentity {
|
||||
logo: boolean
|
||||
}
|
||||
|
||||
/** The human user's profile as `GET /v1/user` serves it: the display
|
||||
* name the bottom-left account shows and whether a picture is set. */
|
||||
export interface UserProfile {
|
||||
name: string | null
|
||||
avatar: boolean
|
||||
}
|
||||
|
||||
/** The identity's text fields, as a save carries them: an empty
|
||||
* string clears the field. */
|
||||
export interface IdentityTexts {
|
||||
@@ -561,6 +568,19 @@ export interface ClawApi {
|
||||
* `<img>` (the route is bearer-guarded, so a plain src will not do).
|
||||
* The caller revokes the URL when it replaces it. */
|
||||
agentImage(kind: AgentImageKind): Promise<string>
|
||||
/** `GET /v1/user` — the human user's profile. */
|
||||
userProfile(): Promise<UserProfile>
|
||||
/** `PUT /v1/user` — set the display name; an empty string clears
|
||||
* it. */
|
||||
setUserName(name: string): Promise<UserProfile>
|
||||
/** `PUT /v1/user/avatar` — upload the profile picture from a file.
|
||||
* The claw refuses non-images and bodies over 2 MiB. */
|
||||
setUserAvatar(file: File): Promise<UserProfile>
|
||||
/** `DELETE /v1/user/avatar` — drop the profile picture. */
|
||||
clearUserAvatar(): Promise<UserProfile>
|
||||
/** `GET /v1/user/avatar` — the picture as an object URL for an
|
||||
* `<img>`. The caller revokes the URL when it replaces it. */
|
||||
userAvatar(): Promise<string>
|
||||
/**
|
||||
* Stream one session's turns. Resolves with a handle once the fetch
|
||||
* is started; the claw keeps the stream open forever, and a drop is
|
||||
@@ -847,6 +867,37 @@ export function useClaw(token: Ref<string | null>): ClawApi {
|
||||
return URL.createObjectURL(await fetchBlob(`/v1/agent/${kind}`))
|
||||
}
|
||||
|
||||
async function userProfile(): Promise<UserProfile> {
|
||||
return (await get('/v1/user', token.value)) as UserProfile
|
||||
}
|
||||
|
||||
async function setUserName(name: string): Promise<UserProfile> {
|
||||
return (await send('/v1/user', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json', ...authHeaders(token.value) },
|
||||
body: JSON.stringify({ name }),
|
||||
})) as UserProfile
|
||||
}
|
||||
|
||||
async function setUserAvatar(file: File): Promise<UserProfile> {
|
||||
return (await send('/v1/user/avatar', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': file.type || 'application/octet-stream', ...authHeaders(token.value) },
|
||||
body: file,
|
||||
})) as UserProfile
|
||||
}
|
||||
|
||||
async function clearUserAvatar(): Promise<UserProfile> {
|
||||
return (await send('/v1/user/avatar', {
|
||||
method: 'DELETE',
|
||||
headers: authHeaders(token.value),
|
||||
})) as UserProfile
|
||||
}
|
||||
|
||||
async function userAvatar(): Promise<string> {
|
||||
return URL.createObjectURL(await fetchBlob('/v1/user/avatar'))
|
||||
}
|
||||
|
||||
async function attachmentUrl(id: string): Promise<string> {
|
||||
const cached = attachmentUrls.get(id)
|
||||
if (cached) return cached
|
||||
@@ -1042,6 +1093,11 @@ export function useClaw(token: Ref<string | null>): ClawApi {
|
||||
setAgentImage,
|
||||
clearAgentImage,
|
||||
agentImage,
|
||||
userProfile,
|
||||
setUserName,
|
||||
setUserAvatar,
|
||||
clearUserAvatar,
|
||||
userAvatar,
|
||||
attachmentUrl,
|
||||
subscribeEvents,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user