Skip to content

feat: opt-in auto-open for pasted work/user links#80

Merged
wsxiaolin merged 2 commits into
mainfrom
codex/add-link-auto-open-feature
May 30, 2026
Merged

feat: opt-in auto-open for pasted work/user links#80
wsxiaolin merged 2 commits into
mainfrom
codex/add-link-auto-open-feature

Conversation

@wsxiaolin

Copy link
Copy Markdown
Member

Motivation

  • Provide a convenient way to open copied experiment/discussion/profile links directly from the clipboard while keeping it opt-in and respecting permissions and error handling.

Description

  • Added a new settings toggle autoOpenCopiedLink (default off) to src/config/user.config.ts to enable/disable the feature from Settings.
  • Added localization keys settings.autoOpenCopiedLink in all supported locales under src/i18n/* so the setting is translatable.
  • Implemented a global paste handler in src/main.ts that 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.
  • Enforced permission and error handling by requiring login for user-profile jumps, showing a warning if not logged in, and capturing route/navigation failures to window.$ErrorLogger while showing an error toast.

Testing

  • Ran npm run lint:i18n and the i18n key consistency check passed.
  • Ran npm run build and the project built successfully for production.

Codex Task

@wsxiaolin

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/main.ts
const target = parseCopiedRouteTarget(pastedText)
if (!target) return

if (target.needLogin && !storageManager.getObj('userInfo').value?.User?.ID) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread src/main.ts Outdated
Comment on lines +65 to +66
const experimentTag = text.match(/<experiment=([a-f0-9]{24})>/i)
if (experimentTag?.[1]) return { path: `/p/Experiment/${experimentTag[1]}`, needLogin: false }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@wsxiaolin

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/main.ts
const target = parseCopiedRouteTarget(pastedText)
if (!target) return

if (target.needLogin && !storageManager.getObj('userInfo').value?.User?.ID) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread src/main.ts
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 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@wsxiaolin wsxiaolin merged commit d8ab836 into main May 30, 2026
5 checks passed
@wsxiaolin wsxiaolin deleted the codex/add-link-auto-open-feature branch May 31, 2026 08:37
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.

1 participant