Skip to content

Conversation

@zmrlft
Copy link
Contributor

@zmrlft zmrlft commented Jan 5, 2026

Type of Changes

  • ✨ New feature (feat)
  • 🐛 Bug fix (fix)
  • 📝 Documentation change (docs)
  • 💄 UI/style change (style)
  • ♻️ Code refactoring (refactor)
  • ⚡ Performance improvement (perf)
  • ✅ Test related (test)
  • 🔧 Build or dependencies update (build)
  • 🔄 CI/CD related (ci)
  • 🌐 Internationalization (i18n)
  • 🧠 AI model related (ai)
  • 🔄 Revert a previous commit (revert)
  • 📦 Other changes that do not modify src or test files (chore)

Description

add long press to translate

Related Issue

Closes #671

How Has This Been Tested?

  • Added unit tests
  • Verified through manual testing

Screenshots

https://cap.so/s/21xn880saryr37j

Checklist

  • I have tested these changes locally
  • I have updated the documentation accordingly if necessary
  • My code follows the code style of this project
  • My changes do not break existing functionality
  • If my code was generated by AI, I have proofread and improved it as necessary.

Additional Information

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: c286101

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@read-frog/extension Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 5, 2026
@github-actions github-actions bot added the feat label Jan 5, 2026
@dosubot
Copy link

dosubot bot commented Jan 5, 2026

Related Documentation

Checked 7 published document(s) in 0 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 11 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/locales/tr.yml">

<violation number="1" location="src/locales/tr.yml:20">
P3: Inconsistent capitalization. Similar entries like `hover: Üzerine Gel` capitalize the second word. Consider `Uzun Basma` for consistency with the established pattern in this locale file.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

alwaysTranslate: Bu siteyi her zaman çevir
options: Seçenekler
hover: Üzerine Gel
longPress: Uzun basma
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 5, 2026

Choose a reason for hiding this comment

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

P3: Inconsistent capitalization. Similar entries like hover: Üzerine Gel capitalize the second word. Consider Uzun Basma for consistency with the established pattern in this locale file.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/locales/tr.yml, line 20:

<comment>Inconsistent capitalization. Similar entries like `hover: Üzerine Gel` capitalize the second word. Consider `Uzun Basma` for consistency with the established pattern in this locale file.</comment>

<file context>
@@ -17,6 +17,7 @@ popup:
   alwaysTranslate: Bu siteyi her zaman çevir
   options: Seçenekler
   hover: Üzerine Gel
+  longPress: Uzun basma
   translateParagraph: paragrafı çevirmek için
   discord:
</file context>
Fix with Cubic

@ananaBMaster
Copy link
Collaborator

@claude review this PR

@claude
Copy link

claude bot commented Jan 8, 2026

Claude encountered an error —— View job

Command failed: git fetch origin --depth=20 feat/the-feature-longPress-translate

I'll analyze this and get back to you.

@ananaBMaster
Copy link
Collaborator

@claude review this PR

@claude
Copy link

claude bot commented Jan 8, 2026

Claude encountered an error —— View job

Command failed: git fetch origin --depth=20 feat/the-feature-longPress-translate

I'll analyze this and get back to you.

Copy link
Owner

@mengxi-ream mengxi-ream left a comment

Choose a reason for hiding this comment

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

PR Review: feat: add long press to translate

Overview

This PR adds a "Long Press" option as an alternative trigger for paragraph translation. Instead of requiring a modifier key + hover, users can now long-press (1 second) on text to translate it. The feature includes:

  • New LongPress hotkey option
  • Mouse event handlers (mousedown, mouseup, mousemove)
  • Movement tolerance (6px) to cancel accidental triggers
  • Translations for 8 locales

Taste Score

🟢 Good taste - Clean implementation following existing patterns


Strengths

  • Follows existing patterns: Uses the same hotkey infrastructure and config system
  • Good UX considerations: 6px movement tolerance prevents accidental triggers during normal clicking
  • Proper guards: Checks for editable elements, button type, and enabled state
  • Complete i18n: All 8 locale files updated consistently

Issues & Suggestions

🔴 Potential Bug: Event listener on document vs document.body

- document.body.addEventListener('mousemove', ...)
+ document.addEventListener('mousemove', ...)

The original mousemove was on document.body, now it's on document. This could cause behavior differences on pages where body doesn't cover the viewport. Consider keeping document.body for the position tracking or verify this change is intentional.

🟡 Minor: Consider extracting shared position update

The mousePosition update in mousedown duplicates the one in mousemove. This seems intentional for the timing, but worth noting.

🟡 Missing test coverage

The PR mentions only manual testing. Consider adding unit tests for:

  • Long press timer triggering at 1000ms
  • Movement tolerance cancellation at 6px
  • Editable element exclusion
  • Button type filtering (only left click)

🟢 Good: Async config fetch inside timer

The getLocalConfig() call inside the timeout is correct - it fetches fresh config at trigger time, not stale config from mousedown.


Nitpicks

  1. Magic number: LONG_PRESS_TRIGGER_MS = 1000 - Consider if this should be user-configurable in the future

Security & Performance

✅ No security concerns - purely UI interaction logic
✅ Lightweight - only adds event listeners, no expensive computations


Summary

Recommendation: Approve with minor suggestions

The implementation is clean and follows project conventions. The main suggestion is to verify the document vs document.body change for mousemove events is intentional. Adding unit tests would strengthen the PR but isn't blocking.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 8, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 17 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/utils/config/migration-scripts/v041-to-v042.ts">

<violation number="1" location="src/utils/config/migration-scripts/v041-to-v042.ts:21">
P2: Migration fallback may silently reset valid hotkey values to 'control'. If `oldHotkey` is not in the migration map (e.g., already lowercase like `'alt'` or an unmapped key), the user's setting will be lost. Consider preserving unknown values: `HOTKEY_MIGRATION[oldHotkey] ?? oldHotkey ?? 'control'`</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


export function migrate(oldConfig: any): any {
const oldHotkey = oldConfig.translate?.node?.hotkey
const newHotkey = oldHotkey ? (HOTKEY_MIGRATION[oldHotkey] ?? 'control') : 'control'
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 8, 2026

Choose a reason for hiding this comment

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

P2: Migration fallback may silently reset valid hotkey values to 'control'. If oldHotkey is not in the migration map (e.g., already lowercase like 'alt' or an unmapped key), the user's setting will be lost. Consider preserving unknown values: HOTKEY_MIGRATION[oldHotkey] ?? oldHotkey ?? 'control'

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/config/migration-scripts/v041-to-v042.ts, line 21:

<comment>Migration fallback may silently reset valid hotkey values to 'control'. If `oldHotkey` is not in the migration map (e.g., already lowercase like `'alt'` or an unmapped key), the user's setting will be lost. Consider preserving unknown values: `HOTKEY_MIGRATION[oldHotkey] ?? oldHotkey ?? 'control'`</comment>

<file context>
@@ -0,0 +1,33 @@
+
+export function migrate(oldConfig: any): any {
+  const oldHotkey = oldConfig.translate?.node?.hotkey
+  const newHotkey = oldHotkey ? (HOTKEY_MIGRATION[oldHotkey] ?? 'control') : 'control'
+
+  return {
</file context>
Fix with Cubic

@ananaBMaster ananaBMaster merged commit ed8ed19 into mengxi-ream:main Jan 8, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 不支持鼠标长按文本进行翻译吗?就一段一段翻译

3 participants