feat: opt-in auto-open for pasted work/user links#80
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd5c367990
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const target = parseCopiedRouteTarget(pastedText) | ||
| if (!target) return | ||
|
|
||
| if (target.needLogin && !storageManager.getObj('userInfo').value?.User?.ID) { |
There was a problem hiding this comment.
Check the stored user id directly
When a logged-in user pastes a copied user link, this branch still shows "Please login first" and returns because userInfo is stored as the user object itself (sm.setObj('userInfo', res.Data.User) in src/components/popup/loginModel.vue), and the rest of the app reads userInfo.value.ID, not userInfo.value.User.ID. In that context the new user-link auto-open path is unreachable for all logged-in users.
Useful? React with 👍 / 👎.
| const experimentTag = text.match(/<experiment=([a-f0-9]{24})>/i) | ||
| if (experimentTag?.[1]) return { path: `/p/Experiment/${experimentTag[1]}`, needLogin: false } |
There was a problem hiding this comment.
Support copied discussion internal links
The parser only recognizes <experiment=...> internal work tags, but the existing copy action emits <${category.toLowerCase()}=...> for every work in src/views/ExperimentSummary.vue, so discussions are copied as <discussion=...>... </discussion> and fall through without navigation. With the setting enabled, pasting the app's own copied discussion link therefore does nothing even though the feature is advertised for copied work links.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e07d290052
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const target = parseCopiedRouteTarget(pastedText) | ||
| if (!target) return | ||
|
|
||
| if (target.needLogin && !storageManager.getObj('userInfo').value?.User?.ID) { |
There was a problem hiding this comment.
Check the stored user ID at the top level
When a logged-in user pastes a <user=...> link, this check still treats them as logged out because loginModel.vue stores res.Data.User directly under userInfo, and the rest of the app reads fields like storageManager.getObj('userInfo')?.value?.ID/Nickname. Since value.User is undefined in that stored shape, user-profile auto-open is always blocked with the login warning for normal logged-in sessions.
Useful? React with 👍 / 👎.
| if (discussionHash?.[1]) return { path: `/p/Discussion/${discussionHash[1]}`, needLogin: false } | ||
|
|
||
| const discussionQuery = text.match(/\?[\w-]+-([a-f0-9]{24})\?/i) | ||
| if (discussionQuery?.[1]) return { path: `/p/Discussion/${discussionQuery[1]}`, needLogin: false } |
There was a problem hiding this comment.
Route experiment query links as experiments
For legacy/shared URLs such as ?chinese-experiment-<id>?, the regex matches the ID but then always builds /p/Discussion/..., discarding the experiment part of the link. ExperimentSummary passes route.params.category to /Contents/GetSummary, so experiment IDs opened through this path are fetched as discussions and fail or show the wrong category instead of opening the copied work link.
Useful? React with 👍 / 👎.
Motivation
Description
autoOpenCopiedLink(defaultoff) tosrc/config/user.config.tsto enable/disable the feature from Settings.settings.autoOpenCopiedLinkin all supported locales undersrc/i18n/*so the setting is translatable.src/main.tsthat parses pasted text for known patterns (examples:https://dl.turtlesim.com/plc/?chinese-experiment-<id>?,#/p/Discussion/<id>,<experiment=<id>>,<user=<id>>) and navigates to the corresponding route when enabled.window.$ErrorLoggerwhile showing an error toast.Testing
npm run lint:i18nand the i18n key consistency check passed.npm run buildand the project built successfully for production.Codex Task