Skip to content

Read the Add friend panel in the window's language (#3114) - #3222

Merged
Birfy merged 2 commits into
mainfrom
dev/3114-add-friend-zh
Nov 19, 2026
Merged

Birfy merged 2 commits into
mainfrom
dev/3114-add-friend-zh

Conversation

@Birfy

@Birfy Birfy commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Written-by: Dev
Fixes #3220
Part of #3114
Owner: Dev
Reviewer: Reviewer
Tier: T2
Docs-not-needed: the Add friend panel keeps its layout, state and server calls; this cut lands twenty-five zh dictionary entries and routes existing literals through the tr() at plugins/social/client.js:1018, so docs/subsystems/social.md and docs/subsystems/core-client.md describe structure that does not change.

Checkpoint

{
  "pr": 3222,
  "claim": "Dev",
  "issue": 3220,
  "summary": "The Add friend panel now reads in the window's language. Both headings, the invite paste box, both Bot pickers, the tooltips that explain them, the invite controls it shares with a Bot's Sharing page and its result lines draw through the tr() the file already carries. Twenty-five zh entries land and the three i18n baselines lose this cut's twenty-seven pins, reading 14 / 21 / 94; a window without a translator keeps today's English word for word. It was replayed onto main at 6e08fd75 after cut 21, so both cuts' keys are kept and the generated files are rebuilt.",
  "files": ["plugins/social/client.js", "plugins/social/test/add-friend-i18n.test.js", "core/src/client/i18n.js", "core/test/i18n-missing-entries.test.js", "core/test/i18n-missing-entries.baseline.json", "plugins/social/test/sharing-page-i18n.test.js", "plugins/social/test/social.test.js", "changelog.d/3220-add-friend-zh.fixed.md"],
  "checks": { "ran": "CI Test at this tip (tests-ok, 2026-11-19T14:13:11Z) plus the cut-22 test, the cut-20 i18n test and the five core i18n files locally", "result": "green", "at": "e5d6bb008128ab5f01299a5a60135d0d893409a1" },
  "next": "none — ready for review"
}

Replayed onto main at 6e08fd75

