Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

3.7 KB
Raw Blame

A profile page sets the user's avatar and nickname

  • Date: 2026-09-12
  • Type: feature
  • Scope: server, web, docs
  • PR: #714

中文版

An account was its user id everywhere it appeared: the sidebar's bottom user row, the collapsed rail's trigger, the admin user list. A new Profile page, heading the personal group of the System settings dialog, gives every account an avatar and a nickname, and the surfaces that used to draw the id and its letter tile draw those instead.

Details

  • The page holds two rows and no footer: every control writes when it is used, and the button that writes a value stands beside that value. Change avatar opens a picture picker and the picked image applies at once — centre-cropped to a square and re-encoded at 128×128 as PNG, or as JPEG at quality 0.85 when the PNG would pass 100 KB; an image still over 128 KiB is refused inline instead of being sent for the server to reject. Restore default beside it puts the letter tile back. The nickname is typed text, so it keeps an explicit Save next to the field and a Restore default of its own, whose default is the user id; both write on click, so the two buttons beside one field never disagree about when they act. It is 1–32 characters, counted as characters so a Chinese name may be 32 of them, and saving it blank clears it. On both rows the buttons hold their width and the field is what gives, so a narrow dialog never breaks a label across two lines — flex will not shrink a control below its min-content width, and for a CJK label that is one character, so a squeezed button stacks 恢复默认 two high where an English one is held open by its longest word.
  • A button that would write what is already stored is disabled, and nothing is applied optimistically: every surface, the page's own preview included, draws what is stored, so a write that fails leaves the screen agreeing with the server and reports the failure inline rather than showing an avatar that disappears on the next load.
  • The page is visible in every session, the desktop shell's own token window included — unlike the Account page beside it, which needs a password to change. PUT /api/me/profile follows the same rule and takes any authenticated session.
  • The route is a patch: an absent field keeps its stored value, null clears it, and a body naming neither field is a 400. It validates the nickname's length and rejects control characters in it, and requires the avatar to be a data:image/(png|jpeg|webp);base64,… URL of at most 131072 characters whose payload decodes — the same number, in the same unit, that the browser measures its re-encode against.
  • GET /api/me carries displayName and avatar, omitted when unset. The admin user list carries the nickname only — it is unpaged, and an avatar per account would answer a table that shows the nickname alone with megabytes. The avatar and nickname render through one shared UserAvatar component, so the nav row, the collapsed rail, the new account-menu header and the page's own 64px preview cannot drift apart; the admin list shows the nickname in small grey text under the user id.
  • Schema migration 5, user-profile: two nullable columns, users.display_name and users.avatar. Additive and swap-safe — a platform rolled back to a predecessor that does not know them never reads or writes them — and reversible, though its down drops the columns and takes every stored nickname and avatar with them. Nothing to do for an existing install: every account simply starts with no profile and keeps showing its user id until it sets one.