feat(persona): user persona (casual/dev/team) — UI preference, not a role - #3
Merged
Conversation
…role Adds a `persona` UI-tailoring preference to `users.setting` JSON so the dashboard can adapt for non-technical end users without doubling permissions. Same backend role, different sidebar/defaults per user. Three personas: - casual : non-tech end users. Sidebar shrinks to chat + playground + wallet + profile; the Create Key flow defaults to Simple; default landing route is /playground (in-browser chat so they can try AI without setting up a client). - dev : developers. Full non-admin sidebar (chat + console + personal). Create Key defaults to Advanced; default landing route is /keys. - team : team / enterprise. Same sidebar as dev for now; reserved for future audit / sub-account features. Storage: - New `Persona string` field on dto.UserSetting (with omitempty). - controller.Register seeds new accounts with persona="unset" so the frontend can distinguish "new account, needs picker" from "legacy user, persona key absent → default to dev silently". Frontend: - New components/persona-picker-dialog.tsx — 3-card modal with explicit descriptions and an example footnote per persona. - New components/persona-picker-host.tsx mounted in AuthenticatedLayout detects setting.persona === "unset" and prompts the picker (mandatory: dismissible=false). On pick: PUT /api/user/setting with persona + matching sidebar_modules preset, hydrate auth-store, navigate to preset's default route only if user is on a generic landing. - New hooks/use-persona.ts: usePersona() returns the effective persona (legacy fallback = dev), useShouldPromptPersona() returns the sentinel check for the picker mount. - New features/profile/lib/persona-presets.ts: PERSONA_PRESETS map + resolveEffectivePersona helper (single source of truth for "what does this user's setting JSON mean"). - Profile / Sidebar Modules card gets a "Quick start preset" 3-button row at the top — picking writes persona + sidebar_modules in one PUT and re-hydrates the granular switches below to match. Cleanup of B2B2C reseller UI for non-admin users: - Hide Group, Cross-group retry, and Quantity (batch) fields from Advanced mode for non-admin role via useIsAdmin(). These are operator concepts a real developer doesn't need. Admin still sees them. i18n: 17 new en + zh keys for the picker and quick-start preset row. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
hades217
force-pushed
the
feat/user-persona
branch
from
May 16, 2026 08:28
21a1ef0 to
e5169f8
Compare
This was referenced May 16, 2026
10 tasks
hades217
added a commit
that referenced
this pull request
Jun 19, 2026
Multi-agent research synthesis: mirrors the Stripe auto-topup path for Airwallex (Customer + PaymentConsent + PaymentMethod), with data-model changes, webhook hardening, provider-split charge seam, AUD/USD currency unification, risks, test plan, and a 9-PR phased rollout where only the final PR enables real off-session charging. Design only — no code shipped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
为非技术 / 非 admin 用户重做 dashboard 体验,不动权限模型。新增
persona字段(casual/dev/team)存在users.settingJSON 里,只影响 UI 不影响后端权限。三种 persona
chat(playground / chat)console(token / log / mj / task)personal(wallet / profile)admin/playground/keys/keys/dashboard/overview关键设计
setting.persona = "unset",第一次进 dashboard 弹出 PersonaPickerDialog(强制选,没有关闭按钮)persona字段 absent → 静默默认dev,sidebar 跟今天一模一样、不打扰/profile的 Sidebar Modules 卡顶部加了 "Quick start preset" 3 按钮,选完一键应用 sidebar + 持久化 personaPUT /api/user/setting端点,不加新路由;只是dto.UserSetting多了一个字段"Developer 像分销商" 修复(顺手)
Advanced 模式下,对非 admin 用户隐藏:
Admin role 完全保留这些字段,运营功能不动。
Test plan
新用户全流程
老用户保护
Profile 切换
非 admin Advanced 字段隐藏
Admin 不受影响
文件
新增:
web/default/src/components/persona-picker-dialog.tsx— 3 卡片 modalweb/default/src/components/persona-picker-host.tsx— 挂载 + 持久化逻辑web/default/src/features/profile/lib/persona-presets.ts— PERSONA_PRESETS + resolveEffectivePersonaweb/default/src/hooks/use-persona.ts— usePersona / useShouldPromptPersona修改:
dto/user_settings.go— +Persona stringcontroller/user.go— Register 初始化 setting.persona="unset"web/default/src/features/profile/types.ts— UserSettings + UpdateUserSettingsRequest 加 persona / sidebar_modulesweb/default/src/features/profile/components/sidebar-modules-card.tsx— Quick start preset 行web/default/src/components/layout/components/authenticated-layout.tsx— mount PersonaPickerHostweb/default/src/features/keys/components/api-keys-mutate-drawer.tsx— 用 useIsAdmin 隐藏 Group/Cross-group/Quantityweb/default/src/i18n/locales/{en,zh}.json— 17 新 key12 files changed, 662 insertions(+), 4 deletions(-)
🤖 Generated with Claude Code