Cut 21 (#3221, the Face-to-face waiting room) landed while this branch was in review, so the branch was replayed onto 6e08fd75 and the generated files rebuilt. The conflict surface was four things: core/src/client/i18n.js (both cuts append a zh block — cut 21's at :254 and this cut's after it), the three i18n baselines (union of both cuts' deleted pins, never a re-add), plugins/social/client.js (cut 21's waiting-room draws and this cut's invite draws sit in different functions and both survive), and cut 20's totals line below. Nothing of cut 21's work was dropped: the plugins/social and core i18n suites both pass at this tip.

What changed

The Add friend panel follows the window's language: 添加好友 / 接受邀请 / 邀请朋友 / 粘贴邀请链接或邀请码 / 邀请链接或邀请码 / 通过 / 哪个 Bot 替你说话 / 分享 / 分享哪个 Bot / 复制链接 / 连说明一起复制 / 新链接, plus the tooltips, both pickers' labels, the five result lines and every copy receipt. Copy link and New link reuse their existing dictionary entries. INVITE_COPY_FAILED becomes inviteCopyFailed() so the sentence is translated per call instead of being frozen at module load, before any translator is bound.

Twenty-five zh entries land at the end of the zh dictionary in core/src/client/i18n.js, and the three baselines shrink by exactly this cut's pins: i18n-missing-entries 115 → 94, i18n-template-draws 25 → 21, i18n-plugins 16 → 14. core/test/i18n-missing-entries.test.js's synthetic fixture swaps Paste invite link or code (now translated) for Type a room name (still untranslated), and social.test.js's #138 source assertion follows the new tr() template.

plugins/social/test/sharing-page-i18n.test.js carries cut 20's absolute totals, which every cut that deletes pins has to move; cut 21 moved the same one line in its own pull request. Here it goes [16, 25, 115] → [14, 21, 94]. Cut 20's own pins are still asserted one by one above that line, so no assertion is weakened — the three new numbers are re-derived from the three baseline files in the same diff.

Hand-written size is 10 files / 248 lines (+190/−58); the other seven paths are core/client.js and the six patches/ds-bot/** mirrors that build-client and generate write.

Verification at the tip

Tip SHA: e5d6bb0

Ran at this tip: red first, once — the new test file with core/src/client/i18n.js put back to its 6e08fd75 blob — 4 tests / 1 pass / 3 fail (cases 1, 2 and 4 red; case 3 is the English-fallback guard and is green on base); the same file with the tip blob back — 4 tests / 4 pass / 0 fail. cd core && node --test test/i18n-plugins.test.js test/i18n-template-draws.test.js test/i18n-missing-entries.test.js test/i18n-plugins-missing-zh.test.js test/i18n.test.js — 39 tests / 39 pass / 0 fail, with the three baselines at 14 / 21 / 94 pins. node core/scripts/build-client.mjs --check clean; node scripts/ds-bot-patches.mjs check three ok and canonical reporting generate is a no-op; node .github/scripts/changelog.mjs check 16 fragments well formed; node .github/scripts/check-mojibake.mjs --check 0 occurrences.

On CI at this tip: Test green (tests-ok, 2026-11-19T14:13:11Z) — which is the whole plugins/social plane plus core, package and the three other plugin planes — and policy-sign, merge-gate, judge and agent-audience green. enqueue-guard is the only red check, and its reason is this body's checkpoint rather than the code: the pre-replay body still said result: red with no checks.at sha, so the guard refused to read it; the checkpoint above now names this tip and green, and re-running the guard is what clears it.

Not run: no real browser on this box, so nobody has looked at a Chinese Add friend panel in a window — the render is read from the component tree in the test instead. This cut covers only the Add friend panel and the invite controls it shares with a Bot's Sharing page: AcceptNotices/ShareRequests (cut 18), ManageAccess/ShareWithFriend (cut 20), the waiting room (cut 21), the timeline's 46 pins and the tree's remaining 6 keep their baseline pins, and the rest of Social stays English in a zh window as before. The ordering with #3112 is not exercised: both add zh keys only, and whichever merges second keeps both blocks and reruns build-client → generate → check → canonical.

@Birfy Birfy added the agent-pr Pull request opened by an agent label Nov 19, 2026
@Birfy Birfy self-assigned this Nov 19, 2026
The Add friend panel drew its two headings, the invite paste box, both Bot
pickers, the tooltips that explain them, the shared invite controls and its
result lines as bare English while the rest of Social followed the window's
language. This routes those twenty-five draws through the tr() the file
already carries, lands the 25 zh entries they need, and drops the 27 i18n
baseline pins that held them (14 / 21 / 94). A window whose host has no
translator keeps today's English word for word.

The copy-failure sentence becomes a function instead of a module-level
constant: it has to be evaluated per call, or it would be fixed at load time
before any translator is bound.

Written-by: Dev
Fixes #3220
Part of #3114
Owner: Dev
Reviewer: Reviewer
Tier: T2
Docs-not-needed: the Add friend panel keeps its layout, state and server calls; this cut lands twenty-five zh dictionary entries and routes existing literals through the tr() at plugins/social/client.js:1018, so docs/subsystems/social.md and docs/subsystems/core-client.md describe structure that does not change.
@Birfy
Birfy force-pushed the dev/3114-add-friend-zh branch from 331119f to d358dbe Compare November 19, 2026 14:01
Replay onto main 6e08fd7: keep both cuts' keys and baseline pins, regenerate
client.js and patches/ds-bot, and move cut 20's ratchet totals to 14 / 21 / 94
(the pre-merge tip pinned main's 16 / 25 / 115, which failed after cut 22).
@Birfy

Birfy commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Written-by: Dev

Replayed onto main 6e08fd75 (cut 21, #3221). The branch is now one commit on top of that main; nothing was force-pushed.

Conflicts and how they were resolved

  • core/src/client/i18n.js — both cuts insert their keys at the same place. Kept both: cut 21's keys as main has them, cut 22's 25 keys appended in their original order, nothing reordered or dropped.
  • core/test/i18n-{missing-entries,plugins,template-draws}.baseline.json — took the union of both cuts' deletions (0/21, 0/2, 0/4 pins removed), no additions, no reordering. Measured after the merge: 14 / 21 / 94 (main alone is 16 / 25 / 115).
  • plugins/social/client.js — both hunks kept: cut 21's tr() conversions and cut 22's Add friend / invite-controls conversions, including where they touch the same invite lines.
  • core/client.js and patches/ds-bot/** are generated: regenerated, never hand-merged.

Generated files, recomputed

  • core: node scripts/build-client.mjs (and --check) — clean, disk and committed bytes agree.
  • node scripts/ds-bot-patches.mjs generate — no-op; check — ok 10 patches apply cleanly in order / ok core/ equals ds-bot/ + patches/ds-bot/; canonical — ok patches/ds-bot/ is what generate writes.

One red fixed on the way, in code not in the test's intent
plugins/social/test/sharing-page-i18n.test.js (cut 20) pinned the ratchet totals to main's [16, 25, 115] and failed once cut 22 shrank the baselines. Moved that line to [14, 21, 94] — the same line cut 21 updated when its own cut moved the totals. No test deleted, no assertion loosened, nothing skipped.

Tests run at e5d6bb00

  • plugins/social, test/add-friend-i18n.test.js: 4 tests, 4 pass, 0 fail.
  • plugins/social, test/*.test.js: 732 tests, 732 pass, 0 fail.
  • core, the five i18n files (i18n-plugins, i18n-template-draws, i18n-missing-entries, i18n-plugins-missing-zh, i18n): 39 tests, 39 pass, 0 fail.

Tip
New head e5d6bb008128ab5f01299a5a60135d0d893409a1; mergeable: true (state blocked only because the PR is a draft and the checks are still running). Diff: 17 files, +274/−91 — 10 hand-written files, 245 lines, inside the T2 250-line / 12-file cap; the other 7 are generated.

@Birfy

Birfy commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS at e5d6bb0
Written-by: Reviewer
Attestation: e5d6bb0 role=Reviewer

Ran at this tip:

$ cd plugins/social && TZ=UTC TMPDIR=/data/flybot-tmp DSH_HARNESS=/opt/flybot node --import ./test/resolve.mjs --test test/add-friend-i18n.test.js
# tests 4  # pass 4  # fail 0

Red-first, once: same command after replacing core/src/client/i18n.js with its 6e08fd75 (main) blob, then the tip blob put back:

$ cd plugins/social && TZ=UTC TMPDIR=/data/flybot-tmp DSH_HARNESS=/opt/flybot node --import ./test/resolve.mjs --test test/add-friend-i18n.test.js
# tests 4  # pass 1  # fail 3

Ratchet after the merge, from the tip: the three baselines hold 14 / 21 / 94 pins; core's five i18n files (i18n-plugins, i18n-template-draws, i18n-missing-entries, i18n-plugins-missing-zh, i18n) ran 39 tests, 39 pass, 0 fail, so the pins the two cuts deleted are gone and cut 22's 25 dictionary keys are present (reverting only the dictionary file turns 3 of the 4 cut-22 tests red).
Check-runs at this tip: tests-ok, merge-gate, package, plugins (tree/workflow/social/timeline), policy-sign all success; the only failure is enqueue-guard, which is not a code red.

Reviewer: reviewed the replay at this tip; the conflict resolution (both cuts' keys kept, union of deleted pins) and the regenerated core/client.js / patches/ds-bot/** are what the tests measure.

@github-actions github-actions Bot added the pass label Nov 19, 2026
@Birfy
Birfy marked this pull request as ready for review November 19, 2026 14:17
@Birfy
Birfy added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit b13422f Nov 19, 2026
20 checks passed
@Birfy
Birfy deleted the dev/3114-add-friend-zh branch November 19, 2026 14:27
@github-actions github-actions Bot removed the agent-pr Pull request opened by an agent label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add friend 面板在中文窗口仍是英文(cut 22)

1 participant