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"
|
||||
|
||||
Reference in new issue
Block a user