Skip to content

feat(settings): add optional user ID display and copying - #2011

Open
kiroo92 wants to merge 1 commit into
TokenFlux:mainfrom
kiroo92:feat/user-id-display
Open

kiroo92 wants to merge 1 commit into
TokenFlux:mainfrom
kiroo92:feat/user-id-display

Conversation

@kiroo92

@kiroo92 kiroo92 commented Nov 15, 2026

Copy link
Copy Markdown

Agent

This code is AI-assisted. Prepared with Codex CLI 0.163.0, GPT-6 (the host does not expose the exact model identifier), in the Mirasim CLI environment on 2026-11-15 UTC. Git identity was checked against recent core developers; no Git identity configuration was changed.

Links

Closes #2010.

User request

Verbatim:

拉个最新得库,我要加个功能,然后提交pr

Later requirements and correction:

功能开关增加展示用户id,一个是右上角展示一下,可以快捷复制,一个是个人资料, #开头 比如 #1233

右上角得放在头像下拉框里面啊,编译 啥的注意限制 cpu

Out of scope — refuse

Matched: no. This is an account presentation feature.

Open gate — do not open unless all are satisfied

In scope; new feature linked to #2010; researched against docs and code; verification records commands and observed behavior. Open: yes.

Kind

  • New feature

Issue facts

The current UI lacks an optional user-ID display/copy control in the avatar menu and profile. The user requests quick access to a hash-prefixed account number. Incident frequency is not applicable to this feature. Frontend locations are /profile, the shared avatar dropdown, and /admin/settings?tab=features; relay, billing, and deployment incident details do not apply.

Change

Add the disabled-by-default show_user_id switch under Features. Site settings own persistence and expose the switch through administrator reads, the public API, and HTML injection. A shared control displays and copies #ID inside the avatar dropdown and beside the profile name. Closing the dropdown removes its ID control from the header.

Research

Duplicate / prior art

Searched issues and PRs for user ID, 用户 ID, 显示用户, user identifier, and show_user_id. Existing matches concern API keys, balance dialogs, and other features. No equivalent display switch was found.

Docs and code

docs/guides/index.md lists operational guides; docs/index.md routes configuration and UI rules; the README describes account features. docs/interfaces/configuration.md defines combined runtime settings and now documents this switch. The implementation follows site settings ownership, the existing feature form, and useClipboard.ts feedback.

Alternatives considered

  • Duplicate ID rendering and clipboard calls in both locations.
  • Use one control for formatting, visibility, accessibility, and copying.

The shared control keeps both locations consistent when public settings or the account change.

Files

Paths Purpose
backend/internal/site/ Own and publish the display switch.
backend/internal/settings/ Preserve omitted updates, map readback, and audit changes.
backend/internal/app/settings_composite_runtime_test.go Check field ownership and saved/omitted switch behavior.
frontend/src/components/user/UserIdBadge.vue and related components/tests Render and verify copyable IDs in the requested locations.
frontend/src/views/admin/settings/, API types, and locale files Add the switch to the shared draft, payload, and translations.
docs/interfaces/configuration.md Document defaults and copy format.
assets/screenshots/user-id-display.png Show the avatar menu and profile with the feature enabled.

Behavior

Before: neither requested location offers a configurable ID copy action.

After: enabling the switch displays values such as #1233 in the avatar dropdown and profile. Clicking copies the complete displayed text. Missing/false settings hide both controls; updates omitting the field retain its stored value.

Non-goals: changing ID allocation or account permissions.

Verification

  • go test ./internal/site/... ./internal/settings/... ./internal/app -count=1: all selected packages passed. Regression cases verified disabled defaults, enabled/disabled persistence, omitted-field retention, static ownership, and matching public API/HTML injection values.
  • pnpm --dir frontend exec vitest run --maxWorkers=1 src/components/user/__tests__/UserIdBadge.spec.ts src/components/layout/__tests__/AppHeader.spec.ts src/components/user/profile/__tests__/ProfileInfoCard.spec.ts: 23 tests passed, including copying from the avatar dropdown and hiding its ID while closed.
  • pnpm --dir frontend run lint:check: formatting, ESLint, comments, imports, and UI token checks passed.
  • pnpm --dir frontend run typecheck: no type errors.
  • pnpm --dir frontend run build:assets: production assets built successfully.
  • make fmt and make fmt-check: repository formatters completed and checks passed.
  • Chromium 156 with local API fixtures: both IDs appeared when enabled; clicking the avatar-menu control wrote #1233 to the browser clipboard; disabling hid both; a 390px viewport had no horizontal overflow. The feature form switch started disabled and responded to a click. Desktop and mobile light/dark layouts were inspected.
  • After the user's resource constraint, compilation and checks run with taskset -c 0,1, nice -n 10, and Go parallelism limited to two.
  • The pre-push quick checks passed: Go formatting, architecture rules, changed-package lint (0 issues), package tests, frontend policies and types, 21 tool tests, and 258 related frontend test files with 2162 passing tests.
  • Production database, real-provider traffic, full Docker acceptance, and security scans were not exercised for this presentation/settings change.

User ID in the avatar dropdown and profile

Risks

The switch controls presentation; the current user's authenticated profile supplies the ID. Missing settings keep the feature disabled. Clipboard failures use the existing localized feedback. No follow-up work is identified.

Scope check

Single focused change: yes. Secrets included: no. Unsupported behavior, unchanged upstream errors, and third-party service issues: no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an optional copyable user ID in the account menu and profile

2 participants