Repository navigation
[trees] Add a labels option for localizing tree text - #1272
Conversation
|
@unknwon is attempting to deploy a commit to the Pierre Computer Company Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d8091a4b4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| FileTreeLabelsOption, | ||
| } from '../model/publicTypes'; | ||
|
|
||
| export const DEFAULT_FILE_TREE_LABELS: FileTreeLabels = Object.freeze({ |
There was a problem hiding this comment.
Expose the frozen label defaults as readonly
When a TypeScript consumer customizes the exported defaults in place (for example, by assigning DEFAULT_FILE_TREE_LABELS.searchPlaceholder before passing it as labels), the declared mutable FileTreeLabels type lets the assignment compile, but the top-level Object.freeze makes it throw at runtime in ESM. Expose this constant as Readonly<FileTreeLabels> (or stop freezing it) so its public type matches its runtime behavior.
Useful? React with 👍 / 👎.
Description
Adds a
labelstree option and asetLabels()model method for the user-visible text the tree renders:DEFAULT_FILE_TREE_LABELSexport, one key (and one git status) at a time, so existing output is unchanged.setLabels()followssetIcons()andsetGitStatus(): it stores the resolved labels and re-renders the mounted tree in place. React callers use it through the model like the other runtime setters, sinceuseFileTreereads options once.preloadFileTreerenders the labels into SSR markup. Both it and the constructor pulllabelsout before the remaining options reach the controller.gitStatusPresentation.tsinto the defaults so the text lives in one place. TheA/D/M/R/Ubadge letters stay as they are, since they follow git's own convention.renameFileTreePathsare left as is. They are returned to callers rather than rendered by the tree, so error codes may serve callers better than more labels. Happy to follow up if you prefer otherwise.Motivation & Context
These strings are hard-coded in English inside the shadow root, so apps that localize their UI cannot translate the search placeholder, accessible names, or git status tooltips. Gogs renders the tree beside localized UI and currently has no way to translate them.
Opening as a draft to discuss the API shape before it is considered for merge. A companion PR adds the same option to
@pierre/diffs: #1271.Type of changes
first discussed with the dev team and they should be aware that this PR is
being opened
You must have first discussed with the dev team and they should be aware
that this PR is being opened
Checklist
contributing guidelines
moon run root:lint)moon run root:format)moonx trees:test)The local moon (2.6.5) is outside the pinned
~2.3.3, so I ran the underlying commands directly:oxfmt,oxlint --type-aware(0 warnings, 0 errors on changed files),tsc --noEmitforpackages/trees(clean), andbun test(333 pass, 0 fail, including the four new tests infile-tree-labels.test.ts). The Playwright suite was not run.How was AI used in generating this PR
Drafted with Claude Code (Claude Opus 5.5), including the code, tests, docs, and this description.
Related issues
None filed.