Skip to content

fix(hub-ui): preserve dock order across language changes - #446

Merged
antfu merged 1 commit into
devframes:mainfrom
SaKaNa-Y:fix/stable-dock-order-on-locale
Oct 14, 2026
Merged

antfu merged 1 commit into
devframes:mainfrom
SaKaNa-Y:fix/stable-dock-order-on-locale

Conversation

@SaKaNa-Y

Copy link
Copy Markdown
Contributor

Important

Please take a moment to read this. Thank you!

I should include a brief explanation of the problem in my own words in every PR. If that explanation is missing, please @mention me and do not merge this PR until I have added it. You may also leave this PR unaddressed (because this means I have not fulfilled my responsibilities as the author).

If my explanation is unclear or difficult to follow, please ask me to clarify or provide reproduction steps or supporting evidence.

I welcome suggestions and counterarguments, especially questions about anything I may have overlooked. (Your feedback helps me learn and improve. 🙏)

I hold myself to this standard for every PR, regardless of its size.

When I change the interface language, dock entries with equal custom and default order weights can move. For example, Settings moves from after Terminals to the end of the popup sidebar when switching from English to Chinese. The title comparison uses translated text, so changing the language changes the order.

Use the registered title for this comparison while keeping translated labels on screen. Custom order and default priority still take precedence. Localized copies track their displayed title so a caller can copy an entry and update its title without the old title replacing the update.

Verification:

  • Added tests for default and custom ordering in English, Chinese, and Japanese.
  • Added embedded and standalone context tests covering registration, replacement updates, partial updates, entry state, language changes, and sorting.
  • Previously verified default and custom order in Float, Edge, Popup, and standalone views in Chrome.
  • Full repository lint, knip, tests (1,732 passed, 13 skipped), typecheck, and build passed with both independent fixes applied locally.
  • The isolated ordering branch also passed its dependency build and all 145 hub-ui tests.

@vercel

vercel Bot commented Oct 14, 2026

Copy link
Copy Markdown

@SaKaNa-Y is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

👁️‍🗨️ Review this pull request with grouped, summarized diffs at:
👉 https://pulls.review/gh/devframes/devframe/446?from=github-actions[bot]

raw result

💭 analyzed by vercel-ai-gateway/anthropic/claude-sonnet-5
🕰️ 2026-10-14 04:20 UTC
🔗 head a693bd9
🤖 automated by pulls.review

{
  "headSha": "a693bd947ca15551ee0efa2f8521fd7c7dd24ed5",
  "result": {
    "overallSummary": "Fixes a bug where switching the UI language could reorder dock entries (e.g. Settings moving after Terminals) because the ordering tie-breaker compared translated titles. The fix compares the originally registered title for ordering while still displaying the translated title, and localized copies now track both their original and displayed title so updates don't clobber the registered title. Tests are added to lock in correct ordering across languages and update scenarios.",
    "groups": [
      {
        "key": "fix-ordering",
        "label": "Preserve dock order fix",
        "summary": "Fix dock ordering so it compares the registered (default) title instead of the translated one, preventing entries with equal order weights from reshuffling when the UI language changes. Localized copies now track both their original and displayed title via a hidden symbol so an update can change the displayed title without losing the registered title used for comparisons.",
        "category": "core",
        "filePaths": [
          "packages/hub-ui/src/client/state/locale.ts",
          "packages/hub-ui/src/client/state/context.ts",
          "packages/hub-ui/src/client/state/dock-settings.ts"
        ],
        "fileNotes": [
          {
            "path": "packages/hub-ui/src/client/state/locale.ts",
            "text": "`getDefaultTitle` keeps the original registered title attached to localized copies; it only falls back to `titled.title` when the caller has actually changed the title (not just the display)."
          },
          {
            "path": "packages/hub-ui/src/client/state/dock-settings.ts",
            "text": "Tie-break comparator now uses `getDefaultTitle` instead of the translated `title`, so language changes no longer affect ordering of entries with equal priority."
          }
        ]
      },
      {
        "key": "tests",
        "label": "Ordering and locale tests",
        "summary": "Add tests covering dock ordering stability across English/Chinese/Japanese locales and embedded/standalone contexts, including title update, custom order, and locale-switch scenarios.",
        "category": "tests",
        "filePaths": [
          "packages/hub-ui/src/client/state/context-locale.test.ts",
          "packages/hub-ui/src/client/state/locale.test.ts"
        ],
        "fileNotes": [
          {
            "path": "packages/hub-ui/src/client/state/context-locale.test.ts",
            "text": "End-to-end test using an in-memory RPC client to exercise registration, title updates, locale switches, and custom order through the real docks context."
          }
        ]
      }
    ],
    "schemaVersion": 1,
    "source": "llm",
    "generatedAt": "2026-10-14T04:20:50.343Z",
    "model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
    "locale": "en"
  }
}

@SaKaNa-Y
SaKaNa-Y marked this pull request as ready for review October 14, 2026 04:22
@SaKaNa-Y

Copy link
Copy Markdown
Contributor Author

This does not affect how the tools work, but I expect their order to stay the same when I change the interface language.

@antfu
antfu merged commit 125c61d into devframes:main Oct 14, 2026
12 of 13 checks passed
@SaKaNa-Y
SaKaNa-Y deleted the fix/stable-dock-order-on-locale branch October 14, 2026 13:02
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.

2 participants