Skip to content

Priority Translate button: enqueue near the front of the lane queue - #28

Draft
znsoftm wants to merge 1 commit into
cursor/papers-load-perf-1d37from
cursor/papers-translate-priority-4f0b
Draft

znsoftm wants to merge 1 commit into
cursor/papers-load-perf-1d37from
cursor/papers-translate-priority-4f0b

Conversation

@znsoftm

@znsoftm znsoftm commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Card Translate (「翻译」) now priority-enqueues a paper at the head of its fast/slow lane, so a click runs soon instead of waiting behind the whole backlog.

Stacked on cursor/papers-load-perf-1d37 (the current papers UI + dual-lane translate queue). main does not yet contain the translation system.

Semantics

POST /papers/translate accepts "priority": true on a single id:

  • Insert / bump at lane head. The paper is placed at index 0 of its lane (fast ≤50 pages, slow 51–100). It is the next job that lane will tryPop after currently running work.
  • Does not preempt running jobs. A paper that is already running is still rejected (正在翻译中). Priority only reorders the pending lane queue.
  • Already queued: bump to the lane head (single entry, no duplicate). A second click without priority remains a no-op skip.
  • Translate-all / auto-translate: ignore priority and keep FIFO tail append, so the backlog is not reversed.
  • Page-limit skip: papers with page_count > 100 still reject with too_many_pages; no button is shown.
  • Auth: same manage/auth as other translate enqueue (authorizeSettings / can_manage). Anonymous visitors never see the control.

UI

Shared renderPaperCard (catalog + Hugging Face Daily):

State Control
Untranslated, has local PDF Translate / 「翻译」 (priority: true)
Already queued Prioritize / 「优先」 (bump to lane head)
Done Re-translate / 「再次翻译」 (force + priority)
Running or >100 pages No button

Test plan

  • TestPriorityEnqueueInsertsAheadOfNormalQueue — new priority id sits in front of tail-queued items
  • TestPriorityEnqueueBumpsAlreadyQueued — already-queued id moves to head; no duplicate; non-priority second click is a no-op
  • TestPriorityEnqueueDoesNotPreemptRunning — running id rejected; next tryPop is the prioritized paper
  • TestPriorityEnqueueStaysInLane — slow-lane priority does not jump the fast queue
  • TestPriorityEnqueueIgnoredForTranslateAll — {all:true, priority:true} stays FIFO
  • TestPapersTranslatePostPriorityNearFront — HTTP priority:true requires auth and lands at the lane head
  • Papers HTML i18n + priority: true payload assertions
  • go test ./internal/api/ (full package, pass)
  • Manual /papers: Translate → Translate pending → Prioritize on Gamma; queue became 2401.00003, 2401.00001, 2401.00002 (Gamma at the lane head). Status: 「已移到队列最近位置。」
Open in Web Open in Cursor 

Manual Translate / Prioritize / Re-translate on a paper card now POSTs
priority=true so the job is inserted (or bumped) at the head of its
fast/slow lane, after currently running work. Translate-all stays FIFO.

Co-authored-by: Daniel <znsoft@163.com>
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